1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 15:24:46 -05:00

feat(unstable/test): include test step pass/fail/ignore counts in final report (#12432)

This commit is contained in:
David Sherret 2021-11-15 10:20:37 -05:00 committed by GitHub
parent 58e7b290dc
commit ec9f5d5af2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 5 deletions

View file

@ -48,6 +48,6 @@ failures:
multiple test step failures
failing step in failing test
test result: FAILED. 0 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
test result: FAILED. 0 passed (1 step); 3 failed (5 steps); 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
error: Test failed

View file

@ -5,4 +5,4 @@ test ignored step ...
test step 2 ... ok ([WILDCARD])
ok ([WILDCARD])
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out [WILDCARD]
test result: ok. 1 passed (1 step); 0 failed; 0 ignored (1 step); 0 measured; 0 filtered out [WILDCARD]

View file

@ -107,6 +107,6 @@ failures:
parallel steps when second has sanitizer
parallel steps where only inner tests have sanitizers
test result: FAILED. 0 passed; 7 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
test result: FAILED. 0 passed (4 steps); 7 failed (10 steps); 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
error: Test failed

View file

@ -35,4 +35,4 @@ test steps buffered then streaming reporting ...
test step 2 ... ok ([WILDCARD])
ok ([WILDCARD])
test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out [WILDCARD]
test result: ok. 5 passed (18 steps); 0 failed; 0 ignored; 0 measured; 0 filtered out [WILDCARD]

View file

@ -138,6 +138,10 @@ pub struct TestSummary {
pub passed: usize,
pub failed: usize,
pub ignored: usize,
pub passed_steps: usize,
pub failed_steps: usize,
pub pending_steps: usize,
pub ignored_steps: usize,
pub filtered_out: usize,
pub measured: usize,
pub failures: Vec<(TestDescription, String)>,
@ -150,6 +154,10 @@ impl TestSummary {
passed: 0,
failed: 0,
ignored: 0,
passed_steps: 0,
failed_steps: 0,
pending_steps: 0,
ignored_steps: 0,
filtered_out: 0,
measured: 0,
failures: Vec::new(),
@ -398,12 +406,24 @@ impl TestReporter for PrettyTestReporter {
colors::green("ok").to_string()
};
let get_steps_text = |count: usize| -> String {
if count == 0 {
String::new()
} else if count == 1 {
" (1 step)".to_string()
} else {
format!(" ({} steps)", count)
}
};
println!(
"\ntest result: {}. {} passed; {} failed; {} ignored; {} measured; {} filtered out {}\n",
"\ntest result: {}. {} passed{}; {} failed{}; {} ignored{}; {} measured; {} filtered out {}\n",
status,
summary.passed,
get_steps_text(summary.passed_steps),
summary.failed,
get_steps_text(summary.failed_steps + summary.pending_steps),
summary.ignored,
get_steps_text(summary.ignored_steps),
summary.measured,
summary.filtered_out,
colors::gray(human_elapsed(elapsed.as_millis())),
@ -846,6 +866,21 @@ async fn test_specifiers(
}
TestEvent::StepResult(description, result, duration) => {
match &result {
TestStepResult::Ok => {
summary.passed_steps += 1;
}
TestStepResult::Ignored => {
summary.ignored_steps += 1;
}
TestStepResult::Failed(_) => {
summary.failed_steps += 1;
}
TestStepResult::Pending(_) => {
summary.pending_steps += 1;
}
}
reporter.report_step_result(&description, &result, duration);
}
}