@@ -15,7 +15,7 @@ use crate::errors::{self, Error, ErrorKind};
1515use crate :: header:: TestProps ;
1616use crate :: json;
1717use crate :: read2:: { read2_abbreviated, Truncated } ;
18- use crate :: util:: { add_dylib_path, dylib_env_var, logv, PathBufExt } ;
18+ use crate :: util:: { add_dylib_path, copy_dir_all , dylib_env_var, logv, PathBufExt } ;
1919use crate :: ColorConfig ;
2020use colored:: Colorize ;
2121use miropt_test_tools:: { files_for_miropt_test, MiroptTest , MiroptTestFile } ;
@@ -3458,6 +3458,21 @@ impl<'test> TestCx<'test> {
34583458 let rmake_out_dir = base_dir. join ( "rmake_out" ) ;
34593459 create_dir_all ( & rmake_out_dir) . unwrap ( ) ;
34603460
3461+ // Copy all input files (apart from rmake.rs) to the temporary directory,
3462+ // so that the input directory structure from `tests/run-make/<test>` is mirrored
3463+ // to the `rmake_out` directory.
3464+ for path in walkdir:: WalkDir :: new ( & self . testpaths . file ) . min_depth ( 1 ) {
3465+ let path = path. unwrap ( ) . path ( ) . to_path_buf ( ) ;
3466+ if path. file_name ( ) . map ( |s| s != OsStr :: new ( "rmake.rs" ) ) . unwrap_or ( false ) {
3467+ let target = rmake_out_dir. join ( path. strip_prefix ( & self . testpaths . file ) . unwrap ( ) ) ;
3468+ if path. is_dir ( ) {
3469+ copy_dir_all ( & path, target) . unwrap ( ) ;
3470+ } else {
3471+ fs:: copy ( & path, target) . unwrap ( ) ;
3472+ }
3473+ }
3474+ }
3475+
34613476 // HACK: assume stageN-target, we only want stageN.
34623477 let stage = self . config . stage_id . split ( '-' ) . next ( ) . unwrap ( ) ;
34633478
@@ -3559,7 +3574,7 @@ impl<'test> TestCx<'test> {
35593574 let target_rpath_env_path = env:: join_paths ( target_rpath_env_path) . unwrap ( ) ;
35603575
35613576 let mut cmd = Command :: new ( & recipe_bin) ;
3562- cmd. current_dir ( & self . testpaths . file )
3577+ cmd. current_dir ( & rmake_out_dir )
35633578 . stdout ( Stdio :: piped ( ) )
35643579 . stderr ( Stdio :: piped ( ) )
35653580 . env ( "LD_LIB_PATH_ENVVAR" , dylib_env_var ( ) )
0 commit comments