playbook/tests
csh 6efd637119 🐛 fix(sync): keep agents block blank lines 2026-01-26 09:34:44 +08:00
..
cli 🐛 fix(sync): keep agents block blank lines 2026-01-26 09:34:44 +08:00
integration 🐛 fix(test): skip external root doc links 2026-01-22 16:16:36 +08:00
templates 🔧 chore(templates): align agent templates and docs 2026-01-23 11:37:29 +08:00
README.md 🗑️ remove(legacy): drop old scripts and tests 2026-01-23 14:58:31 +08:00

README.md

🧪 Playbook 测试套件

本目录包含 Playbook 项目的测试,用于验证 CLI、模板与文档链接。

📋 目录结构

tests/
├── README.md                       # 本文件:测试文档
├── cli/                            # Python CLI 测试unittest
│   └── test_playbook_cli.py        # playbook.py 基础功能测试
├── templates/                      # 模板验证测试
│   ├── validate_python_templates.sh    # Python 模板验证
│   ├── validate_cpp_templates.sh       # C++ 模板验证
│   ├── validate_ci_templates.sh        # CI 模板验证
│   └── validate_project_templates.sh   # 项目模板验证
└── integration/                    # 集成测试
    └── check_doc_links.sh          # 文档链接有效性检查

🚀 快速开始

# 进入 playbook 根目录
cd /path/to/playbook

# 1. 运行 Python CLI 测试
python -m unittest discover -s tests/cli -v

# 2. 运行模板验证测试
sh tests/templates/validate_python_templates.sh
sh tests/templates/validate_cpp_templates.sh
sh tests/templates/validate_ci_templates.sh
sh tests/templates/validate_project_templates.sh

# 3. 运行文档链接检查
sh tests/integration/check_doc_links.sh

🧭 CI 自动化测试

测试套件通过 Gitea Actions 自动运行(见 .gitea/workflows/test.yml

  • 触发时机
    • 推送到 main 分支
    • Pull Request 到 main 分支
    • 手动触发workflow_dispatch
  • 运行平台ubuntu-22.04

📚 测试详解

1. Python CLI 测试 (cli/)

使用 unittest 运行,覆盖 scripts/playbook.py 的核心行为:

  • CLI 参数解析与帮助信息
  • TOML 配置解析与动作顺序
  • vendor/sync/install 等基础动作落地

2. 模板验证测试 (templates/)

通过脚本检查各类模板文件结构与关键字段(如占位符、关键配置项)。

3. 文档链接检查 (integration/)

扫描 docs/ 与模板文件中的本地链接,确保引用路径有效。