living_mod_types: a temp folder per call, not per process

Tests run in parallel in one process: with three callers now (lan.rs and
two in mods.rs), one could remove the shared folder while another was
reading it (NotFound in a_mods_register_goals_replaces_its_types_goals).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Horizon agentandClaude Opus 5.5 committed 2026-11-05 08:19:28 +01:00
1 parent 178bf207c6
commit 9861c8352d
1 file changed
+7 -2
+7 -2
View File
@@ -455,8 +455,13 @@ pub(super) fn living_mod_types()
"ruby:settler":{{{villager},"attributes":{{"minecraft:max_health":20.0,"minecraft:movement_speed":0.5}},"template":"minecraft:villager"}},
"ruby:bolt":{{"width":0.25,"height":0.25,"eye_height":0.0,"category":"misc","fire_immune":false,"template":"minecraft:snowball"}}}}"#
);
let root =
std::env::temp_dir().join(format!("horizon-living-mod-types-{}", std::process::id()));
// A folder per call: tests run in parallel in one process, and each removes its own.
static CALLS: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0);
let call = CALLS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
let root = std::env::temp_dir().join(format!(
"horizon-living-mod-types-{}-{call}",
std::process::id()
));
std::fs::create_dir_all(&root).unwrap();
std::fs::write(root.join("entity-types.json"), table).unwrap();
let types = horizon_client::mobs::MobTypes::load_for_server(&root).unwrap();