Skip to content

Commit

Permalink
test: deflake test-runner-output
Browse files Browse the repository at this point in the history
PR-URL: #49878
Fixes: #49853
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
  • Loading branch information
MoLow authored and ruyadorno committed Sep 28, 2023
1 parent 12fe6a0 commit d44a812
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 25 deletions.
16 changes: 8 additions & 8 deletions test/fixtures/test-runner/output/abort.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TAP version 13
# Subtest: not ok 2
not ok 6 - not ok 2
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/abort.js:(LINE):7'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
Expand All @@ -41,7 +41,7 @@ TAP version 13
# Subtest: not ok 3
not ok 7 - not ok 3
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/abort.js:(LINE):7'
failureType: 'testAborted'
error: 'This operation was aborted'
Expand All @@ -62,7 +62,7 @@ TAP version 13
# Subtest: not ok 4
not ok 8 - not ok 4
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/abort.js:(LINE):7'
failureType: 'testAborted'
error: 'This operation was aborted'
Expand All @@ -83,7 +83,7 @@ TAP version 13
# Subtest: not ok 5
not ok 9 - not ok 5
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/abort.js:(LINE):7'
failureType: 'testAborted'
error: 'This operation was aborted'
Expand Down Expand Up @@ -169,7 +169,7 @@ not ok 2 - promise abort signal
# Subtest: not ok 2
not ok 6 - not ok 2
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/abort.js:(LINE):5'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
Expand All @@ -178,7 +178,7 @@ not ok 2 - promise abort signal
# Subtest: not ok 3
not ok 7 - not ok 3
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/abort.js:(LINE):5'
failureType: 'testAborted'
error: 'This operation was aborted'
Expand All @@ -199,7 +199,7 @@ not ok 2 - promise abort signal
# Subtest: not ok 4
not ok 8 - not ok 4
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/abort.js:(LINE):5'
failureType: 'testAborted'
error: 'This operation was aborted'
Expand All @@ -220,7 +220,7 @@ not ok 2 - promise abort signal
# Subtest: not ok 5
not ok 9 - not ok 5
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/abort.js:(LINE):5'
failureType: 'testAborted'
error: 'This operation was aborted'
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/test-runner/output/abort_hooks.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ TAP version 13
# Subtest: test 1
not ok 1 - test 1
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/abort_hooks.js:(LINE):3'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
Expand All @@ -20,7 +20,7 @@ TAP version 13
# Subtest: test 2
not ok 2 - test 2
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/abort_hooks.js:(LINE):3'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/test-runner/output/abort_suite.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TAP version 13
# Subtest: not ok 2
not ok 6 - not ok 2
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/abort_suite.js:(LINE):3'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
Expand All @@ -41,7 +41,7 @@ TAP version 13
# Subtest: not ok 3
not ok 7 - not ok 3
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/abort_suite.js:(LINE):3'
failureType: 'testAborted'
error: 'This operation was aborted'
Expand All @@ -62,7 +62,7 @@ TAP version 13
# Subtest: not ok 4
not ok 8 - not ok 4
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/abort_suite.js:(LINE):3'
failureType: 'testAborted'
error: 'This operation was aborted'
Expand All @@ -83,7 +83,7 @@ TAP version 13
# Subtest: not ok 5
not ok 9 - not ok 5
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/abort_suite.js:(LINE):3'
failureType: 'testAborted'
error: 'This operation was aborted'
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/test-runner/output/arbitrary-output.snapshot
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
TAP version 13
ok 1 - test
---
duration_ms: ZERO
duration_ms: *
...
# arbitrary - pre
ok 2 - test
---
duration_ms: ZERO
duration_ms: *
...
# arbitrary - mid
ok 3 - test
---
duration_ms: ZERO
duration_ms: *
...
# arbitrary - post
1..3
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/test-runner/output/describe_it.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ not ok 51 - subtest sync throw fails
# Subtest: should not run
not ok 1 - should not run
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):3'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
Expand Down Expand Up @@ -544,7 +544,7 @@ not ok 52 - describe sync throw fails
# Subtest: should not run
not ok 1 - should not run
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/describe_it.js:(LINE):3'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/test-runner/output/hooks.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ok 1 - describe hooks
# Subtest: 1
not ok 1 - 1
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):3'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
Expand All @@ -46,7 +46,7 @@ ok 1 - describe hooks
# Subtest: 2
not ok 2 - 2
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/hooks.js:(LINE):3'
failureType: 'cancelledByParent'
error: 'test did not finish before its parent and was cancelled'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ not ok 2 - never resolving promise
# Subtest: fail
not ok 3 - fail
---
duration_ms: ZERO
duration_ms: *
location: '/test/fixtures/test-runner/output/unresolved_promise.js:(LINE):1'
failureType: 'cancelledByParent'
error: 'Promise resolution is still pending but the event loop has already resolved'
Expand Down
3 changes: 0 additions & 3 deletions test/parallel/test-runner-output.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const skipForceColors =

function replaceTestDuration(str) {
return str
.replaceAll(/duration_ms: 0(\r?\n)/g, 'duration_ms: ZERO$1')
.replaceAll(/duration_ms: [0-9.]+/g, 'duration_ms: *')
.replaceAll(/duration_ms [0-9.]+/g, 'duration_ms *');
}
Expand All @@ -20,15 +19,13 @@ const stackTraceBasePath = new RegExp(`${color}\\(${process.cwd()}/?${color}(.*)

function replaceSpecDuration(str) {
return str
.replaceAll(/\(0(\r?\n)ms\)/g, '(ZEROms)')
.replaceAll(/[0-9.]+ms/g, '*ms')
.replaceAll(/duration_ms [0-9.]+/g, 'duration_ms *')
.replace(stackTraceBasePath, '$3');
}

function replaceJunitDuration(str) {
return str
.replaceAll(/time="0"/g, 'time="ZERO"')
.replaceAll(/time="[0-9.]+"/g, 'time="*"')
.replaceAll(/duration_ms [0-9.]+/g, 'duration_ms *')
.replaceAll(hostname(), 'HOSTNAME')
Expand Down

0 comments on commit d44a812

Please sign in to comment.