command.executableSubcommand.inspect.test.js
This file
Path
tests/command.executableSubcommand.inspect.test.js
56 lines · 2.4 KiB · JavaScript
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than 9c7cfc0 point at it.
Prepare for 6.1.0John Geebefore adoption9c7cfc0
lines 1–56why, one step back1const childProcess = require('child_process');2const path = require('path');3const util = require('util');45const execFileAsync = util.promisify(childProcess.execFile);67// Test the special handling for --inspect to increment fixed debug port numbers.8// If we reuse port we can get conflicts because port not released fast enough.910const inspectCommand = path.join(__dirname, './fixtures', 'inspect.js');1112test('when execArgv empty then spawn execArgs empty', async() => {13 const { stdout } = await execFileAsync('node', [inspectCommand, 'sub']);14 expect(stdout).toBe('[]\n');15});1617test('when execArgv --harmony then spawn execArgs --harmony', async() => {18 const { stdout } = await execFileAsync('node', ['--harmony', inspectCommand, 'sub']);19 expect(stdout).toBe("[ '--harmony' ]\n");20});2122// --inspect defaults to 127.0.0.1:9229, port should be incremented23test('when execArgv --inspect then spawn execArgs using port 9230', async() => {24 const { stdout } = await execFileAsync('node', ['--inspect', inspectCommand, 'sub']);25 expect(stdout).toBe("[ '--inspect=127.0.0.1:9230' ]\n");26});2728// custom port29test('when execArgv --inspect=9240 then spawn execArgs using port 9241', async() => {30 const { stdout } = await execFileAsync('node', ['--inspect=9240', inspectCommand, 'sub']);31 expect(stdout).toBe("[ '--inspect=127.0.0.1:9241' ]\n");32});3334// zero is special, random port35test('when execArgv --inspect=0 then spawn execArgs --inspect=0', async() => {36 const { stdout } = await execFileAsync('node', ['--inspect=0', inspectCommand, 'sub']);37 expect(stdout).toBe("[ '--inspect=0' ]\n");38});3940// ip address41test('when execArgv --inspect=127.0.0.1:9250 then spawn execArgs --inspect=127.0.0.1:9251', async() => {42 const { stdout } = await execFileAsync('node', ['--inspect=127.0.0.1:9250', inspectCommand, 'sub']);43 expect(stdout).toBe("[ '--inspect=127.0.0.1:9251' ]\n");44});4546// localhost47test('when execArgv --inspect=localhost:9260 then spawn execArgs --inspect=localhost:9261', async() => {48 const { stdout } = await execFileAsync('node', ['--inspect=localhost:9260', inspectCommand, 'sub']);49 expect(stdout).toBe("[ '--inspect=localhost:9261' ]\n");50});5152// --inspect-port, just test most likely format53test('when execArgv --inspect-port=9270 then spawn execArgs --inspect-port=127.0.0.1:9271', async() => {54 const { stdout } = await execFileAsync('node', ['--inspect-port=9270', inspectCommand, 'sub']);55 expect(stdout).toBe("[ '--inspect-port=127.0.0.1:9271' ]\n");56});