Skip to content

Commit 827b3eb

Browse files
mhdawsonrvagg
authored andcommitted
test: add --repeat option to tools/test.py
I often want to run a test many times to see if a failure can be recreated and I believe this is a common use case. We even have this job in the CI https://ci.nodejs.org/job/node-stress-single-test/configure but often you want to run it on a specific machine. This patch adds the --repeat option so that you can repeat the selected set of tests a number of times. Given existing options in test.py this will allow you to run one or more tests for the number of repeats specified. For example: tools/test.py -j8 --repeat 1000 parallel/test-process-exec-argv runs the test-process-exec-argv test 1000 times, running 8 copies in parallel tools/test.py --repeat 2 would run the entire test suite twice. PR-URL: #6700 Reviewed-By: Ben Noorhduis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: thefourtheye - Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: joaocgreis - João Reis <reis@janeasystems.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
1 parent 7b2949a commit 827b3eb

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tools/test.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,7 @@ def AddTestsToList(self, result, current_path, path, context, arch, mode):
734734
tests = self.GetConfiguration(context).ListTests(current_path, path,
735735
arch, mode)
736736
for t in tests: t.variant_flags = v
737-
result += tests
738-
737+
result += tests * context.repeat
739738

740739
def GetTestStatus(self, context, sections, defs):
741740
self.GetConfiguration(context).GetTestStatus(sections, defs)
@@ -788,7 +787,8 @@ def GetTestStatus(self, context, sections, defs):
788787
class Context(object):
789788

790789
def __init__(self, workspace, buildspace, verbose, vm, args, expect_fail,
791-
timeout, processor, suppress_dialogs, store_unexpected_output):
790+
timeout, processor, suppress_dialogs,
791+
store_unexpected_output, repeat):
792792
self.workspace = workspace
793793
self.buildspace = buildspace
794794
self.verbose = verbose
@@ -799,6 +799,7 @@ def __init__(self, workspace, buildspace, verbose, vm, args, expect_fail,
799799
self.processor = processor
800800
self.suppress_dialogs = suppress_dialogs
801801
self.store_unexpected_output = store_unexpected_output
802+
self.repeat = repeat
802803

803804
def GetVm(self, arch, mode):
804805
if arch == 'none':
@@ -1332,6 +1333,9 @@ def BuildOptions():
13321333
default="")
13331334
result.add_option('--temp-dir',
13341335
help='Optional path to change directory used for tests', default=False)
1336+
result.add_option('--repeat',
1337+
help='Number of times to repeat given tests',
1338+
default=1, type="int")
13351339
return result
13361340

13371341

@@ -1497,7 +1501,8 @@ def Main():
14971501
options.timeout,
14981502
processor,
14991503
options.suppress_dialogs,
1500-
options.store_unexpected_output)
1504+
options.store_unexpected_output,
1505+
options.repeat)
15011506
# First build the required targets
15021507
if not options.no_build:
15031508
reqs = [ ]

0 commit comments

Comments
 (0)