mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 07:27:22 +01:00
9be3d99b2b
The inspector tests should not be in the parallel directory as they likely all (or certainly almost all) use static ports, so port collisions will happen. This moves them all to sequential. We can move them back on a case-by-case basis. They were run sequentially when they were in the inspector directory which they were only moved from very recently. PR-URL: https://github.com/nodejs/node/pull/16281 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Bryan English <bryan@bryanenglish.com>
54 lines
1.7 KiB
JavaScript
54 lines
1.7 KiB
JavaScript
'use strict';
|
|
const { mustCall, skipIfInspectorDisabled } = require('../common');
|
|
|
|
skipIfInspectorDisabled();
|
|
|
|
const assert = require('assert');
|
|
const { URL } = require('url');
|
|
const { spawn } = require('child_process');
|
|
|
|
function test(arg, port = '') {
|
|
const args = [arg, '-p', 'process.debugPort'];
|
|
const proc = spawn(process.execPath, args);
|
|
proc.stdout.setEncoding('utf8');
|
|
proc.stderr.setEncoding('utf8');
|
|
let stdout = '';
|
|
let stderr = '';
|
|
proc.stdout.on('data', (data) => stdout += data);
|
|
proc.stderr.on('data', (data) => stderr += data);
|
|
proc.stdout.on('close', assert.ifError);
|
|
proc.stderr.on('close', assert.ifError);
|
|
proc.stderr.on('data', () => {
|
|
if (!stderr.includes('\n')) return;
|
|
assert(/Debugger listening on (.+)/.test(stderr));
|
|
port = new URL(RegExp.$1).port;
|
|
assert(+port > 0);
|
|
});
|
|
if (/inspect-brk/.test(arg)) {
|
|
proc.stderr.on('data', () => {
|
|
if (stderr.includes('\n') && !proc.killed) proc.kill();
|
|
});
|
|
} else {
|
|
let onclose = () => {
|
|
onclose = () => assert.strictEqual(port, stdout.trim());
|
|
};
|
|
proc.stdout.on('close', mustCall(() => onclose()));
|
|
proc.stderr.on('close', mustCall(() => onclose()));
|
|
proc.on('exit', mustCall((exitCode) => assert.strictEqual(exitCode, 0)));
|
|
}
|
|
}
|
|
|
|
test('--inspect=0');
|
|
test('--inspect=127.0.0.1:0');
|
|
test('--inspect=localhost:0');
|
|
|
|
test('--inspect-brk=0');
|
|
test('--inspect-brk=127.0.0.1:0');
|
|
test('--inspect-brk=localhost:0');
|
|
|
|
// In these cases, the inspector doesn't listen, so an ephemeral port is not
|
|
// allocated and the expected value of `process.debugPort` is `0`.
|
|
test('--inspect-port=0', '0');
|
|
test('--inspect-port=127.0.0.1:0', '0');
|
|
test('--inspect-port=localhost:0', '0');
|