From ab728e9ccfff2d1ac6362b22b579b00120a39f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 9 May 2022 10:56:13 +0200 Subject: [PATCH] feat(test): change "failures:" headers in test report (#14490) --- cli/tests/testdata/compat/test_runner/cjs.out | 4 ++-- cli/tests/testdata/compat/test_runner/esm.out | 4 ++-- cli/tests/testdata/test/aggregate_error.out | 4 ++-- cli/tests/testdata/test/allow_none.out | 4 ++-- cli/tests/testdata/test/exit_sanitizer.out | 4 ++-- cli/tests/testdata/test/fail.out | 4 ++-- cli/tests/testdata/test/fail_fast.out | 4 ++-- cli/tests/testdata/test/fail_fast_with_val.out | 4 ++-- cli/tests/testdata/test/finally_timeout.out | 4 ++-- cli/tests/testdata/test/no_prompt_by_default.out | 4 ++-- cli/tests/testdata/test/no_prompt_with_denied_perms.out | 4 ++-- .../testdata/test/ops_sanitizer_missing_details.out | 4 ++-- .../test/ops_sanitizer_multiple_timeout_tests.out | 4 ++-- .../ops_sanitizer_multiple_timeout_tests_no_trace.out | 4 ++-- cli/tests/testdata/test/ops_sanitizer_unstable.out | 4 ++-- cli/tests/testdata/test/resource_sanitizer.out | 4 ++-- cli/tests/testdata/test/steps/failing_steps.out | 4 ++-- cli/tests/testdata/test/steps/invalid_usage.out | 4 ++-- cli/tools/test.rs | 4 ++-- runtime/colors.rs | 9 +++++++++ 20 files changed, 47 insertions(+), 38 deletions(-) diff --git a/cli/tests/testdata/compat/test_runner/cjs.out b/cli/tests/testdata/compat/test_runner/cjs.out index 918a06b1ac..84f506642f 100644 --- a/cli/tests/testdata/compat/test_runner/cjs.out +++ b/cli/tests/testdata/compat/test_runner/cjs.out @@ -2,7 +2,7 @@ running 2 tests from ./compat/test_runner/cjs.js Correct assertion ... ok ([WILDCARD]) Failed assertion ... FAILED ([WILDCARD]) -failures: + ERRORS Failed assertion => ./compat/test_runner/cjs.js:[WILDCARD] error: AssertionError: Values are not strictly equal: @@ -18,7 +18,7 @@ error: AssertionError: Values are not strictly equal: ^ [WILDCARD] -failures: + FAILURES Failed assertion => ./compat/test_runner/cjs.js:[WILDCARD] diff --git a/cli/tests/testdata/compat/test_runner/esm.out b/cli/tests/testdata/compat/test_runner/esm.out index 7660a3d2a5..9184228b71 100644 --- a/cli/tests/testdata/compat/test_runner/esm.out +++ b/cli/tests/testdata/compat/test_runner/esm.out @@ -2,7 +2,7 @@ running 2 tests from ./compat/test_runner/esm.mjs Correct assertion ... ok ([WILDCARD]) Failed assertion ... FAILED ([WILDCARD]) -failures: + ERRORS Failed assertion => ./compat/test_runner/esm.mjs:[WILDCARD] error: AssertionError: Values are not strictly equal: @@ -18,7 +18,7 @@ error: AssertionError: Values are not strictly equal: ^ [WILDCARD] -failures: + FAILURES Failed assertion => ./compat/test_runner/esm.mjs:[WILDCARD] diff --git a/cli/tests/testdata/test/aggregate_error.out b/cli/tests/testdata/test/aggregate_error.out index dacce89798..c21416e012 100644 --- a/cli/tests/testdata/test/aggregate_error.out +++ b/cli/tests/testdata/test/aggregate_error.out @@ -1,7 +1,7 @@ running 1 test from ./test/aggregate_error.ts aggregate ... FAILED ([WILDCARD]) -failures: + ERRORS aggregate => ./test/aggregate_error.ts:[WILDCARD] error: AggregateError @@ -13,7 +13,7 @@ error: AggregateError ^ at [WILDCARD]/testdata/test/aggregate_error.ts:5:9 -failures: + FAILURES aggregate => ./test/aggregate_error.ts:[WILDCARD] diff --git a/cli/tests/testdata/test/allow_none.out b/cli/tests/testdata/test/allow_none.out index 241a5dd1a8..f52eadb829 100644 --- a/cli/tests/testdata/test/allow_none.out +++ b/cli/tests/testdata/test/allow_none.out @@ -8,7 +8,7 @@ run ... FAILED [WILDCARD] ffi ... FAILED [WILDCARD] hrtime ... FAILED [WILDCARD] -failures: + ERRORS read => ./test/allow_none.ts:[WILDCARD] error: PermissionDenied: Can't escalate parent thread permissions @@ -38,7 +38,7 @@ hrtime => ./test/allow_none.ts:[WILDCARD] error: PermissionDenied: Can't escalate parent thread permissions [WILDCARD] -failures: + FAILURES read => ./test/allow_none.ts:[WILDCARD] write => ./test/allow_none.ts:[WILDCARD] diff --git a/cli/tests/testdata/test/exit_sanitizer.out b/cli/tests/testdata/test/exit_sanitizer.out index 4e117b7b64..9ed9a77f90 100644 --- a/cli/tests/testdata/test/exit_sanitizer.out +++ b/cli/tests/testdata/test/exit_sanitizer.out @@ -4,7 +4,7 @@ exit(0) ... FAILED ([WILDCARD]) exit(1) ... FAILED ([WILDCARD]) exit(2) ... FAILED ([WILDCARD]) -failures: + ERRORS exit(0) => ./test/exit_sanitizer.ts:[WILDCARD] error: AssertionError: Test case attempted to exit with exit code: 0 @@ -27,7 +27,7 @@ error: AssertionError: Test case attempted to exit with exit code: 2 at [WILDCARD] at [WILDCARD]/test/exit_sanitizer.ts:10:8 -failures: + FAILURES exit(0) => ./test/exit_sanitizer.ts:[WILDCARD] exit(1) => ./test/exit_sanitizer.ts:[WILDCARD] diff --git a/cli/tests/testdata/test/fail.out b/cli/tests/testdata/test/fail.out index f996487e13..3b33506e9b 100644 --- a/cli/tests/testdata/test/fail.out +++ b/cli/tests/testdata/test/fail.out @@ -11,7 +11,7 @@ test 7 ... FAILED ([WILDCARD]) test 8 ... FAILED ([WILDCARD]) test 9 ... FAILED ([WILDCARD]) -failures: + ERRORS test 0 => ./test/fail.ts:1:6 error: Error @@ -73,7 +73,7 @@ error: Error ^ at [WILDCARD]/test/fail.ts:29:9 -failures: + FAILURES test 0 => ./test/fail.ts:1:6 test 1 => ./test/fail.ts:4:6 diff --git a/cli/tests/testdata/test/fail_fast.out b/cli/tests/testdata/test/fail_fast.out index 75630072b3..cbfc6ee44b 100644 --- a/cli/tests/testdata/test/fail_fast.out +++ b/cli/tests/testdata/test/fail_fast.out @@ -2,7 +2,7 @@ Check [WILDCARD]/test/fail_fast.ts running 10 tests from ./test/fail_fast.ts test 1 ... FAILED ([WILDCARD]) -failures: + ERRORS test 1 => ./test/fail_fast.ts:[WILDCARD] error: Error @@ -10,7 +10,7 @@ error: Error ^ at [WILDCARD]/test/fail_fast.ts:2:9 -failures: + FAILURES test 1 => ./test/fail_fast.ts:[WILDCARD] diff --git a/cli/tests/testdata/test/fail_fast_with_val.out b/cli/tests/testdata/test/fail_fast_with_val.out index aeb51a20a6..62138830bf 100644 --- a/cli/tests/testdata/test/fail_fast_with_val.out +++ b/cli/tests/testdata/test/fail_fast_with_val.out @@ -3,7 +3,7 @@ running 10 tests from [WILDCARD]/test/fail_fast_with_val.ts test test 1 ... FAILED ([WILDCARD]) test test 2 ... FAILED ([WILDCARD]) -failures: + ERRORS test 1 => ./test/fail_fast_with_val.ts:[WILDCARD] error: Error @@ -15,7 +15,7 @@ error: Error at [WILDCARD]/test/fail_fast_with_val.ts:5:9 at [WILDCARD] -failures: + FAILURES test 1 => ./test/fail_fast_with_val.ts:[WILDCARD] test 2 => ./test/fail_fast_with_val.ts:[WILDCARD] diff --git a/cli/tests/testdata/test/finally_timeout.out b/cli/tests/testdata/test/finally_timeout.out index f72dbce95a..593b9059b1 100644 --- a/cli/tests/testdata/test/finally_timeout.out +++ b/cli/tests/testdata/test/finally_timeout.out @@ -3,7 +3,7 @@ running 2 tests from ./test/finally_timeout.ts error ... FAILED ([WILDCARD]) success ... ok ([WILDCARD]) -failures: + ERRORS error => ./test/finally_timeout.ts:[WILDCARD] error: Error: fail @@ -11,7 +11,7 @@ error: Error: fail ^ at [WILDCARD]/test/finally_timeout.ts:4:11 -failures: + FAILURES error => ./test/finally_timeout.ts:[WILDCARD] diff --git a/cli/tests/testdata/test/no_prompt_by_default.out b/cli/tests/testdata/test/no_prompt_by_default.out index f577337d81..4995a42692 100644 --- a/cli/tests/testdata/test/no_prompt_by_default.out +++ b/cli/tests/testdata/test/no_prompt_by_default.out @@ -1,13 +1,13 @@ running 1 test from ./test/no_prompt_by_default.ts no prompt ... FAILED ([WILDCARD]ms) -failures: + ERRORS no prompt => ./test/no_prompt_by_default.ts:[WILDCARD] error: PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag [WILDCARD] -failures: + FAILURES no prompt => ./test/no_prompt_by_default.ts:[WILDCARD] diff --git a/cli/tests/testdata/test/no_prompt_with_denied_perms.out b/cli/tests/testdata/test/no_prompt_with_denied_perms.out index 6953230434..93e4ae5e80 100644 --- a/cli/tests/testdata/test/no_prompt_with_denied_perms.out +++ b/cli/tests/testdata/test/no_prompt_with_denied_perms.out @@ -1,13 +1,13 @@ running 1 test from ./test/no_prompt_with_denied_perms.ts no prompt ... FAILED ([WILDCARD]ms) -failures: + ERRORS no prompt => ./test/no_prompt_with_denied_perms.ts:[WILDCARD] error: PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag [WILDCARD] -failures: + FAILURES no prompt => ./test/no_prompt_with_denied_perms.ts:[WILDCARD] diff --git a/cli/tests/testdata/test/ops_sanitizer_missing_details.out b/cli/tests/testdata/test/ops_sanitizer_missing_details.out index f5fd086b70..58d6560121 100644 --- a/cli/tests/testdata/test/ops_sanitizer_missing_details.out +++ b/cli/tests/testdata/test/ops_sanitizer_missing_details.out @@ -2,7 +2,7 @@ Check [WILDCARD]test/ops_sanitizer_missing_details.ts running 1 test from ./test/ops_sanitizer_missing_details.ts test 1 ... FAILED [WILDCARD] -failures: + ERRORS test 1 => ./test/ops_sanitizer_missing_details.ts:[WILDCARD] error: Test case is leaking async ops. @@ -11,7 +11,7 @@ error: Test case is leaking async ops. To get more details where ops were leaked, run again with --trace-ops flag. -failures: + FAILURES test 1 => ./test/ops_sanitizer_missing_details.ts:[WILDCARD] diff --git a/cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.out b/cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.out index 954e417881..bb9229c020 100644 --- a/cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.out +++ b/cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests.out @@ -3,7 +3,7 @@ running 2 tests from ./test/ops_sanitizer_multiple_timeout_tests.ts test 1 ... FAILED ([WILDCARD]) test 2 ... FAILED ([WILDCARD]) -failures: + ERRORS test 1 => ./test/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] error: Test case is leaking async ops. @@ -37,7 +37,7 @@ error: Test case is leaking async ops. at [WILDCARD]/testdata/test/ops_sanitizer_multiple_timeout_tests.ts:10:27 at [WILDCARD] -failures: + FAILURES test 1 => ./test/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] test 2 => ./test/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] diff --git a/cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests_no_trace.out b/cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests_no_trace.out index e4ca9b906c..7b2dc168bf 100644 --- a/cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests_no_trace.out +++ b/cli/tests/testdata/test/ops_sanitizer_multiple_timeout_tests_no_trace.out @@ -3,7 +3,7 @@ running 2 tests from ./test/ops_sanitizer_multiple_timeout_tests.ts test 1 ... FAILED ([WILDCARD]) test 2 ... FAILED ([WILDCARD]) -failures: + ERRORS test 1 => ./test/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] error: Test case is leaking async ops. @@ -19,7 +19,7 @@ error: Test case is leaking async ops. To get more details where ops were leaked, run again with --trace-ops flag. -failures: + FAILURES test 1 => ./test/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] test 2 => ./test/ops_sanitizer_multiple_timeout_tests.ts:[WILDCARD] diff --git a/cli/tests/testdata/test/ops_sanitizer_unstable.out b/cli/tests/testdata/test/ops_sanitizer_unstable.out index b8cbf33cba..8be4e45515 100644 --- a/cli/tests/testdata/test/ops_sanitizer_unstable.out +++ b/cli/tests/testdata/test/ops_sanitizer_unstable.out @@ -3,7 +3,7 @@ running 2 tests from ./test/ops_sanitizer_unstable.ts no-op ... ok ([WILDCARD]) leak interval ... FAILED ([WILDCARD]) -failures: + ERRORS leak interval => ./test/ops_sanitizer_unstable.ts:[WILDCARD] error: Test case is leaking async ops. @@ -14,7 +14,7 @@ error: Test case is leaking async ops. at [WILDCARD]/testdata/test/ops_sanitizer_unstable.ts:3:3 at [WILDCARD] -failures: + FAILURES leak interval => ./test/ops_sanitizer_unstable.ts:[WILDCARD] diff --git a/cli/tests/testdata/test/resource_sanitizer.out b/cli/tests/testdata/test/resource_sanitizer.out index 949ec64a7c..f5d097783e 100644 --- a/cli/tests/testdata/test/resource_sanitizer.out +++ b/cli/tests/testdata/test/resource_sanitizer.out @@ -2,7 +2,7 @@ Check [WILDCARD]/test/resource_sanitizer.ts running 1 test from ./test/resource_sanitizer.ts leak ... FAILED ([WILDCARD]) -failures: + ERRORS leak => ./test/resource_sanitizer.ts:[WILDCARD] error: AssertionError: Test case is leaking 2 resources: @@ -12,7 +12,7 @@ error: AssertionError: Test case is leaking 2 resources: at [WILDCARD] -failures: + FAILURES leak => ./test/resource_sanitizer.ts:[WILDCARD] diff --git a/cli/tests/testdata/test/steps/failing_steps.out b/cli/tests/testdata/test/steps/failing_steps.out index 5baa09ce7f..d42736977c 100644 --- a/cli/tests/testdata/test/steps/failing_steps.out +++ b/cli/tests/testdata/test/steps/failing_steps.out @@ -33,7 +33,7 @@ failing step in failing test ... at [WILDCARD] FAILED ([WILDCARD]) -failures: + ERRORS nested failure => ./test/steps/failing_steps.ts:[WILDCARD] error: Error: 1 test step failed. @@ -51,7 +51,7 @@ error: Error: Fail test. ^ at [WILDCARD]/failing_steps.ts:[WILDCARD] -failures: + FAILURES nested failure => ./test/steps/failing_steps.ts:[WILDCARD] multiple test step failures => ./test/steps/failing_steps.ts:[WILDCARD] diff --git a/cli/tests/testdata/test/steps/invalid_usage.out b/cli/tests/testdata/test/steps/invalid_usage.out index afa19c53d4..c3e47c37ed 100644 --- a/cli/tests/testdata/test/steps/invalid_usage.out +++ b/cli/tests/testdata/test/steps/invalid_usage.out @@ -64,7 +64,7 @@ parallel steps where only inner tests have sanitizers ... FAILED ([WILDCARD]) FAILED ([WILDCARD]) -failures: + ERRORS capturing => ./test/steps/invalid_usage.ts:[WILDCARD] error: Error: Cannot run test step after parent scope has finished execution. Ensure any `.step(...)` calls are executed before their parent scope completes execution. @@ -99,7 +99,7 @@ error: Error: 1 test step failed. at runTest ([WILDCARD]) at [WILDCARD] -failures: + FAILURES capturing => ./test/steps/invalid_usage.ts:[WILDCARD] top level missing await => ./test/steps/invalid_usage.ts:[WILDCARD] diff --git a/cli/tools/test.rs b/cli/tools/test.rs index dc3eeba3b8..38c6919ccb 100644 --- a/cli/tools/test.rs +++ b/cli/tools/test.rs @@ -452,7 +452,7 @@ impl TestReporter for PrettyTestReporter { fn report_summary(&mut self, summary: &TestSummary, elapsed: &Duration) { if !summary.failures.is_empty() { let mut failure_titles = vec![]; - println!("\nfailures:\n"); + println!("\n{}\n", colors::white_bold_on_red(" ERRORS ")); for (description, js_error) in &summary.failures { let failure_title = format!( "{} {}", @@ -475,7 +475,7 @@ impl TestReporter for PrettyTestReporter { failure_titles.push(failure_title); } - println!("failures:\n"); + println!("{}\n", colors::white_bold_on_red(" FAILURES ")); for failure_title in failure_titles { println!("{}", failure_title); } diff --git a/runtime/colors.rs b/runtime/colors.rs index f9d48fe53f..7159db9f6f 100644 --- a/runtime/colors.rs +++ b/runtime/colors.rs @@ -123,3 +123,12 @@ pub fn intense_blue>(s: S) -> impl fmt::Display { style_spec.set_fg(Some(Blue)).set_intense(true); style(s, style_spec) } + +pub fn white_bold_on_red>(s: S) -> impl fmt::Display { + let mut style_spec = ColorSpec::new(); + style_spec + .set_bold(true) + .set_bg(Some(Red)) + .set_fg(Some(White)); + style(s, style_spec) +}