Skip to content
Open
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
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/rust-toolchain@1.84.1
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.

12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,28 @@ 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 --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 --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 --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 --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
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