about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWaffle Lapkin <waffle.lapkin@gmail.com>2025-04-14 19:04:34 +0200
committerWaffle Lapkin <waffle.lapkin@gmail.com>2025-04-15 09:46:22 +0200
commit6c441cc7a53e3c9ca0dd1957b8055ccdd851b488 (patch)
treefb0f8cb45259a25afaffe9caf5fed0297f256b1b
parent1397dabd1ec2e58f0cea27fd281dac7104083cca (diff)
downloadrust-6c441cc7a53e3c9ca0dd1957b8055ccdd851b488.tar.gz
rust-6c441cc7a53e3c9ca0dd1957b8055ccdd851b488.zip
canonicalize test build dir before normalizing it
Fix fixes failures of the following tests when build directory is a
symlink:
- `tests/ui/error-codes/E{0464,0523}.rs`
- `tests/ui/crate-loading/crateresolve{1,2}.rs` (those are the same tests)
-rw-r--r--src/tools/compiletest/src/runtest.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 093dc7fa56c..fc83ea42043 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -2375,9 +2375,13 @@ impl<'test> TestCx<'test> {
         let rust_src_dir = rust_src_dir.read_link_utf8().unwrap_or(rust_src_dir.to_path_buf());
         normalize_path(&rust_src_dir.join("library"), "$SRC_DIR_REAL");
 
+        // Canonicalize test build directory path.
+        // Without this some tests fail if build directory is a symlink.
+        let output_base_dir = self.output_base_dir().canonicalize_utf8().unwrap();
+
         // eg.
         // /home/user/rust/build/x86_64-unknown-linux-gnu/test/ui/<test_dir>/$name.$revision.$mode/
-        normalize_path(&self.output_base_dir(), "$TEST_BUILD_DIR");
+        normalize_path(&output_base_dir, "$TEST_BUILD_DIR");
         // eg. /home/user/rust/build
         normalize_path(&self.config.build_root, "$BUILD_DIR");