@@ -178,8 +178,9 @@ def stop(self) -> None:
178178 self ._kill ()
179179
180180 def _run_process (self , runtests : WorkerRunTests , output_fd : int ,
181+ worker_config : StrPath ,
181182 tmp_dir : StrPath | None = None ) -> int | None :
182- popen = create_worker_process (runtests , output_fd , tmp_dir )
183+ popen = create_worker_process (runtests , output_fd , worker_config , tmp_dir )
183184 self ._popen = popen
184185 self ._killed = False
185186
@@ -293,7 +294,8 @@ def create_worker_runtests(self, test_name: TestName,
293294 ** kwargs )
294295
295296 def run_tmp_files (self , worker_runtests : WorkerRunTests ,
296- stdout_fd : int ) -> tuple [int | None , list [StrPath ]]:
297+ stdout_fd : int ,
298+ worker_config : StrPath ) -> tuple [int | None , list [StrPath ]]:
297299 # gh-93353: Check for leaked temporary files in the parent process,
298300 # since the deletion of temporary files can happen late during
299301 # Python finalization: too late for libregrtest.
@@ -305,12 +307,12 @@ def run_tmp_files(self, worker_runtests: WorkerRunTests,
305307 tmp_dir = os .path .abspath (tmp_dir )
306308 try :
307309 retcode = self ._run_process (worker_runtests ,
308- stdout_fd , tmp_dir )
310+ stdout_fd , worker_config , tmp_dir )
309311 finally :
310312 tmp_files = os .listdir (tmp_dir )
311313 os_helper .rmtree (tmp_dir )
312314 else :
313- retcode = self ._run_process (worker_runtests , stdout_fd )
315+ retcode = self ._run_process (worker_runtests , stdout_fd , worker_config )
314316 tmp_files = []
315317
316318 return (retcode , tmp_files )
@@ -369,9 +371,28 @@ def _runtest(self, test_name: TestName,
369371 worker_runtests = self .create_worker_runtests (
370372 test_name , json_file , module_name = module_name )
371373
374+ # Custom runners may map the source tree to a different filesystem
375+ # root (for example, on WASI). Keep the configuration in the test
376+ # directory and resolve its path relative to libregrtest.
377+ config_dir = os .curdir if worker_runtests .python_cmd else None
378+ worker_config = stack .enter_context (tempfile .NamedTemporaryFile (
379+ 'w' , encoding = 'utf-8' , prefix = 'test_python_' , dir = config_dir ,
380+ delete_on_close = False ))
381+ worker_config .write (worker_runtests .as_json ())
382+ # Allow the worker to reopen the file on Windows.
383+ worker_config .close ()
384+ config_path = worker_config .name
385+ if worker_runtests .python_cmd :
386+ try :
387+ config_path = os .path .relpath (config_path , os .path .dirname (__file__ ))
388+ except ValueError :
389+ # On Windows the directories may be on different drives.
390+ pass
391+
372392 retcode : str | int | None
373393 retcode , tmp_files = self .run_tmp_files (worker_runtests ,
374- stdout_file .fileno ())
394+ stdout_file .fileno (),
395+ config_path )
375396
376397 stdout = self .read_stdout (stdout_file )
377398
0 commit comments