Skip to content

Commit ceb6a8c

Browse files
committed
test: fix test-debug-port-from-cmdline
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: #2177 Refs: #2094 PR-URL: #2186 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Alexis Campailla <alexis@janeasystems.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> PR-URL: nodejs/node-v0.x-archive#25748
1 parent 14db629 commit ceb6a8c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ var assert = require('assert');
2424
var spawn = require('child_process').spawn;
2525

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

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

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

4444
process.on('exit', function() {
4545
child.kill();
46+
assertOutputLines();
4647
});
4748

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

5354
if (/Debugger listening/.test(line)) {
54-
assertOutputLines();
5555
process.exit();
5656
}
5757
}

0 commit comments

Comments
 (0)