@@ -15,7 +15,7 @@ use crate::errors::{self, Error, ErrorKind};
15
15
use crate :: header:: TestProps ;
16
16
use crate :: json;
17
17
use 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 } ;
19
19
use crate :: ColorConfig ;
20
20
use colored:: Colorize ;
21
21
use miropt_test_tools:: { files_for_miropt_test, MiroptTest , MiroptTestFile } ;
@@ -3458,6 +3458,21 @@ impl<'test> TestCx<'test> {
3458
3458
let rmake_out_dir = base_dir. join ( "rmake_out" ) ;
3459
3459
create_dir_all ( & rmake_out_dir) . unwrap ( ) ;
3460
3460
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
+
3461
3476
// HACK: assume stageN-target, we only want stageN.
3462
3477
let stage = self . config . stage_id . split ( '-' ) . next ( ) . unwrap ( ) ;
3463
3478
@@ -3559,7 +3574,7 @@ impl<'test> TestCx<'test> {
3559
3574
let target_rpath_env_path = env:: join_paths ( target_rpath_env_path) . unwrap ( ) ;
3560
3575
3561
3576
let mut cmd = Command :: new ( & recipe_bin) ;
3562
- cmd. current_dir ( & self . testpaths . file )
3577
+ cmd. current_dir ( & rmake_out_dir )
3563
3578
. stdout ( Stdio :: piped ( ) )
3564
3579
. stderr ( Stdio :: piped ( ) )
3565
3580
. env ( "LD_LIB_PATH_ENVVAR" , dylib_env_var ( ) )
0 commit comments