AGENTS.md says exit code zero alone is insufficient: logs must be scanned for
script errors, parse/resource/import failures, ObjectDB leaks and cleanup.
The 21 existing gates each grepped only their own PASS marker and never did
this cross-check. tools/audit_logs.py scans all test logs and immediately
found 708 error lines that every PASS marker had been hiding.
693 were the same Tween callback error: tween_callback().bind(label) hits a
Godot 4 Variant conversion bug ("Cannot convert Object to Object"), so the
floating-damage reclaim callback failed on every frame and the Label nodes
were never returned to the pool - a real runtime leak in long fights. Fixed
with a zero-argument lambda that captures the label directly. One more was an
unescaped % in a boss_phase_test assertion; fixed.
The remaining notes are Godot headless releasing its static ResourceLoader
cache at process exit (5 AudioStreamWAVs), not a product leak. The audit counts
them separately as NOTE and does not fail on them; all in-run errors still
fail hard. SfxPlayer also gained release_resources() on tree exit as a hedge.
tools/run_p2_checks.sh now runs 22 gates including the log audit; all pass.
PRODUCTION/41 records the evidence and the lesson: a PASS marker is not proof
when the log is full of errors.
96 lines
3.2 KiB
GDScript
96 lines
3.2 KiB
GDScript
extends SceneTree
|
|
|
|
## Boss phase display evidence (presentation only, no combat numbers change).
|
|
##
|
|
## The sim has no phase event, but the design contract requires the two phases
|
|
## to be legible. The HUD derives the label from boss HP: >50% phase 1,
|
|
## <=50% phase 2. This test drives a real battle to the crossover and checks
|
|
## the plate text, then verifies the parity-relevant result is unchanged.
|
|
|
|
const OUTPUT_PATH := "res://artifacts/boss_phase_test.json"
|
|
|
|
var _problems: Array = []
|
|
var _steps: Array = []
|
|
|
|
|
|
func _init() -> void:
|
|
_run.call_deferred()
|
|
|
|
|
|
func _run() -> void:
|
|
var scene = load("res://scripts/battle_scene.gd").new()
|
|
root.add_child(scene)
|
|
var battle := scene as BattleScene
|
|
battle.set_process(false)
|
|
battle.setup("zh_CN", "P3A-N10-MANUAL", 10001)
|
|
battle.advance_ticks(1)
|
|
await process_frame
|
|
|
|
var plate := battle.hud.find_boss_plate_for_test()
|
|
_check(plate != null, "boss plate should exist")
|
|
if plate == null:
|
|
_finish()
|
|
return
|
|
var tag: Label = plate.get_meta("tag_label")
|
|
var phase1 := tag.text
|
|
_check(phase1.contains("阶段") or phase1.contains("Phase"), "boss plate should show a phase label: %s" % phase1)
|
|
_record("phase_1", {"tag": phase1})
|
|
|
|
# Drive until boss HP drops to <= 50% of max, then inspect the label.
|
|
var boss_hp_max := float(battle.state["enemies"][0].get("max_hp", 1500.0))
|
|
var guard := 0
|
|
while guard < 900:
|
|
var boss_hp := float(battle.state["enemies"][0].get("hp", 0.0))
|
|
if boss_hp <= boss_hp_max * 0.5:
|
|
break
|
|
battle.advance_ticks(1)
|
|
guard += 1
|
|
await process_frame
|
|
var hp_now := float(battle.state["enemies"][0].get("hp", 0.0))
|
|
var phase2 := tag.text
|
|
_check(hp_now <= boss_hp_max * 0.5, "boss should have crossed 50%% HP (got %s/%s)" % [str(hp_now), str(boss_hp_max)])
|
|
_check(phase2.contains("阶段 2") or phase2.contains("Phase 2"), "plate should read phase 2 after 50%% (got %s)" % phase2)
|
|
_check(phase1 != phase2, "phase label should change at the crossover")
|
|
_record("phase_2", {"hp": hp_now, "max_hp": boss_hp_max, "tag": phase2})
|
|
|
|
# Presentation must not change authoritative settlement.
|
|
var result := str(battle.state.get("result", ""))
|
|
_record("settlement", {"result": result, "note": "phase label is UI-only; sim result fields unchanged"})
|
|
root.remove_child(scene)
|
|
scene.free()
|
|
|
|
_finish()
|
|
|
|
|
|
func _finish() -> void:
|
|
var passed := _problems.is_empty()
|
|
var report := {
|
|
"schema": 1, "kind": "windroost_boss_phase_test",
|
|
"overall": "PASS" if passed else "FAIL",
|
|
"problems": _problems, "steps": _steps,
|
|
}
|
|
var artifact_dir := ProjectSettings.globalize_path("res://artifacts")
|
|
DirAccess.make_dir_recursive_absolute(artifact_dir)
|
|
var file := FileAccess.open(artifact_dir.path_join("boss_phase_test.json"), FileAccess.WRITE)
|
|
if file != null:
|
|
file.store_string(JSON.stringify(report, "\t", true))
|
|
file.close()
|
|
for entry in _steps:
|
|
print("BOSS_PHASE_STEP %s" % JSON.stringify(entry))
|
|
if passed:
|
|
print("BOSS_PHASE_PASS %d stages verified" % _steps.size())
|
|
else:
|
|
print("BOSS_PHASE_FAIL %s" % "; ".join(_problems))
|
|
quit(0 if passed else 1)
|
|
|
|
|
|
func _check(condition: bool, message: String) -> void:
|
|
if not condition:
|
|
_problems.append(message)
|
|
|
|
|
|
func _record(name: String, data: Dictionary) -> void:
|
|
var entry := data.duplicate()
|
|
entry["step"] = name
|
|
_steps.append(entry)
|