From 1eb8307cc5f2956f0d8d4e5d61c73b538a3d7551 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 7 Jul 2021 10:51:29 -0700 Subject: [PATCH] test: move debugger test case to parallel Move test case that does not require a predetermined port to parallel. PR-URL: https://github.com/nodejs/node/pull/39300 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Zeyu Yang --- .../test-debugger-unavailable-port.js | 36 +++++++++++++++++++ test/sequential/test-debugger-invalid-args.js | 28 --------------- 2 files changed, 36 insertions(+), 28 deletions(-) create mode 100644 test/parallel/test-debugger-unavailable-port.js diff --git a/test/parallel/test-debugger-unavailable-port.js b/test/parallel/test-debugger-unavailable-port.js new file mode 100644 index 00000000000000..e2920312ffc21c --- /dev/null +++ b/test/parallel/test-debugger-unavailable-port.js @@ -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()); diff --git a/test/sequential/test-debugger-invalid-args.js b/test/sequential/test-debugger-invalid-args.js index 5275d2b1dac9bd..36f8e588b04a6e 100644 --- a/test/sequential/test-debugger-invalid-args.js +++ b/test/sequential/test-debugger-invalid-args.js @@ -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. { @@ -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());