|
1 | 1 | 'use strict'; |
2 | 2 | const common = require('../common'); |
3 | 3 | common.skipIfInspectorDisabled(); |
| 4 | + |
| 5 | +if (common.isWindows) |
| 6 | + common.skip('unsupported function on windows'); |
| 7 | + |
4 | 8 | const assert = require('assert'); |
5 | 9 | const spawn = require('child_process').spawn; |
6 | 10 |
|
7 | 11 | let buffer = ''; |
8 | 12 |
|
9 | 13 | // Connect to debug agent |
10 | | -const interfacer = spawn(process.execPath, ['debug', '-p', '655555']); |
| 14 | +const interfacer = spawn(process.execPath, ['inspect', '-p', '655555']); |
11 | 15 |
|
12 | 16 | interfacer.stdout.setEncoding('utf-8'); |
13 | 17 | interfacer.stderr.setEncoding('utf-8'); |
14 | 18 | const onData = (data) => { |
15 | 19 | data = (buffer + data).split('\n'); |
16 | 20 | buffer = data.pop(); |
17 | | - data.forEach(function(line) { |
18 | | - interfacer.emit('line', line); |
19 | | - }); |
| 21 | + data.forEach((line) => interfacer.emit('line', line)); |
20 | 22 | }; |
21 | 23 | interfacer.stdout.on('data', onData); |
22 | 24 | interfacer.stderr.on('data', onData); |
23 | 25 |
|
24 | | -let lineCount = 0; |
25 | | -interfacer.on('line', function(line) { |
26 | | - let expected; |
27 | | - const pid = interfacer.pid; |
28 | | - switch (++lineCount) { |
29 | | - case 1: |
30 | | - expected = |
31 | | - new RegExp(`^\\(node:${pid}\\) \\[DEP0068\\] DeprecationWarning: `); |
32 | | - assert.match(line, expected); |
33 | | - break; |
34 | | - case 2: |
35 | | - assert.match(line, /Use `node --trace-deprecation \.\.\.` to show where /); |
36 | | - break; |
37 | | - case 3: |
38 | | - // Doesn't currently work on Windows. |
39 | | - if (!common.isWindows) { |
40 | | - expected = "Target process: 655555 doesn't exist."; |
41 | | - assert.strictEqual(line, expected); |
42 | | - } |
43 | | - break; |
44 | | - |
45 | | - default: |
46 | | - if (!common.isWindows) |
47 | | - assert.fail(`unexpected line received: ${line}`); |
48 | | - } |
49 | | -}); |
50 | | - |
51 | | -interfacer.on('exit', function(code, signal) { |
52 | | - assert.strictEqual(code, 1, `Got unexpected code: ${code}`); |
53 | | - if (!common.isWindows) { |
54 | | - assert.strictEqual(lineCount, 3); |
55 | | - } |
56 | | -}); |
| 26 | +interfacer.on('line', common.mustCall((line) => { |
| 27 | + assert.strictEqual(line, 'Target process: 655555 doesn\'t exist.'); |
| 28 | +})); |
0 commit comments