test: resolve trusted temporary roots in profile and live fixtures
This commit is contained in:
@@ -272,7 +272,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
#[ignore = "downloads the real pack/game and executes the official installer; needs network and Java 21"]
|
#[ignore = "downloads the real pack/game and executes the official installer; needs network and Java 21"]
|
||||||
fn live_cold_install_and_corruption_repair() {
|
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-{}",
|
"shacraft-cold-install-{}",
|
||||||
SystemTime::now()
|
SystemTime::now()
|
||||||
.duration_since(std::time::UNIX_EPOCH)
|
.duration_since(std::time::UNIX_EPOCH)
|
||||||
|
|||||||
@@ -459,8 +459,10 @@ mod tests {
|
|||||||
use crate::{java, mojang};
|
use crate::{java, mojang};
|
||||||
|
|
||||||
let client = Client::builder().build().unwrap();
|
let client = Client::builder().build().unwrap();
|
||||||
let root =
|
let root = std::env::temp_dir()
|
||||||
std::env::temp_dir().join(format!("shacraft-neoforge-pipeline-{}", std::process::id()));
|
.canonicalize()
|
||||||
|
.unwrap()
|
||||||
|
.join(format!("shacraft-neoforge-pipeline-{}", std::process::id()));
|
||||||
let game_dir = root.join("game");
|
let game_dir = root.join("game");
|
||||||
let cache_dir = root.join("cache");
|
let cache_dir = root.join("cache");
|
||||||
fs::create_dir_all(&cache_dir).unwrap();
|
fs::create_dir_all(&cache_dir).unwrap();
|
||||||
|
|||||||
@@ -506,6 +506,12 @@ mod tests {
|
|||||||
time::{SystemTime, UNIX_EPOCH},
|
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 {
|
fn manifest(hash: String, size: u64) -> Manifest {
|
||||||
Manifest {
|
Manifest {
|
||||||
schema_version: 1,
|
schema_version: 1,
|
||||||
@@ -531,7 +537,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reports_missing_and_matching_files() {
|
fn reports_missing_and_matching_files() {
|
||||||
let root = std::env::temp_dir().join(format!(
|
let root = trusted_temporary_root().join(format!(
|
||||||
"shacraft-launcher-test-{}-{}",
|
"shacraft-launcher-test-{}-{}",
|
||||||
process::id(),
|
process::id(),
|
||||||
SystemTime::now()
|
SystemTime::now()
|
||||||
@@ -559,7 +565,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn edited_seed_files_remain_up_to_date() {
|
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-{}-{}",
|
"shacraft-seed-test-{}-{}",
|
||||||
process::id(),
|
process::id(),
|
||||||
SystemTime::now()
|
SystemTime::now()
|
||||||
@@ -577,7 +583,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn preserves_changed_seed_files_as_current() {
|
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-{}-{}",
|
"shacraft-launcher-seed-test-{}-{}",
|
||||||
process::id(),
|
process::id(),
|
||||||
SystemTime::now()
|
SystemTime::now()
|
||||||
@@ -600,7 +606,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn refuses_linked_profile_directories() {
|
fn refuses_linked_profile_directories() {
|
||||||
use std::os::unix::fs::symlink;
|
use std::os::unix::fs::symlink;
|
||||||
let root = std::env::temp_dir().join(format!(
|
let root = trusted_temporary_root().join(format!(
|
||||||
"shacraft-link-test-{}-{}",
|
"shacraft-link-test-{}-{}",
|
||||||
process::id(),
|
process::id(),
|
||||||
SystemTime::now()
|
SystemTime::now()
|
||||||
|
|||||||
Reference in New Issue
Block a user