diff --git a/src-tauri/src/commands/game.rs b/src-tauri/src/commands/game.rs index f6e3175..892c0ec 100644 --- a/src-tauri/src/commands/game.rs +++ b/src-tauri/src/commands/game.rs @@ -272,7 +272,7 @@ mod tests { #[test] #[ignore = "downloads the real pack/game and executes the official installer; needs network and Java 21"] fn live_cold_install_and_corruption_repair() { - let directory = std::env::temp_dir().join(format!( + let directory = std::env::temp_dir().canonicalize().unwrap().join(format!( "shacraft-cold-install-{}", SystemTime::now() .duration_since(std::time::UNIX_EPOCH) diff --git a/src-tauri/src/neoforge.rs b/src-tauri/src/neoforge.rs index 25b45c5..445123c 100644 --- a/src-tauri/src/neoforge.rs +++ b/src-tauri/src/neoforge.rs @@ -459,8 +459,10 @@ mod tests { use crate::{java, mojang}; let client = Client::builder().build().unwrap(); - let root = - std::env::temp_dir().join(format!("shacraft-neoforge-pipeline-{}", std::process::id())); + let root = std::env::temp_dir() + .canonicalize() + .unwrap() + .join(format!("shacraft-neoforge-pipeline-{}", std::process::id())); let game_dir = root.join("game"); let cache_dir = root.join("cache"); fs::create_dir_all(&cache_dir).unwrap(); diff --git a/src-tauri/src/profile.rs b/src-tauri/src/profile.rs index 2557190..32eeee1 100644 --- a/src-tauri/src/profile.rs +++ b/src-tauri/src/profile.rs @@ -506,6 +506,12 @@ mod tests { time::{SystemTime, UNIX_EPOCH}, }; + fn trusted_temporary_root() -> std::path::PathBuf { + // Resolve only the OS-provided fixture anchor. The profile root, its + // parent and payload descendants retain their production link checks. + std::env::temp_dir().canonicalize().unwrap() + } + fn manifest(hash: String, size: u64) -> Manifest { Manifest { schema_version: 1, @@ -531,7 +537,7 @@ mod tests { #[test] fn reports_missing_and_matching_files() { - let root = std::env::temp_dir().join(format!( + let root = trusted_temporary_root().join(format!( "shacraft-launcher-test-{}-{}", process::id(), SystemTime::now() @@ -559,7 +565,7 @@ mod tests { #[test] fn edited_seed_files_remain_up_to_date() { - let root = std::env::temp_dir().join(format!( + let root = trusted_temporary_root().join(format!( "shacraft-seed-test-{}-{}", process::id(), SystemTime::now() @@ -577,7 +583,7 @@ mod tests { #[test] fn preserves_changed_seed_files_as_current() { - let root = std::env::temp_dir().join(format!( + let root = trusted_temporary_root().join(format!( "shacraft-launcher-seed-test-{}-{}", process::id(), SystemTime::now() @@ -600,7 +606,7 @@ mod tests { #[test] fn refuses_linked_profile_directories() { use std::os::unix::fs::symlink; - let root = std::env::temp_dir().join(format!( + let root = trusted_temporary_root().join(format!( "shacraft-link-test-{}-{}", process::id(), SystemTime::now()