compiletest: fallback to the original path if it's not a symlink

This commit is contained in:
Urgau 2024-09-27 14:05:24 +02:00
parent 8075ddb98e
commit 61ef9838df
2 changed files with 6 additions and 11 deletions

View file

@ -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());
}

View file

@ -2311,12 +2311,9 @@ fn normalize_output(&self, output: &str, custom_rules: &[(String, String)]) -> S
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 {