@@ -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 } ;
@@ -3471,6 +3471,21 @@ impl<'test> TestCx<'test> {
3471
3471
let rmake_out_dir = base_dir. join ( "rmake_out" ) ;
3472
3472
create_dir_all ( & rmake_out_dir) . unwrap ( ) ;
3473
3473
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
+
3474
3489
// HACK: assume stageN-target, we only want stageN.
3475
3490
let stage = self . config . stage_id . split ( '-' ) . next ( ) . unwrap ( ) ;
3476
3491
@@ -3530,18 +3545,11 @@ impl<'test> TestCx<'test> {
3530
3545
. env ( "PYTHON" , & self . config . python )
3531
3546
. env ( "RUST_BUILD_STAGE" , & self . config . stage_id )
3532
3547
. env ( "RUSTC" , cwd. join ( & self . config . rustc_path ) )
3533
- . env ( "TMPDIR" , & rmake_out_dir)
3534
3548
. env ( "LD_LIB_PATH_ENVVAR" , dylib_env_var ( ) )
3535
3549
. env ( dylib_env_var ( ) , & host_dylib_env_paths)
3536
3550
. env ( "HOST_RPATH_DIR" , cwd. join ( & self . config . compile_lib_path ) )
3537
3551
. 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 ) ;
3545
3553
3546
3554
if std:: env:: var_os ( "COMPILETEST_FORCE_STAGE0" ) . is_some ( ) {
3547
3555
let mut stage0_sysroot = build_root. clone ( ) ;
@@ -3571,7 +3579,7 @@ impl<'test> TestCx<'test> {
3571
3579
let target_rpath_env_path = env:: join_paths ( target_rpath_env_path) . unwrap ( ) ;
3572
3580
3573
3581
let mut cmd = Command :: new ( & recipe_bin) ;
3574
- cmd. current_dir ( & self . testpaths . file )
3582
+ cmd. current_dir ( & rmake_out_dir )
3575
3583
. stdout ( Stdio :: piped ( ) )
3576
3584
. stderr ( Stdio :: piped ( ) )
3577
3585
. env ( "LD_LIB_PATH_ENVVAR" , dylib_env_var ( ) )
@@ -3582,16 +3590,9 @@ impl<'test> TestCx<'test> {
3582
3590
. env ( "SOURCE_ROOT" , & src_root)
3583
3591
. env ( "RUST_BUILD_STAGE" , & self . config . stage_id )
3584
3592
. env ( "RUSTC" , cwd. join ( & self . config . rustc_path ) )
3585
- . env ( "TMPDIR" , & rmake_out_dir)
3586
3593
. env ( "HOST_RPATH_DIR" , cwd. join ( & self . config . compile_lib_path ) )
3587
3594
. 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 ) ;
3595
3596
3596
3597
if let Some ( ref rustdoc) = self . config . rustdoc_path {
3597
3598
cmd. env ( "RUSTDOC" , cwd. join ( rustdoc) ) ;
0 commit comments