diff --git a/tests/ingame/README.md b/tests/ingame/README.md index 4fac2cbfa..260f8b71b 100644 --- a/tests/ingame/README.md +++ b/tests/ingame/README.md @@ -43,7 +43,8 @@ The runner (`tools/ingame-test`): (17 for 1.20.x, 21 for 1.21.x, 25 for 26.x): `JAVA_HOME_` if set, else `JAVA_HOME`, else `java` on `PATH`. A newer Java runs older servers. 3. Runs a debug client per script, joining as that version, then resets the - player for the next one. + player for the next one, and the world to noon in clear weather with time + ticking. With `--jobs N`, N workers per version each start their own server and world under `target/ingame/workers///` and take scripts from a shared diff --git a/tools/ingame-test/src/main.rs b/tools/ingame-test/src/main.rs index 7bf79a139..b1d5fdc9a 100644 --- a/tools/ingame-test/src/main.rs +++ b/tools/ingame-test/src/main.rs @@ -626,10 +626,8 @@ impl Server { // out of the reset's reach; keep the area around spawn loaded. server.command("forceload add -48 -48 47 47"); // Mobs spawning at night attack and push the test player mid-script. - // 26.x renamed the rule; each version rejects the name it lacks. - for rule in ["spawn_mobs", "doMobSpawning"] { - server.command(&format!("gamerule {rule} false")); - } + server.gamerule(["spawn_mobs", "doMobSpawning"], false); + server.reset_world(); Ok(server) } @@ -656,6 +654,14 @@ impl Server { let _ = writeln!(self.stdin, "{command}"); } + /// Sets a game rule by its 26.x and older names; each version rejects + /// the name it lacks. + fn gamerule(&mut self, names: [&str; 2], value: bool) { + for name in names { + self.command(&format!("gamerule {name} {value}")); + } + } + /// Clears what a script left behind. Once the player has left and the /// world is saved, their data is deleted so the next join starts fresh. fn reset_player(&mut self) -> Result<(), String> { @@ -678,9 +684,18 @@ impl Server { for _ in 0..2 { self.command("kill @e[type=!player]"); } + self.reset_world(); Ok(()) } + /// Noon, clear and ticking, so a script that doesn't set the time or + /// weather sees the same sky whether it runs first or after others. + fn reset_world(&mut self) { + self.gamerule(["advance_time", "doDaylightCycle"], true); + self.command("time set 6000"); + self.command("weather clear"); + } + /// Blocks until the server exits (Ctrl+C or `stop`). fn wait(&mut self) { let _ = self.child.wait();