test: resolve trusted temporary roots in profile and live fixtures

This commit is contained in:
Emil
2026-09-09 20:29:04 +03:00
parent 738399b452
commit daefc3f5e7
3 changed files with 15 additions and 7 deletions
+1 -1
View File
@@ -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)
+4 -2
View File
@@ -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();
+10 -4
View File
@@ -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()