Skip to content

Commit

Permalink
test: use unique tmpdirs for each test
Browse files Browse the repository at this point in the history
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: nodejs#28858
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
joaocgreis authored and Trott committed Aug 11, 2019
1 parent df936c5 commit d3f20a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/common/tmpdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ const testRoot = process.env.NODE_TEST_DIR ?

// 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.
const tmpdirName = '.tmp.' + (process.env.TEST_THREAD_ID || '0');
const tmpdirName = '.tmp.' +
(process.env.TEST_SERIAL_ID || process.env.TEST_THREAD_ID || '0');
const tmpPath = path.join(testRoot, tmpdirName);

function refresh(opts = {}) {
Expand Down
5 changes: 5 additions & 0 deletions tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class ProgressIndicator(object):

def __init__(self, cases, flaky_tests_mode):
self.cases = cases
self.serial_id = 0
self.flaky_tests_mode = flaky_tests_mode
self.parallel_queue = Queue(len(cases))
self.sequential_queue = Queue(len(cases))
Expand Down Expand Up @@ -146,6 +147,8 @@ def RunSingle(self, parallel, thread_id):
case = test
case.thread_id = thread_id
self.lock.acquire()
case.serial_id = self.serial_id
self.serial_id += 1
self.AboutToRun(case)
self.lock.release()
try:
Expand Down Expand Up @@ -504,6 +507,7 @@ def __init__(self, context, path, arch, mode):
self.mode = mode
self.parallel = False
self.disable_core_files = False
self.serial_id = 0
self.thread_id = 0

def IsNegative(self):
Expand Down Expand Up @@ -535,6 +539,7 @@ def RunCommand(self, command, env):
def Run(self):
try:
result = self.RunCommand(self.GetCommand(), {
"TEST_SERIAL_ID": "%d" % self.serial_id,
"TEST_THREAD_ID": "%d" % self.thread_id,
"TEST_PARALLEL" : "%d" % self.parallel
})
Expand Down

0 comments on commit d3f20a4

Please sign in to comment.