Files
gplan-2/game/tests/unit/data_config/reward_dangling_treasure_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

57 lines
2.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.
# 致命类用例(独立进程,期望退出码 1)
# reward_dangling_treasure——RewardTable aux 投放行双表校验:aux 行 effect_id 引用 retired
# 道具(夹具用 loot_compass)时,config_db 跨表校验必须报 reward_dangling_treasure、
# load_tables 整体拒绝(退役件/失义件不得出现在掉落投放面)。
# 运行:godot --headless --path game --script res://tests/unit/data_config/reward_dangling_treasure_test.gd
# 退出码协议:1 = 校验正确拒绝(预期);2 = 违规表被放行(回归信号)。
extends SceneTree
const ConfigDBScript := preload("res://core/config_db.gd")
const Kit := preload("res://tests/unit/test_kit.gd") # T6 收口:BAD 表目录夹具共享(copy_tables)
const SRC_DIR := "res://data/tables"
const BAD_DIR := "user://treasure_fixture_dangling"
func _inject_violation() -> bool:
# 判据出处: design/gdd/systems/表现与支撑/数据配置.md:199 校验类别:悬空引用夹具(悬空引用组)
var path := BAD_DIR + "/reward.tres"
var f := FileAccess.open(path, FileAccess.READ)
if f == null:
return false
var s := f.get_as_text()
f.close()
# 追加式注入(现行表已无 aux 行可作锚):向 rows 尾追加
# 一块引用已退役 loot_compass 的 aux 投放行,双表校验须拦(retired 不入投放面)。
var inject := ', {\n\n"reward_id": "treasure_dangling_probe",\n"cell_type": "treasure_item",\n"polarity": "positive",\n"effect_id": "loot_compass",\n"display_name": "悬空探针",\n"power": 0,\n"weight": 1,\n"pool_tag": "cell",\n"tier": 1\n}'
var idx := s.rfind("\n}]")
if idx < 0:
return false
s = s.substr(0, idx) + inject + s.substr(idx)
var w := FileAccess.open(path, FileAccess.WRITE)
if w == null:
return false
w.store_string(s)
w.close()
return true
func _init() -> void:
# 判据出处: design/gdd/systems/表现与支撑/数据配置.md:200 致命真的会死:悬空引用被拒绝、进程非 0(拒绝组)
if not Kit.copy_tables(SRC_DIR, BAD_DIR) or not _inject_violation():
push_error("[reward_dangling_treasure_test] 夹具目录准备失败")
quit(2)
return
var db = ConfigDBScript.new()
var ok: bool = db.load_tables(BAD_DIR, false)
if ok:
push_error("[reward_dangling_treasure_test] 违规表被放行——aux 双表校验失守(回归)")
quit(2)
return
if db.diagnostics_count("error") >= 1:
print("[reward_dangling_treasure_test] 双表校验触发(reward_dangling_treasure 诊断在案,加载被拒)")
quit(1)
return
push_error("[reward_dangling_treasure_test] 加载被拒但无 reward_dangling_treasure 诊断——校验通道静默化(回归)")
quit(2)