diff --git a/game/tests/static_scan.sh b/game/tests/static_scan.sh index c1e8a1c1..1be94af6 100755 --- a/game/tests/static_scan.sh +++ b/game/tests/static_scan.sh @@ -20,6 +20,16 @@ fail=0 DIR_CORE="game/core" DIR_PRES="game/presentation" +# python 解释器解析:PATH 有 python 用 python,只有 python3(runner 常态)回落 python3—— +# 硬编码 python 在无别名机器上=127 command not found,三审计零输出静默判红(CI run15 实证)。 +PY_BIN="" +if command -v python >/dev/null 2>&1; then PY_BIN="python" +elif command -v python3 >/dev/null 2>&1; then PY_BIN="python3" +else + echo "[static_scan] FAIL: 无 python 解释器(PATH 上既无 python 也无 python3)" + exit 1 +fi + scan_files() { # scan_files <目录> — 该目录下 .gd 文件数 find "$1" -name '*.gd' 2>/dev/null | wc -l } @@ -36,7 +46,7 @@ require_scan_face() { # require_scan_face <规则名> <目录> — 扫描面 } # S9 — 类型闸(code-conventions §4 机器闸:产品码无类型容器/有值返回缺类型/参数缺类型) -if python tools/audit_type_hints.py; then +if "$PY_BIN" tools/audit_type_hints.py; then echo "[static_scan] S9 ok" else echo "[static_scan] S9 FAIL: 类型闸存量未归零(R1/R2/R3 见上清单)" @@ -44,7 +54,7 @@ else fi # S10 — 文件头闸(code-conventions §1.4.1:## 载体+日期/变更叙事黑名单;行数上限已停用) -if python tools/audit_file_headers.py; then +if "$PY_BIN" tools/audit_file_headers.py; then echo "[static_scan] S10 ok" else echo "[static_scan] S10 FAIL: 文件头存量见上清单" @@ -296,7 +306,7 @@ fi # 簿,登记值只准随还债下降,禁抬高到现状。基线重生成=人工专用(python tools/gdstyle_gate.py # --refresh,附对账;键数骤降逾 10% 或登记值被抬高均拒写,须 --force),禁清基线换绿。二进制本机固定路径 # D:/code/gdstyle/gdstyle.exe(不入库),GDSTYLE_BIN 环境变量覆盖;版本与钉定版不符即红(升级须重测)。 -if python tools/gdstyle_gate.py; then +if "$PY_BIN" tools/gdstyle_gate.py; then echo "[static_scan] S13 ok" else echo "[static_scan] S13 FAIL: 基线外新违规/指标恶化或二进制/版本/扫描面问题(清单见上)"