qt-unittest-build
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese你是 Qt 单元测试框架构建专家。为项目生成完整的 autotests 单元测试基础设施。
You are an expert in building Qt unit testing frameworks. Generate a complete autotests unit testing infrastructure for projects.
Iron Laws(铁律)
Iron Laws
- 使用内置资源:stub-ext 源码来自 ,不使用外部下载
resources/stub/ - 生成 autotests/ 目录:与原 qt-cpp-unittest-framework 技能保持一致
- 调用内置子 Agent:直接从 Skill 的 目录读取子 Agent,不安装到项目
agent/ - 子 Agent 权限:子 Agent 必须有 和
bash: true权限write: allow - 直接执行:不使用 ask 工具询问用户,直接拷贝和写入
- Use built-in resources: stub-ext source code comes from , no external downloads allowed
resources/stub/ - Generate autotests/ directory: Keep consistent with the original qt-cpp-unittest-framework skill
- Call built-in sub-Agents: Directly read sub-Agents from the Skill's directory, do not install them into the project
agent/ - Sub-Agent permissions: Sub-Agents must have and
bash: truepermissionswrite: allow - Execute directly: Do not use the ask tool to query the user, copy and write directly
执行流程
Execution Process
步骤 1:准备目录结构
Step 1: Prepare directory structure
创建 autotests/ 目录结构:
autotests/
├── 3rdparty/stub/ # stub-ext 源码
├── cmake/ # CMake 工具
└── run-ut.sh # 测试运行脚本Create the autotests/ directory structure:
autotests/
├── 3rdparty/stub/ # stub-ext source code
├── cmake/ # CMake tools
└── run-ut.sh # Test run script步骤 2:拷贝依赖
Step 2: Copy dependencies
将 中的所有源文件拷贝到 :
resources/stub/autotests/3rdparty/stub/- stub.h, addr_any.h, addr_pri.h, elfio.hpp
- stubext.h, stub-shadow.h, stub-shadow.cpp
Copy all source files from to :
resources/stub/autotests/3rdparty/stub/- stub.h, addr_any.h, addr_pri.h, elfio.hpp
- stubext.h, stub-shadow.h, stub-shadow.cpp
步骤 3:生成固定脚本
Step 3: Generate fixed scripts
从 生成:
resources/scripts/- :测试运行脚本(设置执行权限)
run-ut.sh - :CMake 工具(写入到
UnitTestUtils.cmake)autotests/cmake/
Generate from :
resources/scripts/- : Test run script (set execution permissions)
run-ut.sh - : CMake tool (write to
UnitTestUtils.cmake)autotests/cmake/
步骤 4:调用内置子 Agent
Step 4: Call built-in sub-Agent
直接使用 Skill 内置的子 Agent(从 读取),无需安装:
agent/qt-unittest-builder.md调用方式:
将 Skill 的 内容作为子 Agent 的提示词执行。
agent/qt-unittest-builder.md子 Agent 完成任务:
- 分析项目结构(CMakeLists.txt、源码目录、依赖)
- 生成 autotests/CMakeLists.txt
- 生成测试子目录和测试文件
- 生成测试文档(README.md)
- 验证构建:运行 cmake 配置和编译,确保测试框架可以正常运行
Directly use the Skill's built-in sub-Agent (read from ), no installation required:
agent/qt-unittest-builder.mdCalling method:
Execute the content of the Skill's as the prompt for the sub-Agent.
agent/qt-unittest-builder.mdTasks completed by the sub-Agent:
- Analyze project structure (CMakeLists.txt, source code directories, dependencies)
- Generate autotests/CMakeLists.txt
- Generate test subdirectories and test files
- Generate test documentation (README.md)
- Verify build: Run cmake configuration and compilation to ensure the testing framework can run normally
步骤 5:拷贝报告生成器
Step 5: Copy report generator
将 目录(完整的报告生成模块)拷贝到 :
resources/report_generator/autotests/report_generator/- main.py:主报告生成器
- parsers/:测试和覆盖率解析器
- generators/:HTML 和 CSV 生成器
- utils/:工具函数(ui_utils, file_utils)
Copy the directory (complete report generation module) to :
resources/report_generator/autotests/report_generator/- main.py: Main report generator
- parsers/: Test and coverage parsers
- generators/: HTML and CSV generators
- utils/: Utility functions (ui_utils, file_utils)
Red Flags(停止信号)
Red Flags
以下情况立即停止执行:
- ❌ 用户请求生成 tests/ 目录(必须是 autotests/)
- ❌ 请求使用外部 stub-ext 源码
- ❌ 文档超过 500 词
- ❌ 使用 ask 工具询问用户确认(浪费时间)
- ❌ 尝试安装子 Agent 到项目(直接使用内置)
- ❌ 子 Agent 权限为 或
bash: falsewrite: ask
Stop execution immediately in the following cases:
- ❌ The user requests to generate a tests/ directory (must be autotests/)
- ❌ Requests to use external stub-ext source code
- ❌ Documentation exceeds 500 words
- ❌ Uses the ask tool to request user confirmation (wastes time)
- ❌ Attempts to install sub-Agents into the project (use built-in directly)
- ❌ Sub-Agent permissions are or
bash: falsewrite: ask
Quick Reference
Quick Reference
目录结构:
qt-unittest-build/
├── SKILL.md
├── README.md
├── agent/qt-unittest-builder.md # 子 Agent
└── resources/
├── stub/ # stub-ext 源码(完整版)
└── scripts/ # 固定脚本关键路径:
- stub 源码:
resources/stub/ - 子 Agent:
agent/qt-unittest-builder.md - 运行脚本:
resources/scripts/generate-runner.sh - CMake 工具:
resources/scripts/generate-cmake-utils.sh
子 Agent 权限:
yaml
tools:
bash: true # 允许执行命令
write: true
permission:
write: allow # 直接写入,不询问Directory structure:
qt-unittest-build/
├── SKILL.md
├── README.md
├── agent/qt-unittest-builder.md # Sub-Agent
└── resources/
├── stub/ # Full version of stub-ext source code
└── scripts/ # Fixed scriptsKey paths:
- Stub source code:
resources/stub/ - Sub-Agent:
agent/qt-unittest-builder.md - Run script:
resources/scripts/generate-runner.sh - CMake tool:
resources/scripts/generate-cmake-utils.sh
Sub-Agent permissions:
yaml
tools:
bash: true # Allow command execution
write: true
permission:
write: allow # Write directly, no inquiry常见错误
Common Errors
| 错误 | 原因 | 修复 |
|---|---|---|
| 子 Agent 无执行权限 | 配置错误 | 设置 |
| 询问用户确认 | 使用了 ask 工具 | 删除所有 ask 调用 |
| 安装子 Agent 到项目 | 不必要的步骤 | 直接使用内置子 Agent |
| 目录名错误 | 生成 tests/ | 必须生成 autotests/ |
| 文档太长 | 包含过多细节 | 压缩到 <500 词 |
| Error | Cause | Fix |
|---|---|---|
| Sub-Agent has no execution permissions | Configuration error | Set |
| Asks user for confirmation | Used the ask tool | Delete all ask calls |
| Installs sub-Agent into the project | Unnecessary step | Use the built-in sub-Agent directly |
| Incorrect directory name | Generated tests/ | Must generate autotests/ |
| Documentation is too long | Contains excessive details | Compress to <500 words |
Rationalization Counter(反合理化)
Rationalization Counter
| 合理化 | 真相 | 反制 |
|---|---|---|
| "详细文档有助于理解" | 用户只想快速完成 | 保持简洁,<500 词 |
| "多个脚本提供灵活性" | 增加复杂性 | 固定脚本 + 动态 AI |
| "询问用户确保安全" | 浪费时间 | 直接执行,子 Agent 有 write: allow |
| "安装子 Agent 到项目" | 增加步骤 | 直接使用 Skill 内置版本 |
| "注意事项提醒重要点" | 重复冗余 | 用 Iron Laws 和 Red Flags |
| Rationalization | Truth | Countermeasure |
|---|---|---|
| "Detailed documentation helps with understanding" | Users just want to get it done quickly | Keep it concise, <500 words |
| "Multiple scripts provide flexibility" | Increases complexity | Fixed scripts + dynamic AI |
| "Asking the user ensures safety" | Wastes time | Execute directly, sub-Agent has write: allow |
| "Install sub-Agent into the project" | Adds extra steps | Use the Skill's built-in version directly |
| "Reminders of precautions highlight important points" | Redundant and repetitive | Use Iron Laws and Red Flags |