Skip to content
This repository has been archived by the owner on Oct 16, 2021. It is now read-only.

Commit

Permalink
test: fix test-debug-port-from-cmdline
Browse files Browse the repository at this point in the history
This change is a backport of 2b4b600
from io.js.

Original commit message:

  This test was failing because the spawned process was terminated
  before anything could be done, by calling child.stdin.end. With this
  change, the child's stdin is no longer closed. When the stdin is not
  a tty, io.js waits for the whole input before starting, so the child
  must be run with --interactive to process the command sent by the
  parent. The child is killed explicitly by the parent before it exits.

  This test was failing silently because the asserts were not called if
  nothing was received from the child. This fix moves assertOutputLines
  to always run on exit.

  Fixes: nodejs/node#2177
  Refs: nodejs/node#2094
  PR-URL: nodejs/node#2186
  Reviewed-By: Colin Ihrig <[email protected]>
  Reviewed-By: Rod Vagg <[email protected]>
  Reviewed-By: Johan Bergström <[email protected]>
  Reviewed-By: Alexis Campailla <[email protected]>

Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: nodejs#25748
  • Loading branch information
joaocgreis authored and jBarz committed Nov 4, 2016
1 parent a5a8fc6 commit 02cfeb4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/simple/test-debug-port-from-cmdline.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ var assert = require('assert');
var spawn = require('child_process').spawn;

var debugPort = common.PORT;
var args = ['--debug-port=' + debugPort];
var args = ['--interactive', '--debug-port=' + debugPort];
var childOptions = { stdio: ['pipe', 'pipe', 'pipe', 'ipc'] };
var child = spawn(process.execPath, args, childOptions);

child.stdin.end("process.send({ msg: 'childready' });");
child.stdin.write("process.send({ msg: 'childready' });\n");

child.stderr.on('data', function(data) {
var lines = data.toString().replace(/\r/g, '').trim().split('\n');
Expand All @@ -43,6 +43,7 @@ child.on('message', function onChildMsg(message) {

process.on('exit', function() {
child.kill();
assertOutputLines();
});

var outputLines = [];
Expand All @@ -51,7 +52,6 @@ function processStderrLine(line) {
outputLines.push(line);

if (/Debugger listening/.test(line)) {
assertOutputLines();
process.exit();
}
}
Expand Down

0 comments on commit 02cfeb4

Please sign in to comment.