mirror of
https://github.com/nodejs/node.git
synced 2025-05-04 20:09:32 +00:00

Before ``` ❯ tools/test.py "sequential/test-debugger*" [00:25|% 100|+ 32|- 0]: Done All tests passed. ❯ tools/test.py -J "parallel/test-debugger*" [00:05|% 100|+ 6|- 0]: Done All tests passed. ``` After ``` ❯ tools/test.py "sequential/test-debugger*" [00:06|% 100|+ 5|- 0]: Done All tests passed. ❯ tools/test.py -J "parallel/test-debugger*" [00:05|% 100|+ 33|- 0]: Done All tests passed. ``` PR-URL: https://github.com/nodejs/node/pull/47274 Refs: https://github.com/nodejs/node/issues/47146 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: James M Snell <jasnell@gmail.com>
91 lines
2.4 KiB
JavaScript
91 lines
2.4 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
|
|
common.skipIfInspectorDisabled();
|
|
|
|
const fixtures = require('../common/fixtures');
|
|
const startCLI = require('../common/debugger');
|
|
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
|
|
// Run after quit/restart.
|
|
{
|
|
const scriptFullPath = fixtures.path('debugger', 'three-lines.js');
|
|
const script = path.relative(process.cwd(), scriptFullPath);
|
|
const cli = startCLI(['--port=0', script]);
|
|
|
|
function onFatal(error) {
|
|
cli.quit();
|
|
throw error;
|
|
}
|
|
|
|
cli.waitForInitialBreak()
|
|
.then(() => cli.waitForPrompt())
|
|
.then(() => cli.stepCommand('n'))
|
|
.then(() => {
|
|
assert.ok(
|
|
cli.output.includes(`break in ${script}:2`),
|
|
'steps to the 2nd line'
|
|
);
|
|
})
|
|
.then(() => cli.command('cont'))
|
|
.then(() => cli.waitFor(/disconnect/))
|
|
.then(() => {
|
|
assert.match(
|
|
cli.output,
|
|
/Waiting for the debugger to disconnect/,
|
|
'the child was done');
|
|
})
|
|
.then(() => {
|
|
// On windows the socket won't close by itself
|
|
return cli.command('kill');
|
|
})
|
|
.then(() => cli.command('cont'))
|
|
.then(() => cli.waitFor(/start the app/))
|
|
.then(() => {
|
|
assert.match(cli.output, /Use `run` to start the app again/);
|
|
})
|
|
.then(() => cli.stepCommand('run'))
|
|
.then(() => cli.waitForInitialBreak())
|
|
.then(() => cli.waitForPrompt())
|
|
.then(() => {
|
|
assert.deepStrictEqual(
|
|
cli.breakInfo,
|
|
{ filename: script, line: 1 },
|
|
);
|
|
})
|
|
.then(() => cli.stepCommand('n'))
|
|
.then(() => {
|
|
assert.deepStrictEqual(
|
|
cli.breakInfo,
|
|
{ filename: script, line: 2 },
|
|
);
|
|
})
|
|
.then(() => cli.stepCommand('restart'))
|
|
.then(() => cli.waitForInitialBreak())
|
|
.then(() => {
|
|
assert.deepStrictEqual(
|
|
cli.breakInfo,
|
|
{ filename: script, line: 1 },
|
|
);
|
|
})
|
|
.then(() => cli.command('kill'))
|
|
.then(() => cli.command('cont'))
|
|
.then(() => cli.waitFor(/start the app/))
|
|
.then(() => {
|
|
assert.match(cli.output, /Use `run` to start the app again/);
|
|
})
|
|
.then(() => cli.stepCommand('run'))
|
|
.then(() => cli.waitForInitialBreak())
|
|
.then(() => cli.waitForPrompt())
|
|
.then(() => {
|
|
assert.deepStrictEqual(
|
|
cli.breakInfo,
|
|
{ filename: script, line: 1 },
|
|
);
|
|
})
|
|
.then(() => cli.quit())
|
|
.then(null, onFatal);
|
|
}
|