Merge pull request #698 from ludovic111/launcher-win-fix

Launcher: Windows tests pass again (releases blocked since launcher-v0.4.0)
This commit is contained in:
Ludovic Marie
2026-10-17 15:02:37 +02:00
committed by GitHub
5 changed files with 59 additions and 13 deletions
+2 -1
View File
@@ -138,7 +138,8 @@ jobs:
echo "::notice::No Metal toolchain on this runner: GPUI compiles its shaders at run time"
echo "LAUNCHER_FEATURES=gpui/runtime_shaders" >> "$GITHUB_ENV"
fi
- run: cargo test --release --locked --lib ${LAUNCHER_FEATURES:+--features "$LAUNCHER_FEATURES"}
# Every test target (the library, the binary, tests/), on each system the launcher ships for.
- run: cargo test --release --locked ${LAUNCHER_FEATURES:+--features "$LAUNCHER_FEATURES"}
- run: cargo build --release --locked ${LAUNCHER_FEATURES:+--features "$LAUNCHER_FEATURES"}
- name: The version is the release's
run: |
+12
View File
@@ -2681,10 +2681,22 @@ dependencies = [
"zip",
]
[[package]]
name = "horizon-mods"
version = "0.1.0"
dependencies = [
"log",
"serde",
"serde_json",
"toml 1.1.8+spec-1.1.0",
"zip",
]
[[package]]
name = "horizon-port-pack"
version = "0.1.0"
dependencies = [
"horizon-mods",
"serde",
"serde_json",
"sha1",
+2 -1
View File
@@ -241,7 +241,8 @@ mod tests {
.map(|a| a.to_string_lossy().into_owned())
.collect();
assert_eq!(args.len(), 4);
assert!(args[1].ends_with("a/carry") && args[3].ends_with("b/carry"));
assert_eq!(Path::new(&args[1]), work.join("mods").join("a").join("carry"));
assert_eq!(Path::new(&args[3]), work.join("mods").join("b").join("carry"));
assert_eq!(cmd.get_current_dir(), Some(profile_home(&work).as_path()));
assert!(profile_home(&work).is_dir());
fs::remove_dir_all(&root).unwrap();
+13 -3
View File
@@ -426,16 +426,26 @@ fn make_link(target: &Path, link: &Path) -> std::io::Result<()> {
std::os::unix::fs::symlink(target, link)
}
/// Symlinks need developer mode on Windows: a junction for a folder, a hard link for a file.
/// Symlinks need developer mode on Windows: a junction for a folder, a hard link for a file (a
/// copy on another volume).
#[cfg(windows)]
fn make_link(target: &Path, link: &Path) -> std::io::Result<()> {
use std::os::windows::process::CommandExt;
if !target.is_dir() {
return fs::hard_link(target, link).or_else(|_| fs::copy(target, link).map(|_| ()));
}
// Always quoted: cmd reads `&`, `^` or `(` in an unquoted path (a user folder may have
// them) as its own syntax. A Windows path never holds a quote.
let quoted = |path: &Path| {
let mut arg = std::ffi::OsString::from("\"");
arg.push(path);
arg.push("\"");
arg
};
let status = std::process::Command::new("cmd")
.args(["/C", "mklink", "/J"])
.arg(link)
.arg(target)
.raw_arg(quoted(link))
.raw_arg(quoted(target))
.stdout(std::process::Stdio::null())
.status()?;
match status.success() {
+30 -8
View File
@@ -94,15 +94,25 @@ fn resolve_with(
}
}
/// Whether `a` and `b` are one file, as a symlink (Unix) or a hard link (Windows) makes them:
/// a byte written through `a` shows in `b`. Both are left as they were.
fn same_file(a: &Path, b: &Path) -> bool {
use std::io::Write;
let (before_a, before_b) = (fs::read(a).unwrap(), fs::read(b).unwrap());
let mut file = fs::OpenOptions::new().write(true).open(a).unwrap();
file.write_all(&[!before_a[0]]).unwrap();
drop(file);
let same = fs::read(b).unwrap() != before_b;
fs::write(a, &before_a).unwrap();
same
}
/// The linked folder is the official layout, pointing at the launcher's files.
fn assert_linked(linked: &Path, base: &Path, jar: &str) {
let v = linked.join("versions/26.3");
assert_eq!(fs::read(v.join("26.3.jar")).unwrap(), CLIENT);
assert_eq!(fs::read(v.join("26.3.json")).unwrap(), MANIFEST);
assert_eq!(
fs::canonicalize(v.join("26.3.jar")).unwrap(),
fs::canonicalize(base.join(jar)).unwrap()
);
assert!(same_file(&v.join("26.3.jar"), &base.join(jar)));
assert_eq!(
fs::read(linked.join("libraries/org/lib/1/lib-1.jar")).unwrap(),
b"lib"
@@ -110,6 +120,19 @@ fn assert_linked(linked: &Path, base: &Path, jar: &str) {
assert!(linked.join("assets/indexes/30.json").is_file());
}
/// Folders whose names cmd would read as its own syntax unquoted are still linked (Windows makes
/// a junction through `mklink /J`; a name without spaces isn't quoted by itself).
#[test]
fn folders_with_ampersands_are_linked() {
let s = Scratch::new("a&b(c)");
let jar = "libraries/com/mojang/minecraft/26.3/minecraft-26.3-client.jar";
let dir = s.launcher("Prism&Co", "", jar);
let linked = s.0.join("linked&here");
let got = resolve_with(&dir, &[], &linked, &Mojang::new(MANIFEST)).unwrap();
assert_eq!(got, linked);
assert_linked(&linked, &dir, jar);
}
#[test]
fn maven_names_become_repository_paths() {
assert_eq!(
@@ -295,10 +318,9 @@ fn relinking_follows_the_launcher_the_files_now_come_from() {
let modrinth = s.0.join("ModrinthApp");
s.write("ModrinthApp/meta/versions/26.3/26.3.jar", CLIENT);
resolve_with(&modrinth, &[], &linked, &mojang).unwrap();
assert_eq!(
fs::canonicalize(linked.join("versions/26.3/26.3.jar")).unwrap(),
fs::canonicalize(modrinth.join("meta/versions/26.3/26.3.jar")).unwrap()
);
let jar = linked.join("versions/26.3/26.3.jar");
assert!(same_file(&jar, &modrinth.join("meta/versions/26.3/26.3.jar")));
assert!(!same_file(&jar, &prism.join(prism_jar)));
// The Modrinth App folder has no libraries or assets: the old links are gone, and the
// folders they pointed at are untouched.
assert!(fs::symlink_metadata(linked.join("libraries")).is_err());