-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
perf/refactor: partial test runner refactor #7109
Conversation
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.
lgtm, most of the debt here is from small refactoring in related parts of the code and not refactoring the entire thing (e.g. Vec<TestOutcome>
)
makes sense to move free fns to lib
} | ||
|
||
decoders.push(decoder); | ||
} |
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.
Decoder is now obtained from the initial test results.
let mut total_failed = 0; | ||
let mut total_skipped = 0; | ||
let mut suite_results: Vec<TestOutcome> = Vec::new(); | ||
// Build the trace decoder. |
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.
Multiple decoders don't achieve anything more than a single one, so reuse a single decoder and clear the test-dependent data to reuse allocations.
crates/forge/bin/cmd/test/mod.rs
Outdated
@@ -434,59 +383,60 @@ impl TestArgs { | |||
TraceKind::Deployment => false, | |||
}; | |||
|
|||
// Traces need to be identified for gas reports too. | |||
if should_include || self.gas_report { |
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.
Supersedes #7093
} | ||
|
||
if self.gas_report { | ||
gas_report.analyze(&result.traces, &decoder).await; | ||
} | ||
|
||
// If the test failed, we want to stop processing the rest of the tests | ||
if self.fail_fast && result.status == TestStatus::Failure { | ||
break 'outer |
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 previously exited the loop without printing the summary. We also need to do this now since we push the results into the outcome at the end to avoid unnecessary cloning.
let block_outcome = TestOutcome::new( | ||
[(contract_name.clone(), suite_result)].into(), | ||
self.allow_failure, | ||
); |
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 was pretty dumb.
|
||
total_passed += block_outcome.successes().count(); | ||
total_failed += block_outcome.failures().count(); | ||
total_skipped += block_outcome.skips().count(); |
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.
Moved to lazily calculating later. It's cheap anyway.
@@ -550,157 +498,6 @@ impl Provider for TestArgs { | |||
} | |||
} | |||
|
|||
/// The result of a single test | |||
#[derive(Clone, Debug)] | |||
pub struct Test { |
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.
Moved to library
32b0aa8
to
962eb31
Compare
962eb31
to
7e18213
Compare
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.
so glad we're making some progress on the runner stuff
pub calls: Vec<u64>, | ||
pub min: u64, | ||
pub mean: u64, | ||
pub median: u64, | ||
pub max: u64, |
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 is much better
} | ||
|
||
/// Flattens the test outcome into a list of individual tests. | ||
// TODO: Replace this with `tests` and make it return `TestRef<'_>` |
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.
good idea
Numerous perf improvements and simplifications in test runner code.
Option::as_slice
Vec<TestOutcome>
does not make sense, as only oneTestOutcome
is returned from the main testing function and it's the aggregate of all test suites. This fixes some displaying bugsTest
toSuiteTestResult
, kinda ran out of names, but it's better than just "test". This is constructed by flattening both maps inTestOutcome
, and wraps aTestResult
.Review with "hide whitespace"