-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_runner: support using
--inspect
with --test
PR-URL: #44520 Backport-PR-URL: #44873 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
- Loading branch information
1 parent
99ee5e4
commit 64d343a
Showing
13 changed files
with
391 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
|
||
const common = require('../../common'); | ||
const fixtures = require('../../common/fixtures'); | ||
const { run } = require('node:test'); | ||
const assert = require('node:assert'); | ||
|
||
const badPortError = { name: 'RangeError', code: 'ERR_SOCKET_BAD_PORT' }; | ||
let inspectPort = 'inspectPort' in process.env ? Number(process.env.inspectPort) : undefined; | ||
let expectedError; | ||
|
||
if (process.env.inspectPort === 'addTwo') { | ||
inspectPort = common.mustCall(() => { return process.debugPort += 2; }); | ||
} else if (process.env.inspectPort === 'string') { | ||
inspectPort = 'string'; | ||
expectedError = badPortError; | ||
} else if (process.env.inspectPort === 'null') { | ||
inspectPort = null; | ||
} else if (process.env.inspectPort === 'bignumber') { | ||
inspectPort = 1293812; | ||
expectedError = badPortError; | ||
} else if (process.env.inspectPort === 'negativenumber') { | ||
inspectPort = -9776; | ||
expectedError = badPortError; | ||
} else if (process.env.inspectPort === 'bignumberfunc') { | ||
inspectPort = common.mustCall(() => 123121); | ||
expectedError = badPortError; | ||
} else if (process.env.inspectPort === 'strfunc') { | ||
inspectPort = common.mustCall(() => 'invalidPort'); | ||
expectedError = badPortError; | ||
} | ||
|
||
const stream = run({ files: [fixtures.path('test-runner/run_inspect_assert.js')], inspectPort }); | ||
if (expectedError) { | ||
stream.on('test:fail', common.mustCall(({ error }) => { | ||
assert.deepStrictEqual({ name: error.cause.name, code: error.cause.code }, expectedError); | ||
})); | ||
} else { | ||
stream.on('test:fail', common.mustNotCall()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
const assert = require('node:assert'); | ||
|
||
const { expectedPort, expectedInitialPort, expectedHost } = process.env; | ||
const debugOptions = | ||
require('internal/options').getOptionValue('--inspect-port'); | ||
|
||
if ('expectedPort' in process.env) { | ||
assert.strictEqual(process.debugPort, +expectedPort); | ||
} | ||
|
||
if ('expectedInitialPort' in process.env) { | ||
assert.strictEqual(debugOptions.port, +expectedInitialPort); | ||
} | ||
|
||
if ('expectedHost' in process.env) { | ||
assert.strictEqual(debugOptions.host, expectedHost); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.