Skip to content

Commit

Permalink
compiletest: fallback to the original path if it's not a symlink
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Sep 27, 2024
1 parent 8075ddb commit 61ef983
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
8 changes: 3 additions & 5 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1146,11 +1146,9 @@ fn expand_variables(mut value: String, config: &Config) -> String {
}

if value.contains(RUST_SRC_BASE) {
let src_base = config
.sysroot_base
.join("lib/rustlib/src/rust")
.read_link()
.expect("lib/rustlib/src/rust in target is a symlink to checkout root");
let src_base = config.sysroot_base.join("lib/rustlib/src/rust");
src_base.try_exists().expect(&*format!("{} should exists", src_base.display()));
let src_base = src_base.read_link().unwrap_or(src_base);
value = value.replace(RUST_SRC_BASE, &src_base.to_string_lossy());
}

Expand Down
9 changes: 3 additions & 6 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2311,12 +2311,9 @@ impl<'test> TestCx<'test> {
normalize_path(parent_build_dir, "$BUILD_DIR");

// Real paths into the libstd/libcore
let rust_src_dir = &self
.config
.sysroot_base
.join("lib/rustlib/src/rust")
.read_link()
.expect("lib/rustlib/src/rust in target is a symlink to checkout root");
let rust_src_dir = &self.config.sysroot_base.join("lib/rustlib/src/rust");
rust_src_dir.try_exists().expect(&*format!("{} should exists", rust_src_dir.display()));
let rust_src_dir = rust_src_dir.read_link().unwrap_or(rust_src_dir.to_path_buf());
normalize_path(&rust_src_dir.join("library"), "$SRC_DIR_REAL");

if json {
Expand Down

0 comments on commit 61ef983

Please sign in to comment.