Skip to content

Commit

Permalink
feat(test): Run test matrix on stdlib tests (#6352)
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh authored Oct 25, 2024
1 parent bcd8976 commit 4c39514
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
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 @@ use nargo::{
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 @@ pub struct Options {
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.
#[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 @@ fn run_stdlib_tests() {
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

0 comments on commit 4c39514

Please sign in to comment.