@@ -3440,14 +3440,42 @@ impl<'test> TestCx<'test> {
3440
3440
// library.
3441
3441
// 2. We need to run the recipe binary.
3442
3442
3443
- // FIXME(jieyouxu): hm, cwd doesn't look right here?
3444
- let cwd = env:: current_dir ( ) . unwrap ( ) ;
3445
- // FIXME(jieyouxu): is there a better way to get `src_root`?
3446
- let src_root = self . config . src_base . parent ( ) . unwrap ( ) . parent ( ) . unwrap ( ) ;
3447
- let src_root = cwd. join ( & src_root) ;
3448
- // FIXME(jieyouxu): is there a better way to get `build_root`?
3449
- let build_root = self . config . build_base . parent ( ) . unwrap ( ) . parent ( ) . unwrap ( ) ;
3450
- let build_root = cwd. join ( & build_root) ;
3443
+ // FIXME(jieyouxu): path examples
3444
+ // source_root="/home/gh-jieyouxu/rust"
3445
+ // src_root="/home/gh-jieyouxu/rust"
3446
+ // build_root="/home/gh-jieyouxu/rust/build/aarch64-unknown-linux-gnu"
3447
+ // self.config.build_base="/home/gh-jieyouxu/rust/build/aarch64-unknown-linux-gnu/test/run-make"
3448
+ // support_lib_deps="/home/gh-jieyouxu/rust/build/aarch64-unknown-linux-gnu/stage1-tools/aarch64-unknown-linux-gnu/release/deps"
3449
+ // support_lib_deps_deps="/home/gh-jieyouxu/rust/build/aarch64-unknown-linux-gnu/stage1-tools/release/deps"
3450
+ // recipe_bin="/home/gh-jieyouxu/rust/build/aarch64-unknown-linux-gnu/test/run-make/a-b-a-linker-guard/a-b-a-linker-guard/rmake"
3451
+
3452
+ // So we assume the rust-lang/rust project setup looks like (our `.` is the top-level
3453
+ // directory, irrelevant entries to our purposes omitted):
3454
+ //
3455
+ // ```
3456
+ // . // <- `source_root`
3457
+ // ├── build/ // <- `build_root`
3458
+ // ├── compiler/
3459
+ // ├── library/
3460
+ // ├── src/
3461
+ // │ └── tools/
3462
+ // │ └── run_make_support/
3463
+ // └── tests
3464
+ // └── run-make/
3465
+ // ```
3466
+
3467
+ // `source_root` is the top-level directory containing the rust-lang/rust checkout.
3468
+ let source_root =
3469
+ self . config . find_rust_src_root ( ) . expect ( "could not determine rust source root" ) ;
3470
+ debug ! ( ?source_root) ;
3471
+ // `self.config.build_base` is actually the build base folder + "test" + test suite name, it
3472
+ // looks like `build/<host_tuplet>/test/run-make`. But we want `build/<host_tuplet>/`. Note
3473
+ // that the `build` directory does not need to be called `build`, nor does it need to be
3474
+ // under `source_root`, so we must compute it based off of `self.config.build_base`.
3475
+ debug ! ( ?self . config. build_base) ;
3476
+ let build_root =
3477
+ self . config . build_base . parent ( ) . and_then ( Path :: parent) . unwrap ( ) . to_path_buf ( ) ;
3478
+ debug ! ( ?build_root) ;
3451
3479
3452
3480
// We construct the following directory tree for each rmake.rs test:
3453
3481
// ```
@@ -3462,7 +3490,7 @@ impl<'test> TestCx<'test> {
3462
3490
//
3463
3491
// This setup intentionally diverges from legacy Makefile run-make tests.
3464
3492
// FIXME(jieyouxu): is there a better way to compute `base_dir`?
3465
- let base_dir = cwd . join ( self . output_base_name ( ) ) ;
3493
+ let base_dir = self . output_base_name ( ) ;
3466
3494
if base_dir. exists ( ) {
3467
3495
self . aggressive_rm_rf ( & base_dir) . unwrap ( ) ;
3468
3496
}
@@ -3532,7 +3560,7 @@ impl<'test> TestCx<'test> {
3532
3560
Vec :: from_iter ( env:: split_paths ( & env:: var ( dylib_env_var ( ) ) . unwrap ( ) ) ) ;
3533
3561
3534
3562
let mut host_dylib_env_paths = Vec :: new ( ) ;
3535
- host_dylib_env_paths. push ( cwd . join ( & self . config . compile_lib_path ) ) ;
3563
+ host_dylib_env_paths. push ( self . config . compile_lib_path . clone ( ) ) ;
3536
3564
host_dylib_env_paths. extend ( orig_dylib_env_paths. iter ( ) . cloned ( ) ) ;
3537
3565
let host_dylib_env_paths = env:: join_paths ( host_dylib_env_paths) . unwrap ( ) ;
3538
3566
@@ -3551,17 +3579,18 @@ impl<'test> TestCx<'test> {
3551
3579
. env ( "TARGET" , & self . config . target )
3552
3580
. env ( "PYTHON" , & self . config . python )
3553
3581
. env ( "RUST_BUILD_STAGE" , & self . config . stage_id )
3554
- . env ( "RUSTC" , cwd . join ( & self . config . rustc_path ) )
3582
+ . env ( "RUSTC" , & self . config . rustc_path )
3555
3583
. env ( "LD_LIB_PATH_ENVVAR" , dylib_env_var ( ) )
3556
3584
. env ( dylib_env_var ( ) , & host_dylib_env_paths)
3557
- . env ( "HOST_RPATH_DIR" , cwd . join ( & self . config . compile_lib_path ) )
3558
- . env ( "TARGET_RPATH_DIR" , cwd . join ( & self . config . run_lib_path ) )
3585
+ . env ( "HOST_RPATH_DIR" , & self . config . compile_lib_path )
3586
+ . env ( "TARGET_RPATH_DIR" , & self . config . run_lib_path )
3559
3587
. env ( "LLVM_COMPONENTS" , & self . config . llvm_components ) ;
3560
3588
3561
3589
// In test code we want to be very pedantic about values being silently discarded that are
3562
3590
// annotated with `#[must_use]`.
3563
3591
cmd. arg ( "-Dunused_must_use" ) ;
3564
3592
3593
+ // FIXME(jieyouxu): explain this!
3565
3594
if std:: env:: var_os ( "COMPILETEST_FORCE_STAGE0" ) . is_some ( ) {
3566
3595
let mut stage0_sysroot = build_root. clone ( ) ;
3567
3596
stage0_sysroot. push ( "stage0-sysroot" ) ;
@@ -3602,15 +3631,15 @@ impl<'test> TestCx<'test> {
3602
3631
. env ( dylib_env_var ( ) , & dylib_env_paths)
3603
3632
. env ( "TARGET" , & self . config . target )
3604
3633
. env ( "PYTHON" , & self . config . python )
3605
- . env ( "SOURCE_ROOT" , & src_root )
3634
+ . env ( "SOURCE_ROOT" , & source_root )
3606
3635
. env ( "RUST_BUILD_STAGE" , & self . config . stage_id )
3607
- . env ( "RUSTC" , cwd . join ( & self . config . rustc_path ) )
3608
- . env ( "HOST_RPATH_DIR" , cwd . join ( & self . config . compile_lib_path ) )
3609
- . env ( "TARGET_RPATH_DIR" , cwd . join ( & self . config . run_lib_path ) )
3636
+ . env ( "RUSTC" , & self . config . rustc_path )
3637
+ . env ( "HOST_RPATH_DIR" , & self . config . compile_lib_path )
3638
+ . env ( "TARGET_RPATH_DIR" , & self . config . run_lib_path )
3610
3639
. env ( "LLVM_COMPONENTS" , & self . config . llvm_components ) ;
3611
3640
3612
3641
if let Some ( ref rustdoc) = self . config . rustdoc_path {
3613
- cmd. env ( "RUSTDOC" , cwd . join ( rustdoc) ) ;
3642
+ cmd. env ( "RUSTDOC" , source_root . join ( rustdoc) ) ;
3614
3643
}
3615
3644
3616
3645
if let Some ( ref node) = self . config . nodejs {
0 commit comments