@@ -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 } ;
@@ -3471,6 +3471,21 @@ impl<'test> TestCx<'test> {
34713471 let rmake_out_dir = base_dir. join ( "rmake_out" ) ;
34723472 create_dir_all ( & rmake_out_dir) . unwrap ( ) ;
34733473
3474+ // Copy all input files (apart from rmake.rs) to the temporary directory,
3475+ // so that the input directory structure from `tests/run-make/<test>` is mirrored
3476+ // to the `rmake_out` directory.
3477+ for path in walkdir:: WalkDir :: new ( & self . testpaths . file ) . min_depth ( 1 ) {
3478+ let path = path. unwrap ( ) . path ( ) . to_path_buf ( ) ;
3479+ if path. file_name ( ) . is_some_and ( |s| s != "rmake.rs" ) {
3480+ let target = rmake_out_dir. join ( path. strip_prefix ( & self . testpaths . file ) . unwrap ( ) ) ;
3481+ if path. is_dir ( ) {
3482+ copy_dir_all ( & path, target) . unwrap ( ) ;
3483+ } else {
3484+ fs:: copy ( & path, target) . unwrap ( ) ;
3485+ }
3486+ }
3487+ }
3488+
34743489 // HACK: assume stageN-target, we only want stageN.
34753490 let stage = self . config . stage_id . split ( '-' ) . next ( ) . unwrap ( ) ;
34763491
@@ -3530,18 +3545,11 @@ impl<'test> TestCx<'test> {
35303545 . env ( "PYTHON" , & self . config . python )
35313546 . env ( "RUST_BUILD_STAGE" , & self . config . stage_id )
35323547 . env ( "RUSTC" , cwd. join ( & self . config . rustc_path ) )
3533- . env ( "TMPDIR" , & rmake_out_dir)
35343548 . env ( "LD_LIB_PATH_ENVVAR" , dylib_env_var ( ) )
35353549 . env ( dylib_env_var ( ) , & host_dylib_env_paths)
35363550 . env ( "HOST_RPATH_DIR" , cwd. join ( & self . config . compile_lib_path ) )
35373551 . env ( "TARGET_RPATH_DIR" , cwd. join ( & self . config . run_lib_path ) )
3538- . env ( "LLVM_COMPONENTS" , & self . config . llvm_components )
3539- // We for sure don't want these tests to run in parallel, so make
3540- // sure they don't have access to these vars if we run via `make`
3541- // at the top level
3542- . env_remove ( "MAKEFLAGS" )
3543- . env_remove ( "MFLAGS" )
3544- . env_remove ( "CARGO_MAKEFLAGS" ) ;
3552+ . env ( "LLVM_COMPONENTS" , & self . config . llvm_components ) ;
35453553
35463554 if std:: env:: var_os ( "COMPILETEST_FORCE_STAGE0" ) . is_some ( ) {
35473555 let mut stage0_sysroot = build_root. clone ( ) ;
@@ -3571,7 +3579,7 @@ impl<'test> TestCx<'test> {
35713579 let target_rpath_env_path = env:: join_paths ( target_rpath_env_path) . unwrap ( ) ;
35723580
35733581 let mut cmd = Command :: new ( & recipe_bin) ;
3574- cmd. current_dir ( & self . testpaths . file )
3582+ cmd. current_dir ( & rmake_out_dir )
35753583 . stdout ( Stdio :: piped ( ) )
35763584 . stderr ( Stdio :: piped ( ) )
35773585 . env ( "LD_LIB_PATH_ENVVAR" , dylib_env_var ( ) )
@@ -3582,16 +3590,9 @@ impl<'test> TestCx<'test> {
35823590 . env ( "SOURCE_ROOT" , & src_root)
35833591 . env ( "RUST_BUILD_STAGE" , & self . config . stage_id )
35843592 . env ( "RUSTC" , cwd. join ( & self . config . rustc_path ) )
3585- . env ( "TMPDIR" , & rmake_out_dir)
35863593 . env ( "HOST_RPATH_DIR" , cwd. join ( & self . config . compile_lib_path ) )
35873594 . env ( "TARGET_RPATH_DIR" , cwd. join ( & self . config . run_lib_path ) )
3588- . env ( "LLVM_COMPONENTS" , & self . config . llvm_components )
3589- // We for sure don't want these tests to run in parallel, so make
3590- // sure they don't have access to these vars if we run via `make`
3591- // at the top level
3592- . env_remove ( "MAKEFLAGS" )
3593- . env_remove ( "MFLAGS" )
3594- . env_remove ( "CARGO_MAKEFLAGS" ) ;
3595+ . env ( "LLVM_COMPONENTS" , & self . config . llvm_components ) ;
35953596
35963597 if let Some ( ref rustdoc) = self . config . rustdoc_path {
35973598 cmd. env ( "RUSTDOC" , cwd. join ( rustdoc) ) ;
0 commit comments