From 2388648beabd0387bcba039d58a71f3c8882cee1 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 23 Oct 2016 22:00:37 -0700 Subject: [PATCH] tools: make --repeat work with -j in test.py The repeat option in test.py did not work as expected if `-j` was set to more than one. Repeated tests running at the same time could share temp directories and cause test failures. This was observed with: tools/test.py -J --repeat=10 parallel/test-fs-watch-recursive By using copy.deepCopy(), the repeated tests are separate objects and not references to the same objects. Setting `thread_id` on one of them will now not change the `thread_id` on all of them. And `thread_id` is how the temp directory (and common.PORT as well) are determined. Refs: https://github.com/nodejs/node/pull/9228 PR-URL: https://github.com/nodejs/node/pull/9249 Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Gibson Fahnestock Reviewed-By: Michael Dawson Reviewed-By: James M Snell Reviewed-By: Santiago Gimeno --- tools/test.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/test.py b/tools/test.py index 05cd9243449d27..6e1840b7672006 100755 --- a/tools/test.py +++ b/tools/test.py @@ -42,6 +42,7 @@ import utils import multiprocessing import errno +import copy from os.path import join, dirname, abspath, basename, isdir, exists from datetime import datetime @@ -792,7 +793,9 @@ def AddTestsToList(self, result, current_path, path, context, arch, mode): tests = self.GetConfiguration(context).ListTests(current_path, path, arch, mode) for t in tests: t.variant_flags = v - result += tests * context.repeat + result += tests + for i in range(1, context.repeat): + result += copy.deepcopy(tests) def GetTestStatus(self, context, sections, defs): self.GetConfiguration(context).GetTestStatus(sections, defs)