From b97eec8c0e1c82913a928807340004d6d825b50c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 19 Jul 2021 16:24:45 +0300 Subject: [PATCH] fix tests --- crates/rust-analyzer/tests/slow-tests/testdir.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/rust-analyzer/tests/slow-tests/testdir.rs b/crates/rust-analyzer/tests/slow-tests/testdir.rs index 36271344b70..c7e5c218064 100644 --- a/crates/rust-analyzer/tests/slow-tests/testdir.rs +++ b/crates/rust-analyzer/tests/slow-tests/testdir.rs @@ -11,7 +11,18 @@ pub(crate) struct TestDir { impl TestDir { pub(crate) fn new() -> TestDir { - let base = std::env::temp_dir().join("testdir"); + let temp_dir = std::env::temp_dir(); + // On MacOS builders on GitHub actions, the temp dir is a symlink, and + // that causes problems down the line. Specifically: + // * Cargo may emit different PackageId depending on the working directory + // * rust-analyzer may fail to map LSP URIs to correct paths. + // + // Work-around this by canonicalizing. Note that we don't want to do this + // on *every* OS, as on windows `canonicalize` itself creates problems. + #[cfg(target_os = "macos")] + let temp_dir = temp_dir.canonicalize().unwrap(); + + let base = temp_dir.join("testdir"); let pid = std::process::id(); static CNT: AtomicUsize = AtomicUsize::new(0);