Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

client_changing_workspace_lib_retains_diagnostics fails frequently on slow drives #1466

Closed
@ehuss

Description

@ehuss

The client_changing_workspace_lib_retains_diagnostics test has been failing occasionally on CI:

(possibly others, these are the ones that I can easily find)

I am able to reliably reproduce this error when using a magnetic spinning hard drive (around 80-90% failure rate) on both macos and windows.

After looking at the test, I'm fairly certain the reason is because the tests are sharing the cargo target directory. If one test (such as client_changing_workspace_lib_retains_diagnostics) builds something called "liblibrary", and another test (say client_test_complete_self_crate_name) creates a "liblibrary" at the same time, they will conflict with one another and stomp on each other's files.

I think the solution is that each test should use a dedicated target directory (that is how cargo's test suite works). I'm actually not sure how rls sets the target directory, or why the test suite is set up to reuse it, otherwise I would submit a PR. The following quick-and-dirty hack fixes the problem:

diff --git a/tests/support/client/mod.rs b/tests/support/client/mod.rs
index c563c98..0dcf1d0 100644
--- a/tests/support/client/mod.rs
+++ b/tests/support/client/mod.rs
@@ -58,6 +58,7 @@ impl Project {
     pub fn rls_cmd(&self) -> Command {
         let mut cmd = Command::new(rls_exe());
         cmd.current_dir(self.root());
+        cmd.env("CARGO_TARGET_DIR", self.root().join("target").to_string_lossy().into_owned());
         cmd.stderr(Stdio::inherit());
 
         cmd

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions