diff --git a/test/common/index.js b/test/common/index.js index 1ed9952a514eeb..81e76be0f31b1a 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -39,8 +39,18 @@ const noop = () => {}; // Using a `.` prefixed name, which is the convention for "hidden" on POSIX, // gets tools to ignore it by default or by simple rules, especially eslint. let tmpDirName = '.tmp'; -// PORT should match the definition in test/testpy/__init__.py. -exports.PORT = +process.env.NODE_COMMON_PORT || 12346; + +Object.defineProperty(exports, 'PORT', { + get: () => { + if (+process.env.TEST_PARALLEL) { + throw new Error('common.PORT cannot be used in a parallelized test'); + } + return +process.env.NODE_COMMON_PORT || 12346; + }, + enumerable: true +}); + + exports.isWindows = process.platform === 'win32'; exports.isWOW64 = exports.isWindows && (process.env.PROCESSOR_ARCHITEW6432 !== undefined); @@ -162,7 +172,6 @@ exports.refreshTmpDir = function() { }; if (process.env.TEST_THREAD_ID) { - exports.PORT += process.env.TEST_THREAD_ID * 100; tmpDirName += `.${process.env.TEST_THREAD_ID}`; } exports.tmpDir = path.join(testRoot, tmpDirName); diff --git a/test/testpy/__init__.py b/test/testpy/__init__.py index f113c1253a477f..455d57f4d9157a 100644 --- a/test/testpy/__init__.py +++ b/test/testpy/__init__.py @@ -61,10 +61,7 @@ def GetCommand(self): source = open(self.file).read() flags_match = FLAGS_PATTERN.search(source) if flags_match: - # PORT should match the definition in test/common/index.js. - env = { 'PORT': int(os.getenv('NODE_COMMON_PORT', '12346')) } - env['PORT'] += self.thread_id * 100 - flag = flags_match.group(1).strip().format(**env).split() + flag = flags_match.group(1).strip().split() # The following block reads config.gypi to extract the v8_enable_inspector # value. This is done to check if the inspector is disabled in which case # the '--inspect' flag cannot be passed to the node process as it will diff --git a/tools/test.py b/tools/test.py index ccc25f2a883c15..230774b25619da 100755 --- a/tools/test.py +++ b/tools/test.py @@ -532,7 +532,8 @@ def Run(self): try: result = self.RunCommand(self.GetCommand(), { - "TEST_THREAD_ID": "%d" % self.thread_id + "TEST_THREAD_ID": "%d" % self.thread_id, + "TEST_PARALLEL" : "%d" % self.parallel }) finally: # Tests can leave the tty in non-blocking mode. If the test runner