Skip to content

Commit 61ef983

Browse files
committed
compiletest: fallback to the original path if it's not a symlink
1 parent 8075ddb commit 61ef983

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

Diff for: src/tools/compiletest/src/header.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1146,11 +1146,9 @@ fn expand_variables(mut value: String, config: &Config) -> String {
11461146
}
11471147

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

Diff for: src/tools/compiletest/src/runtest.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -2311,12 +2311,9 @@ impl<'test> TestCx<'test> {
23112311
normalize_path(parent_build_dir, "$BUILD_DIR");
23122312

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

23222319
if json {

0 commit comments

Comments
 (0)