diff options
author | Jackson Tian <puling.tyq@alibaba-inc.com> | 2015-03-27 10:28:24 +0800 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2015-03-27 17:28:48 +0100 |
commit | a2ea16838ff7e5170387f6d08c85392eda843b29 (patch) | |
tree | e5a669e8e4b1e3a74fea0eb92850857aa231d82f /test/debugger | |
parent | 955c1508dab1d7f3e4684e6f6b0bd40218e8c297 (diff) | |
download | node-new-a2ea16838ff7e5170387f6d08c85392eda843b29.tar.gz |
debugger: don't spawn child process in remote mode
When debug in remote mode with host:port or pid, the interface
spawn child process also. If the debugger agent is running, will
get following output:
```
< Error: listen EADDRINUSE :::5858
< at Object.exports._errnoException (util.js:734:11)
< at exports._exceptionWithHostPort (util.js:757:20)
< at Agent.Server._listen2 (net.js:1155:14)
< at listen (net.js:1181:10)
< at Agent.Server.listen (net.js:1268:5)
< at Object.start (_debug_agent.js:21:9)
< at startup (node.js:68:9)
< at node.js:799:3
```
This fix won't spawn child process and no more error message was
shown.
When use `iojs debug`, the tip information just like this:
```
Usage: iojs debug script.js
```
This fix will display the advance usage also:
```
Usage: iojs debug script.js
iojs debug <host>:<port>
iojs debug -p <pid>
```
Fixes: https://github.com/iojs/io.js/issues/889
PR-URL: https://github.com/iojs/io.js/pull/1282
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test/debugger')
-rw-r--r-- | test/debugger/test-debugger-remote.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/debugger/test-debugger-remote.js b/test/debugger/test-debugger-remote.js new file mode 100644 index 0000000000..641199a171 --- /dev/null +++ b/test/debugger/test-debugger-remote.js @@ -0,0 +1,52 @@ +var common = require('../common'); +var assert = require('assert'); +var spawn = require('child_process').spawn; + +var port = common.PORT + 1337; +var buffer = ''; +var expected = []; +var scriptToDebug = common.fixturesDir + '/empty.js'; + +function fail() { + assert(0); // `iojs --debug-brk script.js` should not quit +} + +// running with debug agent +var child = spawn(process.execPath, ['--debug-brk=5959', scriptToDebug]); + +console.error(process.execPath, '--debug-brk=5959', scriptToDebug); + +// connect to debug agent +var interfacer = spawn(process.execPath, ['debug', 'localhost:5959']); + +console.error(process.execPath, 'debug', 'localhost:5959'); +interfacer.stdout.setEncoding('utf-8'); +interfacer.stdout.on('data', function(data) { + data = (buffer + data).split('\n'); + buffer = data.pop(); + data.forEach(function(line) { + interfacer.emit('line', line); + }); +}); + +interfacer.on('line', function(line) { + line = line.replace(/^(debug> *)+/, ''); + console.log(line); + var expected = '\bconnecting to localhost:5959 ... ok'; + assert.ok(expected == line, 'Got unexpected line: ' + line); +}); + +// give iojs time to start up the debugger +setTimeout(function() { + child.removeListener('exit', fail); + child.kill(); + interfacer.removeListener('exit', fail); + interfacer.kill(); +}, 2000); + +process.on('exit', function() { + assert(child.killed); + assert(interfacer.killed); +}); + +interfacer.stderr.pipe(process.stderr); |