Skip to content

Commit

Permalink
fix: more bailout
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-ippolito committed Aug 17, 2023
1 parent c400ed1 commit c4e3654
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/internal/test_runner/reporter/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
13 changes: 6 additions & 7 deletions lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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++;
}
Expand Down Expand Up @@ -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 &&
Expand Down Expand Up @@ -754,7 +753,7 @@ class Test extends AsyncResource {
reporter.diagnostic(nesting, loc, diagnostics[i]);
}

if(this.bailedOut){
if (this.bailedOut) {
reporter.bail();
}

Expand Down
3 changes: 2 additions & 1 deletion lib/internal/test_runner/tests_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ class TestsStream extends Readable {
});
}

bail(reason = ''){
bail(nesting, reason = '') {
this[kEmitMessage]('test:bail', {
__proto__: null,
nesting,
reason,
});
}
Expand Down

0 comments on commit c4e3654

Please sign in to comment.