Skip to content

Commit

Permalink
fix(test-runner): make it compatible when running as a sub-process
Browse files Browse the repository at this point in the history
Works around the following bug: nodejs/node#12921
  • Loading branch information
mxschmitt committed Jun 24, 2021
1 parent ba3f0ff commit ecc4552
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/test/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,9 @@ export class Runner {
async _flushOutput() {
// Calling process.exit() might truncate large stdout/stderr output.
// See https://github.com/nodejs/node/issues/6456.
//
// We can use writableNeedDrain to workaround this, but it is only available
// since node v15.2.0.
// See https://nodejs.org/api/stream.html#stream_writable_writableneeddrain.
if ((process.stdout as any).writableNeedDrain)
await new Promise(f => process.stdout.on('drain', f));
if ((process.stderr as any).writableNeedDrain)
await new Promise(f => process.stderr.on('drain', f));
// See https://github.com/nodejs/node/issues/12921
await new Promise<void>(resolve => process.stdout.write('', () => resolve()));
await new Promise<void>(resolve => process.stderr.write('', () => resolve()));
}

async _run(list: boolean, testFileReFilters: FilePatternFilter[], projectName?: string): Promise<RunResult> {
Expand Down

0 comments on commit ecc4552

Please sign in to comment.