node/deps/node-inspect/test/cli/launch.test.js
Jan Krems a7e4b029da
deps: Add node-inspect 1.10.6
This updates the bundled `node-inspect` to 1.10.6.

Highlights:

* `node --debug-port=1234 inspect` respects the custom port.
* Test stability improvements on various platforms.

Compare: https://github.com/nodejs/node-inspect/compare/v1.10.4...v1.10.6

PR-URL: https://github.com/nodejs/node/pull/11869
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-03-20 11:30:42 -04:00

112 lines
2.9 KiB
JavaScript

'use strict';
const Path = require('path');
const { test } = require('tap');
const startCLI = require('./start-cli');
test('examples/empty.js', (t) => {
const script = Path.join('examples', 'empty.js');
const cli = startCLI([script]);
return cli.waitFor(/break/)
.then(() => cli.waitForPrompt())
.then(() => {
t.match(cli.output, 'debug>', 'prints a prompt');
t.match(
cli.output,
'< Debugger listening on port 9229',
'forwards child output');
})
.then(() => cli.command('["hello", "world"].join(" ")'))
.then(() => {
t.match(cli.output, 'hello world', 'prints the result');
})
.then(() => cli.command(''))
.then(() => {
t.match(cli.output, 'hello world', 'repeats the last command on <enter>');
})
.then(() => cli.command('version'))
.then(() => {
t.match(cli.output, process.versions.v8, 'version prints the v8 version');
})
.then(() => cli.quit())
.then((code) => {
t.equal(code, 0, 'exits with success');
});
});
test('run after quit / restart', (t) => {
const script = Path.join('examples', 'three-lines.js');
const cli = startCLI([script]);
function onFatal(error) {
cli.quit();
throw error;
}
return cli.waitFor(/break/)
.then(() => cli.waitForPrompt())
.then(() => cli.stepCommand('n'))
.then(() => {
t.match(
cli.output,
`break in ${script}:2`,
'steps to the 2nd line');
})
.then(() => cli.command('cont'))
.then(() => cli.waitFor(/disconnect/))
.then(() => {
t.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(() => {
t.match(cli.output, 'Use `run` to start the app again');
})
.then(() => cli.stepCommand('run'))
.then(() => cli.waitForPrompt())
.then(() => {
t.match(
cli.output,
`break in ${script}:1`,
'is back at the beginning');
})
.then(() => cli.stepCommand('n'))
.then(() => {
t.match(
cli.output,
`break in ${script}:2`,
'steps to the 2nd line');
})
.then(() => cli.stepCommand('restart'))
.then(() => {
t.match(
cli.output,
`break in ${script}:1`,
'is back at the beginning');
})
.then(() => cli.command('kill'))
.then(() => cli.command('cont'))
.then(() => cli.waitFor(/start the app/))
.then(() => {
t.match(cli.output, 'Use `run` to start the app again');
})
.then(() => cli.stepCommand('run'))
.then(() => cli.waitForPrompt())
.then(() => {
t.match(
cli.output,
`break in ${script}:1`,
'is back at the beginning');
})
.then(() => cli.quit())
.then(null, onFatal);
});