diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2021-11-15 10:20:37 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-15 10:20:37 -0500 |
commit | ec9f5d5af2d915fbf78b003f45d92deae38e2d12 (patch) | |
tree | b83eaf1127cae9e0c6228d5c7b564ac0d6ac8769 | |
parent | 58e7b290dccbf06abb882daf2ae2b4c1df96f73f (diff) |
feat(unstable/test): include test step pass/fail/ignore counts in final report (#12432)
-rw-r--r-- | cli/tests/testdata/test/steps/failing_steps.out | 2 | ||||
-rw-r--r-- | cli/tests/testdata/test/steps/ignored_steps.out | 2 | ||||
-rw-r--r-- | cli/tests/testdata/test/steps/invalid_usage.out | 2 | ||||
-rw-r--r-- | cli/tests/testdata/test/steps/passing_steps.out | 2 | ||||
-rw-r--r-- | cli/tools/test.rs | 37 |
5 files changed, 40 insertions, 5 deletions
diff --git a/cli/tests/testdata/test/steps/failing_steps.out b/cli/tests/testdata/test/steps/failing_steps.out index 1c5e2e591..6fad8078b 100644 --- a/cli/tests/testdata/test/steps/failing_steps.out +++ b/cli/tests/testdata/test/steps/failing_steps.out @@ -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 diff --git a/cli/tests/testdata/test/steps/ignored_steps.out b/cli/tests/testdata/test/steps/ignored_steps.out index c667a3d95..c71c603b3 100644 --- a/cli/tests/testdata/test/steps/ignored_steps.out +++ b/cli/tests/testdata/test/steps/ignored_steps.out @@ -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] diff --git a/cli/tests/testdata/test/steps/invalid_usage.out b/cli/tests/testdata/test/steps/invalid_usage.out index d6f3c8d33..6eba626b6 100644 --- a/cli/tests/testdata/test/steps/invalid_usage.out +++ b/cli/tests/testdata/test/steps/invalid_usage.out @@ -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 diff --git a/cli/tests/testdata/test/steps/passing_steps.out b/cli/tests/testdata/test/steps/passing_steps.out index b92327d17..99834d675 100644 --- a/cli/tests/testdata/test/steps/passing_steps.out +++ b/cli/tests/testdata/test/steps/passing_steps.out @@ -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] diff --git a/cli/tools/test.rs b/cli/tools/test.rs index ab2f801da..33fb2926d 100644 --- a/cli/tools/test.rs +++ b/cli/tools/test.rs @@ -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); } } |