Files
gplan-2/game/tests/unit/example_test.gd
T
DKChan 9f21236f80 工程(注释标记词换代·oracle→判据出处): 用户 2026-11-07 令——判据出处注记的标记词改用项目已有中文名,避免 Oracle 被读成数据库。注释格式句、机检正则、标识符、卡片与登记同步换代;零行为改动。
改动面 112 文件 572+/572-:game/tests/** 与 game/probe/** 共 106 件 545 行 `# oracle:`→`# 判据出处:`;tools/capability_audit.py 正则字面量换中文+ORACLE_*→CRITERION_*/check_oracle_markers→check_criterion_markers/oracle_marked(flagged)→criterion_* 共 11 行;test-conventions.md:119 格式句+:155 措辞;待办清单与需求卡片-QA覆盖余量收口批各 1 处字面量;coverage_enum.py:21 与 camp_scene_layout_test.gd:101 旁支措辞;ui_click_probe.gd 对拍局部变量 oracle→expected 7 处;auto_player.gd 三处 safe_set 真值措辞。不动:历史审计报告两份、test-oracle-anchor 分支名、git 史、生成日志;指针格式/扫描面/判红条件/验收义务全不变。

读数(区内实跑):改前 capability_audit --strict「417 注记函数·红项 0」→改后「417 判据出处注记函数·红项 0」exit=0;新标记 545 行/106 文件,现行义务面 oracle 残留 0(在册沿革除外);diff 自检 game/ 非注释新增行仅 6 行且全在 ui_click_probe.gd 的 expected 变量段;112 改动文件 CRLF=0;py_compile tools/capability_audit.py OK;--docs exit=0【验收通过】无新增红;--gates exit=0(静态扫描绿、闸壳 bash -n ×13 失败 0)。
2026-11-07 07:11:15 +08:00

28 lines
1.6 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# tests/unit/example_test.gd — 示例测试:项目测试协议的活样板(gate-check 硬性要求 ≥1 示例测试)
# 运行:godot --headless --script tests/unit/example_test.gd
# 协议要点(D2 冒烟协议):
# extends SceneTree 以获得 quit(code);断言失败 → push_error + quit(1);全绿 → quit(0)
# --script 模式无 autoload 且无全局标识符(裸引用 ConfigDB = parse error)——
# 涉及表值的测试须显式实例化 ConfigDB,期望由表读值推导不写死
# 第一个真实测试:复制本文件为 tests/unit/<system>/<system>_<feature>_test.gd 并替换占位断言
extends SceneTree
const Kit := preload("res://tests/unit/test_kit.gd") # T6 收口:check/汇总退出样板单点
func _init() -> void:
# 判据出处: design/engineering/test-conventions.md:37 (套件协议模板——执行载体与退出码范例组)
Kit.check("headless SceneTree 协议可用(quit(code) 通道)", _test_headless_protocol())
Kit.check("命名规范可执行:test_[scenario]_[expected]", _test_naming_convention_followed())
quit(Kit.finish("example_test"))
func _test_headless_protocol() -> bool:
# 占位断言:验证脚本本身在 SceneTree 上下文可执行。
# 真实测试写法示例(引用不执行):
# var cfg := ConfigDBStub.new() # 显式实例化,非全局标识符
# return cfg.action_economy.ap_per_round >= 1
return true
func _test_naming_convention_followed() -> bool:
# 占位断言:本文件函数名均以 test_ 前缀 + 场景_期望 结构(docs/code-conventions.md)
return true