fix tests

This commit is contained in:
Aleksey Kladov 2021-07-19 16:24:45 +03:00
parent b8b166e674
commit b97eec8c0e

View file

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