diff --git a/crates/ide-build/src/compile/structure.rs b/crates/ide-build/src/compile/structure.rs index 62dadf40e..ae7926f41 100644 --- a/crates/ide-build/src/compile/structure.rs +++ b/crates/ide-build/src/compile/structure.rs @@ -415,7 +415,7 @@ pub(crate) enum Action { impl Action { pub(crate) fn display(&self, root: &Path) -> String { - let rel = |p: &Path| p.strip_prefix(root).unwrap_or(p).to_string_lossy().into_owned(); + let rel = |p: &Path| p.strip_prefix(root).unwrap_or(p).to_string_lossy().replace('\\', "/"); match self { Action::Clean(dirs) => format!("Clean {}", dirs.iter().map(|d| rel(d)).collect::>().join(", ")), Action::CopyResources { to, .. } => format!("Copy resources to {}", rel(to)), @@ -646,15 +646,15 @@ mod tests { let main_cp = cp(javac); let entries: Vec<&str> = main_cp.split(sep).collect(); assert_eq!(entries.len(), 2, "{main_cp}"); - assert!(entries[0].ends_with("lib/*")); - assert!(entries[1].ends_with("WEB-INF/lib/*")); + assert!(Path::new(entries[0]).ends_with("lib/*")); + assert!(Path::new(entries[1]).ends_with("WEB-INF/lib/*")); assert!(javac.args.windows(2).any(|w| w == ["--release", "17"])); let args = fs::read_to_string(tmp.path().join("cache/javac/production.args")).unwrap(); assert!(args.contains("A.java") && !args.contains("ATest.java")); assert_eq!(shown[2], "Copy resources to out/production/shop"); let test = &plan.steps[3]; let test_cp = cp(test); - assert!(test_cp.starts_with(&root.join("out/production/shop").to_string_lossy().into_owned())); + assert_eq!(Path::new(test_cp.split(sep).next().unwrap()), root.join("out/production/shop")); assert!(test_cp.contains("junit.jar")); } @@ -693,7 +693,9 @@ mod tests { let javac = &plan.steps[0]; assert!(!javac.args.iter().any(|a| a == "-cp"), "{:?}", javac.args); assert!(javac.args.windows(4).any(|w| w == ["-source", "1.8", "-target", "1.8"])); - assert!(javac.args.windows(2).any(|w| w[0] == "-d" && w[1].ends_with("build/classes/production/p"))); + assert!( + javac.args.windows(2).any(|w| w[0] == "-d" && Path::new(&w[1]).ends_with("build/classes/production/p")) + ); } #[test] diff --git a/crates/ide-tools/src/archive.rs b/crates/ide-tools/src/archive.rs index 25d316c5a..0e7a63e74 100644 --- a/crates/ide-tools/src/archive.rs +++ b/crates/ide-tools/src/archive.rs @@ -536,15 +536,16 @@ mod tests { let dest = tmp.path().join("install with spaces"); extract(&archive, ArchiveKind::Zip, &dest, "unity-debug", &CancellationToken::new()).unwrap(); let target = locate(&dest, &["UnityDebug.exe".into()]).unwrap(); - let wrapper = - link_executable_with_runtime(&dest.join("bin"), "unity-debug", &target, cfg!(unix).then_some("mono")) - .unwrap(); + let bin = dest.join("bin"); + let wrapper = link_executable_with_runtime(&bin, "unity-debug", &target, cfg!(unix).then_some("mono")).unwrap(); let script = fs::read_to_string(wrapper).unwrap(); + #[cfg(unix)] assert!(script.contains(&*target.to_string_lossy())); #[cfg(unix)] assert!(script.contains("exec mono '") && script.contains("\"$@\"")); + // The shim names the adapter relative to itself (see `cmd_path`). #[cfg(windows)] - assert!(script.contains("\" %*") && !script.contains("mono ")); + assert!(script.contains(&format!("\"{}\" %*", cmd_path(&bin, &target))) && !script.contains("mono ")); assert_eq!(fs::read(target.with_extension("exe.config")).unwrap(), b"runtime config"); assert_eq!(fs::read(target.parent().unwrap().join("Mono.Debugger.Soft.dll")).unwrap(), b"dependency"); }