2021-04-09 08:55:45 +02:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
|
|
|
|
common.skipIfInspectorDisabled();
|
|
|
|
|
|
|
|
const fixtures = require('../common/fixtures');
|
2021-05-04 06:58:42 +02:00
|
|
|
const startCLI = require('../common/debugger');
|
2021-04-09 08:55:45 +02:00
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
// Run after quit/restart.
|
|
|
|
{
|
2021-06-26 07:11:59 +02:00
|
|
|
const scriptFullPath = fixtures.path('debugger', 'three-lines.js');
|
2021-04-09 08:55:45 +02:00
|
|
|
const script = path.relative(process.cwd(), scriptFullPath);
|
2023-03-28 00:03:40 +02:00
|
|
|
const cli = startCLI(['--port=0', script]);
|
2021-04-09 08:55:45 +02:00
|
|
|
|
|
|
|
function onFatal(error) {
|
|
|
|
cli.quit();
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
|
|
|
|
cli.waitForInitialBreak()
|
|
|
|
.then(() => cli.waitForPrompt())
|
|
|
|
.then(() => cli.stepCommand('n'))
|
|
|
|
.then(() => {
|
|
|
|
assert.ok(
|
2023-03-17 15:32:39 +01:00
|
|
|
cli.output.includes(`step in ${script}:2`),
|
2021-04-09 08:55:45 +02:00
|
|
|
'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);
|
|
|
|
}
|