# tests/run_all.gd — CI 冒烟统一入口(ADR-0004 双载体的逻辑冒烟调用点) # 用法:godot --headless --script tests/run_all.gd (CI 侧包装外部超时:timeout 120s …) # 协议:套件清单逐条"套件 → 期望退出码"(D2 AC-2b manifest);致命类独立进程。 # 现状:正式 Godot 工程尚未在根目录创建(代码在 prototypes/dungeon-sweeper-vertical-slice/, # 其 smoke/smoke_all.gd 96/96 为参考实现)——本入口当前仅验证运行协议自身; # 正式工程落地后,把套件清单登记进 _suites()。 extends SceneTree func _init() -> void: print("[run_all] formal smoke entry — protocol check") if DisplayServer.get_name() != "headless": push_warning("[run_all] 建议以 --headless 运行(D2 冒烟协议)") var failures := 0 for suite in _suites(): failures += _run_suite(suite) if failures > 0: push_error("[run_all] %d 个套件失败" % failures) quit(1) return print("[run_all] all green (%d suites)" % _suites().size()) quit(0) # 返回 Array of Dictionary:{ "path": String, "expect": int } # 正式工程落地后在此登记;探针场景(.tscn 载体)由 CI 单独步骤调用,不经本入口。 func _suites() -> Array: return [ # {"path": "res://tests/unit/example_test.gd", "expect": 0}, # {"path": "res://tests/unit/reward_economy/reward_roll_test.gd", "expect": 0}, # 致命类(独立进程,期望非 0): # {"path": "res://tests/unit/d2/fixture_missing_table_test.gd", "expect": 1}, ] func _run_suite(suite: Dictionary) -> int: # SceneTree 脚本内不能直接以 OS.execute 递归调 godot 的成熟形态留待正式工程 # (需解析 godot 二进制路径);当前协议检查阶段只断言清单形态合法。 var path: String = suite.get("path", "") if path.is_empty(): push_error("[run_all] suite missing path") return 1 print("[run_all] registered: %s (expect=%d)" % [path, suite.get("expect", 0)]) return 0