Skip to content

Commit 65ee909

Browse files
committed
test: distinguish native spawn pressure from timeout
1 parent a5bf96d commit 65ee909

3 files changed

Lines changed: 27 additions & 9 deletions

File tree

‎crates/codeguard-cli/tests/native_version_observation.rs‎

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,29 @@ fn unsupported_version_stderr_and_nonzero_exit_are_distinct() {
7979
#[test]
8080
fn timeout_cancellation_and_exhausted_budget_keep_native_failure_kind() {
8181
for variant in 0..3 {
82-
let fixture = Fixture::new();
83-
let mut request = fixture.request("exec /bin/sleep 1");
84-
let cancelled = AtomicBool::new(variant == 1);
85-
request.process.deadline = if variant == 2 {
86-
Instant::now()
87-
} else {
88-
Instant::now() + Duration::from_millis(30)
89-
};
90-
let result = observe_native_version(&request, &cancelled);
82+
let mut result = None;
83+
for attempt in 0..3 {
84+
let fixture = Fixture::new();
85+
let mut request = fixture.request("exec /bin/sleep 2");
86+
let cancelled = AtomicBool::new(variant == 1);
87+
request.process.deadline = if variant == 2 {
88+
Instant::now()
89+
} else {
90+
Instant::now() + Duration::from_millis(500)
91+
};
92+
let observed = observe_native_version(&request, &cancelled);
93+
// 并行 CI 偶发进程配额耗尽时,重新创建私有样例;只有真实超时才满足本用例。
94+
if variant == 0
95+
&& observed.termination == Some(Termination::SpawnFailure)
96+
&& attempt < 2
97+
{
98+
std::thread::sleep(Duration::from_millis(20));
99+
continue;
100+
}
101+
result = Some(observed);
102+
break;
103+
}
104+
let result = result.unwrap();
91105
let (termination, reason) = match variant {
92106
0 => (Termination::TimedOut, "version_timed_out"),
93107
1 => (Termination::Cancelled, "request_cancelled"),

‎openspec/changes/introduce-rust-codeguard-cli/tasks.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,3 +1113,5 @@ TDD缺自动同步先RED。相关普通:build9、work sync15、next6,共30
11131113
14.7 / 14.17 / 14.19 项目报告限制投影:`check all` 的 0.34.0 封闭协议逐候选附带固定清单的有界 `known_limitations`,VB.NET 已知误报与 CFQuery SQL 覆盖缺口不再只存在于独立库存命令;0.33.0 Schema 归档,清单解析失败时保持未完成。真实双文件目标测试先 RED 后 GREEN,六项候选回归与 18 项聚合契约通过,分批 32 份真实候选测试逐观察确认非空限制,真实 JSON 通过 Draft 2020-12、旧 Schema/伪造放行被拒。默认宿主自动对话渲染、原生对照、系统精度和发行仍缺,父任务不勾选;见[局部验收](../../../tests/acceptance/check-all-known-grammar-limitations.md)。
11141114

11151115
14.7 / 14.19 文本反馈局部增量:`check all` 默认终端输出现在有界显示候选的固定已知限制,VB.NET 误报样例先 RED 后 GREEN,目标测试 1/1 通过,源码行未回显。显式 CLI 输出可由调用方转发,插件默认 Hook 的自动触发与宿主对话渲染仍未验收,父任务不勾选;见[同一局部验收](../../../tests/acceptance/check-all-known-grammar-limitations.md)。
1116+
1117+
5.2 / 5.6 Linux CI 版本探测测试稳定性:旧 30ms 超时夹具在并行负载下实际返回 `SpawnFailure`,不能误报为运行时超时。现在使用 500ms 预算与 2 秒睡眠,仅在瞬时启动失败时创建新夹具重试,最终仍严格要求 `TimedOut`;本机定向 1/1、完整文件 7/7 通过。远端复验仍待本次 PR CI,父任务保持未完成;见[原生版本诊断验收](../../../tests/acceptance/native-version-diagnostics.md)。

‎tests/acceptance/native-version-diagnostics.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ CODEGUARD_RUFF_BIN=/opt/anaconda3/bin/ruff cargo test -p codeguard-cli --test ru
1919
7 项探测中的真实 Ruff 用例仅证明版本诊断。默认目标及 runtime process/private log/边界共 43 项通过;另外明确设置 CODEGUARD_RUFF_BIN,补跑两套各 5 项 ignored 真实扫描回归,10 项全部通过。这些扫描验证现有局部 Ruff 配置/范围/报告,不证明完整门禁。all-target Clippy、格式、OpenSpec strict 与 diff 检查通过。
2020

2121
完整 doctor、可信工具锁、原生兼容与运行环境、其它适配器复用、准备报告持久化/同步仍缺;5.2/5.6 不勾选,完整计划保持进行中。
22+
23+
2026-10-03 的 [CI 37112015676](https://github.com/full-stack-plugins/codeguard/actions/runs/37112015676) 在 30ms 超时样例中得到 `SpawnFailure` 而非 `TimedOut`。运行时正确保留了独立的启动失败类别;失败点是测试在并行 Linux 负载下未能真正启动睡眠进程。测试现给启动过程 500ms,令受测进程睡眠 2 秒,并仅对瞬时 `SpawnFailure` 使用新的私有夹具重试最多两次;最终仍必须观察到真正的 `TimedOut`,不能把启动失败当成超时通过。本机定向测试 1/1、该文件全部 7/7 通过,远端重新验收待最新 PR CI 完成。

0 commit comments

Comments
 (0)