Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions tooling/nargo_cli/tests/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
nargo.arg("--enable-brillig-debug-assertions");

// Enable enums and ownership as unstable features
nargo.arg("-Zenums");

Check warning on line 37 in tooling/nargo_cli/tests/execute.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (Zenums)
nargo.arg("-Zownership");

Check warning on line 38 in tooling/nargo_cli/tests/execute.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (Zownership)

if force_brillig.0 {
{
Expand Down Expand Up @@ -63,7 +63,15 @@
}

fn delete_test_program_dir_occurrences(string: String, test_program_dir: &Path) -> String {
// Assuming `test_program_dir` is "/projects/noir/test_programs/compile_failure/some_program"...

// `test_program_base_dir` is "/projects/noir/test_programs"
let test_program_base_dir = test_program_dir.parent().unwrap().parent().unwrap();

// `root_dir` is "/projects/noir"
let root_dir = test_program_base_dir.parent().unwrap();

// Here we turn the paths into strings and ensure they end with a `/`
let mut test_program_base_dir = test_program_base_dir.to_string_lossy().to_string();
if !test_program_base_dir.ends_with('/') {
test_program_base_dir.push('/');
Expand All @@ -74,12 +82,25 @@
test_program_dir.push('/');
}

// We replace both test_program_dir (test_programs/compile_failure/foo) and its ancestor
// (test_programs) because in some cases some programs refer to other programs in `test_programs`.
// `test_program_dir_without_root is "test_programs/compile_failure".
// This one is needed because tests might run from the root of the project and paths
// will end up starting with "test_programs/compile_failure/...".
let test_program_dir_without_root =
test_program_dir.strip_prefix(&root_dir.to_string_lossy().to_string()).unwrap();
let test_program_dir_without_root = test_program_dir_without_root
.strip_prefix('/')
.unwrap_or(test_program_dir_without_root);

// We replace all of these:
// - test_program_dir ("/projects/noir/test_programs/compile_failure/foo")
// - test_program_base_dir ("/projects/noir/test_programs")
// - test_program_dir_without_root ("test_programs/compile_failure")
string
.lines()
.map(|line| {
line.replace(&test_program_dir, "").replace(&test_program_base_dir, "../../")
line.replace(&test_program_dir, "")
.replace(&test_program_base_dir, "../../")
.replace(test_program_dir_without_root, "")
})
.collect::<Vec<String>>()
.join("\n")
Expand Down
Loading