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