19
19
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
20
// USE OR OTHER DEALINGS IN THE SOFTWARE.
23
22
var common = require('../common');
24
var assert = require('assert');
25
var spawn = require('child_process').spawn;
26
var debug = require('_debugger');
28
23
var script = common.fixturesDir + '/breakpoints_utf8.js';
30
var child = spawn(process.execPath, ['debug', script]);
33
child.stdout.setEncoding('utf-8');
34
child.stdout.on('data', function(data) {
35
data = (buffer + data.toString()).split(/\n/g);
37
data.forEach(function(line) {
38
child.emit('line', line);
41
child.stderr.pipe(process.stdout);
45
child.on('line', function(line) {
46
assert.ok(expected.length > 0, 'Got unexpected line: ' + line);
48
var expectedLine = expected[0].lines.shift();
49
assert.ok(line.match(expectedLine) !== null, line + ' != ' + expectedLine);
51
if (expected[0].lines.length === 0) {
52
var callback = expected[0].callback;
54
callback && callback();
58
function addTest(input, output) {
60
if (expected.length > 0) {
61
child.stdin.write(expected[0].input + '\n');
63
if (!expected[0].lines) {
64
setTimeout(function() {
65
var callback = expected[0].callback;
68
callback && callback();
75
expected.push({input: input, lines: output, callback: next});
80
/listening on port 5858/,
89
/9/, /10/, /11/, /12/, /13/
93
addTest('watch("\'x\'")');
101
/3/, /4/, /5/, /6/, /7/
105
addTest('watchers', [
110
addTest('unwatch("\'x\'")');
115
/10/, /11/, /12/, /13/, /14/
121
/3/, /4/, /5/, /6/, /7/
124
// Set breakpoint by function name
125
addTest('sb("setInterval()", "!(setInterval.flag++)")', [
126
/1/, /2/, /3/, /4/, /5/, /6/, /7/, /8/, /9/, /10/
131
/break in node.js:\d+/,
132
/\d/, /\d/, /\d/, /\d/, /\d/
137
/Can't request backtrace now/
146
if (quit.called) return;
148
child.stdin.write('quit');
151
setTimeout(function() {
153
if (expected.length > 0 && expected[0].lines) {
154
err = err + '. Expected: ' + expected[0].lines.shift();
157
throw new Error(err);
160
process.once('uncaughtException', function(e) {
162
console.error(e.toString());
163
child.kill('SIGKILL');
167
process.on('exit', function(code) {
170
assert.equal(expected.length, 0);
24
process.env.NODE_DEBUGGER_TEST_SCRIPT = script;
26
require('./test-debugger-repl.js');