1
0
Files
DiAL/openspec/specs/test-output-cleanliness/spec.md
lanyuanxiaoyao f3df3a203b docs: 优化审查提示词,禁止 subagent 读取文件,明确 apply 阶段不动主规范
config.yaml: subagent 限定为计算密集/多步骤任务,文件读取用 Read 工具
prompt-proposal-review.md: 收集阶段加入读取约束和分步策略,复核补全待澄清清单
prompt-apply-review.md: 禁止同步主规范,新增 Spec 覆盖完整性扫描与补充流程
2026-05-20 17:44:02 +08:00

30 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Test Output Cleanliness
## Purpose
确保测试运行时输出干净、无噪音,便于开发者快速定位问题。
## Requirements
### Requirement: 测试不应产生无关 console 输出
测试运行时,由测试用例预期的容错行为(如 JSON 解析失败、checker rejected触发的 `console.warn` 输出 SHALL 在测试代码中被抑制,不污染测试报告。
#### Scenario: 容错测试抑制 console.warn
- **WHEN** 测试用例故意注入损坏数据或触发异常以验证系统容错行为
- **THEN** 测试 SHALL 在执行前临时覆盖 `console.warn` 为空函数,在 finally 块中恢复原始函数
#### Scenario: 非预期 console.warn 不被抑制
- **WHEN** 测试用例并非专门测试容错行为
- **THEN** 测试 SHALL NOT 抑制 `console.warn`,确保意外 warn 可被观测
### Requirement: 探针执行失败日志输出单行消息
ProbeEngine 在捕获 checker rejected 时,`console.warn` SHALL 输出单行错误消息文本MUST NOT 输出 Error 对象(会导致多行堆栈噪音)。
#### Scenario: checker rejected 输出单行日志
- **WHEN** checker 执行抛出未捕获异常Promise rejected
- **THEN** `console.warn` SHALL 输出格式为 `探针执行失败: <message>` 的单行文本,其中 message 使用 `formatReason()` 提取
#### Scenario: formatReason 复用
- **WHEN** 构建失败日志消息和写入 CheckFailure
- **THEN** 两者 SHALL 共用同一个 `formatReason` 函数提取错误消息