Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
f35cdd0c
Commit
f35cdd0c
authored
Jul 10, 2025
by
Luke Sandberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a unit test for the new traversal algorithm
parent
67b17f17
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
mod.rs
turbopack/crates/turbopack-core/src/module_graph/mod.rs
+51
-0
No files found.
turbopack/crates/turbopack-core/src/module_graph/mod.rs
View file @
f35cdd0c
...
@@ -2000,6 +2000,57 @@ pub mod tests {
...
@@ -2000,6 +2000,57 @@ pub mod tests {
.await
;
.await
;
}
}
#[tokio
::
test]
async
fn
traverse_edges_from_entries_fixed_point_diamond
()
{
run_graph_test
(
vec!
[
rcstr!
(
"a.js"
)],
{
let
mut
deps
=
FxHashMap
::
default
();
// A cycle of length 3
deps
.insert
(
rcstr!
(
"a.js"
),
vec!
[
rcstr!
(
"b.js"
)]);
deps
.insert
(
rcstr!
(
"b.js"
),
vec!
[
rcstr!
(
"c.js"
)]);
deps
.insert
(
rcstr!
(
"c.js"
),
vec!
[
rcstr!
(
"a.js"
)]);
deps
},
|
graph
,
entry_modules
,
module_to_name
|
{
let
mut
visits
=
Vec
::
new
();
let
mut
count
=
0
;
graph
.traverse_edges_from_entries_fixed_point
(
entry_modules
,
|
parent
,
target
|
{
visits
.push
((
parent
.map
(|(
node
,
_
)|
module_to_name
.get
(
&
node
.module
)
.unwrap
()
.clone
()),
module_to_name
.get
(
&
target
.module
())
.unwrap
()
.clone
(),
));
count
+=
1
;
// We are a cycle so we need to break the loop eventually
Ok
(
if
count
<
6
{
GraphTraversalAction
::
Continue
}
else
{
GraphTraversalAction
::
Skip
})
},
)
?
;
assert_eq!
(
vec!
[
(
None
,
rcstr!
(
"a.js"
)),
(
Some
(
rcstr!
(
"a.js"
)),
rcstr!
(
"b.js"
)),
(
Some
(
rcstr!
(
"b.js"
)),
rcstr!
(
"c.js"
)),
(
Some
(
rcstr!
(
"c.js"
)),
rcstr!
(
"a.js"
)),
(
Some
(
rcstr!
(
"a.js"
)),
rcstr!
(
"b.js"
)),
(
Some
(
rcstr!
(
"b.js"
)),
rcstr!
(
"c.js"
)),
],
visits
);
Ok
(())
},
)
.await
;
}
#[turbo_tasks
::
value(shared)]
#[turbo_tasks
::
value(shared)]
struct
TestRepo
{
struct
TestRepo
{
repo
:
FxHashMap
<
FileSystemPath
,
Vec
<
FileSystemPath
>>
,
repo
:
FxHashMap
<
FileSystemPath
,
Vec
<
FileSystemPath
>>
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment