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

  1. 使用内置资源:stub-ext 源码来自
    resources/stub/
    ,不使用外部下载
  2. 生成 autotests/ 目录:与原 qt-cpp-unittest-framework 技能保持一致
  3. 调用内置子 Agent:直接从 Skill 的
    agent/
    目录读取子 Agent,不安装到项目
  4. 子 Agent 权限:子 Agent 必须有
    bash: true
    write: allow
    权限
  5. 直接执行:不使用 ask 工具询问用户,直接拷贝和写入
  1. Use built-in resources: stub-ext source code comes from
    resources/stub/
    , no external downloads allowed
  2. Generate autotests/ directory: Keep consistent with the original qt-cpp-unittest-framework skill
  3. Call built-in sub-Agents: Directly read sub-Agents from the Skill's
    agent/
    directory, do not install them into the project
  4. Sub-Agent permissions: Sub-Agents must have
    bash: true
    and
    write: allow
    permissions
  5. 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
resources/stub/
to
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
    :测试运行脚本(设置执行权限)
  • UnitTestUtils.cmake
    :CMake 工具(写入到
    autotests/cmake/
Generate from
resources/scripts/
:
  • run-ut.sh
    : Test run script (set execution permissions)
  • UnitTestUtils.cmake
    : CMake tool (write to
    autotests/cmake/
    )

步骤 4:调用内置子 Agent

Step 4: Call built-in sub-Agent

直接使用 Skill 内置的子 Agent(从
agent/qt-unittest-builder.md
读取),无需安装:
调用方式: 将 Skill 的
agent/qt-unittest-builder.md
内容作为子 Agent 的提示词执行。
子 Agent 完成任务
  1. 分析项目结构(CMakeLists.txt、源码目录、依赖)
  2. 生成 autotests/CMakeLists.txt
  3. 生成测试子目录和测试文件
  4. 生成测试文档(README.md)
  5. 验证构建:运行 cmake 配置和编译,确保测试框架可以正常运行
Directly use the Skill's built-in sub-Agent (read from
agent/qt-unittest-builder.md
), no installation required:
Calling method: Execute the content of the Skill's
agent/qt-unittest-builder.md
as the prompt for the sub-Agent.
Tasks completed by the sub-Agent:
  1. Analyze project structure (CMakeLists.txt, source code directories, dependencies)
  2. Generate autotests/CMakeLists.txt
  3. Generate test subdirectories and test files
  4. Generate test documentation (README.md)
  5. 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
resources/report_generator/
directory (complete report generation module) to
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: false
    write: 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
    bash: false
    or
    write: 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 scripts
Key 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 无执行权限配置错误设置
bash: true, write: allow
询问用户确认使用了 ask 工具删除所有 ask 调用
安装子 Agent 到项目不必要的步骤直接使用内置子 Agent
目录名错误生成 tests/必须生成 autotests/
文档太长包含过多细节压缩到 <500 词
ErrorCauseFix
Sub-Agent has no execution permissionsConfiguration errorSet
bash: true, write: allow
Asks user for confirmationUsed the ask toolDelete all ask calls
Installs sub-Agent into the projectUnnecessary stepUse the built-in sub-Agent directly
Incorrect directory nameGenerated tests/Must generate autotests/
Documentation is too longContains excessive detailsCompress to <500 words

Rationalization Counter(反合理化)

Rationalization Counter

合理化真相反制
"详细文档有助于理解"用户只想快速完成保持简洁,<500 词
"多个脚本提供灵活性"增加复杂性固定脚本 + 动态 AI
"询问用户确保安全"浪费时间直接执行,子 Agent 有 write: allow
"安装子 Agent 到项目"增加步骤直接使用 Skill 内置版本
"注意事项提醒重要点"重复冗余用 Iron Laws 和 Red Flags
RationalizationTruthCountermeasure
"Detailed documentation helps with understanding"Users just want to get it done quicklyKeep it concise, <500 words
"Multiple scripts provide flexibility"Increases complexityFixed scripts + dynamic AI
"Asking the user ensures safety"Wastes timeExecute directly, sub-Agent has write: allow
"Install sub-Agent into the project"Adds extra stepsUse the Skill's built-in version directly
"Reminders of precautions highlight important points"Redundant and repetitiveUse Iron Laws and Red Flags