node/test/parallel/test-debugger-repeat-last.js
Sakthipriyan Vairamani 612307564b test: make import common as the first line
The `test/common` module has the capability to identify if any variable
is leaked to the global scope and fail the test. So that has to be
imported at the beginning.

PR-URL: https://github.com/nodejs/node/pull/7786
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2016-07-21 16:39:21 -07:00

46 lines
1.0 KiB
JavaScript

'use strict';
const common = require('../common');
const path = require('path');
const spawn = require('child_process').spawn;
const assert = require('assert');
const fixture = path.join(
common.fixturesDir,
'debugger-repeat-last.js'
);
const args = [
'debug',
`--port=${common.PORT}`,
fixture
];
const proc = spawn(process.execPath, args, { stdio: 'pipe' });
proc.stdout.setEncoding('utf8');
var stdout = '';
var sentCommand = false;
var sentEmpty = false;
var sentExit = false;
proc.stdout.on('data', (data) => {
stdout += data;
if (!sentCommand && stdout.includes('> 1')) {
setImmediate(() => {proc.stdin.write('n\n');});
return sentCommand = true;
}
if (!sentEmpty && stdout.includes('> 3')) {
setImmediate(() => {proc.stdin.write('\n');});
return sentEmpty = true;
}
if (!sentExit && sentCommand && sentEmpty) {
setTimeout(() => {proc.stdin.write('\n\n\n.exit\n\n\n');}, 1);
return sentExit = true;
}
});
process.on('exit', (exitCode) => {
assert.strictEqual(exitCode, 0);
console.log(stdout);
});