diff options
| author | David Wood <david.wood@huawei.com> | 2022-05-09 04:18:35 +0100 |
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2022-05-12 07:21:51 +0100 |
| commit | b5545f1b0c28a7acba27d1985a934845a013af1b (patch) | |
| tree | df9b44047e4e429e4a5e1f8b7bfbd53055a47b96 /src | |
| parent | 5685abc96b4e2fa1be05ed4beefb72708c233739 (diff) | |
| download | rust-b5545f1b0c28a7acba27d1985a934845a013af1b.tar.gz rust-b5545f1b0c28a7acba27d1985a934845a013af1b.zip | |
compiletest: normalize paths from repository root
When testing macros from `rustc_macros` in `ui-fulldeps` tests, sometimes paths from the compiler source tree can be shown in error messages - these need to be normalized. Signed-off-by: David Wood <david.wood@huawei.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 6d94fe3ebb9..a59a0584d5e 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -3494,22 +3494,21 @@ impl<'test> TestCx<'test> { normalize_path(parent_dir, "$DIR"); // Paths into the libstd/libcore - let src_dir = self - .config - .src_base - .parent() - .unwrap() - .parent() - .unwrap() - .parent() - .unwrap() - .join("library"); + let base_dir = self.config.src_base.parent().unwrap().parent().unwrap().parent().unwrap(); + let src_dir = base_dir.join("library"); normalize_path(&src_dir, "$SRC_DIR"); + // `ui-fulldeps` tests can show paths to the compiler source when testing macros from + // `rustc_macros` + // eg. /home/user/rust/compiler + let compiler_src_dir = base_dir.join("compiler"); + normalize_path(&compiler_src_dir, "$COMPILER_DIR"); + if let Some(virtual_rust_source_base_dir) = option_env!("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR").map(PathBuf::from) { normalize_path(&virtual_rust_source_base_dir.join("library"), "$SRC_DIR"); + normalize_path(&virtual_rust_source_base_dir.join("compiler"), "$COMPILER_DIR"); } // Paths into the build directory |
