extends SceneTree const Fixture = preload("res://campaign/fg2_fixture.gd") const RELEASE_SIDE_EFFECT_TOKENS := [ "state.initialize(", "state.restore_snapshot(", "market.begin_run_creation(", "market.materialize_opening_offers(", "market.set_opening_selection(", "market.commit_run_creation(", "market.commit_battle_offer(", "market.restore_snapshot(", "market.hire(", "market.commit_deployment(", "resolver.settle_battle(", ] var failures: Array[String] = [] func _initialize() -> void: call_deferred("run_test") func run_test() -> void: assert_release_safe("res://p10_0/market_service.gd") assert_release_safe("res://campaign/fg2_fixture.gd") var market: Dictionary = Fixture.canonical_market_state() var encounter: Dictionary = Fixture.canonical_encounter_state() var reward: Dictionary = Fixture.reward_market_state() var recovery: Dictionary = Fixture.recovery_market_state() expect(String(market.get("current_run", {}).get("phase", "")) == "market", "canonical Market snapshot is executable") expect(String(encounter.get("current_run", {}).get("phase", "")) == "encounter", "canonical encounter snapshot is executable") expect(not Dictionary(reward.get("current_run", {}).get("pending_reward", {})).is_empty(), "reward snapshot is executable") expect(bool(recovery.get("current_run", {}).get("recovery_required", false)), "recovery snapshot is executable") expect(String(recovery.get("current_run", {}).get("phase", "")) == "market", "recovery returns to Market") if failures.is_empty(): print("ABG_FG2_RELEASE_SAFE_FIXTURE_OK snapshots=4 side_effect_asserts=0") quit(0) else: for failure in failures: push_error(failure) quit(1) func assert_release_safe(path: String) -> void: var source := FileAccess.get_file_as_string(path) expect(not source.is_empty(), "source is readable: %s" % path) for line in source.split("\n"): if "assert(" not in line: continue for token in RELEASE_SIDE_EFFECT_TOKENS: expect(token not in line, "Release side effect is outside assert: %s" % line.strip_edges()) func expect(condition: bool, message: String) -> void: if not condition: failures.append("FG-2 Release-safe fixture: %s" % message)