Skip to content

Commit

Permalink
Use a Mutex to make sure only one test compiles artifacts in a given …
Browse files Browse the repository at this point in the history
…directory at any time
  • Loading branch information
aakoshh committed Nov 4, 2024
1 parent 85a6b2b commit 52d25ac
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ build-data = "0.1.3"
bincode = "1.3.3"
hex = "0.4.2"
const_format = "0.2.30"
lazy_static = "1.4"
num-bigint = "0.4"
num-traits = "0.2"
similar-asserts = "1.5.0"
Expand Down
4 changes: 2 additions & 2 deletions acvm-repo/bn254_blackbox_solver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ workspace = true
acir.workspace = true
acvm_blackbox_solver.workspace = true
hex.workspace = true
lazy_static = "1.4"
lazy_static.workspace = true

ark-bn254.workspace = true
grumpkin.workspace = true
grumpkin.workspace = true
ark-ec.workspace = true
ark-ff.workspace = true
num-bigint.workspace = true
Expand Down
1 change: 1 addition & 0 deletions tooling/nargo_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ sha3.workspace = true
iai = "0.1.1"
test-binary = "3.0.2"
test-case.workspace = true
lazy_static.workspace = true
light-poseidon = "0.2.0"


Expand Down
16 changes: 15 additions & 1 deletion tooling/nargo_cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ struct MatrixConfig {

impl Default for MatrixConfig {
fn default() -> Self {
Self { vary_brillig: false, vary_inliner: true }
Self {
// Only used with execution, and only on selected tests.
vary_brillig: false,
// Only seems to have an effect on the `execute_success` cases.
vary_inliner: false,
}
}
}

Expand All @@ -111,16 +116,25 @@ fn generate_test_cases(
test_content: &str,
matrix_config: &MatrixConfig,
) {
let mutex_name = format! {"TEST_MUTEX_{}", test_name.to_uppercase()};
let brillig_cases = if matrix_config.vary_brillig { "[false, true]" } else { "[false]" };
let inliner_cases = if matrix_config.vary_inliner { "[i64::MIN, 0, i64::MAX]" } else { "[0]" };
write!(
test_file,
r#"
lazy_static::lazy_static! {{
/// Prevent concurrent tests in the matrix from overwriting the compilation artifacts in {test_dir}
static ref {mutex_name}: std::sync::Mutex<()> = std::sync::Mutex::new(());
}}
#[test_case::test_matrix(
{brillig_cases},
{inliner_cases}
)]
fn test_{test_name}(force_brillig: bool, inliner_aggressiveness: i64) {{
// Ignore poisoning errors if some of the matrix cases failed.
let _guard = {mutex_name}.lock().unwrap_or_else(|e| e.into_inner());
let test_program_dir = PathBuf::from("{test_dir}");
let mut nargo = Command::cargo_bin("nargo").unwrap();
Expand Down

0 comments on commit 52d25ac

Please sign in to comment.