Skip to content

Commit d3f20a4

Browse files
joaocgreisTrott
authored andcommitted
test: use unique tmpdirs for each test
Tests can leave processes running blocking the tmpdir. This does not yet prevent tests from doing that, but prevents failures on subsequent tests. PR-URL: #28858 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent df936c5 commit d3f20a4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

test/common/tmpdir.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ const testRoot = process.env.NODE_TEST_DIR ?
8989

9090
// Using a `.` prefixed name, which is the convention for "hidden" on POSIX,
9191
// gets tools to ignore it by default or by simple rules, especially eslint.
92-
const tmpdirName = '.tmp.' + (process.env.TEST_THREAD_ID || '0');
92+
const tmpdirName = '.tmp.' +
93+
(process.env.TEST_SERIAL_ID || process.env.TEST_THREAD_ID || '0');
9394
const tmpPath = path.join(testRoot, tmpdirName);
9495

9596
function refresh(opts = {}) {

tools/test.py

+5
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class ProgressIndicator(object):
7777

7878
def __init__(self, cases, flaky_tests_mode):
7979
self.cases = cases
80+
self.serial_id = 0
8081
self.flaky_tests_mode = flaky_tests_mode
8182
self.parallel_queue = Queue(len(cases))
8283
self.sequential_queue = Queue(len(cases))
@@ -146,6 +147,8 @@ def RunSingle(self, parallel, thread_id):
146147
case = test
147148
case.thread_id = thread_id
148149
self.lock.acquire()
150+
case.serial_id = self.serial_id
151+
self.serial_id += 1
149152
self.AboutToRun(case)
150153
self.lock.release()
151154
try:
@@ -504,6 +507,7 @@ def __init__(self, context, path, arch, mode):
504507
self.mode = mode
505508
self.parallel = False
506509
self.disable_core_files = False
510+
self.serial_id = 0
507511
self.thread_id = 0
508512

509513
def IsNegative(self):
@@ -535,6 +539,7 @@ def RunCommand(self, command, env):
535539
def Run(self):
536540
try:
537541
result = self.RunCommand(self.GetCommand(), {
542+
"TEST_SERIAL_ID": "%d" % self.serial_id,
538543
"TEST_THREAD_ID": "%d" % self.thread_id,
539544
"TEST_PARALLEL" : "%d" % self.parallel
540545
})

0 commit comments

Comments
 (0)