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

feat(test): Run test matrix on stdlib tests #6352

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
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
34 changes: 34 additions & 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 @@ -146,6 +146,7 @@ num-bigint = "0.4"
num-traits = "0.2"
similar-asserts = "1.5.0"
tempfile = "3.6.0"
test-case = "3.3.1"
jsonrpc = { version = "0.16.0", features = ["minreq_http"] }
flate2 = "1.0.24"
color-eyre = "0.6.2"
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 @@ -86,6 +86,7 @@ sha2.workspace = true
sha3.workspace = true
iai = "0.1.1"
test-binary = "3.0.2"
test-case.workspace = true
light-poseidon = "0.2.0"


Expand Down
18 changes: 14 additions & 4 deletions tooling/nargo_cli/tests/stdlib-tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Execute unit tests in the Noir standard library.
#![allow(clippy::items_after_test_module)]
use clap::Parser;
use fm::FileManager;
use noirc_driver::{check_crate, file_manager_with_stdlib, CompileOptions};
Expand All @@ -12,6 +13,7 @@
parse_all, prepare_package,
};
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
use test_case::test_matrix;

#[derive(Parser, Debug)]
#[command(ignore_errors = true)]
Expand All @@ -29,14 +31,22 @@
impl Options {
pub fn function_name_match(&self) -> FunctionNameMatch {
match self.args.as_slice() {
[_, lib] => FunctionNameMatch::Contains(lib.as_str()),
[_test_name, lib] => FunctionNameMatch::Contains(lib.as_str()),
_ => FunctionNameMatch::Anything,
}
}
}

#[test]
fn run_stdlib_tests() {
/// Inliner aggressiveness results in different SSA.
/// Inlining happens if `inline_cost - retain_cost < aggressiveness` (see `inlining.rs`).
/// NB the CLI uses maximum aggressiveness.
///
/// Even with the same inlining aggressiveness, forcing Brillig can trigger different behaviour.

Check warning on line 44 in tooling/nargo_cli/tests/stdlib-tests.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (behaviour)
#[test_matrix(
[false, true],
[i64::MIN, 0, i64::MAX]
)]
fn run_stdlib_tests(force_brillig: bool, inliner_aggressiveness: i64) {
let opts = Options::parse();

let mut file_manager = file_manager_with_stdlib(&PathBuf::from("."));
Expand Down Expand Up @@ -80,7 +90,7 @@
None,
Some(dummy_package.root_dir.clone()),
Some(dummy_package.name.to_string()),
&CompileOptions::default(),
&CompileOptions { force_brillig, inliner_aggressiveness, ..Default::default() },
);
(test_name, status)
})
Expand Down
Loading