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.
101 lines
3.5 KiB
GDScript
101 lines
3.5 KiB
GDScript
extends SceneTree
|
|
|
|
## Temporary SFX evidence: every stream loads, mute is a hard gate, and the
|
|
## authoritative battle events map to the priority feedback cues.
|
|
|
|
const OUTPUT_PATH := "res://artifacts/audio_test.json"
|
|
|
|
var _problems: Array = []
|
|
var _steps: Array = []
|
|
|
|
|
|
func _init() -> void:
|
|
_run.call_deferred()
|
|
|
|
|
|
func _run() -> void:
|
|
var player := SfxPlayer.new()
|
|
root.add_child(player)
|
|
await process_frame
|
|
|
|
var names := ["click", "hit", "shield_break", "ultimate", "victory", "defeat", "upgrade", "ui", "reward"]
|
|
for name in names:
|
|
_check(player.stream_count() >= names.size(), "expected %d SFX streams" % names.size())
|
|
_check(player._streams.has("windplain_loop") or player._bgm_stream != null, "BGM stream should load")
|
|
_record("streams", {"loaded": player.stream_count(), "expected": names.size(), "bgm": player._bgm_stream != null})
|
|
|
|
# Rate limiting: the same cue may play at most 3 times per second.
|
|
player.reset_played()
|
|
for i in range(5):
|
|
player.play("hit")
|
|
_check(player.played_names().size() == 3, "rate limit should cap repeated hit at 3, got %d" % player.played_names().size())
|
|
_record("rate_limit", {"plays": player.played_names().size()})
|
|
|
|
# Mute is a hard gate, including BGM.
|
|
player.reset_played()
|
|
player.start_bgm()
|
|
_check(player.is_bgm_playing(), "BGM should start when unmuted")
|
|
player.set_muted(true)
|
|
_check(not player.is_bgm_playing(), "mute should stop BGM")
|
|
player.play("hit")
|
|
player.play("ultimate")
|
|
_check(player.played_names().is_empty(), "muted plays must be suppressed")
|
|
_record("muted", {"played": player.played_names(), "bgm_playing": player.is_bgm_playing()})
|
|
player.set_muted(false)
|
|
|
|
# Battle events drive both VFX and audio from the same source.
|
|
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(300)
|
|
await process_frame
|
|
await process_frame
|
|
var played := battle.hud.sfx.played_names()
|
|
for expected in ["click", "hit", "shield_break", "ultimate"]:
|
|
_check(played.has(expected), "battle events should have played %s, got %s" % [expected, str(played)])
|
|
_record("battle_events", {"played": played, "event_count": (battle.state.get("event_log", []) as Array).size()})
|
|
if battle.hud.sfx != null:
|
|
battle.hud.sfx.release_resources()
|
|
root.remove_child(scene)
|
|
scene.free()
|
|
|
|
# Release audio resources before exit so Godot does not report leaks.
|
|
player.set_muted(true)
|
|
root.remove_child(player)
|
|
player.release_resources()
|
|
player.free()
|
|
|
|
var passed := _problems.is_empty()
|
|
var report := {
|
|
"schema": 1, "kind": "windroost_audio_test",
|
|
"status": "temporary_placeholder_sfx",
|
|
"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("audio_test.json"), FileAccess.WRITE)
|
|
if file != null:
|
|
file.store_string(JSON.stringify(report, "\t", true))
|
|
file.close()
|
|
for entry in _steps:
|
|
print("AUDIO_STEP %s" % JSON.stringify(entry))
|
|
if passed:
|
|
print("AUDIO_PASS %d stages verified" % _steps.size())
|
|
else:
|
|
print("AUDIO_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)
|