@@ -68,8 +68,10 @@ def run_test_in_subprocess(testname: str, ns: Namespace, tmp_dir: str) -> subpro
6868 '--worker-args' , worker_args ]
6969
7070 env = dict (os .environ )
71- env ['TMPDIR' ] = tmp_dir
72- env ['TEMPDIR' ] = tmp_dir
71+ if tmp_dir is not None :
72+ env ['TMPDIR' ] = tmp_dir
73+ env ['TEMP' ] = tmp_dir
74+ env ['TMP' ] = tmp_dir
7375
7476 # Running the child from the same working directory as regrtest's original
7577 # invocation ensures that TEMPDIR for the child is the same when
@@ -271,17 +273,21 @@ def _run_process(self, test_name: str, tmp_dir: str) -> tuple[int, str, str]:
271273 self .current_test_name = None
272274
273275 def _runtest (self , test_name : str ) -> MultiprocessResult :
274- # gh-93353: Check for leaked temporary files in the parent process,
275- # since the deletion of temporary files can happen late during
276- # Python finalization: too late for libregrtest.
277- tmp_dir = os .getcwd () + '_tmpdir'
278- tmp_dir = os .path .abspath (tmp_dir )
279- try :
280- os .mkdir (tmp_dir )
281- retcode , stdout = self ._run_process (test_name , tmp_dir )
282- finally :
283- tmp_files = os .listdir (tmp_dir )
284- os_helper .rmtree (tmp_dir )
276+ if self .ns .use_mp == 1 :
277+ # gh-93353: Check for leaked temporary files in the parent process,
278+ # since the deletion of temporary files can happen late during
279+ # Python finalization: too late for libregrtest.
280+ tmp_dir = os .getcwd () + '_tmpdir'
281+ tmp_dir = os .path .abspath (tmp_dir )
282+ try :
283+ os .mkdir (tmp_dir )
284+ retcode , stdout = self ._run_process (test_name , tmp_dir )
285+ finally :
286+ tmp_files = os .listdir (tmp_dir )
287+ os_helper .rmtree (tmp_dir )
288+ else :
289+ retcode , stdout = self ._run_process (test_name , None )
290+ tmp_files = ()
285291
286292 if retcode is None :
287293 return self .mp_result_error (Timeout (test_name ), stdout )
@@ -306,8 +312,8 @@ def _runtest(self, test_name: str) -> MultiprocessResult:
306312
307313 if tmp_files :
308314 msg = (f'\n \n '
309- f'Warning -- Test leaked temporary files ( { len ( tmp_files ) } ): '
310- f'{ ", " .join (sorted (tmp_files ))} ' )
315+ f'Warning -- { test_name } leaked temporary files '
316+ f'( { len ( tmp_files ) } ): { ", " .join (sorted (tmp_files ))} ' )
311317 stdout += msg
312318 if isinstance (result , Passed ):
313319 result = EnvChanged .from_passed (result )
0 commit comments