tapjs/tap-parser

tap-parser command exits before flushing

Closed this issue · 0 comments

If the parsed tap input contains failures, it will forcibly exit the process with process.exit(1) before all output is flushed.

This is evident when piping tap-parser output to other programs, and likely only on POSIX systems where process.stdout is asynchronous. Here is a minimal reproduction case:

test.js

const {test} = require('tap')

test('generate a lot of output', async (t) => {
  for (let i = 0; i < 10000; i++) {
    // sprinkle in some failures
    const assert = i % 39 > 0 ? 'pass' : 'fail'
    t[assert]('this is some sample output')
  }
})

pipe.js

#!/usr/bin/env node

process.stdin.pipe(process.stdout)

Run

node test.js | tap-parser -t | ./pipe.js

Output

...snip...
ok 1300 - this is some sample output
ok 1301 - this is some sample output
ok 1302 - this is some sample output
ok 1303 - this is some sample output
ok 1304 - this is some sample output
ok 1305 - this is some sample output
ok 1306 - this is some sample output
ok 1307 - this is some sample output
ok 1308 - this is some sample output
ok 1309 - this is some sample output
ok 1310 - this is some sample output
ok 1311 - this is some sample output
ok 1312 - this is s
[end of output]