[PR #4881] [MERGED] Game tests: test environments #5914

Closed
opened 2026-11-03 05:15:52 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4881
Author: @levzzz5154
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154

Base: main ← Head: parity/T3-test-env


📝 Commits (4)

  • cf8cab1 Game tests: test environments (game rules, weather, clock time, difficulty, functions, all_of)
  • a52f904 Merge hr/main
  • 52890d2 Merge hr/main
  • b2bf03c Merge hr/main

📊 Changes

4 files changed (+406 additions, -6 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+1 -0)
📝 crates/horizon-client/src/game/commands.rs (+6 -2)
📝 crates/horizon-client/src/game/game_tests.rs (+24 -4)
➕ crates/horizon-client/src/game/test_environments.rs (+375 -0)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally.

Part of #3520 (game-test framework, after #4873 and #4878).

Rows

  • TestEnvironmentDefinition (setup/teardown/activate): a batch's environment was ignored (every test ran in the default). The data pack's test_environment entries (or inline definitions, and all_of of references) are now read and activated when a batch starts (GameTestRunner.runBatch: after endCurrentEnvironment) and torn down when the next batch starts, the runner ends, or /test stop/a halt clears it (GameTestRunner.stop).
    • all_of: set up in order, torn down in reverse.
    • game_rules: the listed rules set, the previous values restored.
    • weather: Weather.Type (clear/rain/thunder) via setWeatherParameters (100000/0 or 0/100000 timers); teardown resetWeatherCycle then the previous type.
    • clock_time: the overworld clock set to the time, the previous total restored (Horizon has only the overworld clock; other clocks change nothing).
    • difficulty: setDifficulty(d, true) (extracted from /difficulty as set_difficulty_forced), restored after.
    • function: the setup/teardown function run with game master permission and suppressed output; a missing one is logged (Test Batch failed for non-existent function).
    • timeline_attributes: not applied (no environment attribute system to layer timelines on).

Vanilla followed

TestEnvironmentDefinition and its AllOf, ClockTime, SetDifficulty, Functions, SetGameRules, Weather records, GameTestRunner.runBatch/endCurrentEnvironment/stop.

Tests

test_environments::tests (parsing with references and nesting, invalid definitions, weather timers). fmt and clippy -D warnings clean. Not run in-game.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/4881 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `parity/T3-test-env` --- ### 📝 Commits (4) - [`cf8cab1`](https://github.com/horizon-rust/horizon/commit/cf8cab121c3b880c7ed7cc375434a62342e8be87) Game tests: test environments (game rules, weather, clock time, difficulty, functions, all_of) - [`a52f904`](https://github.com/horizon-rust/horizon/commit/a52f904ff5e59bdfd66056874812e963142216c4) Merge hr/main - [`52890d2`](https://github.com/horizon-rust/horizon/commit/52890d2f8f704c7966cef9a5c968988a187d69f0) Merge hr/main - [`b2bf03c`](https://github.com/horizon-rust/horizon/commit/b2bf03c7498639419dde83c4d9d2290272f9b752) Merge hr/main ### 📊 Changes **4 files changed** (+406 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+1 -0) 📝 `crates/horizon-client/src/game/commands.rs` (+6 -2) 📝 `crates/horizon-client/src/game/game_tests.rs` (+24 -4) ➕ `crates/horizon-client/src/game/test_environments.rs` (+375 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. Part of #3520 (game-test framework, after #4873 and #4878). ## Rows - `TestEnvironmentDefinition` (`setup`/`teardown`/`activate`): a batch's environment was ignored (every test ran in the default). The data pack's `test_environment` entries (or inline definitions, and `all_of` of references) are now read and activated when a batch starts (`GameTestRunner.runBatch`: after `endCurrentEnvironment`) and torn down when the next batch starts, the runner ends, or `/test stop`/a halt clears it (`GameTestRunner.stop`). - `all_of`: set up in order, torn down in reverse. - `game_rules`: the listed rules set, the previous values restored. - `weather`: `Weather.Type` (clear/rain/thunder) via `setWeatherParameters` (100000/0 or 0/100000 timers); teardown `resetWeatherCycle` then the previous type. - `clock_time`: the overworld clock set to the time, the previous total restored (Horizon has only the overworld clock; other clocks change nothing). - `difficulty`: `setDifficulty(d, true)` (extracted from `/difficulty` as `set_difficulty_forced`), restored after. - `function`: the setup/teardown function run with game master permission and suppressed output; a missing one is logged (`Test Batch failed for non-existent function`). - `timeline_attributes`: not applied (no environment attribute system to layer timelines on). ## Vanilla followed `TestEnvironmentDefinition` and its `AllOf`, `ClockTime`, `SetDifficulty`, `Functions`, `SetGameRules`, `Weather` records, `GameTestRunner.runBatch/endCurrentEnvironment/stop`. ## Tests `test_environments::tests` (parsing with references and nesting, invalid definitions, weather timers). fmt and clippy `-D warnings` clean. Not run in-game. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:15:52 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5914
No description provided.