@@ -89,12 +89,13 @@ def __init__(self, ns: Namespace, _add_python_opts: bool = False):
89
89
self .cmdline_args : TestList = ns .args
90
90
91
91
# Workers
92
- if ns .use_mp is None :
93
- num_workers = 0 # run sequentially
92
+ self .single_process : bool = ns .single_process
93
+ if self .single_process or ns .use_mp is None :
94
+ num_workers = 0 # run sequentially in a single process
94
95
elif ns .use_mp <= 0 :
95
- num_workers = - 1 # use the number of CPUs
96
+ num_workers = - 1 # run in parallel, use the number of CPUs
96
97
else :
97
- num_workers = ns .use_mp
98
+ num_workers = ns .use_mp # run in parallel
98
99
self .num_workers : int = num_workers
99
100
self .worker_json : StrJSON | None = ns .worker_json
100
101
@@ -236,7 +237,7 @@ def list_tests(tests: TestTuple):
236
237
237
238
def _rerun_failed_tests (self , runtests : RunTests ):
238
239
# Configure the runner to re-run tests
239
- if self .num_workers == 0 :
240
+ if self .num_workers == 0 and not self . single_process :
240
241
# Always run tests in fresh processes to have more deterministic
241
242
# initial state. Don't re-run tests in parallel but limit to a
242
243
# single worker process to have side effects (on the system load
@@ -246,7 +247,6 @@ def _rerun_failed_tests(self, runtests: RunTests):
246
247
tests , match_tests_dict = self .results .prepare_rerun ()
247
248
248
249
# Re-run failed tests
249
- self .log (f"Re-running { len (tests )} failed tests in verbose mode in subprocesses" )
250
250
runtests = runtests .copy (
251
251
tests = tests ,
252
252
rerun = True ,
@@ -256,7 +256,15 @@ def _rerun_failed_tests(self, runtests: RunTests):
256
256
match_tests_dict = match_tests_dict ,
257
257
output_on_failure = False )
258
258
self .logger .set_tests (runtests )
259
- self ._run_tests_mp (runtests , self .num_workers )
259
+
260
+ msg = f"Re-running { len (tests )} failed tests in verbose mode"
261
+ if not self .single_process :
262
+ msg = f"{ msg } in subprocesses"
263
+ self .log (msg )
264
+ self ._run_tests_mp (runtests , self .num_workers )
265
+ else :
266
+ self .log (msg )
267
+ self .run_tests_sequentially (runtests )
260
268
return runtests
261
269
262
270
def rerun_failed_tests (self , runtests : RunTests ):
@@ -371,7 +379,7 @@ def run_tests_sequentially(self, runtests) -> None:
371
379
tests = count (jobs , 'test' )
372
380
else :
373
381
tests = 'tests'
374
- msg = f"Run { tests } sequentially"
382
+ msg = f"Run { tests } sequentially in a single process "
375
383
if runtests .timeout :
376
384
msg += " (timeout: %s)" % format_duration (runtests .timeout )
377
385
self .log (msg )
@@ -599,7 +607,7 @@ def _add_cross_compile_opts(self, regrtest_opts):
599
607
keep_environ = True
600
608
601
609
if cross_compile and hostrunner :
602
- if self .num_workers == 0 :
610
+ if self .num_workers == 0 and not self . single_process :
603
611
# For now use only two cores for cross-compiled builds;
604
612
# hostrunner can be expensive.
605
613
regrtest_opts .extend (['-j' , '2' ])
0 commit comments