Skip to content

Commit ccbb00e

Browse files
committed
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: thefourtheye - Sakthipriyan Vairamani <[email protected]> Reviewed-By: joaocgreis - João Reis <[email protected]> Reviewed-By: Johan Bergström <[email protected]>
1 parent d13b9d3 commit ccbb00e

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
@@ -726,8 +726,7 @@ def AddTestsToList(self, result, current_path, path, context, arch, mode):
726726
tests = self.GetConfiguration(context).ListTests(current_path, path,
727727
arch, mode)
728728
for t in tests: t.variant_flags = v
729-
result += tests
730-
729+
result += tests * context.repeat
731730

732731
def GetTestStatus(self, context, sections, defs):
733732
self.GetConfiguration(context).GetTestStatus(sections, defs)
@@ -780,7 +779,8 @@ def GetTestStatus(self, context, sections, defs):
780779
class Context(object):
781780

782781
def __init__(self, workspace, buildspace, verbose, vm, args, expect_fail,
783-
timeout, processor, suppress_dialogs, store_unexpected_output):
782+
timeout, processor, suppress_dialogs,
783+
store_unexpected_output, repeat):
784784
self.workspace = workspace
785785
self.buildspace = buildspace
786786
self.verbose = verbose
@@ -791,6 +791,7 @@ def __init__(self, workspace, buildspace, verbose, vm, args, expect_fail,
791791
self.processor = processor
792792
self.suppress_dialogs = suppress_dialogs
793793
self.store_unexpected_output = store_unexpected_output
794+
self.repeat = repeat
794795

795796
def GetVm(self, arch, mode):
796797
if arch == 'none':
@@ -1324,6 +1325,9 @@ def BuildOptions():
13241325
default="")
13251326
result.add_option('--temp-dir',
13261327
help='Optional path to change directory used for tests', default=False)
1328+
result.add_option('--repeat',
1329+
help='Number of times to repeat given tests',
1330+
default=1, type="int")
13271331
return result
13281332

13291333

@@ -1489,7 +1493,8 @@ def Main():
14891493
options.timeout,
14901494
processor,
14911495
options.suppress_dialogs,
1492-
options.store_unexpected_output)
1496+
options.store_unexpected_output,
1497+
options.repeat)
14931498
# First build the required targets
14941499
if not options.no_build:
14951500
reqs = [ ]

0 commit comments

Comments
 (0)