Skip to content

Commit b5545f1

Browse files
committed
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>
1 parent 5685abc commit b5545f1

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3494,22 +3494,21 @@ impl<'test> TestCx<'test> {
34943494
normalize_path(parent_dir, "$DIR");
34953495

34963496
// Paths into the libstd/libcore
3497-
let src_dir = self
3498-
.config
3499-
.src_base
3500-
.parent()
3501-
.unwrap()
3502-
.parent()
3503-
.unwrap()
3504-
.parent()
3505-
.unwrap()
3506-
.join("library");
3497+
let base_dir = self.config.src_base.parent().unwrap().parent().unwrap().parent().unwrap();
3498+
let src_dir = base_dir.join("library");
35073499
normalize_path(&src_dir, "$SRC_DIR");
35083500

3501+
// `ui-fulldeps` tests can show paths to the compiler source when testing macros from
3502+
// `rustc_macros`
3503+
// eg. /home/user/rust/compiler
3504+
let compiler_src_dir = base_dir.join("compiler");
3505+
normalize_path(&compiler_src_dir, "$COMPILER_DIR");
3506+
35093507
if let Some(virtual_rust_source_base_dir) =
35103508
option_env!("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR").map(PathBuf::from)
35113509
{
35123510
normalize_path(&virtual_rust_source_base_dir.join("library"), "$SRC_DIR");
3511+
normalize_path(&virtual_rust_source_base_dir.join("compiler"), "$COMPILER_DIR");
35133512
}
35143513

35153514
// Paths into the build directory

0 commit comments

Comments
 (0)