diff --git a/game/smoke/shot_probe.gd b/game/smoke/shot_probe.gd index edda5c6f..7f4c5215 100644 --- a/game/smoke/shot_probe.gd +++ b/game/smoke/shot_probe.gd @@ -16,6 +16,11 @@ var _meta := {} # 控件实测几何(全局 rect——shot_checker 文字框 func _ready() -> void: + # 运行前提=窗口化真渲染面:headless 下 frame_post_draw 永不触发+视口纹理恒空——无此守卫时 headless 调用方必挂死(2026-10-02 挂死灾害批护栏) + if DisplayServer.get_name() == "headless": + print("[shot_probe] FAIL — 本探针必须窗口化运行(headless 无渲染面,截图必空);headless 自动闸禁跑本探针(正主=tools/probe_gate.sh)") + get_tree().quit(1) + return var args := OS.get_cmdline_user_args() out_dir = args[0] if args.size() >= 1 and args[0] != "" else "user://qa-screens" DirAccess.make_dir_recursive_absolute(out_dir) diff --git a/tools/probe_gate.sh b/tools/probe_gate.sh new file mode 100644 index 00000000..d6233932 --- /dev/null +++ b/tools/probe_gate.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +# 轻闸探针正主(2026-10-02 挂死灾害批落籍)——headless 安全段固化,禁再手拼同款 Godot 命令。 +# 三闸:①每段 timeout 守卫(挂死=FAIL 不静默)②段前预清+段后清本 game 目录孤儿 Godot +# (按命令行精确匹配本 game 路径,不误杀其他 worktree 会话的合法进程)③末尾残留清点=批末闸(必须 0)。 +# 段:ui_input_probe=默认必跑;--click=加跑 ui_click_probe 行为走查(自退出+退出码闸;超时多半= +# 探针未适配新停点层,归 probe适配批);shot_probe 禁入本闸——必须窗口化运行(headless 无渲染面, +# 探针内已有 fail-fast 护栏),归真人目检。 +# 用法: tools/probe_gate.sh [game目录] [--click] 缺省 game 目录=脚本所在仓库的 game/(worktree 内自动指向该 worktree) +# 依赖: Git Bash(coreutils timeout/taskkill) + PowerShell;Godot 路径可用环境变量 GODOT_BIN 覆盖。 +set -u +G="${GODOT_BIN:-/d/code/godot/Godot_v4.7.2-stable_win64_console.exe}" +REPO="$(cd "$(dirname "$0")/.." && pwd)" +GAME=""; WITH_CLICK=0 +for a in "$@"; do + case "$a" in + --click) WITH_CLICK=1 ;; + *) GAME="$a" ;; + esac +done +GAME="${GAME:-$REPO/game}" +GAME_WIN="$(cygpath -m "$GAME")" # Godot --path 需 Windows 形式 +TMP="$(mktemp -d /tmp/probegate_XXXXXX)" +trap 'rm -rf "$TMP"' EXIT +_rc=0 + +orphans() { # 列出命令行含本 game 路径的 Godot 进程 PID(console wrapper+真引擎都算) + printf "Get-CimInstance Win32_Process -Filter \"Name like 'Godot%%'\" | Where-Object { \$_.CommandLine -like '*%s*' } | ForEach-Object { \$_.ProcessId }\n" "$GAME_WIN" > "$TMP/k.ps1" + powershell -NoProfile -ExecutionPolicy Bypass -File "$(cygpath -w "$TMP/k.ps1")" 2>/dev/null | tr -d '\r' +} +kill_orphans() { + local p; for p in $(orphans); do taskkill //F //PID "$p" >/dev/null 2>&1; done +} + +# 冷检出刷导入(.godot 不入 git,fresh worktree 首跑一次性付) +if [ ! -f "$GAME/.godot/uid_cache.bin" ]; then + echo "[probe_gate] 冷检出:editor --quit 刷导入(一次性,可到 1-2 分钟)" + timeout 300 "$G" --headless --path "$GAME_WIN" --editor --quit >/dev/null 2>&1 + kill_orphans +fi + +pre="$(orphans | wc -l | tr -d ' ')" +if [ "$pre" -gt 0 ]; then echo "[probe_gate] 预清本闸残留 Godot×$pre"; kill_orphans; fi + +echo "======== ui_input_probe ========" +timeout 120 "$G" --headless --path "$GAME_WIN" res://smoke/ui_input_probe.tscn >"$TMP/uip.log" 2>&1 +st=$?; kill_orphans +grep -E "PASS|FAIL|问题" "$TMP/uip.log" | head -12 +if [ "$st" -eq 124 ] || [ "$st" -eq 137 ]; then + echo "[probe_gate] FAIL — ui_input_probe 超时挂死(exit=$st),孤儿已清"; _rc=1 +elif ! grep -q "PASS" "$TMP/uip.log"; then + echo "[probe_gate] FAIL — ui_input_probe 未见 PASS(exit=$st)"; _rc=1 +fi + +if [ "$WITH_CLICK" -eq 1 ]; then + echo "======== ui_click_probe 行为走查 ========" + timeout 240 "$G" --headless --path "$GAME_WIN" res://smoke/ui_click_probe.tscn >"$TMP/clk.log" 2>&1 + st=$?; kill_orphans + grep -E "click_probe" "$TMP/clk.log" | tail -4 + if [ "$st" -eq 124 ] || [ "$st" -eq 137 ]; then + echo "[probe_gate] FAIL — ui_click_probe 超时(exit=$st):挂死或探针未适配新停点层(归 probe适配批),孤儿已清"; _rc=1 + elif [ "$st" -ne 0 ]; then + echo "[probe_gate] FAIL — ui_click_probe 退出码=$st(done=false 或 问题>0)"; _rc=1 + fi +fi + +echo "======== 残留检查(批末闸) ========" +left="$(orphans | wc -l | tr -d ' ')" +total="$(tasklist 2>/dev/null | grep -ci '^Godot' || true)" +echo "本闸残留 Godot=$left(必须0) 全局 Godot 进程=$total(其他会话的仅报数不算账)" +if [ "$left" -ne 0 ]; then echo "[probe_gate] FAIL — 本闸残留未清零"; kill_orphans; _rc=1; fi +if [ "$_rc" -eq 0 ]; then echo "[probe_gate] 全绿"; else echo "[probe_gate] 存在 FAIL,见上"; fi +exit "$_rc"