@@ -300,25 +300,6 @@ async fn run_tests_in_directory(args: &RunArgs) -> Result<Vec<TestResult>> {
300300 ) ;
301301 eprintln ! ( "{}" , "-" . repeat( 50 ) ) ;
302302
303- let mut config = devenv:: config:: Config :: load_from ( path) ?;
304- for input in args. override_input . chunks_exact ( 2 ) {
305- config
306- . override_input_url ( & input[ 0 ] , & input[ 1 ] )
307- . wrap_err ( format ! (
308- "Failed to override input {} with {}" ,
309- & input[ 0 ] , & input[ 1 ]
310- ) ) ?;
311- }
312-
313- // Override the input for the devenv module
314- config
315- . add_input (
316- "devenv" ,
317- & format ! ( "path:{}?dir=src/modules" , cwd. display( ) ) ,
318- & [ ] ,
319- )
320- . wrap_err ( "Failed to add devenv input" ) ?;
321-
322303 // Determine whether to use a temporary directory
323304 let ( devenv_root, devenv_dotfile, _tmpdir) = if test_config. use_tmp_dir {
324305 // Create temp directory in system temp dir, not the current directory
@@ -367,6 +348,36 @@ async fn run_tests_in_directory(args: &RunArgs) -> Result<Vec<TestResult>> {
367348 ( devenv_root, devenv_dotfile, None )
368349 } ;
369350
351+ // Run .patch.sh if it exists (must run before loading config)
352+ let patch_script = PathBuf :: from ( ".patch.sh" ) ;
353+ if patch_script. exists ( ) {
354+ eprintln ! ( " Running .patch.sh" ) ;
355+ let _ = Command :: new ( "bash" )
356+ . arg ( & patch_script)
357+ . status ( )
358+ . into_diagnostic ( ) ?;
359+ }
360+
361+ // Now load config from the current directory (which might be temp dir)
362+ let mut config = devenv:: config:: Config :: load_from ( & devenv_root) ?;
363+ for input in args. override_input . chunks_exact ( 2 ) {
364+ config
365+ . override_input_url ( & input[ 0 ] , & input[ 1 ] )
366+ . wrap_err ( format ! (
367+ "Failed to override input {} with {}" ,
368+ & input[ 0 ] , & input[ 1 ]
369+ ) ) ?;
370+ }
371+
372+ // Override the input for the devenv module
373+ config
374+ . add_input (
375+ "devenv" ,
376+ & format ! ( "path:{}?dir=src/modules" , cwd. display( ) ) ,
377+ & [ ] ,
378+ )
379+ . wrap_err ( "Failed to add devenv input" ) ?;
380+
370381 let options = DevenvOptions {
371382 config,
372383 devenv_root : Some ( devenv_root. clone ( ) ) ,
@@ -377,18 +388,6 @@ async fn run_tests_in_directory(args: &RunArgs) -> Result<Vec<TestResult>> {
377388
378389 eprintln ! ( " Running {dir_name}" ) ;
379390
380- // A script to patch files in the working directory before the shell.
381- let patch_script = ".patch.sh" ;
382-
383- // Run .patch.sh if it exists
384- if PathBuf :: from ( patch_script) . exists ( ) {
385- eprintln ! ( " Running {patch_script}" ) ;
386- let _ = Command :: new ( "bash" )
387- . arg ( patch_script)
388- . status ( )
389- . into_diagnostic ( ) ?;
390- }
391-
392391 // A script to run inside the shell before the test.
393392 let setup_script = ".setup.sh" ;
394393
0 commit comments