@@ -87,12 +87,13 @@ def __init__(self, ns: Namespace, _add_python_opts: bool = False):
8787        self .cmdline_args : TestList  =  ns .args 
8888
8989        # 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 
9293        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 
9495        else :
95-             num_workers  =  ns .use_mp 
96+             num_workers  =  ns .use_mp    # run in parallel 
9697        self .num_workers : int  =  num_workers 
9798        self .worker_json : StrJSON  |  None  =  ns .worker_json 
9899
@@ -234,7 +235,7 @@ def list_tests(tests: TestTuple):
234235
235236    def  _rerun_failed_tests (self , runtests : RunTests ):
236237        # Configure the runner to re-run tests 
237-         if  self .num_workers  ==  0 :
238+         if  self .num_workers  ==  0   and   not   self . single_process :
238239            # Always run tests in fresh processes to have more deterministic 
239240            # initial state. Don't re-run tests in parallel but limit to a 
240241            # single worker process to have side effects (on the system load 
@@ -244,7 +245,6 @@ def _rerun_failed_tests(self, runtests: RunTests):
244245        tests , match_tests_dict  =  self .results .prepare_rerun ()
245246
246247        # Re-run failed tests 
247-         self .log (f"Re-running { len (tests )}  )
248248        runtests  =  runtests .copy (
249249            tests = tests ,
250250            rerun = True ,
@@ -254,7 +254,15 @@ def _rerun_failed_tests(self, runtests: RunTests):
254254            match_tests_dict = match_tests_dict ,
255255            output_on_failure = False )
256256        self .logger .set_tests (runtests )
257-         self ._run_tests_mp (runtests , self .num_workers )
257+ 
258+         msg  =  f"Re-running { len (tests )}  
259+         if  not  self .single_process :
260+             msg  =  f"{ msg }  
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 )
258266        return  runtests 
259267
260268    def  rerun_failed_tests (self , runtests : RunTests ):
@@ -367,7 +375,7 @@ def run_tests_sequentially(self, runtests):
367375            tests  =  count (jobs , 'test' )
368376        else :
369377            tests  =  'tests' 
370-         msg  =  f"Run { tests }  
378+         msg  =  f"Run { tests }  in a single process " 
371379        if  runtests .timeout :
372380            msg  +=  " (timeout: %s)"  %  format_duration (runtests .timeout )
373381        self .log (msg )
@@ -589,7 +597,7 @@ def _add_cross_compile_opts(self, regrtest_opts):
589597            keep_environ  =  True 
590598
591599        if  cross_compile  and  hostrunner :
592-             if  self .num_workers  ==  0 :
600+             if  self .num_workers  ==  0   and   not   self . single_process :
593601                # For now use only two cores for cross-compiled builds; 
594602                # hostrunner can be expensive. 
595603                regrtest_opts .extend (['-j' , '2' ])
0 commit comments