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, root: PathBuf,
sources: Vec<Source>, sources: Vec<Source>,
warnings: Vec<Warning>, warnings: Vec<Warning>,
checks_count: Option<usize>,
event_listener: T, event_listener: T,
functions: IndexMap<FunctionAccessKey, TypedFunction>, functions: IndexMap<FunctionAccessKey, TypedFunction>,
data_types: IndexMap<DataTypeKey, TypedDataType>, data_types: IndexMap<DataTypeKey, TypedDataType>,
@ -128,6 +129,7 @@ where
root, root,
sources: vec![], sources: vec![],
warnings: vec![], warnings: vec![],
checks_count: None,
event_listener, event_listener,
functions, functions,
data_types, data_types,
@ -336,6 +338,17 @@ where
let tests = self.run_tests(tests, seed); 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 let errors: Vec<Error> = tests
.iter() .iter()
.filter_map(|e| { .filter_map(|e| {

View File

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