1 var common = require('../common');
2 var assert = require('assert');
3 var spawn = require('child_process').spawn;
5 var debugPort = common.PORT;
6 var args = ['--debug-port=' + debugPort];
7 var childOptions = { stdio: ['pipe', 'pipe', 'pipe', 'ipc'] };
8 var child = spawn(process.execPath, args, childOptions);
10 child.stdin.end("process.send({ msg: 'childready' });");
12 child.stderr.on('data', function(data) {
13 var lines = data.toString().replace(/\r/g, '').trim().split('\n');
14 lines.forEach(processStderrLine);
17 child.on('message', function onChildMsg(message) {
18 if (message.msg === 'childready') {
19 process._debugProcess(child.pid);
23 process.on('exit', function() {
28 function processStderrLine(line) {
29 console.log('> ' + line);
30 outputLines.push(line);
32 if (/Debugger listening/.test(line)) {
38 function assertOutputLines() {
40 'Starting debugger agent.',
41 'Debugger listening on port ' + debugPort
44 assert.equal(outputLines.length, expectedLines.length);
45 for (var i = 0; i < expectedLines.length; i++)
46 assert.equal(outputLines[i], expectedLines[i]);