雾格已于 2026-09-14 从设计中永久移除(05-不做清单),本批把残留从实现到文档清干净。 代码与数据表: - 删:雾布置管线(区域生长/厚度约束/safe_nonzero 强制)、雾预算核算、雾指标输出 (actual_fog_ratio / fog_burden_ratio / delta_budget_fog)、求解器"雾元知识"信息通道、 硬编码 "fog" 变异、雾池加载护栏、雾格渲染/tint/雾区全开信号、雾图例条目、雾首遇提示、 雾教学断言;variation/board_gen/reward_config 三表雾字段与雾校验 - 删 inferability_core(雾移除后恒等于主指标,留着会制造双判据假象)及其 3 处消费方 - 留:变异框架面(variants/variant_ids/候选池门控/变异表加载通道与通用字段/ 出生区无变异不变式/事件载荷 variant_ids 空槽),MVP 下恒空;加行即生效承诺不变 - 验证:冒烟 196/196(+3 变异框架面断言)、三场景探针全 PASS、 期望扫描与清理前同种子逐位相同(L2 板去雾后可推理率 0.908→0.951) 文档与 registry: - 十份系统文档的雾失义登记与待拍板条目按删除概念 SOP 关闭并补版本历史;03/02 顶层同步 - design/ux/battle.md 与 interaction-patterns.md 去雾(格态收窄两态)+ 修订记录表 - registry:删 t_fog_min / fog_region_count / fog_target_ratio / terrain_variation_acceptance_mapping / pricing_constraints 等键;指标集八项→四项;hint_id 去 fog_first; variation_table 反向边收敛为三个真实引用方 - 连带:art-bible 雾资产占位、tests/README 示例测试名、doc-conventions 第 4 节正例、 研究件失效注记、切片 README 现状陈述与补记
68 lines
3.4 KiB
Markdown
68 lines
3.4 KiB
Markdown
# Test Infrastructure — Dungeon Sweeper
|
||
|
||
**Engine**: Godot 4.7.2-stable(GDScript 单语言)
|
||
**Test Framework**: 双载体(ADR-0004)——`--headless --script` 逻辑冒烟 + headless 场景探针;gdUnit4 **deferred**(D2 OQ1 关闭形态,正式 CI 期再议)
|
||
**CI**: `.github/workflows/tests.yml`(首次 push 到 GitHub 后自动生效;仓库 2026-09-12 尚未初始化 git)
|
||
**Setup date**: 2026-09-12
|
||
**参考实现**: `prototypes/dungeon-sweeper-vertical-slice/smoke/`(冒烟 96/96 + 三 UI 探针——正式工程的活样板)
|
||
|
||
## Directory Layout
|
||
|
||
```
|
||
tests/
|
||
unit/ # 隔离单元测试(公式/状态机/纯逻辑)——extends SceneTree + quit(code)
|
||
integration/ # 跨系统测试(Core-Core 集成、回放确定性、存档往返)
|
||
smoke/ # critical-paths.md——人工 gate 清单(/smoke-check 读取)
|
||
evidence/ # 截图与人工签核记录
|
||
run_all.gd # CI 冒烟统一入口(套件 manifest 协议,D2 AC-2b)
|
||
static_scan.sh # ADR-0004 静态扫描域 S1–S8 可执行子集
|
||
```
|
||
|
||
## Running Tests
|
||
|
||
```bash
|
||
# 逻辑冒烟(双载体之一)——Windows 须用 console 版 exe 取 stdout
|
||
godot --headless --script tests/run_all.gd # 统一入口(CI 调用点)
|
||
godot --headless --script tests/unit/example_test.gd
|
||
|
||
# 场景探针(双载体之二)——以探针场景为运行目标,走完整项目引导(autoload 在位)
|
||
godot --headless --path . res://tests/probes/<probe>.tscn
|
||
|
||
# CI 旁必须配外部 wall-clock 超时(ADR-0004:引擎无死锁探测)
|
||
timeout 120s godot --headless --script tests/run_all.gd
|
||
```
|
||
|
||
**协议要点**(D2 冒烟协议 + ADR-0004):
|
||
- 冒烟脚本 `extends SceneTree` 以获得 `quit(code)`;成功 `quit(0)`、失败 `quit(1)`
|
||
- `--script` 模式**不加载 autoload 且不注册全局标识符**(裸引用 `ConfigDB` = parse error)——ConfigDB/RngService 由脚本显式实例化,core 一律构造注入
|
||
- 致命类用例独立进程,runner manifest 登记"调用 → 期望退出码"
|
||
- 每用例先 `reset_diagnostics()`(诊断收集器协议)
|
||
- 期望值由表读值推导,不写死玩法数值
|
||
|
||
## Test Naming
|
||
|
||
- **Files**: `[system]_[feature]_test.gd`(领域命名,禁 ID 前缀——docs/code-conventions.md)
|
||
- **Functions**: `test_[scenario]_[expected]`
|
||
- **Example**: `reward_roll_test.gd` → `test_power_interval_rolls_within_bounds()`
|
||
|
||
## Story Type → Test Evidence
|
||
|
||
| Story Type | Required Evidence | Location |
|
||
|---|---|---|
|
||
| Logic | Automated unit test — must pass | `tests/unit/[system]/` |
|
||
| Integration | Integration test OR playtest doc | `tests/integration/[system]/` |
|
||
| Visual/Feel | Screenshot + lead sign-off | `tests/evidence/` |
|
||
| UI | Manual walkthrough OR interaction test(场景探针为首选) | `tests/evidence/` |
|
||
| Config/Data | Smoke check pass | `production/qa/smoke-*.md` |
|
||
|
||
## Static Scan(提交前双跑:本地 + CI)
|
||
|
||
`tests/static_scan.sh` 实现 ADR-0004 扫描域 S1–S8 的可执行子集;规则全集与动机见
|
||
`docs/architecture/adr-0004-test-carrier-and-ci.md`。新违规案例必须**先补扫描规则再修码**。
|
||
|
||
## CI
|
||
|
||
Tests run automatically on every push to `main` and on every pull request.
|
||
A failed test suite blocks merging. **gdUnit4 安装说明(deferred,届时启用)**:
|
||
AssetLib → GdUnit4 → Install → Project Settings → Plugins 勾选 → 重启编辑器 → 确认 `res://addons/gdunit4/`。
|