Skip to content

Commit

Permalink
test: move debugger test case to parallel
Browse files Browse the repository at this point in the history
Move test case that does not require a predetermined port to parallel.

PR-URL: #39300
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Zeyu Yang <[email protected]>
  • Loading branch information
Trott committed Jul 10, 2021
1 parent debdc1d commit 6463adf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 28 deletions.
36 changes: 36 additions & 0 deletions test/parallel/test-debugger-unavailable-port.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'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 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());
28 changes: 0 additions & 28 deletions test/sequential/test-debugger-invalid-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ 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.
{
Expand All @@ -31,29 +29,3 @@ const { createServer } = require('net');
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());

0 comments on commit 6463adf

Please sign in to comment.