• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3
4common.skipIfInspectorDisabled();
5
6const fixtures = require('../common/fixtures');
7const startCLI = require('../common/debugger');
8
9const assert = require('assert');
10const { createServer } = require('net');
11
12// Launch w/ unavailable port.
13(async () => {
14  const blocker = createServer((socket) => socket.end());
15  const port = await new Promise((resolve, reject) => {
16    blocker.on('error', reject);
17    blocker.listen(0, '127.0.0.1', () => resolve(blocker.address().port));
18  });
19
20  try {
21    const script = fixtures.path('debugger', 'three-lines.js');
22    const cli = startCLI([`--port=${port}`, script]);
23    const code = await cli.quit();
24
25    assert.doesNotMatch(
26      cli.output,
27      /report this bug/,
28      'Omits message about reporting this as a bug');
29    assert.ok(
30      cli.output.includes(`waiting for 127.0.0.1:${port} to be free`),
31      'Tells the user that the port wasn\'t available');
32    assert.strictEqual(code, 1);
33  } finally {
34    blocker.close();
35  }
36})().then(common.mustCall());
37