@@ -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 } ;
@@ -3457,6 +3457,21 @@ impl<'test> TestCx<'test> {
3457
3457
let rmake_out_dir = base_dir. join ( "rmake_out" ) ;
3458
3458
create_dir_all ( & rmake_out_dir) . unwrap ( ) ;
3459
3459
3460
+ // Copy all input files (apart from rmake.rs) to the temporary directory,
3461
+ // so that the input directory structure from `tests/run-make/<test>` is mirrored
3462
+ // to the `rmake_out` directory.
3463
+ for path in walkdir:: WalkDir :: new ( & self . testpaths . file ) . min_depth ( 1 ) {
3464
+ let path = path. unwrap ( ) . path ( ) . to_path_buf ( ) ;
3465
+ if path. file_name ( ) . map ( |s| s != OsStr :: new ( "rmake.rs" ) ) . unwrap_or ( false ) {
3466
+ let target = rmake_out_dir. join ( path. strip_prefix ( & self . testpaths . file ) . unwrap ( ) ) ;
3467
+ if path. is_dir ( ) {
3468
+ copy_dir_all ( & path, target) . unwrap ( ) ;
3469
+ } else {
3470
+ fs:: copy ( & path, target) . unwrap ( ) ;
3471
+ }
3472
+ }
3473
+ }
3474
+
3460
3475
// HACK: assume stageN-target, we only want stageN.
3461
3476
let stage = self . config . stage_id . split ( '-' ) . next ( ) . unwrap ( ) ;
3462
3477
@@ -3558,7 +3573,7 @@ impl<'test> TestCx<'test> {
3558
3573
let target_rpath_env_path = env:: join_paths ( target_rpath_env_path) . unwrap ( ) ;
3559
3574
3560
3575
let mut cmd = Command :: new ( & recipe_bin) ;
3561
- cmd. current_dir ( & self . testpaths . file )
3576
+ cmd. current_dir ( & rmake_out_dir )
3562
3577
. stdout ( Stdio :: piped ( ) )
3563
3578
. stderr ( Stdio :: piped ( ) )
3564
3579
. env ( "LD_LIB_PATH_ENVVAR" , dylib_env_var ( ) )
0 commit comments