playbook/test
csh 565071c11f 🎨 style(md): lint and format all Markdown files
- Update .markdownlint.json: disable MD024 (duplicate headings) and MD025 (multiple h1)
  - MD024: test cases intentionally use duplicate headings for test IDs
  - MD025: function catalog files use multiple h1 for different function groups
- Fix MD040: add language identifiers to fenced code blocks in test/agent/README.md
- Fix MD031: add blank lines around fenced code blocks
- Run prettier to format all Markdown files consistently
- Fix table alignment and spacing issues

All markdownlint errors are now resolved.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-21 17:37:29 +08:00
..
agent 🎨 style(md): lint and format all Markdown files 2026-06-21 17:37:29 +08:00
cli 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
integration 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
templates 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
README.md 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
test_deployment_routes_e2e.py 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
test_firstparty_skills_quality.py 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
test_format_md_action.py 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
test_gitattributes_modes.py 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
test_gitea_workflow_bootstrap.py 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
test_main_loop_cli.py 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
test_no_backup_flags.py 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
test_playbook_docs_index.py 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
test_script_line_endings.py 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
test_skills_readme.py 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
test_sync_directory_actions.py 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
test_sync_templates_placeholders.py 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
test_thirdparty_skill_curation.py 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
test_thirdparty_skills_pipeline.py 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
test_toml_edge_cases.py 📝 docs(tsl): clarify syntax constraints and enhance test infrastructure 2026-06-21 17:04:50 +08:00
test_tsl_entrypoints_consistency.py test(tsl): adjust overly strict test assertions 2026-06-21 17:29:22 +08:00

README.md

🧪 Playbook 测试套件

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

📋 目录结构

tests/
├── README.md                       # 本文件:测试文档
├── cli/                            # Python CLI 测试unittest
│   ├── test_claude_md_sync.py      # CLAUDE.md 同步与注入测试
│   ├── test_install_skills.py      # install_skills 与 skill_link 行为测试
│   ├── test_sync_standards_cli.py  # sync_standards 规则集同步测试
│   └── test_playbook_cli.py        # playbook.py 基础功能测试
├── test_format_md_action.py        # format_md 动作测试
├── test_gitea_workflow_bootstrap.py # Gitea workflow 自举顺序回归测试
├── test_firstparty_skills_quality.py # first-party skills 元数据与结构质量测试
├── test_gitattributes_modes.py     # gitattr_mode 行为测试
├── test_no_backup_flags.py         # no_backup 行为测试
├── test_sync_directory_actions.py  # sync_memory_bank/sync_prompts 行为测试
├── test_main_loop_cli.py           # main_loop CLI 测试
├── test_thirdparty_skills_pipeline.py # thirdparty skills 流水线配置与同步产物测试
├── test_sync_templates_placeholders.py # 占位符替换测试sync_rules/sync_standards
├── test_toml_edge_cases.py         # TOML 解析边界测试
├── 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

# 1.1 运行其他 Python 测试tests/ 下的 test_*.py
python -m unittest discover -s tests -p "test_*.py" -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 配置解析与动作顺序
  • snapshot install/sync_rules/sync_memory_bank/sync_prompts/sync_standards 等基础动作落地

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

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

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

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