From 7419c2610495bd56c236b02d1aa4d4f2b500e36a Mon Sep 17 00:00:00 2001 From: Jhon42 <75667418+Convicts42@users.noreply.github.com> Date: Wed, 25 Nov 2026 15:55:19 +0100 Subject: [PATCH] Tests: keep the launcher tests' data out of the user's XCL folder Three launcher tests run `xcl run ` without XCL_DATA_ROOT. The launcher writes the title's xcl.toml before it looks for an executable, so every run of the suite left three folders (xcl-no-exe-*, xcl-multi-exe-*, xcl-self-copy-*) in the user's %LOCALAPPDATA%\XCL. They now run through one helper that gives XCL a data root next to the test's game folder, removed with it, and asserts that the title's xcl.toml is there: without the data root the three tests fail. The other three exit before anything is written. Co-Authored-By: Claude Opus 5.5 --- crates/xcl/tests/launcher_e2e.rs | 35 +++++++++++++++++--------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/crates/xcl/tests/launcher_e2e.rs b/crates/xcl/tests/launcher_e2e.rs index 4100fad051..bc181126c4 100644 --- a/crates/xcl/tests/launcher_e2e.rs +++ b/crates/xcl/tests/launcher_e2e.rs @@ -1,5 +1,5 @@ use std::path::PathBuf; -use std::process::Command; +use std::process::{Command, Output}; use std::time::{SystemTime, UNIX_EPOCH}; struct TempDir(PathBuf); @@ -22,6 +22,21 @@ impl Drop for TempDir { } } +/// `xcl run` on a game folder, with a data root of its own next to it: without one XCL makes the +/// title's data folder in the user's `%LOCALAPPDATA%\XCL`, where it stays after the test. +fn run_game_folder(game: &TempDir) -> Output { + let data = TempDir(game.0.with_extension("data")); + let output = Command::new(env!("CARGO_BIN_EXE_xcl")) + .arg("run") + .arg(&game.0) + .env("XCL_DATA_ROOT", &data.0) + .output() + .unwrap(); + let title = data.0.join(game.0.file_name().unwrap()); + assert!(title.join("xcl.toml").is_file(), "the title's data is not in the test's data root: {output:?}"); + output +} + #[test] fn launcher_missing_target_argument_exits_code_two() { let output = Command::new(env!("CARGO_BIN_EXE_xcl")) @@ -64,11 +79,7 @@ fn launcher_directory_without_executables_exits_code_two() { let dir = TempDir::new("xcl-no-exe"); std::fs::write(dir.0.join("readme.txt"), b"no executables here").unwrap(); - let output = Command::new(env!("CARGO_BIN_EXE_xcl")) - .arg("run") - .arg(&dir.0) - .output() - .unwrap(); + let output = run_game_folder(&dir); assert_eq!(output.status.code(), Some(2)); let err = String::from_utf8(output.stderr).unwrap(); assert!(err.contains("no game .exe file in")); @@ -80,11 +91,7 @@ fn launcher_directory_with_ambiguous_executables_exits_code_two() { std::fs::write(dir.0.join("game_a.exe"), b"executable a").unwrap(); std::fs::write(dir.0.join("game_b.exe"), b"executable b").unwrap(); - let output = Command::new(env!("CARGO_BIN_EXE_xcl")) - .arg("run") - .arg(&dir.0) - .output() - .unwrap(); + let output = run_game_folder(&dir); assert_eq!(output.status.code(), Some(2)); let err = String::from_utf8(output.stderr).unwrap(); assert!(err.contains("several .exe files")); @@ -98,11 +105,7 @@ fn launcher_directory_with_only_xcl_copy_warns_self() { let dest_xcl = dir.0.join("xcl.exe"); std::fs::copy(self_exe, &dest_xcl).unwrap(); - let output = Command::new(self_exe) - .arg("run") - .arg(&dir.0) - .output() - .unwrap(); + let output = run_game_folder(&dir); assert_eq!(output.status.code(), Some(2)); let err = String::from_utf8(output.stderr).unwrap(); assert!(err.contains("only xcl.exe – that is XCL itself; do not copy it into the game folder"));