From d3f20a47255a0f88fa85ee4f9c18a77aeb8f7475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Thu, 25 Jul 2019 20:20:57 +0100 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/28858 Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig --- test/common/tmpdir.js | 3 ++- tools/test.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test/common/tmpdir.js b/test/common/tmpdir.js index 33b2264a8d69f5..92bcc9521a8bdb 100644 --- a/test/common/tmpdir.js +++ b/test/common/tmpdir.js @@ -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 = {}) { diff --git a/tools/test.py b/tools/test.py index ff08749425eb5a..0726619bd092a0 100755 --- a/tools/test.py +++ b/tools/test.py @@ -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)) @@ -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: @@ -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): @@ -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 })