-
Notifications
You must be signed in to change notification settings - Fork 236
Parametrized tests #3669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1431-refactor-function-names-generated-by-plugin
Are you sure you want to change the base?
Parametrized tests #3669
Conversation
…tps://github.com/foundry-rs/starknet-foundry into 1431-parametrized-tests
); | ||
} | ||
|
||
// TODO: Use separate process (with oracle) instead of heavy fib calculation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: Currently this tests uses same approach as the one in fuzzer - fuzzing_exit_first
. However, this is technically non-deterministic and ultimately we should use an external process (oracles) to make one of the tests fail before another.
If you agree with above, I will create and link an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can create one for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also have an e2e contract test that uses name:
.
); | ||
} | ||
|
||
// TODO: Use separate process (with oracle) instead of heavy fib calculation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can create one for that
pub fn new(map: &HashMap<SmolStr, Vec<Expr>>) -> Self { | ||
Self(map.clone()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's bit weird to hide a clone like this, I'd prefer an explicit clone at caller side.
use std::sync::LazyLock; | ||
|
||
static RE_SANITIZE: LazyLock<Regex> = | ||
LazyLock::new(|| Regex::new(r"[^a-zA-Z0-9]+").expect("Failed to create regex")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we even have this kind of invalid characters in the test name itself?
fn sanitize_expr(expr: &Expr, db: &SimpleParserDatabase) -> String { | ||
let expr_text = &expr.as_syntax_node().get_text(db); | ||
let expr_sanitized = RE_SANITIZE | ||
.replace_all(expr_text, "_") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does the replacement work exactly? If I have multiple consecutive invalid characters, will they be replaced with multiple _
or a single one?
|
||
Ok(quote!( | ||
#[implicit_precedence(core::pedersen::Pedersen, core::RangeCheck, core::integer::Bitwise, core::ec::EcOp, core::poseidon::Poseidon, core::SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, core::gas::GasBuiltin, System)] | ||
#[snforge_internal_test_executable] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if #[test]
managed to execute already before? Won't that duplicate the executables?
let param_count = func | ||
.declaration(db) | ||
.signature(db) | ||
.parameters(db) | ||
.elements(db) | ||
.len(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This query could be reused, not sure how expensive it is though.
Ok(()) | ||
} | ||
|
||
fn get_filtered_func_attributes( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's filtering out just test attr in case there is no fuzzer then maybe it can be named something more explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add some multiple attributes tests cases with at least fuzzer, test and test_case present?
And please explicitly test the expansion of this order:
#[test]
#[fuzzer]
#[test_case(...)]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add/expand e2e/plugin_diagnostics.rs
tests to check for diagnostics with #[test_case]
attribute.
Towards #1431
Stack:
with_parsed_values
#3670Introduced changes
Introduce parametrized tests by addin
#[test_case]
attribute.Checklist
CHANGELOG.md