From e8388cff3c2334ca76b972cff1c408ab96c70a8d Mon Sep 17 00:00:00 2001 From: FrancoGiachetta Date: Fri, 26 Sep 2025 12:33:04 -0300 Subject: [PATCH 1/4] use cargo-nextest instead of cargo test --- .config/nextest.toml | 4 ++++ .github/workflows/ci.yml | 8 ++++++++ Makefile | 8 ++++---- 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 .config/nextest.toml diff --git a/.config/nextest.toml b/.config/nextest.toml new file mode 100644 index 000000000..870bf3b87 --- /dev/null +++ b/.config/nextest.toml @@ -0,0 +1,4 @@ +[profile.ci] +inherits = "dev" +opt-level = 3 +debug = "line-tables-only" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb89c3a71..ea51be335 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,6 +114,10 @@ jobs: RUST_LOG: cairo_native=debug,cairo_native_test=debug steps: - uses: actions/checkout@v4 + - name: Install testing tools + uses: taiki-e/install-action + with: + tool: cargo-nextest - name: check and free hdd space left run: | echo "Listing 20 largest packages" @@ -165,6 +169,10 @@ jobs: RUST_LOG: cairo_native=debug,cairo_native_test=debug steps: - uses: actions/checkout@v4 + - name: Install testing tools + uses: taiki-e/install-action + with: + tool: cargo-nextest - name: Rustup toolchain install uses: dtolnay/rust-toolchain@1.84.1 with: diff --git a/Makefile b/Makefile index 88dfc1372..2a2a886e4 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ check: check-llvm .PHONY: test test: check-llvm needs-cairo2 build-alexandria - cargo test --profile ci --features=with-cheatcode,with-debug-utils,testing + cargo nextest run --profile ci --features=with-cheatcode,with-debug-utils,testing .PHONY: test-cairo test-cairo: check-llvm needs-cairo2 @@ -70,15 +70,15 @@ test-cairo: check-llvm needs-cairo2 .PHONY: proptest proptest: check-llvm needs-cairo2 - cargo test --profile ci --features=with-cheatcode,with-debug-utils,testing proptest + cargo nextest run --profile ci --features=with-cheatcode,with-debug-utils,testing proptest .PHONY: test-cli test-ci: check-llvm needs-cairo2 build-alexandria - cargo test --profile ci --features=with-cheatcode,with-debug-utils,testing + cargo nextest run --profile ci --features=with-cheatcode,with-debug-utils,testing .PHONY: proptest-cli proptest-ci: check-llvm needs-cairo2 - cargo test --profile ci --features=with-cheatcode,with-debug-utils,testing proptest + cargo nextest run --profile ci --features=with-cheatcode,with-debug-utils,testing proptest .PHONY: coverage coverage: check-llvm needs-cairo2 build-alexandria From a84d7bb22a8f79c956ec984c53c146c28bbe37fc Mon Sep 17 00:00:00 2001 From: FrancoGiachetta Date: Fri, 26 Sep 2025 12:38:58 -0300 Subject: [PATCH 2/4] parallelize tests run in cairo-native-bin-utils --- Cargo.lock | 1 + binaries/cairo-native-bin-utils/Cargo.toml | 1 + binaries/cairo-native-bin-utils/src/test.rs | 56 +++++++++++---------- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6e56276d8..02eaf02e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1103,6 +1103,7 @@ dependencies = [ "colored 2.2.0", "itertools 0.14.0", "num-traits", + "rayon", "scarb-metadata", "starknet-types-core", "tracing", diff --git a/binaries/cairo-native-bin-utils/Cargo.toml b/binaries/cairo-native-bin-utils/Cargo.toml index 873e463bd..13f6ba6f3 100644 --- a/binaries/cairo-native-bin-utils/Cargo.toml +++ b/binaries/cairo-native-bin-utils/Cargo.toml @@ -21,3 +21,4 @@ num-traits.workspace = true scarb-metadata.workspace = true starknet-types-core.workspace = true tracing.workspace = true +rayon.workspace = true diff --git a/binaries/cairo-native-bin-utils/src/test.rs b/binaries/cairo-native-bin-utils/src/test.rs index c17b2cde5..35e071359 100644 --- a/binaries/cairo-native-bin-utils/src/test.rs +++ b/binaries/cairo-native-bin-utils/src/test.rs @@ -19,6 +19,7 @@ use cairo_native::{ use colored::Colorize; use itertools::Itertools; use num_traits::ToPrimitive; +use rayon::iter::{IntoParallelIterator, ParallelIterator}; #[cfg(feature = "scarb")] use scarb_metadata::{PackageMetadata, TargetMetadata}; use starknet_types_core::felt::Felt; @@ -182,32 +183,33 @@ pub fn run_tests( .compile(&sierra_program, false, Some(Default::default()), None) .unwrap(); - let native_executor: Box _> = match args.run_mode { - RunMode::Aot => { - let executor = - AotNativeExecutor::from_native_module(native_module, args.opt_level.into())?; - Box::new(move |function_id, args, gas, syscall_handler| { - executor.invoke_dynamic_with_syscall_handler( - function_id, - args, - gas, - syscall_handler, - ) - }) - } - RunMode::Jit => { - let executor = - JitNativeExecutor::from_native_module(native_module, args.opt_level.into())?; - Box::new(move |function_id, args, gas, syscall_handler| { - executor.invoke_dynamic_with_syscall_handler( - function_id, - args, - gas, - syscall_handler, - ) - }) - } - }; + let native_executor: Box _ + Sync> = + match args.run_mode { + RunMode::Aot => { + let executor = + AotNativeExecutor::from_native_module(native_module, args.opt_level.into())?; + Box::new(move |function_id, args, gas, syscall_handler| { + executor.invoke_dynamic_with_syscall_handler( + function_id, + args, + gas, + syscall_handler, + ) + }) + } + RunMode::Jit => { + let executor = + JitNativeExecutor::from_native_module(native_module, args.opt_level.into())?; + Box::new(move |function_id, args, gas, syscall_handler| { + executor.invoke_dynamic_with_syscall_handler( + function_id, + args, + gas, + syscall_handler, + ) + }) + } + }; let gas_metadata = GasMetadata::new( &sierra_program, @@ -231,7 +233,7 @@ pub fn run_tests( mismatch_reason: vec![], })); named_tests - .into_iter() + .into_par_iter() .map( |(name, test)| -> anyhow::Result<(String, Option)> { if test.ignored { From eba0c04426bcb7fd6671f17e3a15b7aa2330a7f8 Mon Sep 17 00:00:00 2001 From: Franco Giachetta Date: Fri, 26 Sep 2025 15:25:51 -0300 Subject: [PATCH 3/4] Update .github/workflows/ci.yml Co-authored-by: DiegoC <90105443+DiegoCivi@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea51be335..3b8aff93a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -115,7 +115,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Install testing tools - uses: taiki-e/install-action + uses: taiki-e/install-action@v2 with: tool: cargo-nextest - name: check and free hdd space left From fce28257f559f03c05aed82b8d76fd3070fc1727 Mon Sep 17 00:00:00 2001 From: FrancoGiachetta Date: Mon, 29 Sep 2025 10:09:44 -0300 Subject: [PATCH 4/4] remove nextest config --- .config/nextest.toml | 4 ---- Makefile | 12 ++++++------ 2 files changed, 6 insertions(+), 10 deletions(-) delete mode 100644 .config/nextest.toml diff --git a/.config/nextest.toml b/.config/nextest.toml deleted file mode 100644 index 870bf3b87..000000000 --- a/.config/nextest.toml +++ /dev/null @@ -1,4 +0,0 @@ -[profile.ci] -inherits = "dev" -opt-level = 3 -debug = "line-tables-only" diff --git a/Makefile b/Makefile index 2a2a886e4..e45b11cc2 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ check: check-llvm .PHONY: test test: check-llvm needs-cairo2 build-alexandria - cargo nextest run --profile ci --features=with-cheatcode,with-debug-utils,testing + cargo nextest run --features=with-cheatcode,with-debug-utils,testing .PHONY: test-cairo test-cairo: check-llvm needs-cairo2 @@ -70,20 +70,20 @@ test-cairo: check-llvm needs-cairo2 .PHONY: proptest proptest: check-llvm needs-cairo2 - cargo nextest run --profile ci --features=with-cheatcode,with-debug-utils,testing proptest + cargo nextest run --features=with-cheatcode,with-debug-utils,testing proptest .PHONY: test-cli test-ci: check-llvm needs-cairo2 build-alexandria - cargo nextest run --profile ci --features=with-cheatcode,with-debug-utils,testing + cargo nextest run --features=with-cheatcode,with-debug-utils,testing .PHONY: proptest-cli proptest-ci: check-llvm needs-cairo2 - cargo nextest run --profile ci --features=with-cheatcode,with-debug-utils,testing proptest + cargo nextest run --features=with-cheatcode,with-debug-utils,testing proptest .PHONY: coverage coverage: check-llvm needs-cairo2 build-alexandria - cargo llvm-cov --verbose --profile ci --features=with-cheatcode,with-debug-utils,testing --workspace --lcov --output-path lcov.info - cargo llvm-cov --verbose --profile ci --features=with-cheatcode,with-debug-utils,testing --lcov --output-path lcov-test.info run --package cairo-native-test -- corelib + cargo llvm-cov nextest --verbose --features=with-cheatcode,with-debug-utils,testing --workspace --lcov --output-path lcov.info + cargo llvm-cov nextest --verbose --features=with-cheatcode,with-debug-utils,testing --lcov --output-path lcov-test.info run --package cairo-native-test -- corelib .PHONY: doc doc: check-llvm