mirror of
https://github.com/nodejs/node.git
synced 2025-05-05 17:10:40 +00:00

When I moved node-inspect into core, I called a lot of things `inspector-cli` that really should have been `debugger`. This is the last of them to be renamed. PR-URL: https://github.com/nodejs/node/pull/39156 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
60 lines
1.5 KiB
JavaScript
60 lines
1.5 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 { createServer } = require('net');
|
|
|
|
// Launch CLI w/o args.
|
|
{
|
|
const cli = startCLI([]);
|
|
cli.quit()
|
|
.then((code) => {
|
|
assert.strictEqual(code, 1);
|
|
assert.match(cli.output, /^Usage:/, 'Prints usage info');
|
|
});
|
|
}
|
|
|
|
// Launch w/ invalid host:port.
|
|
{
|
|
const cli = startCLI(['localhost:914']);
|
|
cli.quit()
|
|
.then((code) => {
|
|
assert.match(
|
|
cli.output,
|
|
/failed to connect/,
|
|
'Tells the user that the connection failed');
|
|
assert.strictEqual(code, 1);
|
|
});
|
|
}
|
|
|
|
// Launch w/ unavailable port.
|
|
(async () => {
|
|
const blocker = createServer((socket) => socket.end());
|
|
const port = await new Promise((resolve, reject) => {
|
|
blocker.on('error', reject);
|
|
blocker.listen(0, '127.0.0.1', () => resolve(blocker.address().port));
|
|
});
|
|
|
|
try {
|
|
const script = fixtures.path('debugger', 'three-lines.js');
|
|
const cli = startCLI([`--port=${port}`, script]);
|
|
const code = await cli.quit();
|
|
|
|
assert.doesNotMatch(
|
|
cli.output,
|
|
/report this bug/,
|
|
'Omits message about reporting this as a bug');
|
|
assert.ok(
|
|
cli.output.includes(`waiting for 127.0.0.1:${port} to be free`),
|
|
'Tells the user that the port wasn\'t available');
|
|
assert.strictEqual(code, 1);
|
|
} finally {
|
|
blocker.close();
|
|
}
|
|
})().then(common.mustCall());
|