Skip to content

Commit 2b4b600

Browse files
joaocgreiscjihrig
authored andcommitted
test: fix test-debug-port-from-cmdline
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: #2177 Refs: #2094 PR-URL: #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]>
1 parent f95f9ef commit 2b4b600

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/parallel/test-debug-port-from-cmdline.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ var assert = require('assert');
44
var spawn = require('child_process').spawn;
55

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

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

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

2424
process.on('exit', function() {
2525
child.kill();
26+
assertOutputLines();
2627
});
2728

2829
var outputLines = [];
@@ -31,7 +32,6 @@ function processStderrLine(line) {
3132
outputLines.push(line);
3233

3334
if (/Debugger listening/.test(line)) {
34-
assertOutputLines();
3535
process.exit();
3636
}
3737
}

0 commit comments

Comments
 (0)