From c4e36541d846fca851137b9413d63c444d7ae0ba Mon Sep 17 00:00:00 2001 From: Marco Ippolito Date: Mon, 14 Aug 2023 12:31:23 +0200 Subject: [PATCH] fix: more bailout --- lib/internal/test_runner/reporter/tap.js | 2 +- lib/internal/test_runner/test.js | 13 ++++++------- lib/internal/test_runner/tests_stream.js | 3 ++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/internal/test_runner/reporter/tap.js b/lib/internal/test_runner/reporter/tap.js index 9e6a819181d3c1..ba396c640feb4e 100644 --- a/lib/internal/test_runner/reporter/tap.js +++ b/lib/internal/test_runner/reporter/tap.js @@ -64,7 +64,7 @@ async function * tapReporter(source) { yield getCoverageReport(indent(data.nesting), data.summary, '# ', ''); break; case 'test:bail': - yield `Bail out! ${tapEscape(data.reason)}\n`; + yield `${indent(data.nesting)}Bail out! ${tapEscape(data.reason)}\n`; break; } } diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index 77f5b7677aa887..041d94f38960ff 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -504,6 +504,7 @@ class Test extends AsyncResource { this.passed = false; this.error = err; if (bail && !this.root.bailedOut) { + this.bailedOut = true; this.root.bailedOut = true; this.root.postRun(); } @@ -582,12 +583,6 @@ class Test extends AsyncResource { } async run() { - if (bailedOut) { - if (this.parent !== null) { - this.parent.postRun(); - } - return; - } if (this.parent !== null) { this.parent.activeSubtests++; } @@ -727,6 +722,10 @@ class Test extends AsyncResource { this.parent.processReadySubtestRange(false); this.parent.processPendingSubtests(); + if (this.bailedOut) { + this.reporter.bail(this.nesting); + } + if (this.parent === this.root && this.root.activeSubtests === 0 && this.root.pendingSubtests.length === 0 && @@ -754,7 +753,7 @@ class Test extends AsyncResource { reporter.diagnostic(nesting, loc, diagnostics[i]); } - if(this.bailedOut){ + if (this.bailedOut) { reporter.bail(); } diff --git a/lib/internal/test_runner/tests_stream.js b/lib/internal/test_runner/tests_stream.js index 69630963886123..b9d0afb0f26b2b 100644 --- a/lib/internal/test_runner/tests_stream.js +++ b/lib/internal/test_runner/tests_stream.js @@ -62,9 +62,10 @@ class TestsStream extends Readable { }); } - bail(reason = ''){ + bail(nesting, reason = '') { this[kEmitMessage]('test:bail', { __proto__: null, + nesting, reason, }); }