test(templates): add template coverage

This commit is contained in:
csh
2026-01-21 10:51:48 +08:00
parent fc230b7ff9
commit b2eb475a6d
6 changed files with 288 additions and 2 deletions
+39 -2
View File
@@ -9,12 +9,14 @@ tests/
├── README.md # 本文件:测试文档
├── scripts/ # Shell 脚本测试(bats
│ ├── test_sync_standards.bats # sync_standards.sh 测试
│ ├── test_sync_templates.bats # sync_templates.sh 测试
│ ├── test_vendor_playbook.bats # vendor_playbook.sh 测试
│ └── test_install_codex_skills.bats # install_codex_skills.sh 测试
├── templates/ # 模板验证测试
│ ├── validate_python_templates.sh # Python 模板验证
│ ├── validate_cpp_templates.sh # C++ 模板验证
── validate_ci_templates.sh # CI 模板验证
── validate_ci_templates.sh # CI 模板验证
│ └── validate_project_templates.sh # 项目模板验证
└── integration/ # 集成测试
└── check_doc_links.sh # 文档链接有效性检查
```
@@ -31,6 +33,7 @@ cd /path/to/playbook
sudo apt-get install bats # Ubuntu/Debian
cd tests/scripts
bats test_sync_standards.bats
bats test_sync_templates.bats
bats test_vendor_playbook.bats
bats test_install_codex_skills.bats
@@ -39,6 +42,7 @@ cd tests/templates
sh validate_python_templates.sh
sh validate_cpp_templates.sh
sh validate_ci_templates.sh
sh validate_project_templates.sh
# 3. 运行集成测试
cd tests/integration
@@ -88,6 +92,21 @@ sh check_doc_links.sh
- **幂等性**
- 多次执行结果一致
#### test_sync_templates.bats
测试 `scripts/sync_templates.sh` 脚本的功能:
- **基础同步**
- 同步 memory-bank/ 与 docs/prompts/
- 创建 AGENTS.md / AGENT_RULES.md / TODO.md / CONFIRM.md
- **占位符替换**
- `{{PROJECT_NAME}}``{{DATE}}`
- **目录覆盖策略**
-`--force` 时不覆盖已有目录
- `--force` 时覆盖并备份
- **AGENTS.md 更新**
- `--full` 更新 framework 区块
#### test_vendor_playbook.bats
测试 `scripts/vendor_playbook.sh` 脚本的功能:
@@ -227,6 +246,22 @@ sh check_doc_links.sh
- 包含 README 说明文档
- 包含使用说明
#### validate_project_templates.sh
验证项目通用模板:
- **核心模板**
- `templates/AGENTS.template.md`
- `templates/AGENT_RULES.template.md`
- `templates/README.md`
- **memory-bank 模板**
- 项目定位/技术栈/架构/进度/决策/实施计划
- **prompts 模板**
- `prompts/README.md`
- `prompts/system/agent-behavior.template.md`
- `prompts/coding/clarify.template.md`
- `prompts/coding/verify.template.md`
### 3. 集成测试 (integration/)
端到端测试,验证整体功能。
@@ -236,7 +271,7 @@ sh check_doc_links.sh
检查所有 Markdown 文档中的链接有效性:
- **扫描范围**
- 所有 `*.md` 文件
- 所有 `*.md` 文件(排除 `*.template.md`
- 排除 node_modules, .git, build, dist 等目录
- **链接类型**
- Markdown 链接:`[text](link)`
@@ -296,6 +331,7 @@ pip3 install yamllint
# Shell 脚本测试
cd tests/scripts
bats test_sync_standards.bats --tap # TAP 格式输出
bats test_sync_templates.bats
bats test_vendor_playbook.bats --formatter junit # JUnit 格式
# 模板验证测试
@@ -303,6 +339,7 @@ cd tests/templates
sh validate_python_templates.sh
sh validate_cpp_templates.sh
sh validate_ci_templates.sh
sh validate_project_templates.sh
# 集成测试
cd tests/integration