Skip to content

Commit

Permalink
feat(test): change "failures:" headers in test report (denoland#14490)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju committed May 9, 2022
1 parent d0f5cd6 commit ab728e9
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 38 deletions.
4 changes: 2 additions & 2 deletions cli/tests/testdata/compat/test_runner/cjs.out
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -18,7 +18,7 @@ error: AssertionError: Values are not strictly equal:
^
[WILDCARD]

failures:
FAILURES

Failed assertion => ./compat/test_runner/cjs.js:[WILDCARD]

Expand Down
4 changes: 2 additions & 2 deletions cli/tests/testdata/compat/test_runner/esm.out
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -18,7 +18,7 @@ error: AssertionError: Values are not strictly equal:
^
[WILDCARD]

failures:
FAILURES

Failed assertion => ./compat/test_runner/esm.mjs:[WILDCARD]

Expand Down
4 changes: 2 additions & 2 deletions cli/tests/testdata/test/aggregate_error.out
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,7 +13,7 @@ error: AggregateError
^
at [WILDCARD]/testdata/test/aggregate_error.ts:5:9

failures:
FAILURES

aggregate => ./test/aggregate_error.ts:[WILDCARD]

Expand Down
4 changes: 2 additions & 2 deletions cli/tests/testdata/test/allow_none.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/testdata/test/exit_sanitizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/testdata/test/fail.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/testdata/test/fail_fast.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ 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
throw new Error();
^
at [WILDCARD]/test/fail_fast.ts:2:9

failures:
FAILURES

test 1 => ./test/fail_fast.ts:[WILDCARD]

Expand Down
4 changes: 2 additions & 2 deletions cli/tests/testdata/test/fail_fast_with_val.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/testdata/test/finally_timeout.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ 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
throw new Error("fail");
^
at [WILDCARD]/test/finally_timeout.ts:4:11

failures:
FAILURES

error => ./test/finally_timeout.ts:[WILDCARD]

Expand Down
4 changes: 2 additions & 2 deletions cli/tests/testdata/test/no_prompt_by_default.out
Original file line number Diff line number Diff line change
@@ -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]

Expand Down
4 changes: 2 additions & 2 deletions cli/tests/testdata/test/no_prompt_with_denied_perms.out
Original file line number Diff line number Diff line change
@@ -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]

Expand Down
4 changes: 2 additions & 2 deletions cli/tests/testdata/test/ops_sanitizer_missing_details.out
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/testdata/test/ops_sanitizer_unstable.out
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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]

Expand Down
4 changes: 2 additions & 2 deletions cli/tests/testdata/test/resource_sanitizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -12,7 +12,7 @@ error: AssertionError: Test case is leaking 2 resources:

at [WILDCARD]

failures:
FAILURES

leak => ./test/resource_sanitizer.ts:[WILDCARD]

Expand Down
4 changes: 2 additions & 2 deletions cli/tests/testdata/test/steps/failing_steps.out
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/testdata/test/steps/invalid_usage.out
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions cli/tools/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
"{} {}",
Expand All @@ -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);
}
Expand Down
9 changes: 9 additions & 0 deletions runtime/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,12 @@ pub fn intense_blue<S: AsRef<str>>(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: AsRef<str>>(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)
}

0 comments on commit ab728e9

Please sign in to comment.