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: https://github.com/nodejs/node/pull/17559 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
This commit is contained in:
parent
3674bee884
commit
800ce94e5c
@ -40,7 +40,16 @@ const noop = () => {};
|
|||||||
// gets tools to ignore it by default or by simple rules, especially eslint.
|
// gets tools to ignore it by default or by simple rules, especially eslint.
|
||||||
let tmpDirName = '.tmp';
|
let tmpDirName = '.tmp';
|
||||||
|
|
||||||
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.isWindows = process.platform === 'win32';
|
||||||
exports.isWOW64 = exports.isWindows &&
|
exports.isWOW64 = exports.isWindows &&
|
||||||
|
@ -532,7 +532,8 @@ class TestCase(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
result = self.RunCommand(self.GetCommand(), {
|
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:
|
finally:
|
||||||
# Tests can leave the tty in non-blocking mode. If the test runner
|
# Tests can leave the tty in non-blocking mode. If the test runner
|
||||||
|
Loading…
x
Reference in New Issue
Block a user