From e3aefc9f129bb21c821440d8acb6b0b89e33f1da Mon Sep 17 00:00:00 2001 From: Natalie Date: Wed, 24 Jun 2026 04:35:41 -0400 Subject: [PATCH] =?UTF-8?q?test(@projects/@magic-civilization):=20?= =?UTF-8?q?=E2=9C=85=20assert=20expected=20engine=20errors=20in=20negative?= =?UTF-8?q?-path=20tests=20(p2=5F46,=20prologue)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These tests deliberately feed bad input (missing/malformed replay game_id, no-history goto_turn, malformed start-script JSON) and the Rust bindings correctly log an engine error + reject it. GUT's auto error-check flagged those deliberate logs as "Unexpected Errors". Use assert_engine_error(text) to mark them expected (GUT marks the matching error handled). Clears test_p2_46_replay_bridge (4→0) + the prologue load_script rejection path. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../engine/tests/integration/test_p2_46_replay_bridge.gd | 7 +++++++ src/game/engine/tests/unit/test_prologue_driver.gd | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/game/engine/tests/integration/test_p2_46_replay_bridge.gd b/src/game/engine/tests/integration/test_p2_46_replay_bridge.gd index aef8acd9..3c04cf65 100644 --- a/src/game/engine/tests/integration/test_p2_46_replay_bridge.gd +++ b/src/game/engine/tests/integration/test_p2_46_replay_bridge.gd @@ -69,6 +69,11 @@ func test_open_returns_false_for_missing_game() -> void: var ok_malformed: bool = archive.open(_archive_root, "age-of-dwarves", "not-a-uuid") assert_false(ok_malformed, "open() must return false for a malformed game_id") + # Both open() calls deliberately log engine errors for the bad input — + # mark them expected so GUT doesn't flag them as unexpected. + assert_engine_error("archive io error") + assert_engine_error("invalid game_id") + ## Assertion 3: goto_turn() on an unloaded GdReplayPlayer returns an empty ## Dictionary (the safe default when no history is loaded). @@ -77,6 +82,8 @@ func test_goto_turn_returns_empty_dict_when_no_history() -> void: var snap: Dictionary = player.goto_turn(1) assert_true(snap is Dictionary, "goto_turn() must return a Dictionary") assert_eq(snap.size(), 0, "goto_turn() with no loaded history must return empty Dictionary") + # goto_turn with no loaded history deliberately logs an engine error — expected. + assert_engine_error("no history loaded") ## Helper: remove a directory tree recursively (best-effort, ignores errors). diff --git a/src/game/engine/tests/unit/test_prologue_driver.gd b/src/game/engine/tests/unit/test_prologue_driver.gd index 64ff77e2..577daf4c 100644 --- a/src/game/engine/tests/unit/test_prologue_driver.gd +++ b/src/game/engine/tests/unit/test_prologue_driver.gd @@ -91,6 +91,8 @@ func test_load_script_accepts_default_rejects_garbage_when_available() -> void: assert_ne(script_json, "", "default start script readable") assert_true(driver.load_script(script_json), "load_script accepts the bundled default") assert_false(driver.load_script("{ not valid json"), "load_script rejects malformed JSON") + # The malformed-JSON rejection deliberately logs an engine error — expected. + assert_engine_error("malformed script JSON") func test_dispatch_chronicle_events_routes_to_eventbus() -> void: