|
2 | 2 | const common = require('../common');
|
3 | 3 | common.skipIfInspectorDisabled();
|
4 | 4 |
|
5 |
| -// This test ensures that the debug-brk flag will spin up a new process and |
6 |
| -// wait, rather than exit. |
7 |
| - |
| 5 | +// This test ensures that the --debug-brk flag will exit the process |
8 | 6 | const assert = require('assert');
|
9 | 7 | const fixtures = require('../common/fixtures');
|
10 |
| -const spawn = require('child_process').spawn; |
| 8 | +const { spawnSync } = require('child_process'); |
11 | 9 |
|
12 |
| -// file name here doesn't actually matter since |
13 |
| -// debugger will connect regardless of file name arg |
| 10 | +// File name here doesn't actually matter the process will exit on start. |
14 | 11 | const script = fixtures.path('empty.js');
|
15 | 12 |
|
16 | 13 | function test(arg) {
|
17 |
| - const child = spawn(process.execPath, ['--inspect', arg, script]); |
18 |
| - const argStr = child.spawnargs.join(' '); |
19 |
| - const fail = () => assert.fail(true, false, `'${argStr}' should not quit`); |
20 |
| - child.on('exit', fail); |
21 |
| - |
22 |
| - // give node time to start up the debugger |
23 |
| - setTimeout(function() { |
24 |
| - child.removeListener('exit', fail); |
25 |
| - child.kill(); |
26 |
| - }, 2000); |
27 |
| - |
28 |
| - process.on('exit', function() { |
29 |
| - assert(child.killed); |
30 |
| - }); |
| 14 | + const child = spawnSync(process.execPath, ['--inspect', arg, script]); |
| 15 | + const stderr = child.stderr.toString(); |
| 16 | + assert(stderr.includes('DEP0062')); |
| 17 | + assert.strictEqual(child.status, 9); |
31 | 18 | }
|
32 | 19 |
|
33 | 20 | test('--debug-brk');
|
|
0 commit comments