Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Jul 30, 2023
1 parent b6c742b commit b78db15
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 24 deletions.
10 changes: 2 additions & 8 deletions crates/node/platform/tests/project_aliases_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,12 @@ async fn loads_node_aliases_name_scopes() {
assert_eq!(
graph.aliases(),
FxHashMap::from_iter([
(
"project-graph-aliases-explicit",
&Id::raw("explicit")
),
("project-graph-aliases-explicit", &Id::raw("explicit")),
(
"project-graph-aliases-explicit-and-implicit",
&Id::raw("explicitAndImplicit")
),
(
"project-graph-aliases-implicit",
&Id::raw("implicit")
),
("project-graph-aliases-implicit", &Id::raw("implicit")),
("project-graph-aliases-node", &Id::raw("node")),
("pkg-bar", &Id::raw("nodeNameOnly")),
("@scope/pkg-foo", &Id::raw("nodeNameScope"))
Expand Down
2 changes: 2 additions & 0 deletions nextgen/file-group/src/file_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ impl FileGroup {
}
}

list.sort();

Ok(list)
}
}
Expand Down
13 changes: 11 additions & 2 deletions nextgen/project-expander/tests/tasks_expander_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ mod tasks_expander {
[
"a",
"./config.yml",
"./dir/subdir/nested.json",
"./docs.md",
"./other/file.json",
"./dir/subdir/nested.json",
"b"
]
);
Expand All @@ -139,9 +139,9 @@ mod tasks_expander {
[
"a",
"./project/source/config.yml",
"./project/source/dir/subdir/nested.json",
"./project/source/docs.md",
"./project/source/other/file.json",
"./project/source/dir/subdir/nested.json",
"b"
]
);
Expand Down Expand Up @@ -960,6 +960,7 @@ mod tasks_expander {
)]
fn errors_overlapping_file() {
env::remove_var("MOON_DISABLE_OVERLAPPING_OUTPUTS");
env::remove_var("MOON_TEST");

let sandbox = create_sandbox("file-group");
let project = create_project(sandbox.path());
Expand All @@ -978,6 +979,8 @@ mod tasks_expander {
TasksExpander::new(&context)
.expand_outputs(&mut task, &mut boundaries)
.unwrap();

env::set_var("MOON_TEST", "true");
}

#[test]
Expand All @@ -986,6 +989,7 @@ mod tasks_expander {
)]
fn errors_overlapping_glob() {
env::remove_var("MOON_DISABLE_OVERLAPPING_OUTPUTS");
env::remove_var("MOON_TEST");

let sandbox = create_sandbox("file-group");
let project = create_project(sandbox.path());
Expand All @@ -1005,6 +1009,8 @@ mod tasks_expander {
TasksExpander::new(&context)
.expand_outputs(&mut task, &mut boundaries)
.unwrap();

env::set_var("MOON_TEST", "true");
}

#[test]
Expand All @@ -1013,6 +1019,7 @@ mod tasks_expander {
)]
fn errors_overlapping_glob_matching_file() {
env::remove_var("MOON_DISABLE_OVERLAPPING_OUTPUTS");
env::remove_var("MOON_TEST");

let sandbox = create_sandbox("file-group");
let project = create_project(sandbox.path());
Expand All @@ -1032,6 +1039,8 @@ mod tasks_expander {
TasksExpander::new(&context)
.expand_outputs(&mut task, &mut boundaries)
.unwrap();

env::set_var("MOON_TEST", "true");
}
}
}
9 changes: 5 additions & 4 deletions nextgen/project-expander/tests/token_expander_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ mod token_expander {

mod vars {
use super::*;

#[test]
fn replaces_variables() {
let sandbox = create_empty_sandbox();
Expand Down Expand Up @@ -329,8 +330,8 @@ mod token_expander {
expander.expand_inputs(&task).unwrap(),
(
vec![
WorkspaceRelativePathBuf::from("project/source/dir/subdir"),
WorkspaceRelativePathBuf::from("project/source/other"),
WorkspaceRelativePathBuf::from("project/source/dir/subdir")
],
vec![]
)
Expand All @@ -353,9 +354,9 @@ mod token_expander {
(
vec![
WorkspaceRelativePathBuf::from("project/source/config.yml"),
WorkspaceRelativePathBuf::from("project/source/dir/subdir/nested.json"),
WorkspaceRelativePathBuf::from("project/source/docs.md"),
WorkspaceRelativePathBuf::from("project/source/other/file.json"),
WorkspaceRelativePathBuf::from("project/source/dir/subdir/nested.json"),
],
vec![]
)
Expand Down Expand Up @@ -561,8 +562,8 @@ mod token_expander {
expander.expand_outputs(&task).unwrap(),
(
vec![
WorkspaceRelativePathBuf::from("project/source/dir/subdir"),
WorkspaceRelativePathBuf::from("project/source/other"),
WorkspaceRelativePathBuf::from("project/source/dir/subdir")
],
vec![]
)
Expand All @@ -585,9 +586,9 @@ mod token_expander {
(
vec![
WorkspaceRelativePathBuf::from("project/source/config.yml"),
WorkspaceRelativePathBuf::from("project/source/dir/subdir/nested.json"),
WorkspaceRelativePathBuf::from("project/source/docs.md"),
WorkspaceRelativePathBuf::from("project/source/other/file.json"),
WorkspaceRelativePathBuf::from("project/source/dir/subdir/nested.json"),
],
vec![]
)
Expand Down
3 changes: 3 additions & 0 deletions nextgen/project-graph/src/project_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ impl ProjectGraph {
}
}

// Sort so that the order is deterministic
project_ids.sort();

Ok(project_ids)
})
}
Expand Down
5 changes: 4 additions & 1 deletion nextgen/project-graph/src/projects_locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ where
}

// Glob for all other projects
for project_root in glob::walk(workspace_root, &globs)? {
let mut potential_projects = glob::walk(workspace_root, &globs)?;
potential_projects.sort();

for project_root in potential_projects {
if project_root.is_dir() {
let project_source =
to_virtual_string(project_root.strip_prefix(workspace_root).unwrap())?;
Expand Down
2 changes: 1 addition & 1 deletion nextgen/project-graph/tests/project_graph_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,8 @@ mod project_graph {
assert_eq!(
task.deps,
[
Target::parse("tag-three:test").unwrap(),
Target::parse("tag-one:test").unwrap(),
Target::parse("tag-three:test").unwrap(),
]
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ source: nextgen/project-graph/tests/project_graph_test.rs
expression: graph.to_dot()
---
digraph {
0 [ label="alias-one" style=filled, shape=oval, fillcolor=gray, fontcolor=black]
0 [ label="tasks" style=filled, shape=oval, fillcolor=gray, fontcolor=black]
1 [ label="alias-three" style=filled, shape=oval, fillcolor=gray, fontcolor=black]
2 [ label="dupes-task-deps" style=filled, shape=oval, fillcolor=gray, fontcolor=black]
3 [ label="alias-two" style=filled, shape=oval, fillcolor=gray, fontcolor=black]
4 [ label="dupes-depends-on" style=filled, shape=oval, fillcolor=gray, fontcolor=black]
5 [ label="explicit-and-implicit" style=filled, shape=oval, fillcolor=gray, fontcolor=black]
6 [ label="implicit" style=filled, shape=oval, fillcolor=gray, fontcolor=black]
7 [ label="explicit" style=filled, shape=oval, fillcolor=gray, fontcolor=black]
8 [ label="tasks" style=filled, shape=oval, fillcolor=gray, fontcolor=black]
6 [ label="alias-one" style=filled, shape=oval, fillcolor=gray, fontcolor=black]
7 [ label="implicit" style=filled, shape=oval, fillcolor=gray, fontcolor=black]
8 [ label="explicit" style=filled, shape=oval, fillcolor=gray, fontcolor=black]
4 -> 3 [ label="development" arrowhead=box, arrowtail=box]
4 -> 3 [ label="build" arrowhead=box, arrowtail=box]
5 -> 3 [ label="development" arrowhead=box, arrowtail=box]
5 -> 1 [ label="build" arrowhead=box, arrowtail=box]
6 -> 0 [ label="peer" arrowhead=box, arrowtail=box]
6 -> 1 [ label="build" arrowhead=box, arrowtail=box]
7 -> 3 [ label="production" arrowhead=box, arrowtail=box]
7 -> 0 [ label="development" arrowhead=box, arrowtail=box]
7 -> 6 [ label="peer" arrowhead=box, arrowtail=box]
7 -> 1 [ label="build" arrowhead=box, arrowtail=box]
8 -> 3 [ label="production" arrowhead=box, arrowtail=box]
8 -> 6 [ label="development" arrowhead=box, arrowtail=box]
}

0 comments on commit b78db15

Please sign in to comment.