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

The Maven path tests map a free drive letter with `subst`, but nextest runs them in separate processes that could pick the same letter at once, so one test's mapping vanished under the other (ERROR_PATH_NOT_FOUND). The helper now holds a file lock in the temp directory from choosing the letter until the drive is unmapped. Both Maven path tests share this helper; no other `subst` callers exist.
This commit is contained in:
l0ng-ai authored and GitHub committed 2026-11-07 09:33:04 +08:00
1 parent 4beca55a54
commit 809bc1cc2f
1 file changed
+11 -3
+11 -3
View File
@@ -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");