0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-25 08:19:38 +01:00
nodejs/test/sequential/test-debugger-repeat-last.js
Miguel Angel Asencio Hurtado 9a5c3cf185
test: continue normalizing fixtures use
PR-URL: https://github.com/nodejs/node/pull/14716
Refs: https://github.com/nodejs/node/pull/14332
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
2017-08-27 21:14:34 -03:00

46 lines
1.1 KiB
JavaScript

'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
const path = require('../common/fixtures').path;
const spawn = require('child_process').spawn;
const assert = require('assert');
const fixture = path('debugger-repeat-last.js');
const args = [
'inspect',
`--port=${common.PORT}`,
fixture
];
const proc = spawn(process.execPath, args, { stdio: 'pipe' });
proc.stdout.setEncoding('utf8');
let stdout = '';
let sentCommand = false;
let sentExit = false;
proc.stdout.on('data', (data) => {
stdout += data;
// Send 'n' as the first step.
if (!sentCommand && stdout.includes('> 1 ')) {
setImmediate(() => { proc.stdin.write('n\n'); });
return sentCommand = true;
}
// Send empty (repeat last command) until we reach line 5.
if (sentCommand && !stdout.includes('> 5')) {
setImmediate(() => { proc.stdin.write('\n'); });
return true;
}
if (!sentExit && stdout.includes('> 5')) {
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);
});