node/deps/node-inspect/test/cli/invalid-args.test.js
Jan Krems 0b90b071c4
deps: Upgrade node-inspect to 1.11.5
Removes the prompt to report a bug when trying to launch the
debugger using a port that is already in use.

Changeset generated via:

```
rm -rf deps/node-inspect node-inspect-* && \
  curl -sSL "https://github.com/nodejs/node-inspect/archive/v1.11.5.tar.gz" | \
  tar -xzvf - && mv node-inspect-* deps/node-inspect
```

PR-URL: https://github.com/nodejs/node/pull/21055
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2018-06-14 20:34:55 +02:00

54 lines
1.5 KiB
JavaScript

'use strict';
const Path = require('path');
const { createServer } = require('net');
const { test } = require('tap');
const startCLI = require('./start-cli');
test('launch CLI w/o args', (t) => {
const cli = startCLI([]);
return cli.quit()
.then((code) => {
t.equal(code, 1, 'exits with non-zero exit code');
t.match(cli.output, /^Usage:/, 'Prints usage info');
});
});
test('launch w/ invalid host:port', (t) => {
const cli = startCLI(['localhost:914']);
return cli.quit()
.then((code) => {
t.match(
cli.output,
'failed to connect',
'Tells the user that the connection failed');
t.equal(code, 1, 'exits with non-zero exit code');
});
});
test('launch w/ unavailable port', async (t) => {
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 = Path.join('examples', 'three-lines.js');
const cli = startCLI([`--port=${port}`, script]);
const code = await cli.quit();
t.notMatch(
cli.output,
'report this bug',
'Omits message about reporting this as a bug');
t.match(
cli.output,
`waiting for 127.0.0.1:${port} to be free`,
'Tells the user that the port wasn\'t available');
t.equal(code, 1, 'exits with non-zero exit code');
} finally {
blocker.close();
}
});