@@ -89,12 +89,13 @@ def __init__(self, ns: Namespace, _add_python_opts: bool = False):
8989 self .cmdline_args : TestList = ns .args
9090
9191 # 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
9495 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
9697 else :
97- num_workers = ns .use_mp
98+ num_workers = ns .use_mp # run in parallel
9899 self .num_workers : int = num_workers
99100 self .worker_json : StrJSON | None = ns .worker_json
100101
@@ -236,7 +237,7 @@ def list_tests(tests: TestTuple):
236237
237238 def _rerun_failed_tests (self , runtests : RunTests ):
238239 # Configure the runner to re-run tests
239- if self .num_workers == 0 :
240+ if self .num_workers == 0 and not self . single_process :
240241 # Always run tests in fresh processes to have more deterministic
241242 # initial state. Don't re-run tests in parallel but limit to a
242243 # single worker process to have side effects (on the system load
@@ -246,7 +247,6 @@ def _rerun_failed_tests(self, runtests: RunTests):
246247 tests , match_tests_dict = self .results .prepare_rerun ()
247248
248249 # Re-run failed tests
249- self .log (f"Re-running { len (tests )} failed tests in verbose mode in subprocesses" )
250250 runtests = runtests .copy (
251251 tests = tests ,
252252 rerun = True ,
@@ -256,7 +256,15 @@ def _rerun_failed_tests(self, runtests: RunTests):
256256 match_tests_dict = match_tests_dict ,
257257 output_on_failure = False )
258258 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 )
260268 return runtests
261269
262270 def rerun_failed_tests (self , runtests : RunTests ):
@@ -371,7 +379,7 @@ def run_tests_sequentially(self, runtests) -> None:
371379 tests = count (jobs , 'test' )
372380 else :
373381 tests = 'tests'
374- msg = f"Run { tests } sequentially"
382+ msg = f"Run { tests } sequentially in a single process "
375383 if runtests .timeout :
376384 msg += " (timeout: %s)" % format_duration (runtests .timeout )
377385 self .log (msg )
@@ -599,7 +607,7 @@ def _add_cross_compile_opts(self, regrtest_opts):
599607 keep_environ = True
600608
601609 if cross_compile and hostrunner :
602- if self .num_workers == 0 :
610+ if self .num_workers == 0 and not self . single_process :
603611 # For now use only two cores for cross-compiled builds;
604612 # hostrunner can be expensive.
605613 regrtest_opts .extend (['-j' , '2' ])
0 commit comments