-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debugger: improve ESRCH error message
When using `iojs debug -p <pid>` with an invalid pid, the debugger printed an internal error message because it wasn't smart enough to figure out that the target process didn't exist. Now it is. PR-URL: #1863 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Yosuke Furukawa <[email protected]>
- Loading branch information
1 parent
353e26e
commit 81029c6
Showing
2 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict'; | ||
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); // `--debug-brk script.js` should not quit | ||
} | ||
|
||
// connect to debug agent | ||
var interfacer = spawn(process.execPath, ['debug', '-p', '655555']); | ||
|
||
console.error(process.execPath, 'debug', '-p', '655555'); | ||
interfacer.stdout.setEncoding('utf-8'); | ||
interfacer.stderr.setEncoding('utf-8'); | ||
var onData = function(data) { | ||
data = (buffer + data).split('\n'); | ||
buffer = data.pop(); | ||
data.forEach(function(line) { | ||
interfacer.emit('line', line); | ||
}); | ||
}; | ||
interfacer.stdout.on('data', onData); | ||
interfacer.stderr.on('data', onData); | ||
|
||
interfacer.on('line', function(line) { | ||
line = line.replace(/^(debug> *)+/, ''); | ||
var expected = 'Target process: 655555 doesn\'t exist.'; | ||
assert.ok(expected == line, 'Got unexpected line: ' + line); | ||
}); | ||
|
||
interfacer.on('exit', function(code, signal) { | ||
assert.ok(code == 1, 'Got unexpected code: ' + code); | ||
}); |