-
Notifications
You must be signed in to change notification settings - Fork 219
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
feat: skip tests having oracle calls #6666
Open
guipublic
wants to merge
17
commits into
master
Choose a base branch
from
gd/issue_6643
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a1aa047
skip tests having oracle calls
guipublic 50da277
update doc
guipublic d7a3207
fix test case
guipublic 4972251
Merge branch 'master' into gd/issue_6643
guipublic 4a8019d
do not skip tests having mock oracles
guipublic 96368f5
fix merge issue
guipublic 375e971
Merge branch 'master' into gd/issue_6643
guipublic dc3327d
Merge branch 'master' into gd/issue_6643
guipublic 071b2a3
code review
guipublic af3bc52
skip_oracle as a test option
guipublic fd06d99
fit text case
guipublic e4b1b91
Merge branch 'master' into gd/issue_6643
guipublic 14bb5ab
use skip-oracle on CI tests
guipublic a903a30
Merge branch 'master' into gd/issue_6643
guipublic 7b4185c
skip failing tests using oracles
guipublic ea59025
Merge branch 'master' into gd/issue_6643
guipublic c1fe899
skip oracle based on mock count (test)
guipublic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -49,6 +49,10 @@ pub(crate) struct TestCommand { | |||||
/// JSON RPC url to solve oracle calls | ||||||
#[clap(long)] | ||||||
oracle_resolver: Option<String>, | ||||||
|
||||||
/// Flag to skip tests using oracles. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The way it's phrased sounds like any test with an oracle will be skipped. |
||||||
#[arg(long, hide = true)] | ||||||
skip_oracle: bool, | ||||||
} | ||||||
|
||||||
pub(crate) fn run(args: TestCommand, config: NargoConfig) -> Result<(), CliError> { | ||||||
|
@@ -76,7 +80,6 @@ pub(crate) fn run(args: TestCommand, config: NargoConfig) -> Result<(), CliError | |||||
} | ||||||
None => FunctionNameMatch::Anything, | ||||||
}; | ||||||
|
||||||
// Configure a thread pool with a larger stack size to prevent overflowing stack in large programs. | ||||||
// Default is 2MB. | ||||||
let pool = rayon::ThreadPoolBuilder::new().stack_size(4 * 1024 * 1024).build().unwrap(); | ||||||
|
@@ -94,6 +97,7 @@ pub(crate) fn run(args: TestCommand, config: NargoConfig) -> Result<(), CliError | |||||
args.oracle_resolver.as_deref(), | ||||||
Some(workspace.root_dir.clone()), | ||||||
Some(package.name.to_string()), | ||||||
args.skip_oracle, | ||||||
&args.compile_options, | ||||||
) | ||||||
}) | ||||||
|
@@ -133,6 +137,7 @@ fn run_tests<S: BlackBoxFunctionSolver<FieldElement> + Default>( | |||||
foreign_call_resolver_url: Option<&str>, | ||||||
root_path: Option<PathBuf>, | ||||||
package_name: Option<String>, | ||||||
skip_oracle: bool, | ||||||
compile_options: &CompileOptions, | ||||||
) -> Result<Vec<(String, TestStatus)>, CliError> { | ||||||
let test_functions = | ||||||
|
@@ -155,6 +160,7 @@ fn run_tests<S: BlackBoxFunctionSolver<FieldElement> + Default>( | |||||
foreign_call_resolver_url, | ||||||
root_path.clone(), | ||||||
package_name.clone(), | ||||||
skip_oracle, | ||||||
compile_options, | ||||||
); | ||||||
|
||||||
|
@@ -176,6 +182,7 @@ fn run_test<S: BlackBoxFunctionSolver<FieldElement> + Default>( | |||||
foreign_call_resolver_url: Option<&str>, | ||||||
root_path: Option<PathBuf>, | ||||||
package_name: Option<String>, | ||||||
skip_oracle: bool, | ||||||
compile_options: &CompileOptions, | ||||||
) -> TestStatus { | ||||||
// This is really hacky but we can't share `Context` or `S` across threads. | ||||||
|
@@ -199,6 +206,7 @@ fn run_test<S: BlackBoxFunctionSolver<FieldElement> + Default>( | |||||
foreign_call_resolver_url, | ||||||
root_path, | ||||||
package_name, | ||||||
skip_oracle, | ||||||
compile_options, | ||||||
) | ||||||
} | ||||||
|
@@ -275,32 +283,39 @@ fn display_test_report( | |||||
|
||||||
write!(writer, "[{}] ", package.name).expect("Failed to write to stderr"); | ||||||
|
||||||
let count_all = test_report.len(); | ||||||
let count_failed = test_report.iter().filter(|(_, status)| status.failed()).count(); | ||||||
let plural = if count_all == 1 { "" } else { "s" }; | ||||||
if count_failed == 0 { | ||||||
let count_passed = test_report.iter().filter(|(_, status)| status.passed()).count(); | ||||||
let count_skipped = test_report.iter().filter(|(_, status)| status.skipped()).count(); | ||||||
let plural_failed = if count_failed == 1 { "" } else { "s" }; | ||||||
let plural_passed = if count_passed == 1 { "" } else { "s" }; | ||||||
let plural_skipped = if count_skipped == 1 { "" } else { "s" }; | ||||||
let mut previous = false; | ||||||
if count_passed > 0 { | ||||||
aakoshh marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
writer.set_color(ColorSpec::new().set_fg(Some(Color::Green))).expect("Failed to set color"); | ||||||
write!(writer, "{count_all} test{plural} passed").expect("Failed to write to stderr"); | ||||||
writer.reset().expect("Failed to reset writer"); | ||||||
writeln!(writer).expect("Failed to write to stderr"); | ||||||
} else { | ||||||
let count_passed = count_all - count_failed; | ||||||
let plural_failed = if count_failed == 1 { "" } else { "s" }; | ||||||
let plural_passed = if count_passed == 1 { "" } else { "s" }; | ||||||
|
||||||
if count_passed != 0 { | ||||||
writer | ||||||
.set_color(ColorSpec::new().set_fg(Some(Color::Green))) | ||||||
.expect("Failed to set color"); | ||||||
write!(writer, "{count_passed} test{plural_passed} passed, ",) | ||||||
.expect("Failed to write to stderr"); | ||||||
write!(writer, "{count_passed} test{plural_passed} passed",) | ||||||
.expect("Failed to write to stderr"); | ||||||
previous = true; | ||||||
} | ||||||
if count_skipped > 0 { | ||||||
writer | ||||||
.set_color(ColorSpec::new().set_fg(Some(Color::Yellow))) | ||||||
.expect("Failed to set color"); | ||||||
if previous { | ||||||
write!(writer, ", ").expect("Failed to write to stderr"); | ||||||
} | ||||||
guipublic marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
write!(writer, "{count_skipped} test{plural_skipped} skipped") | ||||||
.expect("Failed to write to stderr"); | ||||||
previous = true; | ||||||
} | ||||||
if count_failed > 0 { | ||||||
writer.set_color(ColorSpec::new().set_fg(Some(Color::Red))).expect("Failed to set color"); | ||||||
writeln!(writer, "{count_failed} test{plural_failed} failed") | ||||||
if previous { | ||||||
write!(writer, ", ").expect("Failed to write to stderr"); | ||||||
} | ||||||
write!(writer, "{count_failed} test{plural_failed} failed") | ||||||
.expect("Failed to write to stderr"); | ||||||
writer.reset().expect("Failed to reset writer"); | ||||||
} | ||||||
|
||||||
writeln!(writer).expect("Failed to write to stderr"); | ||||||
writer.reset().expect("Failed to reset writer"); | ||||||
Ok(()) | ||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why aren't all the other mock functions considered to be
Mocked
status?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 wanted to identify mocked oracles by looking at the create_mock() function, but it is not easy. Instead I used an heuristic that consider that all oracles are mocked if there is one create_mock.