Skip to content

The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.

fix(tests): serialize Windows SDK mapped-drive fixtures (#1870)

l0ng-ai809bc1cc2f75
diff --git a/crates/ide-sdk/src/discover.rs b/crates/ide-sdk/src/discover.rs
index 0d7e44b66..5469d6301 100644
--- a/crates/ide-sdk/src/discover.rs
+++ b/crates/ide-sdk/src/discover.rs
@@ -738,12 +738,20 @@ mod maven_path_tests {
struct Subst {
name: String,
root: PathBuf,
+ _lock: std::fs::File,
}
impl Subst {
fn new(target: &Path) -> Self {
- // Tests run in parallel and may race for the same free letter; only a drive that
- // shows this target's marker is ours.
+ // Drive letters are shared across nextest's test processes; hold the lock until unmapping.
+ let lock = std::fs::OpenOptions::new()
+ .read(true)
+ .write(true)
+ .create(true)
+ .truncate(false)
+ .open(std::env::temp_dir().join("openidea-sdk-subst.lock"))
+ .unwrap();
+ lock.lock().unwrap();
let marker = format!("{}.subst", target.file_name().unwrap().to_string_lossy());
std::fs::write(target.join(&marker), "").unwrap();
for letter in (b'D'..=b'Z').rev() {
@@ -754,7 +762,7 @@ mod maven_path_tests {
}
let output = Command::new("subst").arg(&name).arg(target).output().unwrap();
if output.status.success() && root.join(&marker).exists() {
- return Self { name, root };
+ return Self { name, root, _lock: lock };
}
}
panic!("no free drive for Maven path verification");