feat: add test_helpers module (error_utils, test_utils) behind test_utlis flag#2381
feat: add test_helpers module (error_utils, test_utils) behind test_utlis flag#2381naor-starkware wants to merge 13 commits intomainfrom
Conversation
…on_runner flag - Create vm/src/test_helpers/ with error_utils.rs and test_utils.rs - Move from cairo_test_suite/ (fix filename typo: utlis → utils) - Fix crate:: import paths (were cairo_vm:: when outside the crate) - Fix $crate in macro_export macro (clippy::crate_in_macro_def) - Simplify load_cairo_program! path using with_file_name() - Gate module behind function_runner feature in lib.rs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ram! and error_utils checkers Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add AlwaysFailConversion helper + 2 tests for assert_mr_eq! unwrap_or_else panic branch (no-message and message variants) - Allow clippy::result_large_err on hint_err test helper Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… noise Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…y function name error #[macro_export] macros containing closures (|x| ...) cause llvm-cov to emit a "function name is empty" error. Replaced unwrap_or_else(|e| panic!(...)) with match expressions to eliminate closures from macro expansions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Follow-up to dropping the function_runner feature flag. Gate test_helpers module and function_runner module under test_utils, and update the doc comment in function_runner.rs accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2381 +/- ##
========================================
Coverage 96.07% 96.07%
========================================
Files 105 107 +2
Lines 37737 37852 +115
========================================
+ Hits 36254 36366 +112
- Misses 1483 1486 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Benchmark Results for unmodified programs 🚀
|
YairVaknin-starkware
left a comment
There was a problem hiding this comment.
@YairVaknin-starkware reviewed 9 files and all commit messages, and made 4 comments.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on naor-starkware).
vm/src/test_helpers/error_utils.rs line 44 at r2 (raw file):
/// Type alias for check functions that validate test results. pub type VmCheck<T> = fn(&std::result::Result<T, CairoRunError>);
can just be Result, right? pls looks for similar instances where you can shorten.
Code quote:
&std::result::Result<T, CairoRunError>vm/src/test_helpers/error_utils.rs line 62 at r2 (raw file):
} /// Asserts that the result is `HintError::AssertNotEqualFail`.
This funcs have very repetitive boiler plate. Pls extract to a single func which these func will invoke that will get the res and the predicate u check.
Code quote:
/// Asserts that the result is `HintError::AssertNotEqualFail`.vm/src/test_helpers/error_utils.rs line 220 at r2 (raw file):
} /// `expect_hint_assert_not_zero` does not panic on `HintError::AssertNotZero`.
these error tests could be parameterized using rtest to reduce alot of repetitive boilerplate.
vm/src/test_helpers/test_utils.rs line 48 at r2 (raw file):
Ok(v) => v, Err(e) => panic!("conversion to MaybeRelocatable failed: {e:?}"), };
pls factor out the conversion logic of both cases into a single func which also enforces coercion into MaybeRelocatable (currently it will work for any right that is able to be try_into'd left's type).
Code quote:
let right_mr = match ($right).try_into() {
Ok(v) => v,
Err(e) => panic!("conversion to MaybeRelocatable failed: {e:?}"),
};Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nt::Internal These errors arrive wrapped as Hint(Internal(...)) since they originate inside hint execution, not as bare VirtualMachineError variants. Remove now-unused expect_vm_error helper and vm_err test helper. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
naor-starkware
left a comment
There was a problem hiding this comment.
@naor-starkware made 4 comments.
Reviewable status: 7 of 10 files reviewed, 4 unresolved discussions (waiting on YairVaknin-starkware).
vm/src/test_helpers/error_utils.rs line 44 at r2 (raw file):
Previously, YairVaknin-starkware wrote…
can just be Result, right? pls looks for similar instances where you can shorten.
Done.
vm/src/test_helpers/error_utils.rs line 62 at r2 (raw file):
Previously, YairVaknin-starkware wrote…
This funcs have very repetitive boiler plate. Pls extract to a single func which these func will invoke that will get the res and the predicate u check.
Done.
vm/src/test_helpers/error_utils.rs line 220 at r2 (raw file):
Previously, YairVaknin-starkware wrote…
these error tests could be parameterized using rtest to reduce alot of repetitive boilerplate.
Done.
vm/src/test_helpers/test_utils.rs line 48 at r2 (raw file):
Previously, YairVaknin-starkware wrote…
pls factor out the conversion logic of both cases into a single func which also enforces coercion into MaybeRelocatable (currently it will work for any right that is able to be try_into'd left's type).
Done.

TITLE
Description
Description of the pull request changes and motivation.
Checklist
This change is