Skip to content
Myr

test.command.executableSubcommand.inspect.js

This file

Path

test/test.command.executableSubcommand.inspect.js

50 lines · 1.8 KiB · JavaScript

Last changed by

Increment inspector port for spawned subcommands (#991)John Geebefore adoption6d68637

History of this file

Take it

Increment inspector port for spawned subcommands (#991)John Geebefore adoption6d68637

lines 1–50why, one step back
1const exec = require('child_process').exec;
2const path = require('path');3const should = require('should');45var inspectCommand = path.join(__dirname, 'fixtures', 'inspect.js');67exec(`node ${inspectCommand} sub`, function(_error, stdout, stderr) {8 stdout.should.equal('[]\n');9});1011exec(`node --harmony ${inspectCommand} sub`, function(_error, stdout, stderr) {12 stdout.should.equal("[ '--harmony' ]\n");13});1415// Skip tests for node 6 when --inspect was only prototype16if (process.version.substr(1).split('.')[0] === '6') {17 console.log('Skipping --inspect tests for node 6');18} else {19 // Test that inspector port gets incremented.20 // If we reuse port we can get conflicts because port not released fast enough.2122 // --inspect defaults to 127.0.0.1:9229, port should be incremented23 exec(`node --inspect ${inspectCommand} sub`, function(_error, stdout, stderr) {24 stdout.should.equal("[ '--inspect=127.0.0.1:9230' ]\n");25 });2627 // custom port28 exec(`node --inspect=9240 ${inspectCommand} sub`, function(_error, stdout, stderr) {29 stdout.should.equal("[ '--inspect=127.0.0.1:9241' ]\n");30 });31 // zero is special, random port32 exec(`node --inspect=0 ${inspectCommand} sub`, function(_error, stdout, stderr) {33 stdout.should.equal("[ '--inspect=0' ]\n");34 });3536 // ip address37 exec(`node --inspect=127.0.0.1:9250 ${inspectCommand} sub`, function(_error, stdout, stderr) {38 stdout.should.equal("[ '--inspect=127.0.0.1:9251' ]\n");39 });4041 // localhost42 exec(`node --inspect=localhost:9260 ${inspectCommand} sub`, function(_error, stdout, stderr) {43 stdout.should.equal("[ '--inspect=localhost:9261' ]\n");44 });4546 // --inspect-port, just test most likely format47 exec(`node --inspect-port=9270 ${inspectCommand} sub`, function(_error, stdout, stderr) {48 stdout.should.equal("[ '--inspect-port=127.0.0.1:9271' ]\n");49 });50}