From ceb6a8c131e53036f041bd2c5ff834ef1398981e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Wed, 15 Jul 2015 13:19:56 +0100 Subject: test: fix test-debug-port-from-cmdline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change is a backport of 2b4b6006607c33a5699ec53afaf40f987dc11895 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: https://github.com/nodejs/io.js/issues/2177 Refs: https://github.com/nodejs/io.js/issues/2094 PR-URL: https://github.com/nodejs/io.js/pull/2186 Reviewed-By: Colin Ihrig Reviewed-By: Rod Vagg Reviewed-By: Johan Bergström Reviewed-By: Alexis Campailla Reviewed-By: Colin Ihrig PR-URL: https://github.com/joyent/node/pull/25748 --- test/simple/test-debug-port-from-cmdline.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/simple/test-debug-port-from-cmdline.js b/test/simple/test-debug-port-from-cmdline.js index 54ac2d5d6..8200f1216 100644 --- a/test/simple/test-debug-port-from-cmdline.js +++ b/test/simple/test-debug-port-from-cmdline.js @@ -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'); @@ -43,6 +43,7 @@ child.on('message', function onChildMsg(message) { process.on('exit', function() { child.kill(); + assertOutputLines(); }); var outputLines = []; @@ -51,7 +52,6 @@ function processStderrLine(line) { outputLines.push(line); if (/Debugger listening/.test(line)) { - assertOutputLines(); process.exit(); } } -- cgit v1.2.1