Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 03d2514

Browse filesBrowse files
TrottMylesBorins
authored andcommitted
tools,test: throw if common.PORT used in parallel tests
common.PORT should not be used in parallelized tests. (There can be a port collision if another tests requests an arbitrary open port from the operating system and ends up getting common.PORT before a test that uses common.PORT uses the port.) In such a situation, throw an error. PR-URL: #17559 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
1 parent 39e2fb6 commit 03d2514
Copy full SHA for 03d2514

File tree

Expand file treeCollapse file tree

2 files changed

+12
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-2
lines changed
Open diff view settings
Collapse file

‎test/common/index.js‎

Copy file name to clipboardExpand all lines: test/common/index.js
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,16 @@ const noop = () => {};
4040
// gets tools to ignore it by default or by simple rules, especially eslint.
4141
let tmpDirName = '.tmp';
4242

43-
exports.PORT = +process.env.NODE_COMMON_PORT || 12346;
43+
Object.defineProperty(exports, 'PORT', {
44+
get: () => {
45+
if (+process.env.TEST_PARALLEL) {
46+
throw new Error('common.PORT cannot be used in a parallelized test');
47+
}
48+
return +process.env.NODE_COMMON_PORT || 12346;
49+
},
50+
enumerable: true
51+
});
52+
4453

4554
exports.isWindows = process.platform === 'win32';
4655
exports.isWOW64 = exports.isWindows &&
Collapse file

‎tools/test.py‎

Copy file name to clipboardExpand all lines: tools/test.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,8 @@ def Run(self):
532532

533533
try:
534534
result = self.RunCommand(self.GetCommand(), {
535-
"TEST_THREAD_ID": "%d" % self.thread_id
535+
"TEST_THREAD_ID": "%d" % self.thread_id,
536+
"TEST_PARALLEL" : "%d" % self.parallel
536537
})
537538
finally:
538539
# Tests can leave the tty in non-blocking mode. If the test runner

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.