Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[profile.ci]
inherits = "dev"
opt-level = 3
debug = "line-tables-only"
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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@v2
with:
tool: cargo-nextest
- name: check and free hdd space left
run: |
echo "Listing 20 largest packages"
Expand Down Expand Up @@ -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/[email protected]
with:
Expand Down
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.

8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,23 @@ 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
cargo r --profile ci --package cairo-native-test -- --compare-with-cairo-vm corelib

.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
Expand Down
1 change: 1 addition & 0 deletions binaries/cairo-native-bin-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ num-traits.workspace = true
scarb-metadata.workspace = true
starknet-types-core.workspace = true
tracing.workspace = true
rayon.workspace = true
56 changes: 29 additions & 27 deletions binaries/cairo-native-bin-utils/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -182,32 +183,33 @@ pub fn run_tests(
.compile(&sierra_program, false, Some(Default::default()), None)
.unwrap();

let native_executor: Box<dyn Fn(_, _, _, &mut StubSyscallHandler) -> _> = 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<dyn Fn(_, _, _, &mut StubSyscallHandler) -> _ + 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,
Expand All @@ -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<TestResult>)> {
if test.ignored {
Expand Down
Loading