diff --git a/crates/horizon-client/examples/ambient_fixture.rs b/crates/horizon-client/examples/probe/ambient_fixture.rs similarity index 98% rename from crates/horizon-client/examples/ambient_fixture.rs rename to crates/horizon-client/examples/probe/ambient_fixture.rs index d75a1b568..3fd507902 100644 --- a/crates/horizon-client/examples/ambient_fixture.rs +++ b/crates/horizon-client/examples/probe/ambient_fixture.rs @@ -1,8 +1,7 @@ //! Replays `tools/test_ambient_sound_parity.py` scripts through Horizon's //! ambient sound handlers over its `SoundEngine`: //! `ambient_fixture ROOT INPUT OUTPUT`. -#[path = "audio_common/mod.rs"] -mod common; +use crate::audio_common as common; use common::{Fake, d, f, flush}; use horizon_client::ambience::{Ambience, AmbientContext, AmbientSounds, Mood, bubble_column_in}; use horizon_client::sound_engine::{Bound, SoundEngine, TickContext, Ticking}; @@ -47,8 +46,8 @@ fn sounds(a: &[&str]) -> AmbientSounds { } } -fn main() { - let args: Vec = std::env::args().collect(); +pub fn main() { + let args: Vec = crate::args().collect(); let mut engine = SoundEngine::new(SoundRegistry::load(std::path::Path::new(&args[1]))); engine.listening = true; let mut backend = Fake::default(); diff --git a/crates/horizon-client/examples/arrow_probe.rs b/crates/horizon-client/examples/probe/arrow_probe.rs similarity index 99% rename from crates/horizon-client/examples/arrow_probe.rs rename to crates/horizon-client/examples/probe/arrow_probe.rs index 63ff2df32..f72e6276e 100644 --- a/crates/horizon-client/examples/arrow_probe.rs +++ b/crates/horizon-client/examples/probe/arrow_probe.rs @@ -50,8 +50,8 @@ fn particle(k: ArrowParticle) -> &'static str { ArrowParticle::Splash => "splash", } } -fn main() -> Result<()> { - let args: Vec<_> = std::env::args().skip(1).collect(); +pub fn main() -> Result<()> { + let args: Vec<_> = crate::args().skip(1).collect(); if args.len() != 3 { return Err("usage: arrow_probe RESOURCES FIXTURE_DIRECTORY --describe|REFERENCE".into()); } diff --git a/crates/horizon-client/examples/audio_attributes_fixture.rs b/crates/horizon-client/examples/probe/audio_attributes_fixture.rs similarity index 97% rename from crates/horizon-client/examples/audio_attributes_fixture.rs rename to crates/horizon-client/examples/probe/audio_attributes_fixture.rs index 73f463fc4..4bbb3a239 100644 --- a/crates/horizon-client/examples/audio_attributes_fixture.rs +++ b/crates/horizon-client/examples/probe/audio_attributes_fixture.rs @@ -18,8 +18,8 @@ fn music(m: Option<&Music>) -> String { }) } -fn main() { - let args: Vec = std::env::args().collect(); +pub fn main() { + let args: Vec = crate::args().collect(); let root = std::path::Path::new(&args[1]); let tables = MusicTables::load(root); let ambient = AmbientTables::load(root); diff --git a/crates/horizon-client/examples/audio_common/mod.rs b/crates/horizon-client/examples/probe/audio_common/mod.rs similarity index 100% rename from crates/horizon-client/examples/audio_common/mod.rs rename to crates/horizon-client/examples/probe/audio_common/mod.rs diff --git a/crates/horizon-client/examples/auto_jump_probe.rs b/crates/horizon-client/examples/probe/auto_jump_probe.rs similarity index 98% rename from crates/horizon-client/examples/auto_jump_probe.rs rename to crates/horizon-client/examples/probe/auto_jump_probe.rs index d8dee95df..c15565850 100644 --- a/crates/horizon-client/examples/auto_jump_probe.rs +++ b/crates/horizon-client/examples/probe/auto_jump_probe.rs @@ -24,8 +24,8 @@ fn db(v: &Value) -> f64 { f64::from_bits(u64::from_str_radix(v.as_str().unwrap(), 16).unwrap()) } -fn main() -> Result<()> { - let args: Vec<_> = std::env::args().skip(1).collect(); +pub fn main() -> Result<()> { + let args: Vec<_> = crate::args().skip(1).collect(); let [root, input, output, scene_json] = &args[..] else { return Err("usage: auto_jump_probe RESOURCES INPUT OUTPUT SCENE_JSON".into()); }; diff --git a/crates/horizon-client/examples/block_entity_anim_fixture.rs b/crates/horizon-client/examples/probe/block_entity_anim_fixture.rs similarity index 99% rename from crates/horizon-client/examples/block_entity_anim_fixture.rs rename to crates/horizon-client/examples/probe/block_entity_anim_fixture.rs index e108c53b3..3a3a0ef14 100644 --- a/crates/horizon-client/examples/block_entity_anim_fixture.rs +++ b/crates/horizon-client/examples/probe/block_entity_anim_fixture.rs @@ -118,8 +118,8 @@ fn status(s: ShulkerStatus) -> &'static str { } } -fn main() -> Result<()> { - let args: Vec = std::env::args_os().skip(1).map(PathBuf::from).collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args_os().skip(1).map(PathBuf::from).collect(); let [root, inputs, output] = args.as_slice() else { return Err("usage: block_entity_anim_fixture RESOURCES INPUTS OUTPUT".into()); }; diff --git a/crates/horizon-client/examples/block_entity_render_fixture.rs b/crates/horizon-client/examples/probe/block_entity_render_fixture.rs similarity index 99% rename from crates/horizon-client/examples/block_entity_render_fixture.rs rename to crates/horizon-client/examples/probe/block_entity_render_fixture.rs index d844c4e44..a0e3471bc 100644 --- a/crates/horizon-client/examples/block_entity_render_fixture.rs +++ b/crates/horizon-client/examples/probe/block_entity_render_fixture.rs @@ -110,8 +110,8 @@ fn intern(s: &str) -> &'static str { } } -fn main() -> Result<()> { - let args: Vec = std::env::args_os().skip(1).map(PathBuf::from).collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args_os().skip(1).map(PathBuf::from).collect(); let [root, inputs, textures, output] = args.as_slice() else { return Err("usage: block_entity_render_fixture RESOURCES INPUTS TEXTURES OUTPUT".into()); }; diff --git a/crates/horizon-client/examples/block_entity_tickers_fixture.rs b/crates/horizon-client/examples/probe/block_entity_tickers_fixture.rs similarity index 98% rename from crates/horizon-client/examples/block_entity_tickers_fixture.rs rename to crates/horizon-client/examples/probe/block_entity_tickers_fixture.rs index f08c333f6..d375f1b74 100644 --- a/crates/horizon-client/examples/block_entity_tickers_fixture.rs +++ b/crates/horizon-client/examples/probe/block_entity_tickers_fixture.rs @@ -26,8 +26,8 @@ fn entity(name: &str) -> BlockEntity { .unwrap_or_else(|| panic!("no block entity for {name}")) } -fn main() { - let args: Vec = std::env::args().collect(); +pub fn main() { + let args: Vec = crate::args().collect(); let input = std::fs::read_to_string(&args[1]).expect("input"); let mut out = String::new(); let mut entities = BlockEntities::default(); diff --git a/crates/horizon-client/examples/block_particles_fixture.rs b/crates/horizon-client/examples/probe/block_particles_fixture.rs similarity index 95% rename from crates/horizon-client/examples/block_particles_fixture.rs rename to crates/horizon-client/examples/probe/block_particles_fixture.rs index 63ef242b7..0e58d99ea 100644 --- a/crates/horizon-client/examples/block_particles_fixture.rs +++ b/crates/horizon-client/examples/probe/block_particles_fixture.rs @@ -8,8 +8,8 @@ use std::{ io::{BufRead, BufReader, BufWriter, Write}, path::Path, }; -fn main() -> Result<(), Box> { - let args: Vec<_> = std::env::args().collect(); +pub fn main() -> Result<(), Box> { + let args: Vec<_> = crate::args().collect(); let root = Path::new(&args[1]); let assets = Assets::load(root)?; let render = assets.reload(root)?; diff --git a/crates/horizon-client/examples/block_transform_fixture.rs b/crates/horizon-client/examples/probe/block_transform_fixture.rs similarity index 96% rename from crates/horizon-client/examples/block_transform_fixture.rs rename to crates/horizon-client/examples/probe/block_transform_fixture.rs index 01d92a047..9d8d1d7db 100644 --- a/crates/horizon-client/examples/block_transform_fixture.rs +++ b/crates/horizon-client/examples/probe/block_transform_fixture.rs @@ -51,8 +51,8 @@ impl Around for Column { } } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let root = Path::new( args.get(1) .ok_or("usage: block_transform_fixture RESOURCES INPUT OUTPUT")?, diff --git a/crates/horizon-client/examples/breaking_fixture.rs b/crates/horizon-client/examples/probe/breaking_fixture.rs similarity index 96% rename from crates/horizon-client/examples/breaking_fixture.rs rename to crates/horizon-client/examples/probe/breaking_fixture.rs index da696b88e..c5a816ccd 100644 --- a/crates/horizon-client/examples/breaking_fixture.rs +++ b/crates/horizon-client/examples/probe/breaking_fixture.rs @@ -16,8 +16,8 @@ use std::{ }; /// The stage sprite origin the cracks carry (the oracle compares the geometry and UVs only). const STAGE: [f32; 2] = [0.25, 0.5]; -fn main() -> Result<(), Box> { - let args: Vec<_> = std::env::args().collect(); +pub fn main() -> Result<(), Box> { + let args: Vec<_> = crate::args().collect(); let root = Path::new(&args[1]); let assets = Assets::load(root)?; let render = assets.reload(root)?; diff --git a/crates/horizon-client/examples/camera_probe.rs b/crates/horizon-client/examples/probe/camera_probe.rs similarity index 99% rename from crates/horizon-client/examples/camera_probe.rs rename to crates/horizon-client/examples/probe/camera_probe.rs index 2d7f716f0..38f3c23be 100644 --- a/crates/horizon-client/examples/camera_probe.rs +++ b/crates/horizon-client/examples/probe/camera_probe.rs @@ -323,8 +323,8 @@ fn avatar(c: &Value, out: &mut impl Write) -> Result<()> { Ok(()) } -fn main() -> Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args().collect(); let input = BufReader::new(File::open(&args[1])?); let mut out = BufWriter::new(File::create(&args[2])?); for (n, line) in input.lines().enumerate() { diff --git a/crates/horizon-client/examples/cauldron_fixture.rs b/crates/horizon-client/examples/probe/cauldron_fixture.rs similarity index 98% rename from crates/horizon-client/examples/cauldron_fixture.rs rename to crates/horizon-client/examples/probe/cauldron_fixture.rs index 6aa942d42..95b075d70 100644 --- a/crates/horizon-client/examples/cauldron_fixture.rs +++ b/crates/horizon-client/examples/probe/cauldron_fixture.rs @@ -70,8 +70,8 @@ fn describe(state: &BlockState) -> String { format!("{}|{}", state.name, props.join(",")) } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let root = Path::new( args.get(1) .ok_or("usage: cauldron_fixture RESOURCES INPUT OUTPUT")?, diff --git a/crates/horizon-client/examples/chat_screen_fixture.rs b/crates/horizon-client/examples/probe/chat_screen_fixture.rs similarity index 95% rename from crates/horizon-client/examples/chat_screen_fixture.rs rename to crates/horizon-client/examples/probe/chat_screen_fixture.rs index c5cba6b9d..229d8d861 100644 --- a/crates/horizon-client/examples/chat_screen_fixture.rs +++ b/crates/horizon-client/examples/probe/chat_screen_fixture.rs @@ -5,6 +5,7 @@ //! the oracle's JSON form. //! //! usage: chat_screen_fixture RESOURCES REGISTRIES CASES OUTPUT +use crate::pack_screen_fixture; use horizon_client::{ chat::{ChatAction, ChatScreen, Commands}, command::vanilla, @@ -15,14 +16,11 @@ use horizon_client::{ use serde_json::{Value, json}; use std::{fmt::Write as _, fs, path::PathBuf}; use winit::keyboard::KeyCode as K; -#[path = "pack_screen_fixture.rs"] -#[allow(dead_code)] -mod pack_screen_fixture; #[path = "chat_screen_fixture/registries.rs"] mod registries; -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args_os().skip(1).map(PathBuf::from).collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args_os().skip(1).map(PathBuf::from).collect(); let [root, registries, inputs, output] = args.as_slice() else { return Err("usage: chat_screen_fixture RESOURCES REGISTRIES CASES OUTPUT".into()); }; diff --git a/crates/horizon-client/examples/chat_screen_fixture/registries.rs b/crates/horizon-client/examples/probe/chat_screen_fixture/registries.rs similarity index 100% rename from crates/horizon-client/examples/chat_screen_fixture/registries.rs rename to crates/horizon-client/examples/probe/chat_screen_fixture/registries.rs diff --git a/crates/horizon-client/examples/cloud_fixture.rs b/crates/horizon-client/examples/probe/cloud_fixture.rs similarity index 92% rename from crates/horizon-client/examples/cloud_fixture.rs rename to crates/horizon-client/examples/probe/cloud_fixture.rs index 7c00bfb3a..4ba072dbb 100644 --- a/crates/horizon-client/examples/cloud_fixture.rs +++ b/crates/horizon-client/examples/probe/cloud_fixture.rs @@ -1,8 +1,8 @@ //! CloudRenderer face selection and mesh traversal, without a GPU. use horizon_client::clouds; use std::{fmt::Write, fs}; -fn main() -> Result<(), Box> { - let args: Vec<_> = std::env::args().collect(); +pub fn main() -> Result<(), Box> { + let args: Vec<_> = crate::args().collect(); let mut output = String::new(); for (case, line) in fs::read_to_string(&args[1])?.lines().enumerate() { let values: Vec = line diff --git a/crates/horizon-client/examples/command_parse_fixture.rs b/crates/horizon-client/examples/probe/command_parse_fixture.rs similarity index 99% rename from crates/horizon-client/examples/command_parse_fixture.rs rename to crates/horizon-client/examples/probe/command_parse_fixture.rs index 1cc1f95d5..17437cd72 100644 --- a/crates/horizon-client/examples/command_parse_fixture.rs +++ b/crates/horizon-client/examples/probe/command_parse_fixture.rs @@ -132,8 +132,8 @@ fn tree(d: &Dispatcher, node: usize) -> Value { v } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); if args.get(1).map(String::as_str) == Some("tree") { let d = &vanilla::registered(false); let mut v = tree(d, 0); diff --git a/crates/horizon-client/examples/container_screen_probe.rs b/crates/horizon-client/examples/probe/container_screen_probe.rs similarity index 97% rename from crates/horizon-client/examples/container_screen_probe.rs rename to crates/horizon-client/examples/probe/container_screen_probe.rs index b89b23a2a..e82b5bdf5 100644 --- a/crates/horizon-client/examples/container_screen_probe.rs +++ b/crates/horizon-client/examples/probe/container_screen_probe.rs @@ -24,8 +24,8 @@ fn input_name(input: Input) -> &'static str { } } -fn main() -> Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args().collect(); let input = BufReader::new(File::open(&args[1])?); let mut out = BufWriter::new(File::create(&args[2])?); for (n, line) in input.lines().enumerate() { diff --git a/crates/horizon-client/examples/creative_search_fixture.rs b/crates/horizon-client/examples/probe/creative_search_fixture.rs similarity index 95% rename from crates/horizon-client/examples/creative_search_fixture.rs rename to crates/horizon-client/examples/probe/creative_search_fixture.rs index 628e0486d..1f4f04b37 100644 --- a/crates/horizon-client/examples/creative_search_fixture.rs +++ b/crates/horizon-client/examples/probe/creative_search_fixture.rs @@ -11,8 +11,8 @@ use horizon_client::{ use serde_json::{Value, json}; use std::{fs, path::Path}; -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let usage = "usage: creative_search_fixture RESOURCES CREATIVE_JSON VANILLA_JSON OUTPUT"; let names = Names::load(Path::new(args.get(1).ok_or(usage)?)); let creative = Creative::from_json(&serde_json::from_slice(&fs::read( diff --git a/crates/horizon-client/examples/probe/dispatch.rs b/crates/horizon-client/examples/probe/dispatch.rs new file mode 100644 index 000000000..b40cf1a6e --- /dev/null +++ b/crates/horizon-client/examples/probe/dispatch.rs @@ -0,0 +1,49 @@ +//! How the probe binary runs a probe. main.rs lists the probes and nothing else (tools/parity.py leaves it out of +//! the harnesses' dependencies); code every probe relies on goes here. +use std::process::ExitCode; + +/// `probes! { a, b, }` declares the binary's `main`, which runs the probe module named by its first argument. +macro_rules! probes { + ($($name:ident,)*) => { + fn run(name: &str) -> Option { + use std::process::Termination; + Some(match name { + $(stringify!($name) => $name::main().report(),)* + _ => return None, + }) + } + + fn main() -> std::process::ExitCode { + dispatch::main(&[$(stringify!($name)),*], run) + } + }; +} + +/// The probe's command line as its own example saw it: the program, then the arguments after the probe's name. +pub fn args() -> std::vec::IntoIter { + let mut args: Vec = std::env::args().collect(); + if args.len() > 1 { + args.remove(1); + } + args.into_iter() +} + +/// args(), as OsStrings. +pub fn args_os() -> std::vec::IntoIter { + let mut args: Vec<_> = std::env::args_os().collect(); + if args.len() > 1 { + args.remove(1); + } + args.into_iter() +} + +pub fn main(names: &[&str], run: fn(&str) -> Option) -> ExitCode { + let name = std::env::args().nth(1).unwrap_or_default(); + run(&name).unwrap_or_else(|| { + eprintln!( + "usage: probe [arguments...]\nprobes: {}", + names.join(" ") + ); + ExitCode::from(2) + }) +} diff --git a/crates/horizon-client/examples/emitter_particles_probe.rs b/crates/horizon-client/examples/probe/emitter_particles_probe.rs similarity index 96% rename from crates/horizon-client/examples/emitter_particles_probe.rs rename to crates/horizon-client/examples/probe/emitter_particles_probe.rs index 7469bb368..6349eb8dc 100644 --- a/crates/horizon-client/examples/emitter_particles_probe.rs +++ b/crates/horizon-client/examples/probe/emitter_particles_probe.rs @@ -14,8 +14,8 @@ fn d(v: f64) -> String { format!("{:016x}", v.to_bits()) } -fn main() -> Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args().collect(); let mut out = BufWriter::new(File::create(&args[2])?); for (n, line) in BufReader::new(File::open(&args[1])?).lines().enumerate() { let c: Value = serde_json::from_str(&line?)?; diff --git a/crates/horizon-client/examples/enchanting_fixture.rs b/crates/horizon-client/examples/probe/enchanting_fixture.rs similarity index 94% rename from crates/horizon-client/examples/enchanting_fixture.rs rename to crates/horizon-client/examples/probe/enchanting_fixture.rs index 736b9189e..4c0fe6350 100644 --- a/crates/horizon-client/examples/enchanting_fixture.rs +++ b/crates/horizon-client/examples/probe/enchanting_fixture.rs @@ -10,8 +10,8 @@ use horizon_client::{ }; use std::{fmt::Write as _, fs, path::Path}; -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let root = Path::new( args.get(1) .ok_or("usage: enchanting_fixture RESOURCES INPUT OUTPUT")?, diff --git a/crates/horizon-client/examples/entity_anim_fixture.rs b/crates/horizon-client/examples/probe/entity_anim_fixture.rs similarity index 99% rename from crates/horizon-client/examples/entity_anim_fixture.rs rename to crates/horizon-client/examples/probe/entity_anim_fixture.rs index e5a146ef9..0a2e2951f 100644 --- a/crates/horizon-client/examples/entity_anim_fixture.rs +++ b/crates/horizon-client/examples/probe/entity_anim_fixture.rs @@ -3,7 +3,7 @@ //! posed model with `mobs::render::draw` under the case's living-entity root //! transform and writes each drawn part's packed vertex normals. //! -//! cargo run --profile fast -p horizon-client --example entity_anim_fixture -- \ +//! cargo run --profile fast -p horizon-client --example probe -- entity_anim_fixture \ //! RESOURCES VANILLA.jsonl OUT.jsonl use horizon_client::mesher::Vertex; use horizon_client::mobs::{ @@ -288,8 +288,8 @@ fn entity_state(mob: &mut Mob, species: Species, case: &Value) { } } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().skip(1).collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().skip(1).collect(); let root = PathBuf::from(&args[0]); let types = MobTypes::load(&root)?; let animations = MobData::load_animations(&root); diff --git a/crates/horizon-client/examples/entity_components_probe.rs b/crates/horizon-client/examples/probe/entity_components_probe.rs similarity index 96% rename from crates/horizon-client/examples/entity_components_probe.rs rename to crates/horizon-client/examples/probe/entity_components_probe.rs index 0d4a51e8c..2b1c3233f 100644 --- a/crates/horizon-client/examples/entity_components_probe.rs +++ b/crates/horizon-client/examples/probe/entity_components_probe.rs @@ -61,8 +61,8 @@ fn species(id: &str) -> Species { } } -fn main() -> Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args().collect(); let input = BufReader::new(File::open(&args[1])?); let mut out = BufWriter::new(File::create(&args[2])?); for (n, line) in input.lines().enumerate() { diff --git a/crates/horizon-client/examples/entity_death_loot_fixture.rs b/crates/horizon-client/examples/probe/entity_death_loot_fixture.rs similarity index 99% rename from crates/horizon-client/examples/entity_death_loot_fixture.rs rename to crates/horizon-client/examples/probe/entity_death_loot_fixture.rs index a8eceb8ca..86ef275d9 100644 --- a/crates/horizon-client/examples/entity_death_loot_fixture.rs +++ b/crates/horizon-client/examples/probe/entity_death_loot_fixture.rs @@ -53,8 +53,8 @@ fn line(s: &LootStack) -> String { out } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let root = Path::new( args.get(1) .ok_or("usage: entity_death_loot_fixture RESOURCES INPUT OUTPUT")?, diff --git a/crates/horizon-client/examples/entity_particles_probe.rs b/crates/horizon-client/examples/probe/entity_particles_probe.rs similarity index 95% rename from crates/horizon-client/examples/entity_particles_probe.rs rename to crates/horizon-client/examples/probe/entity_particles_probe.rs index ef38f1000..cdb0344df 100644 --- a/crates/horizon-client/examples/entity_particles_probe.rs +++ b/crates/horizon-client/examples/probe/entity_particles_probe.rs @@ -13,8 +13,8 @@ fn d(v: f64) -> String { format!("{:016x}", v.to_bits()) } -fn main() -> Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args().collect(); let mut out = BufWriter::new(File::create(&args[2])?); for (n, line) in BufReader::new(File::open(&args[1])?).lines().enumerate() { let c: Value = serde_json::from_str(&line?)?; diff --git a/crates/horizon-client/examples/environment_fixture.rs b/crates/horizon-client/examples/probe/environment_fixture.rs similarity index 97% rename from crates/horizon-client/examples/environment_fixture.rs rename to crates/horizon-client/examples/probe/environment_fixture.rs index 7f331962a..27846fe82 100644 --- a/crates/horizon-client/examples/environment_fixture.rs +++ b/crates/horizon-client/examples/probe/environment_fixture.rs @@ -9,8 +9,8 @@ use horizon_client::{ }; use std::{collections::HashMap, fmt::Write as _, fs, path::Path}; -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let root = Path::new( args.get(1) .ok_or("usage: environment_fixture RESOURCES INPUT OUTPUT")?, diff --git a/crates/horizon-client/examples/finalize_spawn_fixture.rs b/crates/horizon-client/examples/probe/finalize_spawn_fixture.rs similarity index 99% rename from crates/horizon-client/examples/finalize_spawn_fixture.rs rename to crates/horizon-client/examples/probe/finalize_spawn_fixture.rs index 9b1ba4f38..b1b25e723 100644 --- a/crates/horizon-client/examples/finalize_spawn_fixture.rs +++ b/crates/horizon-client/examples/probe/finalize_spawn_fixture.rs @@ -388,8 +388,8 @@ fn describe(m: &Mob, all: &[Mob], regs: &SpawnRegistries) -> String { t.join(" ") } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let root = Path::new( args.get(1) .ok_or("usage: finalize_spawn_fixture RESOURCES INPUT OUTPUT HALLOWEEN")?, diff --git a/crates/horizon-client/examples/fire_starter_sound_probe.rs b/crates/horizon-client/examples/probe/fire_starter_sound_probe.rs similarity index 91% rename from crates/horizon-client/examples/fire_starter_sound_probe.rs rename to crates/horizon-client/examples/probe/fire_starter_sound_probe.rs index 62fab117a..18c1b487a 100644 --- a/crates/horizon-client/examples/fire_starter_sound_probe.rs +++ b/crates/horizon-client/examples/probe/fire_starter_sound_probe.rs @@ -11,8 +11,8 @@ use std::{ io::{BufRead, BufReader, BufWriter, Write}, }; -fn main() -> Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args().collect(); let input = BufReader::new(File::open(&args[1])?); let mut out = BufWriter::new(File::create(&args[2])?); for line in input.lines() { diff --git a/crates/horizon-client/examples/firework_tooltip_fixture.rs b/crates/horizon-client/examples/probe/firework_tooltip_fixture.rs similarity index 92% rename from crates/horizon-client/examples/firework_tooltip_fixture.rs rename to crates/horizon-client/examples/probe/firework_tooltip_fixture.rs index 7f10278b7..385776837 100644 --- a/crates/horizon-client/examples/firework_tooltip_fixture.rs +++ b/crates/horizon-client/examples/probe/firework_tooltip_fixture.rs @@ -4,8 +4,8 @@ use horizon_client::{enchant::Enchantments, item_data::parse_stack, item_tooltip::firework_lines}; use std::{error::Error, fmt::Write, path::PathBuf}; -fn main() -> Result<(), Box> { - let args: Vec = std::env::args().collect(); +pub fn main() -> Result<(), Box> { + let args: Vec = crate::args().collect(); let input = std::fs::read_to_string(&args[1])?; let root = input .lines() diff --git a/crates/horizon-client/examples/first_person_probe.rs b/crates/horizon-client/examples/probe/first_person_probe.rs similarity index 99% rename from crates/horizon-client/examples/first_person_probe.rs rename to crates/horizon-client/examples/probe/first_person_probe.rs index 7b1143114..cb4c38e58 100644 --- a/crates/horizon-client/examples/first_person_probe.rs +++ b/crates/horizon-client/examples/probe/first_person_probe.rs @@ -458,8 +458,8 @@ impl HandWorld for ResetWorld<'_, '_> { } } -fn main() -> Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args().collect(); let input = BufReader::new(File::open(&args[1])?); let mut out = BufWriter::new(File::create(&args[2])?); for (n, line) in input.lines().enumerate() { diff --git a/crates/horizon-client/examples/frame_limiter_probe.rs b/crates/horizon-client/examples/probe/frame_limiter_probe.rs similarity index 97% rename from crates/horizon-client/examples/frame_limiter_probe.rs rename to crates/horizon-client/examples/probe/frame_limiter_probe.rs index 7a5d4e437..b11338afc 100644 --- a/crates/horizon-client/examples/frame_limiter_probe.rs +++ b/crates/horizon-client/examples/probe/frame_limiter_probe.rs @@ -50,8 +50,8 @@ impl LimiterClock for Script { } } -fn main() -> Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args().collect(); let input = BufReader::new(File::open(&args[1])?); let mut out = BufWriter::new(File::create(&args[2])?); for (n, line) in input.lines().enumerate() { diff --git a/crates/horizon-client/examples/game_loop_probe.rs b/crates/horizon-client/examples/probe/game_loop_probe.rs similarity index 99% rename from crates/horizon-client/examples/game_loop_probe.rs rename to crates/horizon-client/examples/probe/game_loop_probe.rs index 66a428162..598f480e6 100644 --- a/crates/horizon-client/examples/game_loop_probe.rs +++ b/crates/horizon-client/examples/probe/game_loop_probe.rs @@ -291,8 +291,8 @@ fn key(c: &Value, out: &mut impl Write) -> Result<()> { Ok(()) } -fn main() -> Result<()> { - let args: Vec<_> = std::env::args().skip(1).collect(); +pub fn main() -> Result<()> { + let args: Vec<_> = crate::args().skip(1).collect(); let mut out = BufWriter::new(File::create(&args[1])?); for line in BufReader::new(File::open(&args[0])?).lines() { let c: Value = serde_json::from_str(&line?)?; diff --git a/crates/horizon-client/examples/ghost_recipe_fixture.rs b/crates/horizon-client/examples/probe/ghost_recipe_fixture.rs similarity index 96% rename from crates/horizon-client/examples/ghost_recipe_fixture.rs rename to crates/horizon-client/examples/probe/ghost_recipe_fixture.rs index 0860fd409..b8c6553be 100644 --- a/crates/horizon-client/examples/ghost_recipe_fixture.rs +++ b/crates/horizon-client/examples/probe/ghost_recipe_fixture.rs @@ -13,8 +13,8 @@ use horizon_client::{ use serde_json::Value; use std::{fmt::Write as _, fs, path::Path}; -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let usage = "usage: ghost_recipe_fixture RESOURCES CASES OUTPUT"; let root = Path::new(args.get(1).ok_or(usage)?); let cases = fs::read_to_string(args.get(2).ok_or(usage)?)?; diff --git a/crates/horizon-client/examples/held_drop_fixture.rs b/crates/horizon-client/examples/probe/held_drop_fixture.rs similarity index 98% rename from crates/horizon-client/examples/held_drop_fixture.rs rename to crates/horizon-client/examples/probe/held_drop_fixture.rs index a0c5d92ba..1275021bb 100644 --- a/crates/horizon-client/examples/held_drop_fixture.rs +++ b/crates/horizon-client/examples/probe/held_drop_fixture.rs @@ -2,7 +2,7 @@ use horizon_client::command::args::GameMode; use horizon_client::items::{ItemStack, take_held_drop}; -fn main() { +pub fn main() { for mode in [ GameMode::Survival, GameMode::Creative, diff --git a/crates/horizon-client/examples/hotbar_fixture.rs b/crates/horizon-client/examples/probe/hotbar_fixture.rs similarity index 94% rename from crates/horizon-client/examples/hotbar_fixture.rs rename to crates/horizon-client/examples/probe/hotbar_fixture.rs index beac564ec..4c89a919f 100644 --- a/crates/horizon-client/examples/hotbar_fixture.rs +++ b/crates/horizon-client/examples/probe/hotbar_fixture.rs @@ -10,8 +10,8 @@ use serde_json::Value; use std::path::Path; use std::{fmt::Write as _, fs}; -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let usage = "usage: hotbar_fixture RESOURCES CASES OUTPUT"; let items = Items::catalog(Path::new(args.first().and(args.get(1)).ok_or(usage)?))?; let known = |id: &str| items.get(id).is_some(); diff --git a/crates/horizon-client/examples/hud_fixture.rs b/crates/horizon-client/examples/probe/hud_fixture.rs similarity index 98% rename from crates/horizon-client/examples/hud_fixture.rs rename to crates/horizon-client/examples/probe/hud_fixture.rs index 4a4c78869..a6f27fcda 100644 --- a/crates/horizon-client/examples/hud_fixture.rs +++ b/crates/horizon-client/examples/probe/hud_fixture.rs @@ -20,8 +20,8 @@ type Result = std::result::Result>; #[path = "hud_fixture/kinds.rs"] mod kinds; -fn main() -> Result<()> { - let args: Vec = std::env::args_os().skip(1).map(PathBuf::from).collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args_os().skip(1).map(PathBuf::from).collect(); let [root, inputs, output] = args.as_slice() else { return Err("usage: hud_fixture RESOURCES INPUTS OUTPUT".into()); }; diff --git a/crates/horizon-client/examples/hud_fixture/kinds.rs b/crates/horizon-client/examples/probe/hud_fixture/kinds.rs similarity index 100% rename from crates/horizon-client/examples/hud_fixture/kinds.rs rename to crates/horizon-client/examples/probe/hud_fixture/kinds.rs diff --git a/crates/horizon-client/examples/input_probe.rs b/crates/horizon-client/examples/probe/input_probe.rs similarity index 94% rename from crates/horizon-client/examples/input_probe.rs rename to crates/horizon-client/examples/probe/input_probe.rs index b628bce5d..ae66f77a6 100644 --- a/crates/horizon-client/examples/input_probe.rs +++ b/crates/horizon-client/examples/probe/input_probe.rs @@ -11,8 +11,8 @@ fn number(v: &Value) -> f32 { fn bits(v: f32) -> u32 { if v.is_nan() { 0x7fc00000 } else { v.to_bits() } } -fn main() -> Result<()> { - let args: Vec<_> = std::env::args().skip(1).collect(); +pub fn main() -> Result<()> { + let args: Vec<_> = crate::args().skip(1).collect(); let mut out = BufWriter::new(File::create(&args[1])?); for line in BufReader::new(File::open(&args[0])?).lines() { let f: Value = serde_json::from_str(&line?)?; diff --git a/crates/horizon-client/examples/interaction_input_fixture.rs b/crates/horizon-client/examples/probe/interaction_input_fixture.rs similarity index 96% rename from crates/horizon-client/examples/interaction_input_fixture.rs rename to crates/horizon-client/examples/probe/interaction_input_fixture.rs index bb408dd88..a6beffc05 100644 --- a/crates/horizon-client/examples/interaction_input_fixture.rs +++ b/crates/horizon-client/examples/probe/interaction_input_fixture.rs @@ -82,8 +82,8 @@ impl TargetUseWorld for World { } } -fn main() -> Result<(), Box> { - let args: Vec<_> = std::env::args().collect(); +pub fn main() -> Result<(), Box> { + let args: Vec<_> = crate::args().collect(); let input = std::io::BufReader::new(std::fs::File::open(&args[1])?); let mut out = std::io::BufWriter::new(std::fs::File::create(&args[2])?); for (i, line) in input.lines().enumerate() { diff --git a/crates/horizon-client/examples/lan_probe.rs b/crates/horizon-client/examples/probe/lan_probe.rs similarity index 96% rename from crates/horizon-client/examples/lan_probe.rs rename to crates/horizon-client/examples/probe/lan_probe.rs index 43ce51f9d..3be556e3b 100644 --- a/crates/horizon-client/examples/lan_probe.rs +++ b/crates/horizon-client/examples/probe/lan_probe.rs @@ -14,8 +14,8 @@ fn unhex(s: &str) -> Vec { .collect() } -fn main() { - let args: Vec = std::env::args().collect(); +pub fn main() { + let args: Vec = crate::args().collect(); let cases = std::fs::read_to_string(&args[1]).unwrap(); let mut out = String::new(); let mut games: Vec = Vec::new(); diff --git a/crates/horizon-client/examples/light_parity.rs b/crates/horizon-client/examples/probe/light_parity.rs similarity index 98% rename from crates/horizon-client/examples/light_parity.rs rename to crates/horizon-client/examples/probe/light_parity.rs index f660189a2..41c2ba784 100644 --- a/crates/horizon-client/examples/light_parity.rs +++ b/crates/horizon-client/examples/probe/light_parity.rs @@ -2,7 +2,7 @@ //! server with Horizon's light engine and compare every SkyLight/BlockLight //! value with the arrays vanilla stored. //! -//! cargo run --profile fast -p horizon-client --example light_parity -- \ +//! cargo run --profile fast -p horizon-client --example probe -- light_parity \ //! RESOURCES DIMENSION_DIR [--nether] [--chunks X0 Z0 X1 Z1] use horizon_client::{ assets::Assets, @@ -21,8 +21,8 @@ use std::{collections::HashMap, path::PathBuf}; type Arrays = HashMap>, Option>)>; -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().skip(1).collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().skip(1).collect(); let root = PathBuf::from( args.first() .ok_or("usage: light_parity RESOURCES DIMENSION_DIR")?, diff --git a/crates/horizon-client/examples/probe/main.rs b/crates/horizon-client/examples/probe/main.rs new file mode 100644 index 000000000..d110ea790 --- /dev/null +++ b/crates/horizon-client/examples/probe/main.rs @@ -0,0 +1,178 @@ +//! Every horizon-client parity probe in one binary: `probe [arguments]` runs `.rs` as its own +//! example did (tools/test_*_parity.py, tools/oracle_harness.py, tools/audio_harness.py). Linking ~80 examples, +//! each with the whole client in it, was most of the parity job's probe build; one binary builds it once. +//! +//! This file only lists the probes, so that adding one reruns no harness: tools/parity.py leaves it out of +//! their dependencies. How a probe runs is in dispatch.rs. +#[macro_use] +mod dispatch; + +use dispatch::{args, args_os}; + +mod ambient_fixture; +mod arrow_probe; +mod audio_attributes_fixture; +/// Sound-engine fakes the audio probes share. +mod audio_common; +mod auto_jump_probe; +mod block_entity_anim_fixture; +mod block_entity_render_fixture; +mod block_entity_tickers_fixture; +mod block_particles_fixture; +mod block_transform_fixture; +mod breaking_fixture; +mod camera_probe; +mod cauldron_fixture; +mod chat_screen_fixture; +mod cloud_fixture; +mod command_parse_fixture; +mod container_screen_probe; +mod creative_search_fixture; +mod emitter_particles_probe; +mod enchanting_fixture; +mod entity_anim_fixture; +mod entity_components_probe; +mod entity_death_loot_fixture; +mod entity_particles_probe; +mod environment_fixture; +mod finalize_spawn_fixture; +mod fire_starter_sound_probe; +mod firework_tooltip_fixture; +mod first_person_probe; +mod frame_limiter_probe; +mod game_loop_probe; +mod ghost_recipe_fixture; +mod held_drop_fixture; +mod hotbar_fixture; +mod hud_fixture; +mod input_probe; +mod interaction_input_fixture; +mod lan_probe; +mod light_parity; +mod marker_particles_probe; +mod menu_fixture; +mod mipmap_probe; +mod mob_ai_probe; +mod mob_attributes_fixture; +mod music_fixture; +mod natural_spawn_fixture; +mod options_probe; +mod pack_resources_fixture; +mod pack_screen_fixture; +mod pack_selection_fixture; +mod particle_providers_probe; +mod pick_block_data_fixture; +mod place_recipe_fixture; +mod player_sync_fixture; +mod raid_fixture; +mod random_tick_sections_probe; +mod recipe_book_fixture; +mod recipe_book_render_fixture; +mod recipe_book_view_fixture; +mod recipe_fixture; +mod scene_collision_probe; +mod scene_motion_probe; +mod scoreboard_fixture; +mod screen_layout_fixture; +mod section_mesh_fixture; +mod server_files_probe; +mod situational_music_fixture; +mod skin_image_fixture; +mod sound_engine_fixture; +mod sound_event_fixture; +mod spawn_rules_fixture; +mod sprint_probe; +mod subtitle_fixture; +mod tab_list_fixture; +mod team_rules_fixture; +mod toggle_keys_probe; +mod tooltip_display_fixture; +mod trading_fixture; +mod translucency_fixture; +mod weather_fixture; +mod world_border_render_fixture; +mod world_options_fixture; + +probes! { + ambient_fixture, + arrow_probe, + audio_attributes_fixture, + auto_jump_probe, + block_entity_anim_fixture, + block_entity_render_fixture, + block_entity_tickers_fixture, + block_particles_fixture, + block_transform_fixture, + breaking_fixture, + camera_probe, + cauldron_fixture, + chat_screen_fixture, + cloud_fixture, + command_parse_fixture, + container_screen_probe, + creative_search_fixture, + emitter_particles_probe, + enchanting_fixture, + entity_anim_fixture, + entity_components_probe, + entity_death_loot_fixture, + entity_particles_probe, + environment_fixture, + finalize_spawn_fixture, + fire_starter_sound_probe, + firework_tooltip_fixture, + first_person_probe, + frame_limiter_probe, + game_loop_probe, + ghost_recipe_fixture, + held_drop_fixture, + hotbar_fixture, + hud_fixture, + input_probe, + interaction_input_fixture, + lan_probe, + light_parity, + marker_particles_probe, + menu_fixture, + mipmap_probe, + mob_ai_probe, + mob_attributes_fixture, + music_fixture, + natural_spawn_fixture, + options_probe, + pack_resources_fixture, + pack_screen_fixture, + pack_selection_fixture, + particle_providers_probe, + pick_block_data_fixture, + place_recipe_fixture, + player_sync_fixture, + raid_fixture, + random_tick_sections_probe, + recipe_book_fixture, + recipe_book_render_fixture, + recipe_book_view_fixture, + recipe_fixture, + scene_collision_probe, + scene_motion_probe, + scoreboard_fixture, + screen_layout_fixture, + section_mesh_fixture, + server_files_probe, + situational_music_fixture, + skin_image_fixture, + sound_engine_fixture, + sound_event_fixture, + spawn_rules_fixture, + sprint_probe, + subtitle_fixture, + tab_list_fixture, + team_rules_fixture, + toggle_keys_probe, + tooltip_display_fixture, + trading_fixture, + translucency_fixture, + weather_fixture, + world_border_render_fixture, + world_options_fixture, +} diff --git a/crates/horizon-client/examples/marker_particles_probe.rs b/crates/horizon-client/examples/probe/marker_particles_probe.rs similarity index 97% rename from crates/horizon-client/examples/marker_particles_probe.rs rename to crates/horizon-client/examples/probe/marker_particles_probe.rs index edf624e73..190751d79 100644 --- a/crates/horizon-client/examples/marker_particles_probe.rs +++ b/crates/horizon-client/examples/probe/marker_particles_probe.rs @@ -22,8 +22,8 @@ use std::{ sync::Arc, }; -fn main() -> Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args().collect(); let root = Path::new(".local/horizon-client/26.3"); let assets = Assets::load(root)?; let facts = BlockFacts::load(root, assets.registry)?; diff --git a/crates/horizon-client/examples/menu_fixture.rs b/crates/horizon-client/examples/probe/menu_fixture.rs similarity index 98% rename from crates/horizon-client/examples/menu_fixture.rs rename to crates/horizon-client/examples/probe/menu_fixture.rs index 1da4a0278..fd226ff88 100644 --- a/crates/horizon-client/examples/menu_fixture.rs +++ b/crates/horizon-client/examples/probe/menu_fixture.rs @@ -74,8 +74,8 @@ fn state(menu: &Menu) -> String { format!("{line} | inv{items}") } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let root = Path::new( args.get(1) .ok_or("usage: menu_fixture RESOURCES INPUT OUTPUT")?, diff --git a/crates/horizon-client/examples/mipmap_probe.rs b/crates/horizon-client/examples/probe/mipmap_probe.rs similarity index 94% rename from crates/horizon-client/examples/mipmap_probe.rs rename to crates/horizon-client/examples/probe/mipmap_probe.rs index 99155fb32..fa94f4e90 100644 --- a/crates/horizon-client/examples/mipmap_probe.rs +++ b/crates/horizon-client/examples/probe/mipmap_probe.rs @@ -4,8 +4,8 @@ //! rows like VanillaMipmapOracle. use std::{fmt::Write as _, fs, path::Path}; -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().skip(1).collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().skip(1).collect(); let input = fs::read_to_string(&args[0])?; let mut lines = input.lines(); let root = Path::new(lines.next().ok_or("no resources root")?); diff --git a/crates/horizon-client/examples/mob_ai_probe.rs b/crates/horizon-client/examples/probe/mob_ai_probe.rs similarity index 99% rename from crates/horizon-client/examples/mob_ai_probe.rs rename to crates/horizon-client/examples/probe/mob_ai_probe.rs index a3abb54d9..d773a509b 100644 --- a/crates/horizon-client/examples/mob_ai_probe.rs +++ b/crates/horizon-client/examples/probe/mob_ai_probe.rs @@ -759,8 +759,8 @@ fn villager(m: &Mob) -> String { s } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().skip(1).collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().skip(1).collect(); if args.len() != 3 { return Err("usage: mob_ai_probe RESOURCES SCENARIOS OUTPUT".into()); } diff --git a/crates/horizon-client/examples/mob_attributes_fixture.rs b/crates/horizon-client/examples/probe/mob_attributes_fixture.rs similarity index 95% rename from crates/horizon-client/examples/mob_attributes_fixture.rs rename to crates/horizon-client/examples/probe/mob_attributes_fixture.rs index 7f8359920..f1fcec701 100644 --- a/crates/horizon-client/examples/mob_attributes_fixture.rs +++ b/crates/horizon-client/examples/probe/mob_attributes_fixture.rs @@ -6,8 +6,8 @@ use horizon_client::mobs::{Mob, MobTypes}; use horizon_core::geometry::Vec3; use std::{fmt::Write as _, fs, path::Path, sync::Arc}; -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let root = Path::new( args.get(1) .ok_or("usage: mob_attributes_fixture RESOURCES OUTPUT")?, diff --git a/crates/horizon-client/examples/music_fixture.rs b/crates/horizon-client/examples/probe/music_fixture.rs similarity index 97% rename from crates/horizon-client/examples/music_fixture.rs rename to crates/horizon-client/examples/probe/music_fixture.rs index 29ccb99b2..02aecb373 100644 --- a/crates/horizon-client/examples/music_fixture.rs +++ b/crates/horizon-client/examples/probe/music_fixture.rs @@ -1,7 +1,6 @@ //! Replays `tools/test_music_parity.py` scripts through Horizon's //! `MusicManager` over its `SoundEngine`: `music_fixture ROOT INPUT OUTPUT`. -#[path = "audio_common/mod.rs"] -mod common; +use crate::audio_common as common; use common::{Fake, describe, f, flush}; use horizon_client::music::{Music, MusicFrequency, MusicManager}; use horizon_client::sound_engine::{Bound, MUSIC, SoundEngine, TickContext}; @@ -21,8 +20,8 @@ fn music(spec: &str) -> Option { )) } -fn main() { - let args: Vec = std::env::args().collect(); +pub fn main() { + let args: Vec = crate::args().collect(); let mut engine = SoundEngine::new(SoundRegistry::load(std::path::Path::new(&args[1]))); engine.listening = true; let mut backend = Fake::default(); diff --git a/crates/horizon-client/examples/natural_spawn_fixture.rs b/crates/horizon-client/examples/probe/natural_spawn_fixture.rs similarity index 99% rename from crates/horizon-client/examples/natural_spawn_fixture.rs rename to crates/horizon-client/examples/probe/natural_spawn_fixture.rs index e4c9b1ce6..c19adc4e1 100644 --- a/crates/horizon-client/examples/natural_spawn_fixture.rs +++ b/crates/horizon-client/examples/probe/natural_spawn_fixture.rs @@ -508,8 +508,8 @@ fn yaw_text(entity: &str, v: f32) -> String { } } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let root = Path::new( args.get(1) .ok_or("usage: natural_spawn_fixture RESOURCES INPUT OUTPUT")?, diff --git a/crates/horizon-client/examples/options_probe.rs b/crates/horizon-client/examples/probe/options_probe.rs similarity index 94% rename from crates/horizon-client/examples/options_probe.rs rename to crates/horizon-client/examples/probe/options_probe.rs index f186af994..97c76c030 100644 --- a/crates/horizon-client/examples/options_probe.rs +++ b/crates/horizon-client/examples/probe/options_probe.rs @@ -7,8 +7,8 @@ use horizon_client::{ }; use std::{fs, io::Write}; -fn main() -> Result<()> { - let args: Vec<_> = std::env::args().skip(1).collect(); +pub fn main() -> Result<()> { + let args: Vec<_> = crate::args().skip(1).collect(); let mut names: Vec<_> = fs::read_dir(&args[0])? .map(|e| e.map(|e| e.path())) .collect::>()?; diff --git a/crates/horizon-client/examples/pack_resources_fixture.rs b/crates/horizon-client/examples/probe/pack_resources_fixture.rs similarity index 97% rename from crates/horizon-client/examples/pack_resources_fixture.rs rename to crates/horizon-client/examples/probe/pack_resources_fixture.rs index 00238fa94..80dbf3496 100644 --- a/crates/horizon-client/examples/pack_resources_fixture.rs +++ b/crates/horizon-client/examples/probe/pack_resources_fixture.rs @@ -30,8 +30,8 @@ fn types(root: &std::path::Path, file: PathBuf, key: &str) -> String { }) .collect() } -fn main() -> Result<(), Box> { - let args: Vec<_> = std::env::args().collect(); +pub fn main() -> Result<(), Box> { + let args: Vec<_> = crate::args().collect(); let input = fs::read_to_string(&args[1])?; let mut lines = input.lines(); let root: Vec<&str> = lines.next().ok_or("empty input")?.split(' ').collect(); diff --git a/crates/horizon-client/examples/pack_screen_fixture.rs b/crates/horizon-client/examples/probe/pack_screen_fixture.rs similarity index 98% rename from crates/horizon-client/examples/pack_screen_fixture.rs rename to crates/horizon-client/examples/probe/pack_screen_fixture.rs index ca7cba7b8..881570990 100644 --- a/crates/horizon-client/examples/pack_screen_fixture.rs +++ b/crates/horizon-client/examples/probe/pack_screen_fixture.rs @@ -66,8 +66,8 @@ pub fn encode(draws: &[Draw]) -> Value { ) } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args_os().skip(1).map(PathBuf::from).collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args_os().skip(1).map(PathBuf::from).collect(); let [root, inputs, output] = args.as_slice() else { return Err("usage: pack_screen_fixture RESOURCES CASES OUTPUT".into()); }; diff --git a/crates/horizon-client/examples/pack_selection_fixture.rs b/crates/horizon-client/examples/probe/pack_selection_fixture.rs similarity index 96% rename from crates/horizon-client/examples/pack_selection_fixture.rs rename to crates/horizon-client/examples/probe/pack_selection_fixture.rs index 65ed2471a..91c587343 100644 --- a/crates/horizon-client/examples/pack_selection_fixture.rs +++ b/crates/horizon-client/examples/probe/pack_selection_fixture.rs @@ -35,8 +35,8 @@ fn lists(m: &SelectionModel) -> Value { json!({"unselected": side(false), "selected": side(true)}) } -fn main() -> Result<()> { - let args: Vec = std::env::args_os().skip(1).map(PathBuf::from).collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args_os().skip(1).map(PathBuf::from).collect(); let [inputs, output] = args.as_slice() else { return Err("usage: pack_selection_fixture INPUTS OUTPUT".into()); }; diff --git a/crates/horizon-client/examples/particle_providers_probe.rs b/crates/horizon-client/examples/probe/particle_providers_probe.rs similarity index 99% rename from crates/horizon-client/examples/particle_providers_probe.rs rename to crates/horizon-client/examples/probe/particle_providers_probe.rs index 8b8bd1e0d..c8cd9d88d 100644 --- a/crates/horizon-client/examples/particle_providers_probe.rs +++ b/crates/horizon-client/examples/probe/particle_providers_probe.rs @@ -140,8 +140,8 @@ fn world(assets: &Assets, facts: &BlockFacts, floor: bool, water: bool) -> Resul Ok(world) } -fn main() -> Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args().collect(); let root = &Path::new(".local/horizon-client").join(horizon_core::VANILLA_VERSION); let assets = Assets::load(root)?; let facts = BlockFacts::load(root, assets.registry)?; diff --git a/crates/horizon-client/examples/pick_block_data_fixture.rs b/crates/horizon-client/examples/probe/pick_block_data_fixture.rs similarity index 96% rename from crates/horizon-client/examples/pick_block_data_fixture.rs rename to crates/horizon-client/examples/probe/pick_block_data_fixture.rs index b47f56733..7496ceb8e 100644 --- a/crates/horizon-client/examples/pick_block_data_fixture.rs +++ b/crates/horizon-client/examples/probe/pick_block_data_fixture.rs @@ -78,8 +78,8 @@ fn case(line: &str) -> Option { Some(out) } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let input = fs::read_to_string( args.get(1) .ok_or("usage: pick_block_data_fixture INPUT OUTPUT")?, diff --git a/crates/horizon-client/examples/place_recipe_fixture.rs b/crates/horizon-client/examples/probe/place_recipe_fixture.rs similarity index 97% rename from crates/horizon-client/examples/place_recipe_fixture.rs rename to crates/horizon-client/examples/probe/place_recipe_fixture.rs index 1e2b66dbf..e59750aaf 100644 --- a/crates/horizon-client/examples/place_recipe_fixture.rs +++ b/crates/horizon-client/examples/probe/place_recipe_fixture.rs @@ -28,8 +28,8 @@ fn state(menu: &Menu) -> String { ) } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let usage = "usage: place_recipe_fixture RESOURCES CASES ORDERS OUTPUT"; let root = Path::new(args.get(1).ok_or(usage)?); let cases = fs::read_to_string(args.get(2).ok_or(usage)?)?; diff --git a/crates/horizon-client/examples/player_sync_fixture.rs b/crates/horizon-client/examples/probe/player_sync_fixture.rs similarity index 96% rename from crates/horizon-client/examples/player_sync_fixture.rs rename to crates/horizon-client/examples/probe/player_sync_fixture.rs index b50a672af..034aa6400 100644 --- a/crates/horizon-client/examples/player_sync_fixture.rs +++ b/crates/horizon-client/examples/probe/player_sync_fixture.rs @@ -8,8 +8,8 @@ fn number(value: &Value) -> f64 { f64::from_bits(u64::from_str_radix(value.as_str().unwrap(), 16).unwrap()) } -fn main() -> Result<(), Box> { - let args: Vec<_> = std::env::args().collect(); +pub fn main() -> Result<(), Box> { + let args: Vec<_> = crate::args().collect(); let input = std::io::BufReader::new(std::fs::File::open(&args[1])?); let mut out = std::io::BufWriter::new(std::fs::File::create(&args[2])?); for line in input.lines() { diff --git a/crates/horizon-client/examples/raid_fixture.rs b/crates/horizon-client/examples/probe/raid_fixture.rs similarity index 99% rename from crates/horizon-client/examples/raid_fixture.rs rename to crates/horizon-client/examples/probe/raid_fixture.rs index dfe517e51..648851474 100644 --- a/crates/horizon-client/examples/raid_fixture.rs +++ b/crates/horizon-client/examples/probe/raid_fixture.rs @@ -459,8 +459,8 @@ fn run_codec(c: &BTreeMap<&str, &str>) -> Result { Ok(log.join(" ; ")) } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let root = Path::new( args.get(1) .ok_or("usage: raid_fixture RESOURCES INPUT OUTPUT")?, diff --git a/crates/horizon-client/examples/random_tick_sections_probe.rs b/crates/horizon-client/examples/probe/random_tick_sections_probe.rs similarity index 98% rename from crates/horizon-client/examples/random_tick_sections_probe.rs rename to crates/horizon-client/examples/probe/random_tick_sections_probe.rs index 91c861f45..27eaf8196 100644 --- a/crates/horizon-client/examples/random_tick_sections_probe.rs +++ b/crates/horizon-client/examples/probe/random_tick_sections_probe.rs @@ -51,8 +51,8 @@ impl LevelAccess for Air { fn emit(&mut self, _: LevelEvent) {} } -fn main() -> Result<(), Box> { - let args: Vec = std::env::args().collect(); +pub fn main() -> Result<(), Box> { + let args: Vec = crate::args().collect(); let input = std::fs::read_to_string(&args[1])?; let root = input .lines() diff --git a/crates/horizon-client/examples/recipe_book_fixture.rs b/crates/horizon-client/examples/probe/recipe_book_fixture.rs similarity index 98% rename from crates/horizon-client/examples/recipe_book_fixture.rs rename to crates/horizon-client/examples/probe/recipe_book_fixture.rs index e165dea9b..7117d4bbe 100644 --- a/crates/horizon-client/examples/recipe_book_fixture.rs +++ b/crates/horizon-client/examples/probe/recipe_book_fixture.rs @@ -57,8 +57,8 @@ fn compound(tag: &Tag) -> String { out } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let usage = "usage: recipe_book_fixture RESOURCES CASES OUTPUT"; let root = Path::new(args.get(1).ok_or(usage)?); let cases = fs::read_to_string(args.get(2).ok_or(usage)?)?; diff --git a/crates/horizon-client/examples/recipe_book_render_fixture.rs b/crates/horizon-client/examples/probe/recipe_book_render_fixture.rs similarity index 99% rename from crates/horizon-client/examples/recipe_book_render_fixture.rs rename to crates/horizon-client/examples/probe/recipe_book_render_fixture.rs index cd904db79..702471700 100644 --- a/crates/horizon-client/examples/recipe_book_render_fixture.rs +++ b/crates/horizon-client/examples/probe/recipe_book_render_fixture.rs @@ -30,8 +30,8 @@ fn round(v: f32) -> f32 { (v * 1e4).round() / 1e4 } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let usage = "usage: recipe_book_render_fixture RESOURCES CASES OUTPUT"; let root = Path::new(args.get(1).ok_or(usage)?); let cases = fs::read_to_string(args.get(2).ok_or(usage)?)?; diff --git a/crates/horizon-client/examples/recipe_book_view_fixture.rs b/crates/horizon-client/examples/probe/recipe_book_view_fixture.rs similarity index 98% rename from crates/horizon-client/examples/recipe_book_view_fixture.rs rename to crates/horizon-client/examples/probe/recipe_book_view_fixture.rs index 8a1e5da0e..b94952ec5 100644 --- a/crates/horizon-client/examples/recipe_book_view_fixture.rs +++ b/crates/horizon-client/examples/probe/recipe_book_view_fixture.rs @@ -15,8 +15,8 @@ use horizon_client::{ use serde_json::Value; use std::{fmt::Write as _, fs, path::Path}; -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let usage = "usage: recipe_book_view_fixture RESOURCES CASES OUTPUT"; let root = Path::new(args.get(1).ok_or(usage)?); let cases = fs::read_to_string(args.get(2).ok_or(usage)?)?; diff --git a/crates/horizon-client/examples/recipe_fixture.rs b/crates/horizon-client/examples/probe/recipe_fixture.rs similarity index 97% rename from crates/horizon-client/examples/recipe_fixture.rs rename to crates/horizon-client/examples/probe/recipe_fixture.rs index e68258e4d..8bdffecd0 100644 --- a/crates/horizon-client/examples/recipe_fixture.rs +++ b/crates/horizon-client/examples/probe/recipe_fixture.rs @@ -12,8 +12,8 @@ use horizon_client::{ }; use std::{fs, path::Path}; -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let root = Path::new( args.get(1) .ok_or("usage: recipe_fixture RESOURCES INPUT OUTPUT")?, diff --git a/crates/horizon-client/examples/scene_collision_probe.rs b/crates/horizon-client/examples/probe/scene_collision_probe.rs similarity index 97% rename from crates/horizon-client/examples/scene_collision_probe.rs rename to crates/horizon-client/examples/probe/scene_collision_probe.rs index 2dae2204c..7f22a1173 100644 --- a/crates/horizon-client/examples/scene_collision_probe.rs +++ b/crates/horizon-client/examples/probe/scene_collision_probe.rs @@ -28,8 +28,8 @@ fn vector(value: &Value) -> Result { }; Ok(Vec3::new(number(0)?, number(1)?, number(2)?)) } -fn main() -> Result<()> { - let args: Vec<_> = std::env::args().skip(1).collect(); +pub fn main() -> Result<()> { + let args: Vec<_> = crate::args().skip(1).collect(); if args.len() != 3 { return Err("usage: scene_collision_probe RESOURCES FIXTURE_DIRECTORY RADIUS".into()); } diff --git a/crates/horizon-client/examples/scene_motion_probe.rs b/crates/horizon-client/examples/probe/scene_motion_probe.rs similarity index 99% rename from crates/horizon-client/examples/scene_motion_probe.rs rename to crates/horizon-client/examples/probe/scene_motion_probe.rs index f4ff07ebf..21977eeab 100644 --- a/crates/horizon-client/examples/scene_motion_probe.rs +++ b/crates/horizon-client/examples/probe/scene_motion_probe.rs @@ -233,8 +233,8 @@ fn snapshot(out: &mut impl Write, player: &PlayerMotion) -> Result<()> { writeln!(out, "events {}", events.join(" | "))?; Ok(()) } -fn main() -> Result<()> { - let args: Vec<_> = std::env::args().skip(1).collect(); +pub fn main() -> Result<()> { + let args: Vec<_> = crate::args().skip(1).collect(); if args.len() != 3 { return Err( "usage: scene_motion_probe RESOURCES FIXTURE_DIRECTORY --describe|REFERENCE".into(), diff --git a/crates/horizon-client/examples/scoreboard_fixture.rs b/crates/horizon-client/examples/probe/scoreboard_fixture.rs similarity index 99% rename from crates/horizon-client/examples/scoreboard_fixture.rs rename to crates/horizon-client/examples/probe/scoreboard_fixture.rs index 1fe5bab91..4a2534b32 100644 --- a/crates/horizon-client/examples/scoreboard_fixture.rs +++ b/crates/horizon-client/examples/probe/scoreboard_fixture.rs @@ -370,8 +370,8 @@ fn score_json(sc: &sb::Score) -> Value { }) } -fn main() { - let args: Vec = std::env::args().collect(); +pub fn main() { + let args: Vec = crate::args().collect(); let registries: Value = serde_json::from_str(&fs::read_to_string(&args[1]).expect("registries")).expect("json"); let list = |k: &str| -> Vec { diff --git a/crates/horizon-client/examples/screen_layout_fixture.rs b/crates/horizon-client/examples/probe/screen_layout_fixture.rs similarity index 98% rename from crates/horizon-client/examples/screen_layout_fixture.rs rename to crates/horizon-client/examples/probe/screen_layout_fixture.rs index f364037ab..1103f3647 100644 --- a/crates/horizon-client/examples/screen_layout_fixture.rs +++ b/crates/horizon-client/examples/probe/screen_layout_fixture.rs @@ -60,8 +60,8 @@ fn draw_json(d: &ScreenDraw) -> Value { } } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let usage = "usage: screen_layout_fixture RESOURCES INPUT OUTPUT"; let banners = Banners::load(Path::new(args.get(1).ok_or(usage)?)); let input = fs::read_to_string(args.get(2).ok_or(usage)?)?; diff --git a/crates/horizon-client/examples/section_mesh_fixture.rs b/crates/horizon-client/examples/probe/section_mesh_fixture.rs similarity index 99% rename from crates/horizon-client/examples/section_mesh_fixture.rs rename to crates/horizon-client/examples/probe/section_mesh_fixture.rs index 13f1a0f1a..98a4fdc34 100644 --- a/crates/horizon-client/examples/section_mesh_fixture.rs +++ b/crates/horizon-client/examples/probe/section_mesh_fixture.rs @@ -170,8 +170,8 @@ fn scene( } Ok(json!({"name": row["name"], "quads": quads})) } -fn main() -> Result<()> { - let args: Vec<_> = std::env::args().skip(1).collect(); +pub fn main() -> Result<()> { + let args: Vec<_> = crate::args().skip(1).collect(); if args.len() != 3 { return Err( "usage: section_mesh_fixture RESOURCES (INPUT.jsonl | facts) OUTPUT.jsonl".into(), diff --git a/crates/horizon-client/examples/server_files_probe.rs b/crates/horizon-client/examples/probe/server_files_probe.rs similarity index 99% rename from crates/horizon-client/examples/server_files_probe.rs rename to crates/horizon-client/examples/probe/server_files_probe.rs index ce146be78..85b33a764 100644 --- a/crates/horizon-client/examples/server_files_probe.rs +++ b/crates/horizon-client/examples/probe/server_files_probe.rs @@ -11,8 +11,8 @@ use horizon_client::server::{ use horizon_protocol::crypto::uuid_string; use std::{fmt::Write as _, path::Path}; -fn main() -> Result<(), Box> { - let mut args = std::env::args().skip(1); +pub fn main() -> Result<(), Box> { + let mut args = crate::args().skip(1); let root = std::path::PathBuf::from(args.next().ok_or("CASES OUTPUT")?); let output = args.next().ok_or("OUTPUT")?; let mut cases: Vec<_> = std::fs::read_dir(&root)? diff --git a/crates/horizon-client/examples/situational_music_fixture.rs b/crates/horizon-client/examples/probe/situational_music_fixture.rs similarity index 96% rename from crates/horizon-client/examples/situational_music_fixture.rs rename to crates/horizon-client/examples/probe/situational_music_fixture.rs index ae47426bb..898893c09 100644 --- a/crates/horizon-client/examples/situational_music_fixture.rs +++ b/crates/horizon-client/examples/probe/situational_music_fixture.rs @@ -5,8 +5,8 @@ use horizon_client::music::{BackgroundMusic, Music, MusicTables, Situation}; use horizon_client::sound_events::normalize; use std::io::Write; -fn main() { - let args: Vec = std::env::args().collect(); +pub fn main() { + let args: Vec = crate::args().collect(); let tables = MusicTables::load(std::path::Path::new(&args[1])); let input = std::fs::read_to_string(&args[2]).expect("input"); let mut out = std::io::BufWriter::new(std::fs::File::create(&args[3]).expect("output")); diff --git a/crates/horizon-client/examples/skin_image_fixture.rs b/crates/horizon-client/examples/probe/skin_image_fixture.rs similarity index 90% rename from crates/horizon-client/examples/skin_image_fixture.rs rename to crates/horizon-client/examples/probe/skin_image_fixture.rs index 9373fb1f5..e85be6a16 100644 --- a/crates/horizon-client/examples/skin_image_fixture.rs +++ b/crates/horizon-client/examples/probe/skin_image_fixture.rs @@ -9,8 +9,8 @@ use std::{ }; type Result = std::result::Result>; -fn main() -> Result<()> { - let args: Vec = std::env::args_os().skip(1).map(PathBuf::from).collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args_os().skip(1).map(PathBuf::from).collect(); let [inputs, output] = args.as_slice() else { return Err("usage: skin_image_fixture INPUTS OUTPUT".into()); }; diff --git a/crates/horizon-client/examples/sound_engine_fixture.rs b/crates/horizon-client/examples/probe/sound_engine_fixture.rs similarity index 98% rename from crates/horizon-client/examples/sound_engine_fixture.rs rename to crates/horizon-client/examples/probe/sound_engine_fixture.rs index c42ea8bf9..327a8e9d1 100644 --- a/crates/horizon-client/examples/sound_engine_fixture.rs +++ b/crates/horizon-client/examples/probe/sound_engine_fixture.rs @@ -1,8 +1,7 @@ //! Replays `tools/test_sound_engine_parity.py` scripts through Horizon's //! `SoundEngine` with a backend recording what an OpenAL source would hold: //! `sound_engine_fixture ROOT INPUT OUTPUT`. -#[path = "audio_common/mod.rs"] -mod common; +use crate::audio_common as common; use common::{Fake, d, describe, f, flush, result_name}; use horizon_client::sound_engine::{ Attenuation, Backend, CartSound, InstanceId, SoundEngine, SoundInstance, TickContext, @@ -12,8 +11,8 @@ use horizon_core::random::LegacyRandom; use std::collections::BTreeMap; use std::io::Write; -fn main() { - let args: Vec = std::env::args().collect(); +pub fn main() { + let args: Vec = crate::args().collect(); let mut engine = SoundEngine::new(SoundRegistry::load(std::path::Path::new(&args[1]))); engine.listening = true; let mut backend = Fake::default(); diff --git a/crates/horizon-client/examples/sound_event_fixture.rs b/crates/horizon-client/examples/probe/sound_event_fixture.rs similarity index 97% rename from crates/horizon-client/examples/sound_event_fixture.rs rename to crates/horizon-client/examples/probe/sound_event_fixture.rs index 57c6dd7be..6b52dfc9c 100644 --- a/crates/horizon-client/examples/sound_event_fixture.rs +++ b/crates/horizon-client/examples/probe/sound_event_fixture.rs @@ -9,8 +9,8 @@ fn bits(v: f32) -> String { format!("{:08x}", v.to_bits()) } -fn main() { - let args: Vec = std::env::args().collect(); +pub fn main() { + let args: Vec = crate::args().collect(); let registry = SoundRegistry::load(std::path::Path::new(&args[1])); let mut engine = SoundEngine::new(registry); let input = std::fs::read_to_string(&args[2]).expect("input"); diff --git a/crates/horizon-client/examples/spawn_rules_fixture.rs b/crates/horizon-client/examples/probe/spawn_rules_fixture.rs similarity index 98% rename from crates/horizon-client/examples/spawn_rules_fixture.rs rename to crates/horizon-client/examples/probe/spawn_rules_fixture.rs index dc491be00..661194f6d 100644 --- a/crates/horizon-client/examples/spawn_rules_fixture.rs +++ b/crates/horizon-client/examples/probe/spawn_rules_fixture.rs @@ -136,8 +136,8 @@ fn reason(name: &str) -> Reason { } } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let root = Path::new( args.get(1) .ok_or("usage: spawn_rules_fixture RESOURCES INPUT OUTPUT")?, diff --git a/crates/horizon-client/examples/sprint_probe.rs b/crates/horizon-client/examples/probe/sprint_probe.rs similarity index 97% rename from crates/horizon-client/examples/sprint_probe.rs rename to crates/horizon-client/examples/probe/sprint_probe.rs index ab538ffe1..5c161da4f 100644 --- a/crates/horizon-client/examples/sprint_probe.rs +++ b/crates/horizon-client/examples/probe/sprint_probe.rs @@ -20,8 +20,8 @@ fn keys(mask: u64) -> Keys { analog: None, } } -fn main() -> Result<()> { - let args: Vec<_> = std::env::args().skip(1).collect(); +pub fn main() -> Result<()> { + let args: Vec<_> = crate::args().skip(1).collect(); let mut out = BufWriter::new(File::create(&args[1])?); for line in BufReader::new(File::open(&args[0])?).lines() { let f: Value = serde_json::from_str(&line?)?; diff --git a/crates/horizon-client/examples/subtitle_fixture.rs b/crates/horizon-client/examples/probe/subtitle_fixture.rs similarity index 97% rename from crates/horizon-client/examples/subtitle_fixture.rs rename to crates/horizon-client/examples/probe/subtitle_fixture.rs index ac8e8d4d8..8f690f130 100644 --- a/crates/horizon-client/examples/subtitle_fixture.rs +++ b/crates/horizon-client/examples/probe/subtitle_fixture.rs @@ -21,8 +21,8 @@ fn pose(m: [f32; 6]) -> Value { json!(m) } -fn main() -> Result<(), Box> { - let args: Vec = std::env::args_os().skip(1).map(PathBuf::from).collect(); +pub fn main() -> Result<(), Box> { + let args: Vec = crate::args_os().skip(1).map(PathBuf::from).collect(); let [root, inputs, output] = args.as_slice() else { return Err("usage: subtitle_fixture RESOURCES INPUTS OUTPUT".into()); }; diff --git a/crates/horizon-client/examples/tab_list_fixture.rs b/crates/horizon-client/examples/probe/tab_list_fixture.rs similarity index 98% rename from crates/horizon-client/examples/tab_list_fixture.rs rename to crates/horizon-client/examples/probe/tab_list_fixture.rs index aca50e204..6ea822fba 100644 --- a/crates/horizon-client/examples/tab_list_fixture.rs +++ b/crates/horizon-client/examples/probe/tab_list_fixture.rs @@ -53,8 +53,8 @@ fn runs(t: &Text) -> Value { out.into_iter().map(|(r, k)| json!([r, k])).collect() } -fn main() -> Result<()> { - let args: Vec = std::env::args_os().skip(1).map(PathBuf::from).collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args_os().skip(1).map(PathBuf::from).collect(); let [root, inputs, output] = args.as_slice() else { return Err("usage: tab_list_fixture RESOURCES INPUTS OUTPUT".into()); }; diff --git a/crates/horizon-client/examples/team_rules_fixture.rs b/crates/horizon-client/examples/probe/team_rules_fixture.rs similarity index 97% rename from crates/horizon-client/examples/team_rules_fixture.rs rename to crates/horizon-client/examples/probe/team_rules_fixture.rs index ec56b67ee..9a2d716ff 100644 --- a/crates/horizon-client/examples/team_rules_fixture.rs +++ b/crates/horizon-client/examples/probe/team_rules_fixture.rs @@ -8,8 +8,8 @@ use horizon_client::scoreboard::{self as sb, CollisionRule, NameView, Scoreboard use serde_json::{Value, json}; use std::{fs, io::Write}; -fn main() { - let args: Vec = std::env::args().collect(); +pub fn main() { + let args: Vec = crate::args().collect(); let mut out = std::io::BufWriter::new(fs::File::create(&args[2]).expect("output")); for line in fs::read_to_string(&args[1]).expect("inputs").lines() { let c: Value = serde_json::from_str(line).expect("case"); diff --git a/crates/horizon-client/examples/toggle_keys_probe.rs b/crates/horizon-client/examples/probe/toggle_keys_probe.rs similarity index 95% rename from crates/horizon-client/examples/toggle_keys_probe.rs rename to crates/horizon-client/examples/probe/toggle_keys_probe.rs index 01ef5fd4d..d05acdd5c 100644 --- a/crates/horizon-client/examples/toggle_keys_probe.rs +++ b/crates/horizon-client/examples/probe/toggle_keys_probe.rs @@ -11,8 +11,8 @@ use std::{ io::{BufRead, BufReader, BufWriter, Write}, }; -fn main() -> Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args().collect(); let input = BufReader::new(File::open(&args[1])?); let mut out = BufWriter::new(File::create(&args[2])?); for (n, line) in input.lines().enumerate() { diff --git a/crates/horizon-client/examples/tooltip_display_fixture.rs b/crates/horizon-client/examples/probe/tooltip_display_fixture.rs similarity index 93% rename from crates/horizon-client/examples/tooltip_display_fixture.rs rename to crates/horizon-client/examples/probe/tooltip_display_fixture.rs index ec61159cd..8a7525785 100644 --- a/crates/horizon-client/examples/tooltip_display_fixture.rs +++ b/crates/horizon-client/examples/probe/tooltip_display_fixture.rs @@ -3,8 +3,8 @@ use horizon_client::{item_tooltip::TooltipDisplay, items::ItemStack}; use horizon_world::nbt::Tag; use std::{error::Error, fmt::Write}; -fn main() -> Result<(), Box> { - let args: Vec = std::env::args().collect(); +pub fn main() -> Result<(), Box> { + let args: Vec = crate::args().collect(); let mut output = String::new(); for line in std::fs::read_to_string(&args[1])?.lines() { let fields: Vec<&str> = line.split('\t').collect(); diff --git a/crates/horizon-client/examples/trading_fixture.rs b/crates/horizon-client/examples/probe/trading_fixture.rs similarity index 99% rename from crates/horizon-client/examples/trading_fixture.rs rename to crates/horizon-client/examples/probe/trading_fixture.rs index 58824257c..c2215d327 100644 --- a/crates/horizon-client/examples/trading_fixture.rs +++ b/crates/horizon-client/examples/probe/trading_fixture.rs @@ -231,8 +231,8 @@ fn prepare(m: &mut Merchant, gossips: &mut Gossips, kv: &HashMap } } -fn main() -> horizon_client::Result<()> { - let args: Vec = std::env::args().collect(); +pub fn main() -> horizon_client::Result<()> { + let args: Vec = crate::args().collect(); let usage = "usage: trading_fixture RESOURCES INPUT VANILLA_OUTPUT OUTPUT"; let root = Path::new(args.get(1).ok_or(usage)?); let input = fs::read_to_string(args.get(2).ok_or(usage)?)?; diff --git a/crates/horizon-client/examples/translucency_fixture.rs b/crates/horizon-client/examples/probe/translucency_fixture.rs similarity index 93% rename from crates/horizon-client/examples/translucency_fixture.rs rename to crates/horizon-client/examples/probe/translucency_fixture.rs index 11083d6b2..8ea42c1dc 100644 --- a/crates/horizon-client/examples/translucency_fixture.rs +++ b/crates/horizon-client/examples/probe/translucency_fixture.rs @@ -14,8 +14,8 @@ struct Case { cameras: Vec<[f64; 3]>, } -fn main() -> Result<(), Box> { - let args: Vec<_> = std::env::args().skip(1).collect(); +pub fn main() -> Result<(), Box> { + let args: Vec<_> = crate::args().skip(1).collect(); let [input, output] = args.as_slice() else { return Err("usage: translucency_fixture INPUT OUTPUT".into()); }; diff --git a/crates/horizon-client/examples/weather_fixture.rs b/crates/horizon-client/examples/probe/weather_fixture.rs similarity index 95% rename from crates/horizon-client/examples/weather_fixture.rs rename to crates/horizon-client/examples/probe/weather_fixture.rs index 3cf6c31be..b85dd3e09 100644 --- a/crates/horizon-client/examples/weather_fixture.rs +++ b/crates/horizon-client/examples/probe/weather_fixture.rs @@ -8,8 +8,8 @@ fn bits(value: f32) -> String { format!("{:x}", value.to_bits()) } } -fn main() -> Result<(), Box> { - let args: Vec<_> = std::env::args().collect(); +pub fn main() -> Result<(), Box> { + let args: Vec<_> = crate::args().collect(); let mut output = String::new(); let mut parameters = weather::ParameterCache::default(); for (case, line) in fs::read_to_string(&args[1])?.lines().enumerate() { diff --git a/crates/horizon-client/examples/world_border_render_fixture.rs b/crates/horizon-client/examples/probe/world_border_render_fixture.rs similarity index 98% rename from crates/horizon-client/examples/world_border_render_fixture.rs rename to crates/horizon-client/examples/probe/world_border_render_fixture.rs index 1de15eeeb..535118959 100644 --- a/crates/horizon-client/examples/world_border_render_fixture.rs +++ b/crates/horizon-client/examples/probe/world_border_render_fixture.rs @@ -24,8 +24,8 @@ fn doubles(v: &[f64]) -> Value { v.iter().map(|f| f.to_bits() as i64).collect() } -fn main() -> Result<()> { - let args: Vec = std::env::args().skip(1).collect(); +pub fn main() -> Result<()> { + let args: Vec = crate::args().skip(1).collect(); let [inputs, output] = args.as_slice() else { return Err("usage: world_border_render_fixture INPUTS OUTPUT".into()); }; diff --git a/crates/horizon-client/examples/world_options_fixture.rs b/crates/horizon-client/examples/probe/world_options_fixture.rs similarity index 93% rename from crates/horizon-client/examples/world_options_fixture.rs rename to crates/horizon-client/examples/probe/world_options_fixture.rs index 5bbf9f1c7..5bd3026bc 100644 --- a/crates/horizon-client/examples/world_options_fixture.rs +++ b/crates/horizon-client/examples/probe/world_options_fixture.rs @@ -2,8 +2,8 @@ use horizon_protocol::{buf::Reader, packets::play::*}; use std::{error::Error, fmt::Write}; -fn main() -> Result<(), Box> { - let args: Vec = std::env::args().collect(); +pub fn main() -> Result<(), Box> { + let args: Vec = crate::args().collect(); let mut output = String::new(); for line in std::fs::read_to_string(&args[1])?.lines() { let fields: Vec<&str> = line.split('\t').collect(); diff --git a/docs/parity-workflow.md b/docs/parity-workflow.md index a9a453baf..a2cd10584 100644 --- a/docs/parity-workflow.md +++ b/docs/parity-workflow.md @@ -26,7 +26,7 @@ Vanilla oracle runs are reused as well. `tools/parity_shim.py` stands in for `ja Probes build into `.local/parity-target/` with release optimisation but no LTO and 16 codegen units. On ludodesktop that rebuilds every `horizon-world` probe in 3 seconds after a one-line change, against 122 seconds with the release profile. Rust gives these settings identical results (no fast-math; overflow checks as in release), and the full harness suite passes under them. Probes that harnesses build in the dev profile get `opt-level = 3` too, keeping their overflow checks and debug assertions. Harnesses must locate binaries through `cargo metadata` or `lab.cargo_target()`, never a hard-coded `target/`. -The `horizon-world` probes are one binary, `cargo build --release -p horizon-world --example probe`: a harness runs `probe [arguments]`, and `` is a module in `crates/horizon-world/examples/probe/` (add it to the `mod` list and the `probes!` list in its `main.rs`; read arguments with `crate::args()`, which drops the name). Code several probes share goes in `examples/probe/support/`. Linking one binary instead of ~170 examples is most of what a probe build used to cost. The runner counts only the probes a harness ran, the probes and support modules they name and `dispatch.rs` as its dependencies, not `main.rs`, which only lists the probes: editing one probe reruns only its harnesses, and adding one reruns none. +The probes of `horizon-world` and of `horizon-client` are one binary per crate, `cargo build --release -p --example probe`: a harness runs `probe [arguments]`, and `` is a module in `crates//examples/probe/` (add it to the `mod` list and the `probes!` list in its `main.rs`; read arguments with `crate::args()` or `crate::args_os()`, which drop the name). Code several probes share goes in `examples/probe/support/` or a module of its own. Linking one binary instead of ~250 examples is most of what a probe build used to cost. The runner counts only the probes a harness ran, the probes and support modules they name, their own subdirectories and `dispatch.rs` as its dependencies, not `main.rs`, which only lists the probes: editing one probe reruns only its harnesses, and adding one reruns none. Passes are shared between worktrees. A harness's key depends only on the content of its dependencies, not on where they are, so every pass is also written to `parity-shared/` beside the shared vanilla data (`PARITY_SHARED` overrides it). A worktree whose files match those a harness passed with, in any worktree, counts that pass without running the harness: after merging the integration branch, an agent's gate only runs the harnesses its own changes affect. diff --git a/docs/parity/meshing.md b/docs/parity/meshing.md index 5b746e76c..bcd1cbc6a 100644 --- a/docs/parity/meshing.md +++ b/docs/parity/meshing.md @@ -20,7 +20,7 @@ emit for the same scenes. `FluidRenderer.tesselate`, then `RenderShape.MODEL` blocks through `ModelBlockRenderer.tesselateBlock` with smooth lighting on, culling on, cutout leaves, `BlockColors.createDefault()` and `state.getSeed(pos)`. -- **Horizon side**: `crates/horizon-client/examples/section_mesh_fixture.rs` +- **Horizon side**: `crates/horizon-client/examples/probe/section_mesh_fixture.rs` loads the prepared resources (`Assets`, `BlockFacts`, `Biomes`, `load_visibility`, `MeshTables`), builds the same blocks and light in real client `Chunk`s (a 3x3 chunk region), sets every biome's colours to the diff --git a/docs/rust-parity.md b/docs/rust-parity.md index fee801463..98bff8f82 100644 --- a/docs/rust-parity.md +++ b/docs/rust-parity.md @@ -1471,7 +1471,7 @@ the `hp` text when they no longer fit; and the header and footer wrapped by the list in single player unless a `list` objective is set. `tools/test_tab_list_parity.py` runs vanilla's own `extractRenderState` frame after frame (`VanillaTabListOracle`: stand-in connection, level and options, -real `Scoreboard`) against `examples/tab_list_fixture` and compares every fill, +real `Scoreboard`) against `examples/probe/tab_list_fixture.rs` and compares every fill, styled text run, sprite and face blit (as `hud_layout::GuiDraw` calls, painted like the rest of the HUD): **1,000 cases, 3,476 frames and 844,758 calls match**. The game draws the same layout while the player-list key is @@ -1492,7 +1492,7 @@ nearest first. `WorldBorder::warning_strength` feeds `hud_overlays::vignette` the border's warning strength at the camera. `tools/test_world_border_render_parity.py` drives vanilla's border, renderer and vignette (`VanillaWorldBorderRenderOracle`, with a stand-in GPU device, dynamic-uniform writer and render pass) against -`examples/world_border_render_fixture`: **1,500 cases and 16,859 frames match +`examples/probe/world_border_render_fixture.rs`: **1,500 cases and 16,859 frames match bit for bit** (8,513 with the wall drawn). The game draws the wall with `RenderPipelines.WORLD_BORDER`'s overlay blend and the mipmapped forcefield texture, and follows the server's border packets. One border is kept for all diff --git a/tools/audio_harness.py b/tools/audio_harness.py index 6a26f2d44..1d5908fe0 100644 --- a/tools/audio_harness.py +++ b/tools/audio_harness.py @@ -37,7 +37,7 @@ def require_sounds(): def run_harness(name, oracle, example, inputs_text, extra_sources=(), java_args=(), rust_args=(), scope='', timeout=1800): - """Run oracle and example on inputs; returns the number of matched lines.""" + """Run oracle and the client probe `example` on inputs; returns the number of matched lines.""" require_sounds() lock, jars, _ = base.verify_artifacts() libraries = baking.client_libraries() @@ -46,7 +46,7 @@ def run_harness(name, oracle, example, inputs_text, extra_sources=(), java_args= report = build / 'report.json' report.unlink(missing_ok=True) oracle_path = lab.ROOT / f'mods/horizon/src/test/java/dev/horizonlab/parity/{oracle}.java' - example_path = lab.ROOT / f'crates/horizon-client/examples/{example}.rs' + example_path = lab.ROOT / f'crates/horizon-client/examples/probe/{example}.rs' sources = [*COMMON_SOURCES, oracle_path, example_path, *[Path(s) for s in extra_sources]] tested = base.source_hashes(sources) inputs = build / 'inputs.txt' @@ -65,10 +65,10 @@ def run_harness(name, oracle, example, inputs_text, extra_sources=(), java_args= dependencies = os.pathsep.join(map(str, [jars['client'], *libraries])) run(['javac', '--release', lock['minecraft']['java_major'], '-proc:none', '-sourcepath', lab.ROOT / 'mods/horizon/src/test/java', '-cp', dependencies, '-d', classes, oracle_path], 'compile-java') - run(['cargo', 'build', '--locked', '-p', 'horizon-client', '--example', example], 'compile-rust') + run(['cargo', 'build', '--locked', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--locked', '--no-deps', '--format-version', '1'], cwd=lab.ROOT)) - binary = Path(metadata['target_directory']) / 'debug/examples' / (example + ('.exe' if os.name == 'nt' else '')) - run([binary, *rust_args, inputs, build / 'rust.txt'], 'rust') + binary = Path(metadata['target_directory']) / 'debug/examples' / ('probe.exe' if os.name == 'nt' else 'probe') + run([binary, example, *rust_args, inputs, build / 'rust.txt'], 'rust') env = dict(os.environ, ALSOFT_DRIVERS='null') run(['java', '-Xmx1G', '-cp', str(classes) + os.pathsep + dependencies, f'dev.horizonlab.parity.{oracle}', *java_args, inputs, build / 'client.txt'], 'client', env=env) diff --git a/tools/interaction_lab.py b/tools/interaction_lab.py index 0851b6d06..bc574b73d 100644 --- a/tools/interaction_lab.py +++ b/tools/interaction_lab.py @@ -50,7 +50,7 @@ def cargo_example(package, example, *args, profile=None): command = ['cargo', 'run', '-q', '-j3'] if profile: command += ['--profile', profile] - command += ['-p', package, '--example', example, '--', *map(str, args)] + command += ['-p', package, '--example', 'probe', '--', example, *map(str, args)] subprocess.run(command, check=True, cwd=lab.ROOT) diff --git a/tools/oracle_harness.py b/tools/oracle_harness.py index a19b5ba94..c6f45553f 100644 --- a/tools/oracle_harness.py +++ b/tools/oracle_harness.py @@ -31,12 +31,13 @@ def compile_oracle(build, oracle_name, jars, libraries, java_major): def build_probe(build, example): - run_logged(['cargo', 'build', '--locked', '-p', 'horizon-client', '--example', example], + """Build the horizon-client probe binary; returns the command that runs probe `example`.""" + run_logged(['cargo', 'build', '--locked', '-p', 'horizon-client', '--example', 'probe'], build, 'compile-rust-' + example, env=dict(os.environ, CARGO_BUILD_JOBS='3')) import json metadata = json.loads(subprocess.check_output( ['cargo', 'metadata', '--locked', '--no-deps', '--format-version', '1'], cwd=lab.ROOT)) - return Path(metadata['target_directory']) / 'debug/examples' / example + return [Path(metadata['target_directory']) / 'debug/examples/probe', example] def java_run(build, classes, dependencies, main_class, args, name, jvm=()): @@ -64,13 +65,13 @@ def differential(name, oracle, probe, make_input, scope, sources=(), expected_li all_sources = [Path(__file__).resolve(), lab.ROOT / 'tools/oracle_harness.py', lab.ROOT / 'tools/test_rust_parity.py', lab.ROOT / 'tools/lab.py', oracle_path, lab.ROOT / 'Cargo.toml', lab.ROOT / 'Cargo.lock', lab.ROOT / 'crates/horizon-client/Cargo.toml', lab.ROOT / 'crates/horizon-client/src/lib.rs', - lab.ROOT / f'crates/horizon-client/examples/{probe}.rs', *map(Path, sources)] + lab.ROOT / f'crates/horizon-client/examples/probe/{probe}.rs', *map(Path, sources)] tested = base.source_hashes(all_sources) input_path, units = make_input(build) input_hash = lab.digest(input_path, 'sha256') if input_path.is_file() else None classes, dependencies, _ = compile_oracle(build, oracle, jars, libraries, lock['minecraft']['java_major']) - binary = build_probe(build, probe) - run_logged([binary, input_path, build / 'rust.txt'], build, 'rust') + command = build_probe(build, probe) + run_logged([*command, input_path, build / 'rust.txt'], build, 'rust') java_run(build, classes, dependencies, oracle, [input_path, build / 'client.txt'], 'client') try: matched = base.compare(build / 'client.txt', build / 'rust.txt') diff --git a/tools/port_regen.py b/tools/port_regen.py index be2d31843..c47e7cc35 100644 --- a/tools/port_regen.py +++ b/tools/port_regen.py @@ -229,10 +229,10 @@ def gen_vanilla_order(root, version, store, build): "dev.horizonlab.parity.VanillaCommandParseOracle", "tree", build], build) env = dict(os.environ, CARGO_TARGET_DIR=str(root / ".local" / "port-target")) jobs = os.environ.get("FLEET_LOAD_JOBS") - run(["cargo", "build", "-p", "horizon-client", "--example", "command_parse_fixture", + run(["cargo", "build", "-p", "horizon-client", "--example", "probe", *(["-j", jobs] if jobs else [])], root, env=env) - fixture = root / ".local/port-target/debug/examples/command_parse_fixture" - run([fixture, "tree", build / "rust_tree.json"], root) + fixture = root / ".local/port-target/debug/examples/probe" + run([fixture, "command_parse_fixture", "tree", build / "rust_tree.json"], root) return [python(), "tools/generate_command_order.py", build / "tree.json", build / "rust_tree.json"] diff --git a/tools/test_ambient_sound_parity.py b/tools/test_ambient_sound_parity.py index 85cfb20e1..7e272fa94 100644 --- a/tools/test_ambient_sound_parity.py +++ b/tools/test_ambient_sound_parity.py @@ -177,7 +177,7 @@ def main(): 'ambient', 'VanillaAmbientOracle', 'ambient_fixture', ''.join(l + '\n' for l in lines), extra_sources=[h.lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaSoundRig.java', h.lab.ROOT / 'crates/horizon-client/src/ambience.rs', - h.lab.ROOT / 'crates/horizon-client/examples/audio_common/mod.rs'], + h.lab.ROOT / 'crates/horizon-client/examples/probe/audio_common/mod.rs'], java_args=[h.RESOURCES], rust_args=[h.RESOURCES], scope='Real LocalPlayer.updateIsUnderwater, UnderwaterAmbientSoundHandler and BiomeAmbientSoundsHandler (loop cross-fades, additions, ' 'cave mood sampling, moodiness and the mood sound position) with UnderLiquidAmbientSoundInstance/UnderLiquidSubSound/LoopSoundInstance ' diff --git a/tools/test_arrow_parity.py b/tools/test_arrow_parity.py index 0daa2e311..72692eb55 100644 --- a/tools/test_arrow_parity.py +++ b/tools/test_arrow_parity.py @@ -3,7 +3,7 @@ Real vanilla `Arrow` entities tick in an independently built copy of the scene (`VanillaArrowOracle`, client and server jars); Horizon's -`arrows::tick` runs over the scene itself (`examples/arrow_probe.rs`). Every +`arrows::tick` runs over the scene itself (`examples/probe/arrow_probe.rs`). Every operation prints the arrow's position, motion, rotation, ground state, life, shake, stuck block, fire ticks, water flags, fluid heights, removal, crit flag, fall distance and old position (what rendering interpolates from) by exact @@ -224,7 +224,7 @@ def main(): 'VanillaHeightmapOracle', 'VanillaCollisionOracle', 'VanillaBlockStateCodecOracle', 'VanillaSuffocationOracle', 'VanillaFaceSupportOracle', 'VanillaEntityAttributeOracle', 'VanillaBlockLandingOracle', 'VanillaMovementRegistryOracle', 'VanillaDamageSourceOracle']] sources = [Path(__file__), lab.ROOT / 'tools/test_native_client.py', lab.ROOT / 'tools/test_rust_parity.py', lab.ROOT / 'tools/lab.py', - oracle, *helpers, lab.ROOT / 'Cargo.toml', lab.ROOT / 'Cargo.lock', lab.ROOT / 'crates/horizon-client/examples/arrow_probe.rs'] + oracle, *helpers, lab.ROOT / 'Cargo.toml', lab.ROOT / 'Cargo.lock', lab.ROOT / 'crates/horizon-client/examples/probe/arrow_probe.rs'] for crate in ['horizon-core', 'horizon-world', 'horizon-assets', 'horizon-client']: sources += [lab.ROOT / 'crates' / crate / 'Cargo.toml', *sorted((lab.ROOT / 'crates' / crate / 'src').rglob('*.rs'))] tested = base.source_hashes(sources) @@ -241,15 +241,15 @@ def main(): expected = 3 * operations + len(fixtures) (build / 'inputs.txt').write_text(''.join(json.dumps(f, separators=(',', ':')) + '\n' for f in fixtures)) input_hash = lab.digest(build / 'inputs.txt', 'sha256') - run(['cargo', 'build', '--locked', '-p', 'horizon-client', '--example', 'arrow_probe'], 'compile-rust') + run(['cargo', 'build', '--locked', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--locked', '--no-deps', '--format-version', '1'], cwd=lab.ROOT)) - binary = Path(metadata['target_directory']) / 'debug/examples' / ('arrow_probe.exe' if os.name == 'nt' else 'arrow_probe') - run([binary, resources, build, '--describe'], 'describe') + binary = Path(metadata['target_directory']) / 'debug/examples' / ('probe.exe' if os.name=='nt' else 'probe') + run([binary, 'arrow_probe',resources, build, '--describe'], 'describe') references = [] for side, jar in jars.items(): run(['java', '-Xmx768M', '-cp', os.pathsep.join([str(classes), str(jar), dependencies]), 'dev.horizonlab.parity.VanillaArrowOracle', side, build, resources], side) - run([binary, resources, build, side], 'rust-' + side) + run([binary, 'arrow_probe',resources, build, side], 'rust-' + side) matched = base.compare(build / (side + '.txt'), build / ('rust-' + side + '.txt')) if matched != expected: raise AssertionError('Incomplete arrow output') diff --git a/tools/test_auto_jump_parity.py b/tools/test_auto_jump_parity.py index 3e9da7d5a..348bbdbc8 100644 --- a/tools/test_auto_jump_parity.py +++ b/tools/test_auto_jump_parity.py @@ -115,7 +115,7 @@ def main(): sources = [Path(__file__).resolve(), lab.ROOT / 'tools/oracle_harness.py', lab.ROOT / 'tools/lab.py', parity / (oracle + '.java'), parity / 'VanillaSceneCollisionOracle.java', parity / 'VanillaRegistryCollisionScanOracle.java', lab.ROOT / 'Cargo.lock', - lab.ROOT / 'crates/horizon-client/examples/auto_jump_probe.rs', + lab.ROOT / 'crates/horizon-client/examples/probe/auto_jump_probe.rs', lab.ROOT / 'crates/horizon-client/src/auto_jump.rs', lab.ROOT / 'crates/horizon-client/src/motion.rs'] tested = base.source_hashes(sources) fixtures = list(cases(random.Random(0x4155544f))) @@ -123,8 +123,8 @@ def main(): inputs.write_text(''.join(json.dumps(f, separators=(',', ':')) + '\n' for f in fixtures)) input_hash = lab.digest(inputs, 'sha256') classes, dependencies, _ = harness.compile_oracle(build, oracle, jars, libraries, lock['minecraft']['java_major']) - binary = harness.build_probe(build, 'auto_jump_probe') - harness.run_logged([binary, resources, inputs, build / 'rust.txt', build / 'scene.json'], build, 'rust', timeout=3600) + command = harness.build_probe(build, 'auto_jump_probe') + harness.run_logged([*command, resources, inputs, build / 'rust.txt', build / 'scene.json'], build, 'rust', timeout=3600) harness.java_run(build, classes, dependencies, oracle, [inputs, build / 'client.txt', resources, build / 'scene.json'], 'client') matched = harness.compare(build / 'client.txt', build / 'rust.txt', 2 * len(fixtures)) base.ensure_sources_unchanged(sources, tested) diff --git a/tools/test_block_entity_anim_parity.py b/tools/test_block_entity_anim_parity.py index 8935afef4..b0c462aee 100755 --- a/tools/test_block_entity_anim_parity.py +++ b/tools/test_block_entity_anim_parity.py @@ -9,7 +9,7 @@ on a stand-in client level, then per scripted step applies the block event (triggerEvent), runs the entity's own client ticker and the renderer's extractRenderState, printing the fields, the level calls the tick made (neighbour updates, entity pushes/queries, sounds, particles) and the render -state. `examples/block_entity_anim_fixture` replays the steps through +state. `examples/probe/block_entity_anim_fixture` replays the steps through `horizon_client::block_entity_anim` and derives the render state from the `BlockAnim` Horizon's renderer reads. Lines must match exactly (floats as bits). @@ -279,8 +279,8 @@ def main(): *(PARITY / f'{n}.java' for n in ('ParityData', 'VanillaBlockEntityAnimOracle'))], 'compile-java') run(['java', '-Xmx2G', '-cp', str(classes) + os.pathsep + dependencies, 'dev.horizonlab.parity.VanillaBlockEntityAnimOracle', inputs, build / 'vanilla.txt'], 'vanilla') - run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'block_entity_anim_fixture', '--', - resources, inputs, build / 'rust.txt'], 'rust') + run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'probe', '--', + 'block_entity_anim_fixture', resources, inputs, build / 'rust.txt'], 'rust') def split(path): result, current = {}, None diff --git a/tools/test_block_entity_render_parity.py b/tools/test_block_entity_render_parity.py index 3c096bdcc..901f4300f 100644 --- a/tools/test_block_entity_render_parity.py +++ b/tools/test_block_entity_render_parity.py @@ -5,7 +5,7 @@ The Java oracle (VanillaBlockEntityRenderOracle) builds each case's vanilla block entity, sets its animation fields, runs the real BlockEntityRenderer's extractRenderState and submit, and captures what it submits: model vertices after setupAnim and the pose stack (sprite-local UVs, tint, normal, light), -text calls and items. `examples/block_entity_render_fixture` replays the case +text calls and items. `examples/probe/block_entity_render_fixture` replays the case through Horizon's BlockEntityRenderer. Quads are matched by texture and position; colours compare vanilla's tint times the entity shader's `minecraft_mix_light` for the vanilla normal with Horizon's baked colour. @@ -303,8 +303,8 @@ def main(): vanilla = [json.loads(l) for l in (build / 'vanilla.jsonl').read_text().splitlines()] textures = sorted({s['texture'] for v in vanilla for s in v.get('submits', []) if 'texture' in s}) (build / 'textures.txt').write_text(''.join(t + '\n' for t in textures)) - run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'block_entity_render_fixture', '--', - resources, inputs, build / 'textures.txt', build / 'rust.jsonl'], 'rust') + run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'probe', '--', + 'block_entity_render_fixture', resources, inputs, build / 'textures.txt', build / 'rust.jsonl'], 'rust') rust = [json.loads(l) for l in (build / 'rust.jsonl').read_text().splitlines()] assert len(vanilla) == len(rust), (len(vanilla), len(rust)) groups, errors, skipped, passed = {}, {}, {}, 0 diff --git a/tools/test_block_entity_tickers_parity.py b/tools/test_block_entity_tickers_parity.py index 459e7a926..66a84cf48 100644 --- a/tools/test_block_entity_tickers_parity.py +++ b/tools/test_block_entity_tickers_parity.py @@ -6,7 +6,7 @@ one chunk to make its block entity map grow), place, replace and remove block entities, give jukeboxes a record and take it, and unload chunks, with ticks in between. `VanillaBlockEntityTickerOracle` runs them on real `LevelChunk`s of a server level and prints, after each tick, the positions of the live -tickers in list order; `examples/block_entity_tickers_fixture` runs the same +tickers in list order; `examples/probe/block_entity_tickers_fixture` runs the same on `horizon_client::block_entities::BlockEntities`. The block entities are the kinds the game ticks in that list (hoppers, furnaces, beacons, spawners, trial spawners, vaults, hives, crafters, brewing stands, jukebox), with chests and barrels, @@ -120,7 +120,7 @@ def main(): run(['java', '-Xmx1G', '-cp', str(classes) + os.pathsep + dependencies, 'dev.horizonlab.parity.VanillaBlockEntityTickerOracle', inputs, build / 'vanilla.txt'], 'vanilla') run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', - 'block_entity_tickers_fixture', '--', inputs, build / 'rust.txt'], 'rust') + 'probe', '--', 'block_entity_tickers_fixture', inputs, build / 'rust.txt'], 'rust') matched = base.compare(build / 'vanilla.txt', build / 'rust.txt') ticks = sum(1 for line in lines if line == 'tick') listed = sum(len(line.split()) - 1 for line in (build / 'vanilla.txt').read_text().splitlines()) diff --git a/tools/test_block_particles_parity.py b/tools/test_block_particles_parity.py index 3f0f0f99c..7e08e98f8 100644 --- a/tools/test_block_particles_parity.py +++ b/tools/test_block_particles_parity.py @@ -13,7 +13,7 @@ def main(): resources = lab.RESOURCES build = lab.LOCAL / "block-particles-parity" build.mkdir(exist_ok=True) - paths = [lab.ROOT / p for p in ["tools/test_block_particles_parity.py", "tools/test_breaking_model_parity.py", "tools/oracle_harness.py", "tools/lab.py", "crates/horizon-client/src/particles.rs", "crates/horizon-client/src/game.rs", "crates/horizon-client/src/blocks.rs", "crates/horizon-client/src/mesher.rs", "crates/horizon-client/examples/block_particles_fixture.rs", "mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBlockParticlesOracle.java", "crates/horizon-core/src/random.rs", "Cargo.lock", "mods/horizon/src/test/java/dev/horizonlab/parity/VanillaGameplayFactsExporter.java"]] + paths = [lab.ROOT / p for p in ["tools/test_block_particles_parity.py", "tools/test_breaking_model_parity.py", "tools/oracle_harness.py", "tools/lab.py", "crates/horizon-client/src/particles.rs", "crates/horizon-client/src/game.rs", "crates/horizon-client/src/blocks.rs", "crates/horizon-client/src/mesher.rs", "crates/horizon-client/examples/probe/block_particles_fixture.rs", "mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBlockParticlesOracle.java", "crates/horizon-core/src/random.rs", "Cargo.lock", "mods/horizon/src/test/java/dev/horizonlab/parity/VanillaGameplayFactsExporter.java"]] tested = base.source_hashes(paths) rows = [dict(case=i, seed=(-1 if i % 2 else 1) * i * 987654321, **row) for i, row in enumerate(breaking.cases(resources))] rows[0]["seed"] = -(2**63) @@ -21,8 +21,8 @@ def main(): inputs = build / "inputs.jsonl" inputs.write_text("".join(json.dumps(row)+"\n" for row in rows)) classes, dependencies, _ = harness.compile_oracle(build, "VanillaBlockParticlesOracle", jars, baking.client_libraries(), lock["minecraft"]["java_major"]) - binary = harness.build_probe(build, "block_particles_fixture") - harness.run_logged([binary, resources, inputs, build / "rust.jsonl"], build, "rust") + command = harness.build_probe(build, "block_particles_fixture") + harness.run_logged([*command, resources, inputs, build / "rust.jsonl"], build, "rust") harness.java_run(build, classes, dependencies, "VanillaBlockParticlesOracle", [inputs, build / "client.jsonl"], "client") count = hits = burst = 0 max_error = 0.0 diff --git a/tools/test_breaking_model_parity.py b/tools/test_breaking_model_parity.py index 92b74d582..272e57dea 100644 --- a/tools/test_breaking_model_parity.py +++ b/tools/test_breaking_model_parity.py @@ -29,13 +29,13 @@ def canonical(quads): def main(): lock,jars,_=base.verify_artifacts();libraries=baking.client_libraries() resources=lab.RESOURCES;build=lab.LOCAL/"breaking-model-parity";build.mkdir(exist_ok=True) - paths=[lab.ROOT/"tools/test_breaking_model_parity.py",lab.ROOT/"crates/horizon-client/src/breaking.rs",lab.ROOT/"crates/horizon-client/src/game.rs",lab.ROOT/"crates/horizon-client/src/gfx.rs",lab.ROOT/"crates/horizon-client/src/entity.wgsl",lab.ROOT/"crates/horizon-client/src/models/catalog.rs",lab.ROOT/"crates/horizon-client/src/mesher.rs",lab.ROOT/"crates/horizon-client/src/camera.rs",lab.ROOT/"crates/horizon-client/examples/breaking_fixture.rs",lab.ROOT/"mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBreakingModelOracle.java",lab.ROOT/"mods/horizon/src/test/java/dev/horizonlab/parity/VanillaSectionMeshOracle.java",lab.ROOT/"Cargo.lock"] + paths=[lab.ROOT/"tools/test_breaking_model_parity.py",lab.ROOT/"crates/horizon-client/src/breaking.rs",lab.ROOT/"crates/horizon-client/src/game.rs",lab.ROOT/"crates/horizon-client/src/gfx.rs",lab.ROOT/"crates/horizon-client/src/entity.wgsl",lab.ROOT/"crates/horizon-client/src/models/catalog.rs",lab.ROOT/"crates/horizon-client/src/mesher.rs",lab.ROOT/"crates/horizon-client/src/camera.rs",lab.ROOT/"crates/horizon-client/examples/probe/breaking_fixture.rs",lab.ROOT/"mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBreakingModelOracle.java",lab.ROOT/"mods/horizon/src/test/java/dev/horizonlab/parity/VanillaSectionMeshOracle.java",lab.ROOT/"Cargo.lock"] tested=base.source_hashes(paths) rows=[dict(case=i,**row) for i,row in enumerate(cases(resources))] inputs=build/"inputs.jsonl";inputs.write_text("".join(json.dumps(row)+"\n" for row in rows)) classes,dependencies,_=harness.compile_oracle(build,"VanillaBreakingModelOracle",jars,libraries,lock["minecraft"]["java_major"]) - binary=harness.build_probe(build,"breaking_fixture") - harness.run_logged([binary,resources,inputs,build/"rust.jsonl"],build,"rust") + command=harness.build_probe(build,"breaking_fixture") + harness.run_logged([*command,resources,inputs,build/"rust.jsonl"],build,"rust") harness.java_run(build,classes,dependencies,"VanillaBreakingModelOracle",[inputs,build/"client.jsonl"],"client") count=vertices=0;max_error=0.0 with (build/"client.jsonl").open() as native, (build/"rust.jsonl").open() as rust: diff --git a/tools/test_chat_screen_parity.py b/tools/test_chat_screen_parity.py index 1447ebaa6..fead1b5cb 100644 --- a/tools/test_chat_screen_parity.py +++ b/tools/test_chat_screen_parity.py @@ -8,7 +8,7 @@ all, history up and down, Tab and Shift+Tab through suggestions, Escape) and clicks (on the suggestion list, on the input). The Java oracle (VanillaChatScreenOracle) drives a real ChatScreen, whose CommandSuggestions parse with vanilla's client command tree and ask the server's dispatcher -for the suggestions a node leaves to it; examples/chat_screen_fixture runs +for the suggestions a node leaves to it; examples/probe/chat_screen_fixture runs horizon_client::chat::ChatScreen on Horizon's dispatcher. After the actions the input's value, cursor, selection and scroll and the screen's GUI calls (the input background, the EditBox with its argument colouring, cursor, diff --git a/tools/test_command_parse_parity.py b/tools/test_command_parse_parity.py index 192cc5b9f..c43e66b54 100644 --- a/tools/test_command_parse_parity.py +++ b/tools/test_command_parse_parity.py @@ -64,9 +64,9 @@ def main(): registries = json.loads((build / 'registries.json').read_text()) corpus = corpus_module.corpus(tree, registries) (build / 'corpus.txt').write_text(''.join(line + '\n' for line in corpus), encoding='utf-8') - run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'command_parse_fixture'], 'compile-rust') + run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--no-deps', '--format-version', '1'], cwd=lab.ROOT, text=True)) - binary = Path(metadata['target_directory']) / 'release/examples' / ('command_parse_fixture.exe' if os.name == 'nt' else 'command_parse_fixture') + binary = Path(metadata['target_directory']) / 'release/examples' / ('probe.exe' if os.name=='nt' else 'probe') resources = lab.RESOURCES total_failures = 0 summary = [] @@ -79,7 +79,7 @@ def main(): if not (stamp.exists() and stamp.read_text() == digest and (level_dir / 'vanilla.jsonl').exists()): java('run', str(level_dir), str(build / 'corpus.txt'), str(permission)) stamp.write_text(digest) - run([binary, resources, build / 'registries.json', build / 'corpus.txt', str(permission), level_dir / 'rust.jsonl'], f'rust{permission}') + run([binary, 'command_parse_fixture',resources, build / 'registries.json', build / 'corpus.txt', str(permission), level_dir / 'rust.jsonl'], f'rust{permission}') failures = compare(level_dir / 'vanilla.jsonl', level_dir / 'rust.jsonl', args.limit) count = sum(1 for _ in (level_dir / 'vanilla.jsonl').open()) print(f'permission {permission}: {count - failures}/{count} commands match', flush=True) diff --git a/tools/test_creative_parity.py b/tools/test_creative_parity.py index aa23cbbc9..6a96d3c52 100644 --- a/tools/test_creative_parity.py +++ b/tools/test_creative_parity.py @@ -7,7 +7,7 @@ tab built by vanilla's CreativeModeTabs over the vanilla data pack's registries), then what the vanilla client shows: every tab's display items and, for each search query, CreativeModeInventoryScreen.refreshSearchResults' items, searched through the client's own SessionSearchTrees. -examples/creative_search_fixture loads the export into +examples/probe/creative_search_fixture loads the export into horizon_client::creative::Creative. The tabs it shows (id, title, icon, position, every stack with its components), the search tab's stacks and the results of every query must agree. The queries are QUERIES below, then every diff --git a/tools/test_enchanting_parity.py b/tools/test_enchanting_parity.py index 4b5c975d0..9f5f5647f 100644 --- a/tools/test_enchanting_parity.py +++ b/tools/test_enchanting_parity.py @@ -42,7 +42,7 @@ def main(): catalog = json.loads((resources / 'items.json').read_text()) items = sorted(k for k, v in catalog.items() if 'minecraft:enchantable' in v) oracle = lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaEnchantingOracle.java' - sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/enchanting_fixture.rs', + sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/probe/enchanting_fixture.rs', *sorted((lab.ROOT / 'crates/horizon-client/src').glob('*.rs'))] tested = base.source_hashes(sources) inputs = build / 'inputs.txt' @@ -56,10 +56,10 @@ def main(): with (build / (name + '.log')).open('w', encoding='utf-8') as log: base.run(list(map(str, command)), stdout=log, stderr=subprocess.STDOUT) run(['javac', '--release', lock['minecraft']['java_major'], '-proc:none','-sourcepath',str(lab.ROOT/'mods/horizon/src/test/java'), '-cp', str(jars['server']) + os.pathsep + deps, '-d', classes, oracle], 'compile-java') - run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'enchanting_fixture'], 'compile-rust') + run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--no-deps', '--format-version', '1'], cwd=lab.ROOT, text=True)) - binary = Path(metadata['target_directory']) / 'release/examples' / ('enchanting_fixture.exe' if os.name == 'nt' else 'enchanting_fixture') - run([binary, resources, inputs, build / 'rust.txt'], 'rust') + binary = Path(metadata['target_directory']) / 'release/examples' / ('probe.exe' if os.name=='nt' else 'probe') + run([binary, 'enchanting_fixture',resources, inputs, build / 'rust.txt'], 'rust') references = [] for side in ['server']: run(['java', '-Xmx1G', '-cp', os.pathsep.join([str(classes), str(jars[side]), deps]), 'dev.horizonlab.parity.VanillaEnchantingOracle', inputs, build / f'{side}.txt'], side) diff --git a/tools/test_entity_death_loot_parity.py b/tools/test_entity_death_loot_parity.py index 000a2ea6f..b0f77cbfd 100644 --- a/tools/test_entity_death_loot_parity.py +++ b/tools/test_entity_death_loot_parity.py @@ -122,7 +122,7 @@ def main(): tables = resources / 'data/minecraft/loot_table/entities' types = sorted('minecraft:' + p.stem for p in tables.glob('*.json') if p.stem not in SKIPPED) oracle = lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaEntityDeathLootOracle.java' - sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/entity_death_loot_fixture.rs', + sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/probe/entity_death_loot_fixture.rs', lab.ROOT / 'crates/horizon-client/src/mobs/drops.rs', lab.ROOT / 'crates/horizon-world/src/loot.rs'] tested = base.source_hashes(sources) inputs = build / 'inputs.txt' @@ -139,10 +139,10 @@ def main(): '-cp', str(jars['server']) + os.pathsep + deps, '-d', classes, oracle], 'compile-java') run(['java', '-Xmx2G', '-cp', os.pathsep.join([str(classes), str(jars['server']), deps]), 'dev.horizonlab.parity.VanillaEntityDeathLootOracle', inputs, build / 'server.txt'], 'server') - run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'entity_death_loot_fixture'], 'compile-rust') + run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--no-deps', '--format-version', '1'], cwd=lab.ROOT, text=True)) - binary = Path(metadata['target_directory']) / 'release/examples/entity_death_loot_fixture' - run([binary, resources, inputs, build / 'rust.txt'], 'rust') + binary = Path(metadata['target_directory']) / 'release/examples/probe' + run([binary, 'entity_death_loot_fixture', resources, inputs, build / 'rust.txt'], 'rust') errors = [l for l in (build / 'server.txt').read_text().splitlines() if l.startswith('error ')] if errors: raise SystemExit(f'oracle errors ({len(errors)}): {errors[:5]}') diff --git a/tools/test_entity_model_parity.py b/tools/test_entity_model_parity.py index 37c61b4ac..ba54797fa 100644 --- a/tools/test_entity_model_parity.py +++ b/tools/test_entity_model_parity.py @@ -4,7 +4,7 @@ The Java oracle bakes each vanilla model layer, builds the model's own render state class with the generated walk/age/head/attack inputs (plus per-species state fields), runs the real `setupAnim` and writes every part's pose. -`examples/entity_anim_fixture` replays the same inputs through Horizon's +`examples/probe/entity_anim_fixture` replays the same inputs through Horizon's `mobs::anim::setup` and the loaded model tree; the two must agree on every part pose and on the baked polygon count and vertex sums. @@ -364,8 +364,8 @@ def main(): run(['javac', '--release', lock['minecraft']['java_major'], '-proc:none', '-cp', dependencies, '-d', classes, oracle], 'compile-java') run(['java', '-Xmx1G', '-cp', str(classes) + os.pathsep + dependencies, 'dev.horizonlab.parity.VanillaEntityAnimOracle', inputs, build / 'vanilla.jsonl', jars['client']], 'vanilla') - run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'entity_anim_fixture', '--', - resources, build / 'vanilla.jsonl', build / 'rust.jsonl'], 'rust') + run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'probe', '--', + 'entity_anim_fixture', resources, build / 'vanilla.jsonl', build / 'rust.jsonl'], 'rust') vanilla = [json.loads(l) for l in (build / 'vanilla.jsonl').read_text().splitlines()] rust = [json.loads(l) for l in (build / 'rust.jsonl').read_text().splitlines()] assert len(vanilla) == len(rust), (len(vanilla), len(rust)) diff --git a/tools/test_entity_particles_parity.py b/tools/test_entity_particles_parity.py index 2156f97ec..f34528b4c 100644 --- a/tools/test_entity_particles_parity.py +++ b/tools/test_entity_particles_parity.py @@ -74,13 +74,13 @@ def main(): 'tools/test_entity_particles_parity.py', 'tools/oracle_harness.py', 'tools/test_rust_parity.py', 'tools/lab.py', f'mods/horizon/src/test/java/dev/horizonlab/parity/{oracle}.java', 'Cargo.toml', 'Cargo.lock', 'crates/horizon-client/Cargo.toml', 'crates/horizon-client/src/particles.rs', - f'crates/horizon-client/examples/{probe}.rs', 'crates/horizon-core/src/random.rs']] + f'crates/horizon-client/examples/probe/{probe}.rs', 'crates/horizon-core/src/random.rs']] tested = base.source_hashes(sources) cases_path, units = make_cases(build) classes, dependencies, _ = harness.compile_oracle(build, oracle, jars, baking.client_libraries(), lock['minecraft']['java_major']) - binary = harness.build_probe(build, probe) - harness.run_logged([binary, cases_path, build / 'rust.txt'], build, 'rust') + command = harness.build_probe(build, probe) + harness.run_logged([*command, cases_path, build / 'rust.txt'], build, 'rust') harness.java_run(build, classes, dependencies, oracle, [cases_path, build / 'client.txt'], 'client') vanilla = (build / 'client.txt').read_text().splitlines() rust = (build / 'rust.txt').read_text().splitlines() diff --git a/tools/test_environment_render_parity.py b/tools/test_environment_render_parity.py index 2e14bb356..893a1c70d 100755 --- a/tools/test_environment_render_parity.py +++ b/tools/test_environment_render_parity.py @@ -5,7 +5,7 @@ The Java oracle builds vanilla's `EnvironmentAttributeSystem` from the data pack (dimension attributes, one biome's attributes, the dimension timelines and the weather layers) and prints every visual/gameplay attribute for a grid of dimensions, world times, rain/thunder levels and biomes. -`examples/environment_fixture` samples the same cases through Horizon's +`examples/probe/environment_fixture` samples the same cases through Horizon's `Environment::sample` + `apply_weather`; every attribute Horizon computes must agree with vanilla. @@ -66,8 +66,8 @@ def main(): '-cp', str(jars['server']) + os.pathsep + deps, '-d', classes, oracle], 'compile-java') run(['java', '-Xmx1G', '-cp', os.pathsep.join([str(classes), str(jars['server']), deps]), 'dev.horizonlab.parity.VanillaEnvironmentOracle', inputs, build / 'vanilla.jsonl'], 'vanilla') - run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'environment_fixture', '--', - resources, inputs, build / 'rust.jsonl'], 'rust') + run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'probe', '--', + 'environment_fixture', resources, inputs, build / 'rust.jsonl'], 'rust') vanilla = [json.loads(l) for l in (build / 'vanilla.jsonl').read_text().splitlines()] rust = [json.loads(l) for l in (build / 'rust.jsonl').read_text().splitlines()] assert len(vanilla) == len(rust), (len(vanilla), len(rust)) diff --git a/tools/test_finalize_spawn_parity.py b/tools/test_finalize_spawn_parity.py index 7c995fa83..c3130d380 100644 --- a/tools/test_finalize_spawn_parity.py +++ b/tools/test_finalize_spawn_parity.py @@ -118,7 +118,7 @@ def main(): lock, jars, libraries = base.verify_artifacts() resources = lab.RESOURCES oracle = lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaFinalizeSpawnOracle.java' - sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/finalize_spawn_fixture.rs', + sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/probe/finalize_spawn_fixture.rs', lab.ROOT / 'crates/horizon-client/src/mobs/finalize.rs'] tested = base.source_hashes([s for s in sources if s.exists()]) inputs = build / 'inputs.txt' @@ -148,10 +148,10 @@ def main(): print(f'{len(vanilla)} oracle lines') return halloween = vanilla[0].split()[1] - run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'finalize_spawn_fixture'], 'compile-rust') + run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--no-deps', '--format-version', '1'], cwd=lab.ROOT, text=True)) - binary = Path(metadata['target_directory']) / 'release/examples/finalize_spawn_fixture' - run([binary, resources, inputs, build / 'rust.txt', halloween], 'rust') + binary = Path(metadata['target_directory']) / 'release/examples/probe' + run([binary, 'finalize_spawn_fixture', resources, inputs, build / 'rust.txt', halloween], 'rust') rust = (build / 'rust.txt').read_text().splitlines() bad = [(a, b) for a, b in zip(vanilla, rust) if a != b] if bad or len(vanilla) != len(rust): diff --git a/tools/test_firework_tooltip_parity.py b/tools/test_firework_tooltip_parity.py index b3114c01a..14a4138b5 100644 --- a/tools/test_firework_tooltip_parity.py +++ b/tools/test_firework_tooltip_parity.py @@ -4,7 +4,7 @@ Random rockets (flight durations 0 to 3 and higher, up to six explosions, runs of equal ones) and stars, with dye and custom colours, fade colours, trails and twinkles, some without the component (a rocket's default) and some whose tooltip_display hides it. Vanilla prints what `Fireworks.addToTooltip` and `FireworkExplosion.addToTooltip` add -(VanillaFireworkTooltipOracle); Horizon what `item_tooltip::firework_lines` gives (examples/firework_tooltip_fixture). +(VanillaFireworkTooltipOracle); Horizon what `item_tooltip::firework_lines` gives (examples/probe/firework_tooltip_fixture). """ import random try: diff --git a/tools/test_ghost_recipe_parity.py b/tools/test_ghost_recipe_parity.py index ad722109b..ac902a68c 100644 --- a/tools/test_ghost_recipe_parity.py +++ b/tools/test_ghost_recipe_parity.py @@ -10,7 +10,7 @@ against the real menu for every display of the recipe and prints the GhostSlots it fills: the menu slot, whether it is the result and the stacks the slot cycles through (PlaceRecipeHelper's centred placement of shaped recipes, the first slots for shapeless ones, every fuel for an empty fuel slot); -examples/ghost_recipe_fixture prints the same from +examples/probe/ghost_recipe_fixture prints the same from horizon_client::recipe_book::Book::ghost, which the game fills its ghost slots from. The lines must agree. """ diff --git a/tools/test_held_drop_parity.py b/tools/test_held_drop_parity.py index 842ad3d8a..d2f215050 100644 --- a/tools/test_held_drop_parity.py +++ b/tools/test_held_drop_parity.py @@ -35,7 +35,7 @@ def main(): 'dev.horizonlab.parity.VanillaHeldDropOracle', str(build / 'vanilla.txt')], check=True) with (build / 'rust.txt').open('w') as out: subprocess.run(['cargo', 'run', '--quiet', '-p', 'horizon-client', '--example', - 'held_drop_fixture'], cwd=lab.ROOT, stdout=out, check=True) + 'probe', '--', 'held_drop_fixture'], cwd=lab.ROOT, stdout=out, check=True) matched = base.compare(build / 'vanilla.txt', build / 'rust.txt') print(f'Held drop parity passed: {matched} inventory/drop/swing/packet snapshots match vanilla') diff --git a/tools/test_hotbar_parity.py b/tools/test_hotbar_parity.py index 336bda274..b8c83b87c 100644 --- a/tools/test_hotbar_parity.py +++ b/tools/test_hotbar_parity.py @@ -9,7 +9,7 @@ id), rows of the wrong size or type and garbage. The Java oracle (VanillaHotbarOracle) writes the file and loads it with the client's real HotbarManager and DataFixers (DataFixTypes.HOTBAR, so EmptyItemInHotbarFix and every item stack fixer), then Hotbar.load on each row; -examples/hotbar_fixture runs horizon_client::hotbar on the same tag. The nine +examples/probe/hotbar_fixture runs horizon_client::hotbar on the same tag. The nine rows' stacks are compared. """ import argparse diff --git a/tools/test_hud_parity.py b/tools/test_hud_parity.py index a0baa3214..4dcd19a7b 100644 --- a/tools/test_hud_parity.py +++ b/tools/test_hud_parity.py @@ -5,7 +5,7 @@ The Java oracle (VanillaHudOracle) runs vanilla's own code on a stand-in client whose player answers from the case, and records every GuiGraphicsExtractor blit (sprite, texture, position, size, region, colour, pose), fill, text call (string, style runs, position, colour, shadow, pose) -and hotbar item (slot, position, seed, pose). `examples/hud_fixture` lays +and hotbar item (slot, position, seed, pose). `examples/probe/hud_fixture` lays out the same state with `horizon_client::hud_layout`, `hud_overlays` and `chat`; the ordered call lists (and any state read back) must agree. @@ -114,8 +114,8 @@ def main(): *(PARITY / f'{n}.java' for n in ('ParityData', 'ParityFont', 'VanillaHudOracle'))], 'compile-java') run(['java', '-Xmx2G', '-cp', str(classes) + os.pathsep + dependencies, 'dev.horizonlab.parity.VanillaHudOracle', inputs, build / 'vanilla.jsonl'], 'vanilla') - run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'hud_fixture', '--', - resources, inputs, build / 'rust.jsonl'], 'rust') + run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'probe', '--', + 'hud_fixture', resources, inputs, build / 'rust.jsonl'], 'rust') vanilla = [json.loads(l) for l in (build / 'vanilla.jsonl').read_text().splitlines()] rust = [json.loads(l) for l in (build / 'rust.jsonl').read_text().splitlines()] assert len(vanilla) == len(rust) diff --git a/tools/test_light_parity.py b/tools/test_light_parity.py index ad3945ba8..3ed2351fa 100755 --- a/tools/test_light_parity.py +++ b/tools/test_light_parity.py @@ -4,7 +4,7 @@ Builds a scene of slabs, stairs, snow layers, trapdoors, lanterns, glass, leaves, water and glowstone in a fresh vanilla world, lets the vanilla light engine settle, stops the server so the SkyLight/BlockLight arrays are saved, -then relights every saved chunk with `examples/light_parity` and requires every +then relights every saved chunk with `examples/probe/light_parity` and requires every value to agree. The example also replays block edits through the incremental `light::relight` and checks them against a full relight. @@ -92,7 +92,7 @@ def main(): dimension = run / 'world' for extra in (['--chunks', '0', '0', '2', '3'], ['--incremental', '100']): status = subprocess.run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', - '--example', 'light_parity', '--', str(RESOURCES), str(dimension), *extra], + '--example', 'probe', '--', 'light_parity', str(RESOURCES), str(dimension), *extra], cwd=ROOT).returncode if status: sys.exit('light mismatch against vanilla') diff --git a/tools/test_local_input_parity.py b/tools/test_local_input_parity.py index 2873f11a7..adfea1a4b 100644 --- a/tools/test_local_input_parity.py +++ b/tools/test_local_input_parity.py @@ -35,7 +35,7 @@ def main(): build=lab.LOCAL/'rust-local-input';build.mkdir(exist_ok=True) report=build/'report.json';report.unlink(missing_ok=True) oracle=lab.ROOT/'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaLocalInputOracle.java' - sources=[Path(__file__),lab.ROOT/'tools/test_rust_parity.py',lab.ROOT/'tools/test_model_baking_parity.py',lab.ROOT/'tools/lab.py',oracle,lab.ROOT/'Cargo.toml',lab.ROOT/'Cargo.lock',lab.ROOT/'crates/horizon-client/Cargo.toml',lab.ROOT/'crates/horizon-client/src/input.rs',lab.ROOT/'crates/horizon-client/src/lib.rs',lab.ROOT/'crates/horizon-client/examples/input_probe.rs'] + sources=[Path(__file__),lab.ROOT/'tools/test_rust_parity.py',lab.ROOT/'tools/test_model_baking_parity.py',lab.ROOT/'tools/lab.py',oracle,lab.ROOT/'Cargo.toml',lab.ROOT/'Cargo.lock',lab.ROOT/'crates/horizon-client/Cargo.toml',lab.ROOT/'crates/horizon-client/src/input.rs',lab.ROOT/'crates/horizon-client/src/lib.rs',lab.ROOT/'crates/horizon-client/examples/probe/input_probe.rs'] tested=base.source_hashes(sources) def run(command,name): with (build/(name+'.log')).open('w') as log:subprocess.run(list(map(str,command)),cwd=lab.ROOT,check=True,timeout=600,stdout=log,stderr=subprocess.STDOUT) @@ -44,10 +44,10 @@ def main(): classes=build/'classes';classes.mkdir(exist_ok=True) dependencies=os.pathsep.join(map(str,[jars['client'],*libraries])) run(['javac','--release',lock['minecraft']['java_major'],'-proc:none','-sourcepath',str(lab.ROOT/'mods/horizon/src/test/java'),'-cp',dependencies,'-d',classes,oracle],'compile-java') - run(['cargo','build','--locked','-p','horizon-client','--example','input_probe'],'compile-rust') + run(['cargo','build','--locked','-p','horizon-client','--example','probe'],'compile-rust') metadata=json.loads(subprocess.check_output(['cargo','metadata','--locked','--no-deps','--format-version','1'],cwd=lab.ROOT)) - binary=Path(metadata['target_directory'])/'debug/examples'/('input_probe.exe' if os.name=='nt' else 'input_probe') - run([binary,inputs,build/'rust.txt'],'rust') + binary=Path(metadata['target_directory'])/'debug/examples'/('probe.exe' if os.name=='nt' else 'probe') + run([binary,'input_probe',inputs,build/'rust.txt'],'rust') run(['java','-Xmx768M','-cp',str(classes)+os.pathsep+dependencies,'dev.horizonlab.parity.VanillaLocalInputOracle',inputs,build/'client.txt'],'client') matched=base.compare(build/'client.txt',build/'rust.txt') if matched!=len(fixtures):raise AssertionError('Incomplete input output') diff --git a/tools/test_mob_ai_parity.py b/tools/test_mob_ai_parity.py index 01ed4680f..07f41b2af 100644 --- a/tools/test_mob_ai_parity.py +++ b/tools/test_mob_ai_parity.py @@ -467,7 +467,7 @@ def main(): 'dev.horizonlab.parity.VanillaMobAiOracle', inputs, build / 'vanilla.txt', world], build, 'vanilla', timeout=3600) if not args.java_only: - command = ['cargo', 'build', '--locked', '--release', '-p', 'horizon-client', '--example', 'mob_ai_probe'] + command = ['cargo', 'build', '--locked', '--release', '-p', 'horizon-client', '--example', 'probe'] target, env = lab.cargo_target(), None if args.trace: target = lab.LOCAL / 'mob-ai-trace-target' @@ -475,8 +475,8 @@ def main(): env = dict(os.environ, CARGO_TARGET_DIR=str(target), CARGO_PROFILE_RELEASE_DEBUG='line-tables-only', CARGO_PROFILE_RELEASE_LTO='false', CARGO_PROFILE_RELEASE_CODEGEN_UNITS='16') oracle_harness.run_logged(command, build, 'compile-rust', env=env) - binary = target / 'release/examples/mob_ai_probe' - oracle_harness.run_logged([binary, lab.RESOURCES, inputs, build / 'horizon.txt'], build, 'horizon') + binary = target / 'release/examples/probe' + oracle_harness.run_logged([binary, 'mob_ai_probe', lab.RESOURCES, inputs, build / 'horizon.txt'], build, 'horizon') if args.java_only: return names = {s[0] for _, s in chosen} diff --git a/tools/test_mob_attributes_parity.py b/tools/test_mob_attributes_parity.py index 1e4057eb7..6cefdc4b8 100755 --- a/tools/test_mob_attributes_parity.py +++ b/tools/test_mob_attributes_parity.py @@ -62,10 +62,10 @@ def main(): subprocess.run(list(map(str, cmd)), cwd=lab.ROOT, check=True, timeout=3600, stdout=log, stderr=subprocess.STDOUT) run(['javac', '--release', lock['minecraft']['java_major'], '-proc:none', '-cp', str(jars['server']) + os.pathsep + deps, '-d', classes, oracle], 'compile-java') run(['java', '-Xmx1G', '-cp', os.pathsep.join([str(classes), str(jars['server']), deps]), 'dev.horizonlab.parity.VanillaMobAttributesOracle', build / 'vanilla.txt'], 'java') - run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'mob_attributes_fixture'], 'compile-rust') - binary = lab.cargo_target() / 'release/examples/mob_attributes_fixture' + run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') + binary = lab.cargo_target() / 'release/examples/probe' resources = lab.RESOURCES - run([binary, resources, build / 'rust.txt'], 'rust') + run([binary, 'mob_attributes_fixture', resources, build / 'rust.txt'], 'rust') vanilla, rust = parse(build / 'vanilla.txt'), parse(build / 'rust.txt') problems = [] living = [i for i, r in vanilla.items() if 'attrs' in r] diff --git a/tools/test_music_parity.py b/tools/test_music_parity.py index 7d41be5f1..b56c9ab25 100644 --- a/tools/test_music_parity.py +++ b/tools/test_music_parity.py @@ -154,7 +154,7 @@ def main(): 'music', 'VanillaMusicOracle', 'music_fixture', ''.join(l + '\n' for l in lines), extra_sources=[h.lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaSoundRig.java', h.lab.ROOT / 'crates/horizon-client/src/music.rs', - h.lab.ROOT / 'crates/horizon-client/examples/audio_common/mod.rs'], + h.lab.ROOT / 'crates/horizon-client/examples/probe/audio_common/mod.rs'], java_args=[h.RESOURCES], rust_args=[h.RESOURCES], scope='Real MusicManager.tick/startPlaying/stopPlaying/fadePlaying/setMinutesBetweenSongs/showNowPlayingToastIfNeeded with a seeded ' 'random over the real SoundEngine: track starts and replacements, nextSongDelay draws, the three music frequencies, the loading ' diff --git a/tools/test_native_scene_collision.py b/tools/test_native_scene_collision.py index a70cf48fb..8efc6946b 100644 --- a/tools/test_native_scene_collision.py +++ b/tools/test_native_scene_collision.py @@ -70,7 +70,7 @@ def main(): sources = [Path(__file__), lab.ROOT/'tools/test_native_client.py', lab.ROOT/'tools/test_rust_parity.py', lab.ROOT/'tools/lab.py', lab.ROOT/'tools/prepare_native_client.py', oracle, *helpers, lab.ROOT/'Cargo.toml', lab.ROOT/'Cargo.lock', - lab.ROOT/'crates/horizon-client/examples/scene_collision_probe.rs'] + lab.ROOT/'crates/horizon-client/examples/probe/scene_collision_probe.rs'] for crate in ['horizon-core', 'horizon-world', 'horizon-assets', 'horizon-client']: sources += [lab.ROOT/'crates'/crate/'Cargo.toml', *sorted((lab.ROOT/'crates'/crate/'src').rglob('*.rs'))] tested = base.source_hashes(sources) @@ -82,16 +82,16 @@ def main(): dependencies = os.pathsep.join(map(str, libraries)) run(['javac', '--release', lock['minecraft']['java_major'], '-proc:none', '-cp', str(jars['server'])+os.pathsep+dependencies, '-d', classes, oracle, *helpers], 'compile-java') - run(['cargo', 'build', '--locked', '-p', 'horizon-client', '--example', 'scene_collision_probe'], 'compile-rust') + run(['cargo', 'build', '--locked', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--locked', '--no-deps', '--format-version', '1'], cwd=lab.ROOT)) - executable = Path(metadata['target_directory'])/'debug/examples'/('scene_collision_probe.exe' if os.name == 'nt' else 'scene_collision_probe') + executable = Path(metadata['target_directory'])/'debug/examples'/('probe.exe' if os.name=='nt' else 'probe') cases = [] for radius in [1, 2]: build = root/str(radius); build.mkdir(exist_ok=True) fixtures = list(corpus(radius)) (build/'inputs.txt').write_text(''.join(json.dumps(f, separators=(',', ':'))+'\n' for f in fixtures)) input_hash = lab.digest(build/'inputs.txt', 'sha256') - run([executable, resources, build, radius], f'rust-{radius}') + run([executable, 'scene_collision_probe',resources, build, radius], f'rust-{radius}') scene_hash = lab.digest(build/'scene.json', 'sha256') references = [] for side, jar in jars.items(): diff --git a/tools/test_native_scene_motion.py b/tools/test_native_scene_motion.py index 4b8089795..a917d7337 100644 --- a/tools/test_native_scene_motion.py +++ b/tools/test_native_scene_motion.py @@ -789,7 +789,7 @@ def main(): if args.sprint_input:helpers.append(oracle.with_name('VanillaSprintInputOracle.java')) sources=[Path(__file__),lab.ROOT/'tools/test_native_client.py',lab.ROOT/'tools/test_rust_parity.py',lab.ROOT/'tools/lab.py', lab.ROOT/'tools/prepare_native_client.py',oracle,*helpers,lab.ROOT/'Cargo.toml',lab.ROOT/'Cargo.lock', - lab.ROOT/'crates/horizon-client/examples/scene_motion_probe.rs'] + lab.ROOT/'crates/horizon-client/examples/probe/scene_motion_probe.rs'] for crate in ['horizon-core','horizon-world','horizon-assets','horizon-client']: sources += [lab.ROOT/'crates'/crate/'Cargo.toml',*sorted((lab.ROOT/'crates'/crate/'src').rglob('*.rs'))] if args.sprint_input:sources.append(lab.ROOT/'tools/test_model_baking_parity.py') @@ -807,16 +807,16 @@ def main(): damage_dir=build/'damage';damage_dir.mkdir(exist_ok=True) for target, source in [('types.json','damage-types.json'),('tags.json','damage-tags.json')]: (damage_dir/target).write_bytes((resources/source).read_bytes()) - run(['cargo','build','--locked','-p','horizon-client','--example','scene_motion_probe'],'compile-rust') + run(['cargo','build','--locked','-p','horizon-client','--example','probe'],'compile-rust') metadata=json.loads(subprocess.check_output(['cargo','metadata','--locked','--no-deps','--format-version','1'],cwd=lab.ROOT)) - binary=Path(metadata['target_directory'])/'debug/examples'/('scene_motion_probe.exe' if os.name=='nt' else 'scene_motion_probe') - run([binary,resources,build,'--describe'],'describe') + binary=Path(metadata['target_directory'])/'debug/examples'/('probe.exe' if os.name=='nt' else 'probe') + run([binary,'scene_motion_probe',resources,build,'--describe'],'describe') references=[] for side,jar in jars.items(): run(['java','-Xmx768M','-cp',os.pathsep.join([str(classes),str(jar),dependencies]), 'dev.horizonlab.parity.VanillaSceneMotionOracle',side,build,resources],side) replay_hash=lab.digest(build/('inputs-'+side+'.txt'),'sha256') - run([binary,resources,build,side],'rust-'+side) + run([binary,'scene_motion_probe',resources,build,side],'rust-'+side) if replay_hash!=lab.digest(build/('inputs-'+side+'.txt'),'sha256'):raise AssertionError('Identity replay changed') matched=base.compare(build/(side+'.txt'),build/('rust-'+side+'.txt')) if matched!=expected_lines:raise AssertionError('Incomplete motion output') diff --git a/tools/test_natural_spawn_parity.py b/tools/test_natural_spawn_parity.py index fabdc184b..3c95e6ac2 100644 --- a/tools/test_natural_spawn_parity.py +++ b/tools/test_natural_spawn_parity.py @@ -550,7 +550,7 @@ def main(): lock, jars, libraries = base.verify_artifacts() resources = lab.RESOURCES oracle = lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaNaturalSpawnOracle.java' - sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/natural_spawn_fixture.rs', + sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/probe/natural_spawn_fixture.rs', lab.ROOT / 'crates/horizon-client/src/mobs/spawn_selection.rs', lab.ROOT / 'crates/horizon-client/src/mobs/spawn_rules.rs'] tested = base.source_hashes(sources) @@ -568,10 +568,10 @@ def main(): '-cp', str(jars['server']) + os.pathsep + deps, '-d', classes, oracle], 'compile-java') run(['java', '-Xmx3G', '-cp', os.pathsep.join([str(classes), str(jars['server']), deps]), 'dev.horizonlab.parity.VanillaNaturalSpawnOracle', inputs, build / 'server.txt'], 'server') - run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'natural_spawn_fixture'], 'compile-rust') + run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--no-deps', '--format-version', '1'], cwd=lab.ROOT, text=True)) - binary = Path(metadata['target_directory']) / 'release/examples/natural_spawn_fixture' - run([binary, resources, inputs, build / 'rust.txt'], 'rust') + binary = Path(metadata['target_directory']) / 'release/examples/probe' + run([binary, 'natural_spawn_fixture', resources, inputs, build / 'rust.txt'], 'rust') vanilla = (build / 'server.txt').read_text().splitlines() errors = [l for l in vanilla if ' error ' in l] if errors: diff --git a/tools/test_pack_screen_parity.py b/tools/test_pack_screen_parity.py index a73f734fe..1f3f03ede 100644 --- a/tools/test_pack_screen_parity.py +++ b/tools/test_pack_screen_parity.py @@ -14,7 +14,7 @@ records every GuiGraphicsExtractor call of the screen shown at the end (widgets, list backgrounds, scissor, separators, scroll bars, entries with their incompatibility tint, hover overlay and arrows, the selection outline, the search box, the buttons and their tooltip); -examples/pack_screen_fixture runs horizon_client::pack_screen, which the +examples/probe/pack_screen_fixture runs horizon_client::pack_screen, which the game's pack screen is, through the same actions. The call lists must agree. test_pack_screen_parity.py [--count N] [--detail N] diff --git a/tools/test_pack_selection_parity.py b/tools/test_pack_selection_parity.py index 8610d85f3..9af372d1e 100644 --- a/tools/test_pack_selection_parity.py +++ b/tools/test_pack_selection_parity.py @@ -7,7 +7,7 @@ initial selection as options.txt stores it, and the actions the screen's entries take on a click or key press: select (an incompatible pack only when its confirmation is accepted), unselect, move up, move down. The Java oracle (VanillaPackSelectionOracle) runs vanilla's PackRepository and -PackSelectionModel; examples/pack_selection_fixture runs +PackSelectionModel; examples/probe/pack_selection_fixture runs horizon_client::packs::SelectionModel, which the game's pack screen uses. After every action both lists, in order, with each entry's canSelect, canUnselect, canMoveUp and canMoveDown, and the selection committed at the @@ -71,8 +71,8 @@ def main(): *(PARITY / f'{n}.java' for n in ('ParityData', 'VanillaPackSelectionOracle'))], 'compile-java') run(['java', '-Xmx1G', '-cp', str(classes) + os.pathsep + dependencies, 'dev.horizonlab.parity.VanillaPackSelectionOracle', inputs, build / 'vanilla.jsonl'], 'vanilla') - run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'pack_selection_fixture', '--', - inputs, build / 'rust.jsonl'], 'rust') + run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'probe', '--', + 'pack_selection_fixture', inputs, build / 'rust.jsonl'], 'rust') vanilla = [json.loads(l) for l in (build / 'vanilla.jsonl').read_text().splitlines()] rust = [json.loads(l) for l in (build / 'rust.jsonl').read_text().splitlines()] assert len(vanilla) == len(rust) == len(chosen) diff --git a/tools/test_particle_providers_parity.py b/tools/test_particle_providers_parity.py index 2fdd510d9..def7e3bfa 100644 --- a/tools/test_particle_providers_parity.py +++ b/tools/test_particle_providers_parity.py @@ -197,14 +197,14 @@ def main(): 'tools/test_particle_providers_parity.py', 'tools/oracle_harness.py', 'tools/test_rust_parity.py', 'tools/lab.py', f'mods/horizon/src/test/java/dev/horizonlab/parity/{oracle}.java', 'Cargo.toml', 'Cargo.lock', 'crates/horizon-client/Cargo.toml', 'crates/horizon-client/src/particles.rs', - f'crates/horizon-client/examples/{probe}.rs', 'crates/horizon-core/src/random.rs']] + f'crates/horizon-client/examples/probe/{probe}.rs', 'crates/horizon-core/src/random.rs']] tested = base.source_hashes(sources) cases_path, units = make_cases(build) classes, dependencies, _ = harness.compile_oracle(build, oracle, jars, libraries, lock['minecraft']['java_major']) - binary = harness.build_probe(build, probe) + command = harness.build_probe(build, probe) # The oracle runs first: the probe replays the particle seeds it recovered. harness.java_run(build, classes, dependencies, oracle, [cases_path, build / 'client.txt'], 'client') - harness.run_logged([binary, cases_path, build / 'client.txt', build / 'rust.txt'], build, 'rust') + harness.run_logged([*command, cases_path, build / 'client.txt', build / 'rust.txt'], build, 'rust') tolerance = 0 try: matched = base.compare(build / 'client.txt', build / 'rust.txt') diff --git a/tools/test_place_recipe_parity.py b/tools/test_place_recipe_parity.py index 405ad8009..0b4bdf08e 100644 --- a/tools/test_place_recipe_parity.py +++ b/tools/test_place_recipe_parity.py @@ -9,7 +9,7 @@ renamed copies the book must not use, junk, and sometimes a nearly full inventory; the grid is empty, holds the same recipe already (placing again adds one set, or a full stack with shift) or something else. The Java oracle (VanillaPlaceRecipeOracle) runs RecipeBookMenu.handlePlacement as the server's -packet handler does; examples/place_recipe_fixture runs +packet handler does; examples/probe/place_recipe_fixture runs horizon_client::menu's place_recipe. Every menu slot, the whole inventory, the drops and whether the client gets a ghost recipe are compared. diff --git a/tools/test_raid_parity.py b/tools/test_raid_parity.py index 6df5f8fa6..be1ed7e25 100644 --- a/tools/test_raid_parity.py +++ b/tools/test_raid_parity.py @@ -316,7 +316,7 @@ def main(): lock, jars, libraries = base.verify_artifacts() resources = lab.RESOURCES oracle = lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaRaidOracle.java' - sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/raid_fixture.rs', + sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/probe/raid_fixture.rs', lab.ROOT / 'crates/horizon-client/src/raid.rs', lab.ROOT / 'crates/horizon-client/src/patrol.rs'] tested = base.source_hashes(sources) inputs = build / 'inputs.txt' @@ -335,10 +335,10 @@ def main(): '-cp', str(jars['server']) + os.pathsep + deps, '-d', classes, oracle], 'compile-java') run(['java', '-Xmx3G', '-cp', os.pathsep.join([str(classes), str(jars['server']), deps]), 'dev.horizonlab.parity.VanillaRaidOracle', inputs, build / 'server.txt'], 'server') - run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'raid_fixture'], 'compile-rust') + run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--no-deps', '--format-version', '1'], cwd=lab.ROOT, text=True)) - binary = Path(metadata['target_directory']) / 'release/examples/raid_fixture' - run([binary, resources, inputs, build / 'rust.txt'], 'rust') + binary = Path(metadata['target_directory']) / 'release/examples/probe' + run([binary, 'raid_fixture', resources, inputs, build / 'rust.txt'], 'rust') vanilla = (build / 'server.txt').read_text().splitlines() errors = [l for l in vanilla if ' error ' in l] if errors: diff --git a/tools/test_random_tick_sections_parity.py b/tools/test_random_tick_sections_parity.py index 632808523..0b78afadb 100644 --- a/tools/test_random_tick_sections_parity.py +++ b/tools/test_random_tick_sections_parity.py @@ -7,7 +7,7 @@ Each case loads sections (every block state fills one, alone, so each state's ow ticking and a non-ticking state), ticks, sets and removes randomly ticking blocks (leaving them in the palette), and ticks again. Vanilla runs ServerLevel.tickChunk's section loop on real sections with the real getBlockRandomPos (VanillaRandomTickSectionsOracle); Horizon runs Behaviours::tick_chunk_random with the game's RandomTickSections -(examples/random_tick_sections_probe). Both print every drawn position, whether its block and its fluid tick +(examples/probe/random_tick_sections_probe). Both print every drawn position, whether its block and its fluid tick randomly, and the final randValue. """ import itertools diff --git a/tools/test_recipe_book_parity.py b/tools/test_recipe_book_parity.py index 4aa91686e..c25f180ac 100644 --- a/tools/test_recipe_book_parity.py +++ b/tools/test_recipe_book_parity.py @@ -8,7 +8,7 @@ having seen a highlighted recipe, the open and filter settings of the four book types, and saving and loading the player's recipeBook compound (with unknown ids dropped, and a compound missing a list ignored). The Java oracle (VanillaRecipeBookOracle) drives ServerRecipeBook and its codec; -examples/recipe_book_fixture drives horizon_client::recipe_book. After each +examples/probe/recipe_book_fixture drives horizon_client::recipe_book. After each operation the count, the known and highlighted recipes, the settings and the saved compound are compared. """ diff --git a/tools/test_recipe_book_render_parity.py b/tools/test_recipe_book_render_parity.py index 78d911d72..f60ac83fb 100644 --- a/tools/test_recipe_book_render_parity.py +++ b/tools/test_recipe_book_render_parity.py @@ -11,7 +11,7 @@ the mouse. The Java oracle (VanillaRecipeBookScreenOracle) builds vanilla's widgets for that state as RecipeBookComponent.initVisuals and RecipeBookPage.init do and records every GuiGraphicsExtractor call of their extractRenderState, the tooltips and GhostSlots.extractRenderState, with its -pose; examples/recipe_book_render_fixture lays out the same state with +pose; examples/probe/recipe_book_render_fixture lays out the same state with horizon_client::recipe_book_screen, which the game paints. The call lists must agree. """ diff --git a/tools/test_recipe_book_view_parity.py b/tools/test_recipe_book_view_parity.py index a38d04eca..dcdc88a88 100644 --- a/tools/test_recipe_book_view_parity.py +++ b/tools/test_recipe_book_view_parity.py @@ -8,7 +8,7 @@ grid, the furnace, blast furnace or smoker) with random inventory and menu contents and the craftable filter on or off. The Java oracle (VanillaRecipeBookViewOracle, on the client jar) runs ClientRecipeBook, RecipeCollection.selectRecipes and the tab and page logic of -RecipeBookComponent; examples/recipe_book_view_fixture runs +RecipeBookComponent; examples/probe/recipe_book_view_fixture runs horizon_client::recipe_book::ClientBook. Per tab: visibility, pages and every button's displays with their selected and craftable flags, in order (the client's HashMap of display ids decides it). Most cases also carry a diff --git a/tools/test_resource_pack_parity.py b/tools/test_resource_pack_parity.py index 6169542c5..2d9ae2a85 100644 --- a/tools/test_resource_pack_parity.py +++ b/tools/test_resource_pack_parity.py @@ -9,7 +9,7 @@ sources) and selects them over the prepared vanilla resources. The Java oracle and MultiPackResourceManager and asks what each reload listener reads: which pack a file comes from, translations (ClientLanguage), sound events (SoundManager.prepare), font providers (FontManager) and atlas sources -(SpriteSourceList). examples/pack_resources_fixture builds Horizon's resource +(SpriteSourceList). examples/probe/pack_resources_fixture builds Horizon's resource root for the same selection (packs::build_overlay) and reads it with Horizon's loaders. Every answer must agree. """ diff --git a/tools/test_scoreboard_parity.py b/tools/test_scoreboard_parity.py index 8a035eb17..db308d861 100644 --- a/tools/test_scoreboard_parity.py +++ b/tools/test_scoreboard_parity.py @@ -13,7 +13,7 @@ of each collection in vanilla's iteration order (objectivesByName and playerScores as fastutil open hash maps, teamsByName, each team's HashSet of players), and the ScoreboardSaveData.Packed codec output that data/minecraft/scoreboard.dat holds, before and after loading it back. -`examples/scoreboard_fixture` runs the same cases on +`examples/probe/scoreboard_fixture` runs the same cases on `horizon_client::scoreboard`, reloads vanilla's NBT, and vanilla reloads Horizon's NBT; all must agree. The one order vanilla leaves to identity hash codes (each holder's scores within PlayerScores) is compared as a set. @@ -250,10 +250,10 @@ def main(): inputs = build / 'inputs.jsonl' inputs.write_text(''.join(json.dumps(c, ensure_ascii=False) + '\n' for c in chosen), encoding='utf-8') run([*oracle, 'run', inputs, build / 'vanilla.jsonl'], 'vanilla') - run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'scoreboard_fixture'], 'compile-rust') + run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--no-deps', '--format-version', '1'], cwd=lab.ROOT, text=True)) - binary = Path(metadata['target_directory']) / 'release/examples' / ('scoreboard_fixture.exe' if os.name == 'nt' else 'scoreboard_fixture') - run([binary, build / 'registries.json', inputs, build / 'rust.jsonl', build / 'vanilla.jsonl'], 'rust') + binary = Path(metadata['target_directory']) / 'release/examples' / ('probe.exe' if os.name=='nt' else 'probe') + run([binary, 'scoreboard_fixture',build / 'registries.json', inputs, build / 'rust.jsonl', build / 'vanilla.jsonl'], 'rust') read = lambda p: [json.loads(l) for l in p.read_text(encoding='utf-8').splitlines()] vanilla, rust = read(build / 'vanilla.jsonl'), read(build / 'rust.jsonl') assert len(vanilla) == len(rust) diff --git a/tools/test_screen_layout_parity.py b/tools/test_screen_layout_parity.py index d488716f6..c9e791afb 100644 --- a/tools/test_screen_layout_parity.py +++ b/tools/test_screen_layout_parity.py @@ -6,7 +6,7 @@ a loom screen and menu whose state comes from the case (inputs present, the selectable patterns, the selected one, the scroller, the result banner or the six-layer error, the mouse over a pattern button) and CrafterScreen's background, disabled slots and redstone arrow, recording every -GuiGraphicsExtractor call; examples/screen_layout_fixture lays out the same +GuiGraphicsExtractor call; examples/probe/screen_layout_fixture lays out the same state with horizon_client::screen_layout, which the game paints. The ordered call lists must agree. """ diff --git a/tools/test_section_mesh_parity.py b/tools/test_section_mesh_parity.py index 78c0d68e9..65878bc97 100644 --- a/tools/test_section_mesh_parity.py +++ b/tools/test_section_mesh_parity.py @@ -481,7 +481,7 @@ def main(): oracle = lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaSectionMeshOracle.java' helpers = [oracle.with_name(n + '.java') for n in ['VanillaCuboidModelOracle', 'VanillaHeightmapOracle']] sources = [Path(__file__), lab.ROOT / 'tools/lab.py', lab.ROOT / 'tools/test_rust_parity.py', oracle, *helpers, - lab.ROOT / 'Cargo.toml', lab.ROOT / 'Cargo.lock', lab.ROOT / 'crates/horizon-client/examples/section_mesh_fixture.rs'] + lab.ROOT / 'Cargo.toml', lab.ROOT / 'Cargo.lock', lab.ROOT / 'crates/horizon-client/examples/probe/section_mesh_fixture.rs'] for crate in ['horizon-core', 'horizon-world', 'horizon-assets', 'horizon-client']: sources += [lab.ROOT / 'crates' / crate / 'Cargo.toml', *sorted((lab.ROOT / 'crates' / crate / 'src').rglob('*.rs'))] tested = base.source_hashes(sources) @@ -502,14 +502,14 @@ def main(): dependencies = os.pathsep.join(map(str, [jars['client'], *baking.client_libraries()])) run(['javac', '--release', lock['minecraft']['java_major'], '-proc:none','-sourcepath',str(lab.ROOT/'mods/horizon/src/test/java'), '-cp', dependencies, '-d', classes, oracle, *helpers], 'compile-java') env_jobs = os.environ.get('CARGO_BUILD_JOBS', '3') - run(['cargo', 'build', '--locked', '--profile', 'fast', '-j', env_jobs, '-p', 'horizon-client', '--example', 'section_mesh_fixture'], 'compile-rust') + run(['cargo', 'build', '--locked', '--profile', 'fast', '-j', env_jobs, '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--locked', '--no-deps', '--format-version', '1'], cwd=lab.ROOT)) - binary = Path(metadata['target_directory']) / 'fast/examples' / ('section_mesh_fixture.exe' if os.name == 'nt' else 'section_mesh_fixture') + binary = Path(metadata['target_directory']) / 'fast/examples' / ('probe.exe' if os.name=='nt' else 'probe') java = ['java', '-Xmx2G', '-cp', str(classes) + os.pathsep + dependencies, 'dev.horizonlab.parity.VanillaSectionMeshOracle'] - run([binary, resources, inputs, BUILD / 'rust.jsonl'], 'rust') + run([binary, 'section_mesh_fixture',resources, inputs, BUILD / 'rust.jsonl'], 'rust') run([*java, inputs, BUILD / 'client.jsonl', resources], 'client') run([*java, 'facts', BUILD / 'client-facts.jsonl', resources], 'client-facts') - run([binary, resources, 'facts', BUILD / 'rust-facts.jsonl'], 'rust-facts') + run([binary, 'section_mesh_fixture',resources, 'facts', BUILD / 'rust-facts.jsonl'], 'rust-facts') report = {'schema': 1, 'minecraft': lock['minecraft']['version'], 'platform': platform.platform(), 'scenes': len(rows), 'client_quads': 0, 'rust_quads': 0, 'matched_quads': 0, 'identical_quads': 0, 'categories': {}, 'examples': {}, 'per_scene': {}, 'facts': {}} diff --git a/tools/test_server_files_parity.py b/tools/test_server_files_parity.py index 735bca302..82c0eaa8a 100644 --- a/tools/test_server_files_parity.py +++ b/tools/test_server_files_parity.py @@ -194,7 +194,7 @@ def main(): oracle = lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaServerFilesOracle.java' sources = [Path(__file__).resolve(), oracle, lab.ROOT / 'tools/oracle_harness.py', lab.ROOT / 'tools/lab.py', lab.ROOT / 'tools/test_rust_parity.py', lab.ROOT / 'Cargo.lock', - lab.ROOT / 'crates/horizon-client/examples/server_files_probe.rs', + lab.ROOT / 'crates/horizon-client/examples/probe/server_files_probe.rs', *sorted((lab.ROOT / 'crates/horizon-client/src/server').glob('*.rs'))] tested = base.source_hashes(sources) cases, count = make_cases(build) @@ -204,8 +204,8 @@ def main(): oh.run_logged(['javac', '--release', lock['minecraft']['java_major'], '-proc:none', '-sourcepath', lab.ROOT / 'mods/horizon/src/test/java', '-cp', dependencies, '-d', classes, oracle], build, 'compile-java') - binary = oh.build_probe(build, 'server_files_probe') - oh.run_logged([binary, cases, build / 'rust.txt'], build, 'rust') + command = oh.build_probe(build, 'server_files_probe') + oh.run_logged([*command, cases, build / 'rust.txt'], build, 'rust') oh.run_logged(['java', '-Xmx1g', '-Duser.timezone=UTC', '-Djava.awt.headless=true', '-cp', str(classes) + os.pathsep + dependencies, 'dev.horizonlab.parity.VanillaServerFilesOracle', cases, build / 'server.txt'], build, 'server') diff --git a/tools/test_spawn_rules_parity.py b/tools/test_spawn_rules_parity.py index e71a032b5..19bd8db46 100644 --- a/tools/test_spawn_rules_parity.py +++ b/tools/test_spawn_rules_parity.py @@ -138,7 +138,7 @@ def main(): entity_types = json.loads((resources / 'entity-types.json').read_text()) types = sorted(t for t, v in entity_types.items() if 'attributes' in v and t.split(':')[1] not in SKIPPED) oracle = lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaSpawnRulesOracle.java' - sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/spawn_rules_fixture.rs', + sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/probe/spawn_rules_fixture.rs', lab.ROOT / 'crates/horizon-client/src/mobs/spawn_rules.rs'] tested = base.source_hashes(sources) inputs = build / 'inputs.txt' @@ -155,10 +155,10 @@ def main(): '-cp', str(jars['server']) + os.pathsep + deps, '-d', classes, oracle], 'compile-java') run(['java', '-Xmx2G', '-cp', os.pathsep.join([str(classes), str(jars['server']), deps]), 'dev.horizonlab.parity.VanillaSpawnRulesOracle', inputs, build / 'server.txt'], 'server') - run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'spawn_rules_fixture'], 'compile-rust') + run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--no-deps', '--format-version', '1'], cwd=lab.ROOT, text=True)) - binary = Path(metadata['target_directory']) / 'release/examples/spawn_rules_fixture' - run([binary, resources, inputs, build / 'rust.txt'], 'rust') + binary = Path(metadata['target_directory']) / 'release/examples/probe' + run([binary, 'spawn_rules_fixture', resources, inputs, build / 'rust.txt'], 'rust') vanilla = (build / 'server.txt').read_text().splitlines() errors = [l for l in vanilla if ' error ' in l] if errors: diff --git a/tools/test_spawner_parity.py b/tools/test_spawner_parity.py index b1637cf4e..5aa9029e3 100644 --- a/tools/test_spawner_parity.py +++ b/tools/test_spawner_parity.py @@ -230,7 +230,7 @@ def main(): lock, jars, libraries = base.verify_artifacts() resources = lab.RESOURCES oracle = lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaNaturalSpawnOracle.java' - sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/natural_spawn_fixture.rs', + sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/probe/natural_spawn_fixture.rs', lab.ROOT / 'crates/horizon-client/src/mobs/spawner.rs', lab.ROOT / 'crates/horizon-client/src/mobs/spawn_selection.rs', lab.ROOT / 'crates/horizon-client/src/mobs/spawn_rules.rs'] @@ -249,10 +249,10 @@ def main(): '-cp', str(jars['server']) + os.pathsep + deps, '-d', classes, oracle], 'compile-java') run(['java', '-Xmx3G', '-cp', os.pathsep.join([str(classes), str(jars['server']), deps]), 'dev.horizonlab.parity.VanillaNaturalSpawnOracle', inputs, build / 'server.txt'], 'server') - run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'natural_spawn_fixture'], 'compile-rust') + run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--no-deps', '--format-version', '1'], cwd=lab.ROOT, text=True)) - binary = Path(metadata['target_directory']) / 'release/examples/natural_spawn_fixture' - run([binary, resources, inputs, build / 'rust.txt'], 'rust') + binary = Path(metadata['target_directory']) / 'release/examples/probe' + run([binary, 'natural_spawn_fixture', resources, inputs, build / 'rust.txt'], 'rust') vanilla = (build / 'server.txt').read_text().splitlines() errors = [l for l in vanilla if ' error ' in l] if errors: diff --git a/tools/test_sprint_input_parity.py b/tools/test_sprint_input_parity.py index 0fe9eecec..0ac515e44 100644 --- a/tools/test_sprint_input_parity.py +++ b/tools/test_sprint_input_parity.py @@ -40,7 +40,7 @@ def main(): build=lab.LOCAL/'rust-sprint-input';build.mkdir(exist_ok=True) report=build/'report.json';report.unlink(missing_ok=True) oracle=lab.ROOT/'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaSprintInputOracle.java' - sources=[Path(__file__),lab.ROOT/'tools/test_rust_parity.py',lab.ROOT/'tools/test_model_baking_parity.py',lab.ROOT/'tools/lab.py',oracle,lab.ROOT/'Cargo.toml',lab.ROOT/'Cargo.lock',lab.ROOT/'crates/horizon-client/Cargo.toml',lab.ROOT/'crates/horizon-client/src/input.rs',lab.ROOT/'crates/horizon-client/src/sprint.rs',lab.ROOT/'crates/horizon-client/src/lib.rs',lab.ROOT/'crates/horizon-client/examples/sprint_probe.rs'] + sources=[Path(__file__),lab.ROOT/'tools/test_rust_parity.py',lab.ROOT/'tools/test_model_baking_parity.py',lab.ROOT/'tools/lab.py',oracle,lab.ROOT/'Cargo.toml',lab.ROOT/'Cargo.lock',lab.ROOT/'crates/horizon-client/Cargo.toml',lab.ROOT/'crates/horizon-client/src/input.rs',lab.ROOT/'crates/horizon-client/src/sprint.rs',lab.ROOT/'crates/horizon-client/src/lib.rs',lab.ROOT/'crates/horizon-client/examples/probe/sprint_probe.rs'] tested=base.source_hashes(sources) def run(command,name): with (build/(name+'.log')).open('w') as log:subprocess.run(list(map(str,command)),cwd=lab.ROOT,check=True,timeout=600,stdout=log,stderr=subprocess.STDOUT) @@ -49,10 +49,10 @@ def main(): classes=build/'classes';classes.mkdir(exist_ok=True) dependencies=os.pathsep.join(map(str,[jars['client'],*libraries])) run(['javac','--release',lock['minecraft']['java_major'],'-proc:none','-sourcepath',str(lab.ROOT/'mods/horizon/src/test/java'),'-cp',dependencies,'-d',classes,oracle],'compile-java') - run(['cargo','build','--locked','-p','horizon-client','--example','sprint_probe'],'compile-rust') + run(['cargo','build','--locked','-p','horizon-client','--example','probe'],'compile-rust') metadata=json.loads(subprocess.check_output(['cargo','metadata','--locked','--no-deps','--format-version','1'],cwd=lab.ROOT)) - binary=Path(metadata['target_directory'])/'debug/examples'/('sprint_probe.exe' if os.name=='nt' else 'sprint_probe') - run([binary,inputs,build/'rust.txt'],'rust') + binary=Path(metadata['target_directory'])/'debug/examples'/('probe.exe' if os.name=='nt' else 'probe') + run([binary,'sprint_probe',inputs,build/'rust.txt'],'rust') run(['java','-Xmx768M','-cp',str(classes)+os.pathsep+dependencies,'dev.horizonlab.parity.VanillaSprintInputOracle',inputs,build/'client.txt'],'client') matched=base.compare(build/'client.txt',build/'rust.txt') if matched!=operations+len(fixtures):raise AssertionError('Incomplete input output') diff --git a/tools/test_subtitle_parity.py b/tools/test_subtitle_parity.py index 21b4c7175..1444bb5bd 100644 --- a/tools/test_subtitle_parity.py +++ b/tools/test_subtitle_parity.py @@ -11,7 +11,7 @@ it renders), the notification display time, the text background opacity and its "chat only" setting, and a GUI size. Each frame records the fills and texts in order with the pose: which subtitles show, their order, merging of repeats, expiry, the fade by age (looping sounds stay bright longer), the direction -arrows and the box width. `examples/subtitle_fixture` replays the cases through +arrows and the box width. `examples/probe/subtitle_fixture` replays the cases through `horizon_client::subtitles`; the frames must agree exactly. test_subtitle_parity.py [--count N] [--detail N] @@ -133,10 +133,10 @@ def main(): *(PARITY / f'{n}.java' for n in ('ParityFont', 'VanillaSubtitleOracle'))], 'compile-java') run(['java', '-Xmx1G', '-cp', str(classes) + os.pathsep + dependencies, 'dev.horizonlab.parity.VanillaSubtitleOracle', inputs, build / 'vanilla.jsonl'], 'vanilla') - run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'subtitle_fixture'], 'compile-rust') + run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--no-deps', '--format-version', '1'], cwd=lab.ROOT, text=True)) - binary = Path(metadata['target_directory']) / 'release/examples' / ('subtitle_fixture.exe' if os.name == 'nt' else 'subtitle_fixture') - run([binary, resources, inputs, build / 'rust.jsonl'], 'rust') + binary = Path(metadata['target_directory']) / 'release/examples' / ('probe.exe' if os.name=='nt' else 'probe') + run([binary, 'subtitle_fixture',resources, inputs, build / 'rust.jsonl'], 'rust') vanilla = [json.loads(l) for l in (build / 'vanilla.jsonl').read_text(encoding='utf-8').splitlines()] rust = [json.loads(l) for l in (build / 'rust.jsonl').read_text(encoding='utf-8').splitlines()] assert len(vanilla) == len(rust) == len(chosen) diff --git a/tools/test_tab_list_parity.py b/tools/test_tab_list_parity.py index cdf32df65..9b3c65605 100644 --- a/tools/test_tab_list_parity.py +++ b/tools/test_tab_list_parity.py @@ -10,12 +10,12 @@ them (upside-down Dinnerbone and Grumm) and whose real Scoreboard has the case's teams (colour, prefix, suffix), `list` objective (integer or hearts, number formats) and scores, with the header, footer, row background option and Hud ticks. It records every fill, text (as styled runs), sprite and -face blit. `examples/tab_list_fixture` lays out the same frames with +face blit. `examples/probe/tab_list_fixture` lays out the same frames with `horizon_client::tab_list`; the ordered call lists must agree. Downloaded skin images are compared too: VanillaSkinImageOracle decodes PNGs as NativeImage does and runs SkinTextureDownloader.processLegacySkin; -`examples/skin_image_fixture` runs `horizon_client::skins`. Pixels must agree. +`examples/probe/skin_image_fixture` runs `horizon_client::skins`. Pixels must agree. test_tab_list_parity.py [--count N] [--detail N] """ @@ -241,13 +241,13 @@ def main(): *(PARITY / f'{n}.java' for n in ('ParityData', 'ParityFont', 'VanillaTabListOracle', 'VanillaSkinImageOracle'))], 'compile-java') run(['java', '-Xmx2G', '-cp', str(classes) + os.pathsep + dependencies, 'dev.horizonlab.parity.VanillaTabListOracle', inputs, build / 'vanilla.jsonl'], 'vanilla') - run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'tab_list_fixture', '--', - resources, inputs, build / 'rust.jsonl'], 'rust') + run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'probe', '--', + 'tab_list_fixture', resources, inputs, build / 'rust.jsonl'], 'rust') images = build / 'skins.txt'; images.write_text(''.join(i + '\n' for i in skin_images(args.images))) run(['java', '-Xmx1G', '-cp', str(classes) + os.pathsep + dependencies, 'dev.horizonlab.parity.VanillaSkinImageOracle', images, build / 'vanilla-skins.txt'], 'vanilla-skins') - run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'skin_image_fixture', '--', - images, build / 'rust-skins.txt'], 'rust-skins') + run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'probe', '--', + 'skin_image_fixture', images, build / 'rust-skins.txt'], 'rust-skins') vanilla_skins = (build / 'vanilla-skins.txt').read_text().splitlines() rust_skins = (build / 'rust-skins.txt').read_text().splitlines() assert len(vanilla_skins) == len(rust_skins) == args.images diff --git a/tools/test_team_rules_parity.py b/tools/test_team_rules_parity.py index af73aad10..5eb0c7d9d 100644 --- a/tools/test_team_rules_parity.py +++ b/tools/test_team_rules_parity.py @@ -9,7 +9,7 @@ EntitySelector.pushableBy predicate (collision rules), Entity.isInvisibleTo (name tag visibility, with a stand-in client for the viewer, camera and F1) on stand-in entities, for every combination of two teams' options, the three entities' teams (none, either team) and the flags involved. -`examples/team_rules_fixture` answers from `horizon_client::scoreboard`. +`examples/probe/team_rules_fixture` answers from `horizon_client::scoreboard`. test_team_rules_parity.py [--count N] """ @@ -84,10 +84,10 @@ def main(): PARITY / 'VanillaTeamRulesOracle.java'], 'compile-java') run(['java', '-Xmx1G', '-cp', str(classes) + os.pathsep + dependencies, 'dev.horizonlab.parity.VanillaTeamRulesOracle', inputs, build / 'vanilla.jsonl'], 'vanilla') - run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'team_rules_fixture'], 'compile-rust') + run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--no-deps', '--format-version', '1'], cwd=lab.ROOT, text=True)) - binary = Path(metadata['target_directory']) / 'release/examples' / ('team_rules_fixture.exe' if os.name == 'nt' else 'team_rules_fixture') - run([binary, inputs, build / 'rust.jsonl'], 'rust') + binary = Path(metadata['target_directory']) / 'release/examples' / ('probe.exe' if os.name=='nt' else 'probe') + run([binary, 'team_rules_fixture',inputs, build / 'rust.jsonl'], 'rust') vanilla = [json.loads(l) for l in (build / 'vanilla.jsonl').read_text().splitlines()] rust = [json.loads(l) for l in (build / 'rust.jsonl').read_text().splitlines()] assert len(vanilla) == len(rust) == len(chosen) diff --git a/tools/test_trading_parity.py b/tools/test_trading_parity.py index 13ef60880..c26c449fb 100644 --- a/tools/test_trading_parity.py +++ b/tools/test_trading_parity.py @@ -184,7 +184,7 @@ def main(): lock, jars, libraries = base.verify_artifacts() resources = lab.RESOURCES oracle = lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaTradingOracle.java' - sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/trading_fixture.rs', + sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/probe/trading_fixture.rs', lab.ROOT / 'crates/horizon-client/src/merchant.rs', lab.ROOT / 'crates/horizon-client/src/menu.rs'] tested = base.source_hashes([s for s in sources if s.exists()]) inputs = build / 'inputs.txt' @@ -219,9 +219,9 @@ def main(): if args.java_only: print(f'{len(vanilla)} oracle lines') return - run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'trading_fixture'], 'compile-rust') - binary = lab.cargo_target() / 'release/examples/trading_fixture' - run([binary, resources, inputs, build / 'server.txt', build / 'rust.txt'], 'rust') + run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') + binary = lab.cargo_target() / 'release/examples/probe' + run([binary, 'trading_fixture', resources, inputs, build / 'server.txt', build / 'rust.txt'], 'rust') rust = (build / 'rust.txt').read_text().splitlines() bad = [(a, b) for a, b in zip(vanilla, rust) if a != b] if bad or len(vanilla) != len(rust): diff --git a/tools/test_translucency_parity.py b/tools/test_translucency_parity.py index fcf8d3842..fff0390eb 100644 --- a/tools/test_translucency_parity.py +++ b/tools/test_translucency_parity.py @@ -52,7 +52,7 @@ def main(): lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaTranslucencyOracle.java'], 'compile-java') vanilla, rust = build / 'vanilla.jsonl', build / 'rust.jsonl' run(['java', '-cp', str(classes) + os.pathsep + dependencies, 'dev.horizonlab.parity.VanillaTranslucencyOracle', inputs, vanilla], 'vanilla') - run(['cargo', 'run', '--quiet', '--locked', '--profile', args.profile, '-p', 'horizon-client', '--example', 'translucency_fixture', '--', inputs, rust], 'rust') + run(['cargo', 'run', '--quiet', '--locked', '--profile', args.profile, '-p', 'horizon-client', '--example', 'probe', '--', 'translucency_fixture', inputs, rust], 'rust') expected = [json.loads(line) for line in vanilla.read_text().splitlines()] actual = [json.loads(line) for line in rust.read_text().splitlines()] assert len(expected) == len(actual), 'case count differs' diff --git a/tools/test_trial_spawner_parity.py b/tools/test_trial_spawner_parity.py index 6fb79d9e1..bd6d69ac2 100644 --- a/tools/test_trial_spawner_parity.py +++ b/tools/test_trial_spawner_parity.py @@ -194,7 +194,7 @@ def main(): lock, jars, libraries = base.verify_artifacts() resources = lab.RESOURCES oracle = lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaNaturalSpawnOracle.java' - sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/natural_spawn_fixture.rs', + sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/probe/natural_spawn_fixture.rs', lab.ROOT / 'crates/horizon-client/src/mobs/trial_spawner.rs', lab.ROOT / 'crates/horizon-client/src/mobs/spawner.rs', lab.ROOT / 'crates/horizon-client/src/mobs/spawn_selection.rs', @@ -214,10 +214,10 @@ def main(): '-cp', str(jars['server']) + os.pathsep + deps, '-d', classes, oracle], 'compile-java') run(['java', '-Xmx3G', '-cp', os.pathsep.join([str(classes), str(jars['server']), deps]), 'dev.horizonlab.parity.VanillaNaturalSpawnOracle', inputs, build / 'server.txt'], 'server') - run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'natural_spawn_fixture'], 'compile-rust') + run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--no-deps', '--format-version', '1'], cwd=lab.ROOT, text=True)) - binary = Path(metadata['target_directory']) / 'release/examples/natural_spawn_fixture' - run([binary, resources, inputs, build / 'rust.txt'], 'rust') + binary = Path(metadata['target_directory']) / 'release/examples/probe' + run([binary, 'natural_spawn_fixture', resources, inputs, build / 'rust.txt'], 'rust') vanilla = (build / 'server.txt').read_text().splitlines() errors = [l for l in vanilla if ' error ' in l] if errors: diff --git a/tools/test_vault_parity.py b/tools/test_vault_parity.py index 7eeace526..73c41e197 100644 --- a/tools/test_vault_parity.py +++ b/tools/test_vault_parity.py @@ -173,7 +173,7 @@ def main(): lock, jars, libraries = base.verify_artifacts() resources = lab.LOCAL / 'horizon-client/26.3' oracle = lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaNaturalSpawnOracle.java' - sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/natural_spawn_fixture.rs', + sources = [oracle, Path(__file__), lab.ROOT / 'crates/horizon-client/examples/probe/natural_spawn_fixture.rs', lab.ROOT / 'crates/horizon-client/src/vault.rs'] tested = base.source_hashes(sources) inputs = build / 'inputs.txt' @@ -190,10 +190,10 @@ def main(): '-cp', str(jars['server']) + os.pathsep + deps, '-d', classes, oracle], 'compile-java') run(['java', '-Xmx3G', '-cp', os.pathsep.join([str(classes), str(jars['server']), deps]), 'dev.horizonlab.parity.VanillaNaturalSpawnOracle', inputs, build / 'server.txt'], 'server') - run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'natural_spawn_fixture'], 'compile-rust') + run(['cargo', 'build', '--release', '-p', 'horizon-client', '--example', 'probe'], 'compile-rust') metadata = json.loads(subprocess.check_output(['cargo', 'metadata', '--no-deps', '--format-version', '1'], cwd=lab.ROOT, text=True)) - binary = Path(metadata['target_directory']) / 'release/examples/natural_spawn_fixture' - run([binary, resources, inputs, build / 'rust.txt'], 'rust') + binary = Path(metadata['target_directory']) / 'release/examples/probe' + run([binary, 'natural_spawn_fixture', resources, inputs, build / 'rust.txt'], 'rust') vanilla = (build / 'server.txt').read_text().splitlines() errors = [l for l in vanilla if ' error ' in l] if errors: diff --git a/tools/test_world_border_render_parity.py b/tools/test_world_border_render_parity.py index 1a04a0de4..f8c88b6a6 100644 --- a/tools/test_world_border_render_parity.py +++ b/tools/test_world_border_render_parity.py @@ -103,8 +103,8 @@ def main(): PARITY / 'VanillaWorldBorderRenderOracle.java'], 'compile-java') run(['java', '-Xmx1G', '-cp', str(classes) + os.pathsep + dependencies, 'dev.horizonlab.parity.VanillaWorldBorderRenderOracle', inputs, build / 'vanilla.jsonl'], 'vanilla') - run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'world_border_render_fixture', '--', - inputs, build / 'rust.jsonl'], 'rust') + run(['cargo', 'run', '--quiet', '--profile', 'fast', '-p', 'horizon-client', '--example', 'probe', '--', + 'world_border_render_fixture', inputs, build / 'rust.jsonl'], 'rust') vanilla = [json.loads(l) for l in (build / 'vanilla.jsonl').read_text().splitlines()] rust = [json.loads(l) for l in (build / 'rust.jsonl').read_text().splitlines()] assert len(vanilla) == len(rust)