Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli/test): improve test output readability #24357

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat(cli/test): improve test output readability (#24071)
Indent last line of tests that contain multiple steps.
  • Loading branch information
nkaradzhov committed Jun 28, 2024
commit ee32ccf1b7f00e4af311e936af5e6561b1f69821
14 changes: 14 additions & 0 deletions cli/tools/test/reporters/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ impl PrettyTestReporter {
elapsed: u64,
) {
self.write_output_end();
if self.in_new_line
&& (matches!(result, TestStepResult::Ok)
|| matches!(result, TestStepResult::Failed(_)))
{
write!(&mut self.writer, " ").unwrap();
}
if self.in_new_line || self.scope_test_id != Some(description.id) {
self.force_report_step_wait(description);
}
Expand Down Expand Up @@ -270,6 +276,14 @@ impl TestReporter for PrettyTestReporter {
}

self.write_output_end();

if self.in_new_line
&& (matches!(result, TestResult::Ok)
|| matches!(result, TestResult::Failed(_)))
{
write!(&mut self.writer, " ").unwrap();
}

if self.in_new_line || self.scope_test_id != Some(description.id) {
self.force_report_wait(description);
}
Expand Down
22 changes: 11 additions & 11 deletions tests/testdata/node/test.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,55 @@ sync pass todo ...
------- output -------
Warning: Not implemented: test.TestContext.todo
----- output end -----
sync pass todo ... ok [WILDCARD]
sync pass todo ... ok [WILDCARD]
sync pass todo with message ...
------- output -------
Warning: Not implemented: test.TestContext.todo
----- output end -----
sync pass todo with message ... ok [WILDCARD]
sync pass todo with message ... ok [WILDCARD]
sync fail todo ...
------- output -------
Warning: Not implemented: test.TestContext.todo
----- output end -----
sync fail todo ... FAILED [WILDCARD]
sync fail todo ... FAILED [WILDCARD]
sync fail todo with message ...
------- output -------
Warning: Not implemented: test.TestContext.todo
----- output end -----
sync fail todo with message ... FAILED [WILDCARD]
sync fail todo with message ... FAILED [WILDCARD]
sync skip pass ...
------- output -------
Warning: Not implemented: test.TestContext.skip
----- output end -----
sync skip pass ... ok [WILDCARD]
sync skip pass ... ok [WILDCARD]
sync skip pass with message ...
------- output -------
Warning: Not implemented: test.TestContext.skip
----- output end -----
sync skip pass with message ... ok [WILDCARD]
sync skip pass with message ... ok [WILDCARD]
sync pass ...
------- output -------
DIAGNOSTIC: this test should pass
----- output end -----
sync pass ... ok [WILDCARD]
sync pass ... ok [WILDCARD]
sync throw fail ... FAILED [WILDCARD]
async skip pass ...
------- output -------
Warning: Not implemented: test.TestContext.skip
----- output end -----
async skip pass ... ok [WILDCARD]
async skip pass ... ok [WILDCARD]
async pass ... ok [WILDCARD]
async throw fail ... FAILED [WILDCARD]
nested test ...
nested 1 ...
nested 2 ... ok [WILDCARD]
nested 1 ... ok [WILDCARD]
nested test ... ok [WILDCARD]
nested 1 ... ok [WILDCARD]
nested test ... ok [WILDCARD]
async skip fail ...
------- output -------
Warning: Not implemented: test.TestContext.skip
----- output end -----
async skip fail ... FAILED [WILDCARD]
async skip fail ... FAILED [WILDCARD]
async assertion fail ... FAILED [WILDCARD]
resolve pass ... ok [WILDCARD]
reject fail ... FAILED [WILDCARD]
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/node/test_no_sanitizers/test.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
running 1 test from ./node/test_no_sanitizers/test.js
should not complain about resource and op sanitizers ...
nested test ... ok ([WILDCARD])
should not complain about resource and op sanitizers ... ok ([WILDCARD])
should not complain about resource and op sanitizers ... ok ([WILDCARD])

ok | 1 passed (1 step) | 0 failed ([WILDCARD])

2 changes: 1 addition & 1 deletion tests/testdata/test/load_unload.out
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test ...
------- output -------
test
----- output end -----
test ... ok ([WILDCARD])
test ... ok ([WILDCARD])
------- post-test output -------
unload
----- post-test output end -----
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/test/meta.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ check values ...
import.meta.main: false
import.meta.url: [WILDCARD]/test/meta.ts
----- output end -----
check values ... ok ([WILDCARD])
check values ... ok ([WILDCARD])

ok | 1 passed | 0 failed ([WILDCARD])

16 changes: 8 additions & 8 deletions tests/testdata/test/pass.out
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,42 @@ test 8 ...
------- output -------
console.log
----- output end -----
test 8 ... ok ([WILDCARD])
test 8 ... ok ([WILDCARD])
test 9 ...
------- output -------
console.error
----- output end -----
test 9 ... ok ([WILDCARD])
test 9 ... ok ([WILDCARD])
test\b ...
------- output -------
console.error
----- output end -----
test\b ... ok ([WILDCARD])
test\b ... ok ([WILDCARD])
test\f ...
------- output -------
console.error
----- output end -----
test\f ... ok ([WILDCARD])
test\f ... ok ([WILDCARD])
test\t ...
------- output -------
console.error
----- output end -----
test\t ... ok ([WILDCARD])
test\t ... ok ([WILDCARD])
test\n ...
------- output -------
console.error
----- output end -----
test\n ... ok ([WILDCARD])
test\n ... ok ([WILDCARD])
test\r ...
------- output -------
console.error
----- output end -----
test\r ... ok ([WILDCARD])
test\r ... ok ([WILDCARD])
test\v ...
------- output -------
console.error
----- output end -----
test\v ... ok ([WILDCARD])
test\v ... ok ([WILDCARD])

ok | 16 passed | 0 failed ([WILDCARD])

2 changes: 1 addition & 1 deletion tests/testdata/test/replace_timers.js.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
running 1 test from ./test/replace_timers.js
foo ...
bar ... ok ([WILDCARD])
foo ... ok ([WILDCARD])
foo ... ok ([WILDCARD])

ok | 1 passed (1 step) | 0 failed ([WILDCARD])

8 changes: 4 additions & 4 deletions tests/testdata/test/steps/failing_steps.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ nested failure ...
step 1 ...
inner 1 ... FAILED ([WILDCARD])
inner 2 ... ok ([WILDCARD])
step 1 ... FAILED (due to 1 failed step) ([WILDCARD])
nested failure ... FAILED (due to 1 failed step) ([WILDCARD])
step 1 ... FAILED (due to 1 failed step) ([WILDCARD])
nested failure ... FAILED (due to 1 failed step) ([WILDCARD])
multiple test step failures ...
step 1 ... FAILED ([WILDCARD])
step 2 ... FAILED ([WILDCARD])
multiple test step failures ... FAILED (due to 2 failed steps) ([WILDCARD])
multiple test step failures ... FAILED (due to 2 failed steps) ([WILDCARD])
failing step in failing test ...
step 1 ... FAILED ([WILDCARD])
failing step in failing test ... FAILED ([WILDCARD])
failing step in failing test ... FAILED ([WILDCARD])

ERRORS

Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/test/steps/ignored_steps.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ running 1 test from ./test/steps/ignored_steps.ts
ignored step ...
step 1 ... ignored ([WILDCARD])
step 2 ... ok ([WILDCARD])
ignored step ... ok ([WILDCARD])
ignored step ... ok ([WILDCARD])

ok | 1 passed (1 step) | 0 failed | 0 ignored (1 step) [WILDCARD]
26 changes: 13 additions & 13 deletions tests/testdata/test/steps/invalid_usage.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@
running 7 tests from ./test/steps/invalid_usage.ts
capturing ...
some step ... ok ([WILDCARD])
capturing ... FAILED ([WILDCARD])
capturing ... FAILED ([WILDCARD])
top level missing await ...
step ... INCOMPLETE
top level missing await ... FAILED (due to incomplete steps) ([WILDCARD])
top level missing await ... FAILED (due to incomplete steps) ([WILDCARD])
inner missing await ...
step ...
inner ... INCOMPLETE
step ... FAILED (due to incomplete steps) ([WILDCARD])
inner missing await ... FAILED (due to 1 failed step) ([WILDCARD])
step ... FAILED (due to incomplete steps) ([WILDCARD])
inner missing await ... FAILED (due to 1 failed step) ([WILDCARD])
parallel steps with sanitizers ...
step 1 ... INCOMPLETE
step 2 ... FAILED ([WILDCARD])
parallel steps with sanitizers ... FAILED (due to incomplete steps) ([WILDCARD])
step 2 ... FAILED ([WILDCARD])
parallel steps with sanitizers ... FAILED (due to incomplete steps) ([WILDCARD])
parallel steps when first has sanitizer ...
step 1 ... ok ([WILDCARD])
step 2 ... FAILED ([WILDCARD])
parallel steps when first has sanitizer ... FAILED (due to 1 failed step) ([WILDCARD])
step 2 ... FAILED ([WILDCARD])
parallel steps when first has sanitizer ... FAILED (due to 1 failed step) ([WILDCARD])
parallel steps when second has sanitizer ...
step 1 ... ok ([WILDCARD])
step 2 ... FAILED ([WILDCARD])
parallel steps when second has sanitizer ... FAILED (due to 1 failed step) ([WILDCARD])
step 2 ... FAILED ([WILDCARD])
parallel steps when second has sanitizer ... FAILED (due to 1 failed step) ([WILDCARD])
parallel steps where only inner tests have sanitizers ...
step 1 ...
step inner ... ok ([WILDCARD])
step 1 ... ok ([WILDCARD])
step 2 ...
step 1 ... ok ([WILDCARD])
step 2 ...
step inner ... FAILED ([WILDCARD])
step 2 ... FAILED (due to 1 failed step) ([WILDCARD])
parallel steps where only inner tests have sanitizers ... FAILED (due to 1 failed step) ([WILDCARD])
parallel steps where only inner tests have sanitizers ... FAILED (due to 1 failed step) ([WILDCARD])

ERRORS

Expand Down
8 changes: 4 additions & 4 deletions tests/testdata/test/steps/output_within.out
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ description ...
------- output -------
3
----- output end -----
inner 1 ... ok ([WILDCARD]s)
inner 1 ... ok ([WILDCARD]s)
inner 2 ...
------- output -------
4
----- output end -----
inner 2 ... ok ([WILDCARD]s)
inner 2 ... ok ([WILDCARD]s)
------- output -------
5
----- output end -----
step 1 ... ok ([WILDCARD]s)
step 1 ... ok ([WILDCARD]s)
------- output -------
6
----- output end -----
description ... ok ([WILDCARD]s)
description ... ok ([WILDCARD]s)
[WILDCARD]
28 changes: 14 additions & 14 deletions tests/testdata/test/steps/passing_steps.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,41 @@ description ...
step 1 ...
inner 1 ... ok ([WILDCARD]s)
inner 2 ... ok ([WILDCARD]s)
step 1 ... ok ([WILDCARD]s)
description ... ok ([WILDCARD]s)
step 1 ... ok ([WILDCARD]s)
description ... ok ([WILDCARD]s)
description function as first arg ...
step1 ...
inner1 ... ok ([WILDCARD]s)
inner1 ... ok ([WILDCARD]s)
step1 ... ok ([WILDCARD]s)
description function as first arg ... ok ([WILDCARD]s)
step1 ... ok ([WILDCARD]s)
description function as first arg ... ok ([WILDCARD]s)
parallel steps without sanitizers ...
step 1 ... ok ([WILDCARD])
step 2 ... ok ([WILDCARD])
parallel steps without sanitizers ... ok ([WILDCARD])
step 2 ... ok ([WILDCARD])
parallel steps without sanitizers ... ok ([WILDCARD])
parallel steps without sanitizers due to parent ...
step 1 ... ok ([WILDCARD])
step 2 ... ok ([WILDCARD])
parallel steps without sanitizers due to parent ... ok ([WILDCARD])
step 2 ... ok ([WILDCARD])
parallel steps without sanitizers due to parent ... ok ([WILDCARD])
steps with disabled sanitizers, then enabled, then parallel disabled ...
step 1 ...
step 1 ...
step 1 ...
step 1 ... ok ([WILDCARD])
step 1 ... ok ([WILDCARD])
step 1 ... ok ([WILDCARD])
step 2 ... ok ([WILDCARD])
step 1 ... ok ([WILDCARD])
step 2 ... ok ([WILDCARD])
step 1 ... ok ([WILDCARD])
step 1 ... ok ([WILDCARD])
steps with disabled sanitizers, then enabled, then parallel disabled ... ok ([WILDCARD])
steps with disabled sanitizers, then enabled, then parallel disabled ... ok ([WILDCARD])
steps buffered then streaming reporting ...
step 1 ...
step 1 - 1 ... ok ([WILDCARD])
step 1 - 2 ...
step 1 - 2 ...
step 1 - 2 - 1 ... ok ([WILDCARD])
step 1 - 2 ... ok ([WILDCARD])
step 1 ... ok ([WILDCARD])
step 1 ... ok ([WILDCARD])
step 2 ... ok ([WILDCARD])
steps buffered then streaming reporting ... ok ([WILDCARD])
steps buffered then streaming reporting ... ok ([WILDCARD])

ok | 6 passed (21 steps) | 0 failed [WILDCARD]