mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 07:27:22 +01:00
27c0a0ca9d
PR-URL: https://github.com/nodejs/node/pull/9921 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
54 lines
1.5 KiB
JavaScript
54 lines
1.5 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-util-regression-fixture.js'
|
|
);
|
|
|
|
const args = [
|
|
'debug',
|
|
`--port=${common.PORT}`,
|
|
fixture
|
|
];
|
|
|
|
const proc = spawn(process.execPath, args, { stdio: 'pipe' });
|
|
proc.stdout.setEncoding('utf8');
|
|
proc.stderr.setEncoding('utf8');
|
|
|
|
let stdout = '';
|
|
let stderr = '';
|
|
|
|
let nextCount = 0;
|
|
let exit = false;
|
|
|
|
proc.stdout.on('data', (data) => {
|
|
stdout += data;
|
|
if (stdout.includes('> 1') && nextCount < 1 ||
|
|
stdout.includes('> 2') && nextCount < 2 ||
|
|
stdout.includes('> 3') && nextCount < 3 ||
|
|
stdout.includes('> 4') && nextCount < 4) {
|
|
nextCount++;
|
|
proc.stdin.write('n\n');
|
|
} else if (!exit && (stdout.includes('< { a: \'b\' }'))) {
|
|
exit = true;
|
|
proc.stdin.write('.exit\n');
|
|
} else if (stdout.includes('program terminated')) {
|
|
// Catch edge case present in v4.x
|
|
// process will terminate after call to util.inspect
|
|
common.fail('the program should not terminate');
|
|
}
|
|
});
|
|
|
|
proc.stderr.on('data', (data) => stderr += data);
|
|
|
|
process.on('exit', (code) => {
|
|
assert.strictEqual(code, 0, 'the program should exit cleanly');
|
|
assert.strictEqual(stdout.includes('{ a: \'b\' }'), true,
|
|
'the debugger should print the result of util.inspect');
|
|
assert.strictEqual(stderr, '', 'stderr should be empty');
|
|
});
|