(file, expectedTestName)
| 7 | const { finished } = require('stream/promises'); |
| 8 | |
| 9 | async function runAndKill(file, expectedTestName) { |
| 10 | if (common.isWindows) { |
| 11 | common.printSkipMessage(`signals are not supported in windows, skipping ${file}`); |
| 12 | return; |
| 13 | } |
| 14 | let stdout = ''; |
| 15 | const child = spawn(process.execPath, ['--test', '--test-reporter=tap', file]); |
| 16 | child.stdout.setEncoding('utf8'); |
| 17 | child.stdout.on('data', (chunk) => { |
| 18 | if (!stdout.length) child.kill('SIGINT'); |
| 19 | stdout += chunk; |
| 20 | }); |
| 21 | const [code, signal] = await once(child, 'exit'); |
| 22 | await finished(child.stdout); |
| 23 | assert(stdout.startsWith('TAP version 13\n')); |
| 24 | // Verify interrupted test message |
| 25 | assert(stdout.includes(`Interrupted while running: ${expectedTestName}`), |
| 26 | `Expected output to contain interrupted test name`); |
| 27 | assert.strictEqual(signal, null); |
| 28 | assert.strictEqual(code, 1); |
| 29 | } |
| 30 | |
| 31 | if (process.argv[2] === 'child') { |
| 32 | const test = require('node:test'); |
no test coverage detected
searching dependent graphs…