Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tests): Prevent EOF error while running test programs #6455

Merged
merged 7 commits into from
Nov 5, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use a Mutex to make sure only one test compiles artifacts in a given …
…directory at any time
aakoshh committed Nov 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 52d25ac6d355983168ab711b28a0d8047775e647
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
@@ -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"
4 changes: 2 additions & 2 deletions acvm-repo/bn254_blackbox_solver/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tooling/nargo_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"


16 changes: 15 additions & 1 deletion tooling/nargo_cli/build.rs
Original file line number Diff line number Diff line change
@@ -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,
}
}
}

@@ -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();