Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added test and improved for #1042

  • Loading branch information...
commit a627b7992a8c08ffd6dd6a4335f41dd8777e1445 1 parent 8013e66
@koichik authored
Showing with 53 additions and 4 deletions.
  1. +5 −4 lib/_debugger.js
  2. +48 −0 test/simple/test-debugger-interface.js
View
9 lib/_debugger.js
@@ -646,6 +646,7 @@ function Interface() {
}
});
}
+exports.Interface = Interface;
Interface.prototype.complete = function(line) {
@@ -1058,6 +1059,10 @@ Interface.prototype.trySpawn = function(cb) {
client.reqContinue(function() {
if (cb) cb();
});
+
+ client.on('break', function(res) {
+ self.handleBreak(res.body);
+ });
});
client.on('close', function() {
@@ -1074,10 +1079,6 @@ Interface.prototype.trySpawn = function(cb) {
self.term.prompt();
});
- client.on('break', function(res) {
- self.handleBreak(res.body);
- });
-
client.on('error', connectError);
function connectError() {
// If it's failed to connect 4 times then don't catch the next error
View
48 test/simple/test-debugger-interface.js
@@ -0,0 +1,48 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var common = require('../common');
+var assert = require('assert');
+
+process.argv[2] = common.fixturesDir + '/exit.js';
+var debug = require('_debugger');
+var interface = new debug.Interface();
+
+var events = [];
+interface.trySpawn(function() {
+ events.push('continue');
+});
+
+var client = interface.client;
+client.on('break', function() {
+ events.push('break');
+});
+client.on('end', function() {
+ interface.quit();
+});
+setTimeout(function() {
+ interface.quit();
+}, 1000);
+
+process.on('exit', function() {
+ assert.deepEqual(events, ['break', 'continue']);
+});
+
Please sign in to comment.
Something went wrong with that request. Please try again.