Correctly report the checks count
It might be slightly cleaner and more extensible to change to return a summary, potentially even making track the tests, coverage, etc. so it can be serialized to JSON. But, for now, this is much simpler, and the approach that KtorZ suggested.
This commit is contained in:
@@ -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,15 @@ 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| {
|
||||
|
||||
@@ -120,7 +120,7 @@ where
|
||||
eprintln!(
|
||||
"{}",
|
||||
Summary {
|
||||
check_count: None,
|
||||
check_count: project.checks_count,
|
||||
warning_count,
|
||||
error_count: errs.len(),
|
||||
}
|
||||
@@ -132,7 +132,7 @@ where
|
||||
eprintln!(
|
||||
"{}",
|
||||
Summary {
|
||||
check_count: Some(41),
|
||||
check_count: project.checks_count,
|
||||
error_count: 0,
|
||||
warning_count
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user