Merge pull request #862 from SundaeSwap-finance/pi/summary-check-count

Include the number of tests / checks run as part of the summary
This commit is contained in:
Matthias Benkort 2024-03-09 13:10:16 +01:00 committed by GitHub
commit 7f0df40b4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 1 deletions

View File

@ -89,6 +89,7 @@ where
root: PathBuf,
sources: Vec<Source>,
warnings: Vec<Warning>,
checks_count: Option<usize>,
event_listener: T,
functions: IndexMap<FunctionAccessKey, TypedFunction>,
data_types: IndexMap<DataTypeKey, TypedDataType>,
@ -128,6 +129,7 @@ where
root,
sources: vec![],
warnings: vec![],
checks_count: None,
event_listener,
functions,
data_types,
@ -336,6 +338,17 @@ where
let tests = self.run_tests(tests, seed);
self.checks_count = if tests.is_empty() {
None
} else {
Some(tests.iter().fold(0, |acc, test| {
acc + match test {
TestResult::PropertyTestResult(r) => r.iterations,
_ => 1,
}
}))
};
let errors: Vec<Error> = tests
.iter()
.filter_map(|e| {

View File

@ -24,6 +24,7 @@ impl ExitFailure {
}
struct Summary {
check_count: Option<usize>,
warning_count: usize,
error_count: usize,
}
@ -31,10 +32,22 @@ struct Summary {
impl Display for Summary {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(&format!(
" {} {} {}, {} {}",
" {} {}{}{} {}, {} {}",
"Summary"
.if_supports_color(Stderr, |s| s.purple())
.if_supports_color(Stderr, |s| s.bold()),
if let Some(c) = self.check_count {
format!("{} ", c)
} else {
"".to_string()
},
match self.check_count {
Some(1) => "check, ",
Some(_) => "checks, ",
None => "",
}
.if_supports_color(Stderr, |s| s.green())
.if_supports_color(Stderr, |s| s.bold()),
self.error_count,
if self.error_count == 1 {
"error"
@ -111,6 +124,7 @@ where
eprintln!(
"{}",
Summary {
check_count: project.checks_count,
warning_count,
error_count: errs.len(),
}
@ -122,6 +136,7 @@ where
eprintln!(
"{}",
Summary {
check_count: project.checks_count,
error_count: 0,
warning_count
}