Skip to content

test(engine): fix flaky Windows timeout in git-files scope test#372

Merged
rhuanbarreto merged 3 commits into
mainfrom
fix/git-files-scope-threshold-windows-flake
May 28, 2026
Merged

test(engine): fix flaky Windows timeout in git-files scope test#372
rhuanbarreto merged 3 commits into
mainfrom
fix/git-files-scope-threshold-windows-flake

Conversation

@rhuanbarreto

Copy link
Copy Markdown
Contributor

Summary

Fixes a recurring Windows smoke-test flake in tests/engine/git-files.test.ts (most recently observed on #366).

The test resolveScopedFiles > warns when file scope exceeds threshold created 1001 real files + git add . to trip the file-count warning. On Windows CI runners that filesystem work exceeded the test's 30s timeout, so git add . was SIGTERM'd mid-run (git add . failed (exit 143), 143 = 128 + SIGTERM), failing the suite non-deterministically. It does not reproduce locally on faster filesystems.

Changes

  • src/engine/git-files.tsresolveScopedFiles gains an optional fileWarnThreshold?: number (defaults to the existing SCOPE_FILE_WARN_THRESHOLD = 1000); the warn condition uses it.
  • tests/engine/git-files.test.ts — the test injects fileWarnThreshold: 5 and creates only 6 files instead of 1001, and drops the per-test 30_000 override (which was tighter than the global --timeout 60000, making timeouts more likely).
  • .archgate/adrs/ARCH-005-testing-standards.md — captures the pattern: make large production thresholds injectable; don't materialize giant fixtures to cross a threshold; never lower a per-test timeout below the global.

No production behavior change — the default threshold is unchanged.

Test plan

  • bun test tests/engine/git-files.test.ts — 31 pass / 0 fail
  • bun run validate — lint, typecheck, format, full suite (1212 pass / 0 fail), ADR check 30/30
  • CI green, including Windows smoke test

The `resolveScopedFiles > warns when file scope exceeds threshold` test
created 1001 real files plus `git add .` to trip the file-count warning.
On Windows CI runners that filesystem work exceeded the per-test 30s
timeout, killing `git add .` mid-run (exit 143 = SIGTERM) and flaking the
Windows smoke test.

Make the warn threshold injectable via an optional `fileWarnThreshold`
parameter on `resolveScopedFiles` (defaults to SCOPE_FILE_WARN_THRESHOLD).
The test now injects a threshold of 5 and creates only 6 files — fast and
deterministic on every platform — and drops the 30s per-test override
(which was tighter than the 60s global, making timeouts more likely).

Capture the pattern in ARCH-005 (Testing Standards).

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 28, 2026

Copy link
Copy Markdown

Deploying archgate-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: ada3df3
Status: ✅  Deploy successful!
Preview URL: https://2e57b100.archgate-cli.pages.dev
Branch Preview URL: https://fix-git-files-scope-threshol.archgate-cli.pages.dev

View logs

oxfmt formats markdown too — normalize emphasis markers in the
testing-standards ADR so `bun run format:check` passes in CI.

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Metric Value
Lines 90.0% (6552 / 7280)
Threshold 90% minimum — met
Platforms Linux + Windows

Full HTML report available in workflow artifacts.

Per-directory breakdown
Directory Coverage Lines
src/commands/ 88.1% 2069 / 2348
src/engine/ 93.1% 1209 / 1299
src/formats/ 100.0% 141 / 141
src/helpers/ 89.7% 3133 / 3492

@rhuanbarreto rhuanbarreto merged commit d249f93 into main May 28, 2026
18 checks passed
@rhuanbarreto rhuanbarreto deleted the fix/git-files-scope-threshold-windows-flake branch May 28, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant