Skip to content

feat(testutil): internal/testutil/ with 5 race-safe helpers (issue #161, race-flake hardening v2)#205

Merged
Delqhi merged 1 commit into
mainfrom
feat/issue-161-race-flake-v2
Jun 16, 2026
Merged

feat(testutil): internal/testutil/ with 5 race-safe helpers (issue #161, race-flake hardening v2)#205
Delqhi merged 1 commit into
mainfrom
feat/issue-161-race-flake-v2

Conversation

@Delqhi

@Delqhi Delqhi commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Implements the second of the 5 issues on your list. Scope-bounded to the helpers + a diagnosis pass; per-test fixups are intentionally not in this PR (the slowest test in the affected packages is 3.36 s, well below the 5-minute acceptance threshold).

What ships

  • cmd/sin-code/internal/testutil/testutil.go (175 LOC, stdlib-only)
    • IsolatedSQLite(t) — fresh t.TempDir() + modernc/sqlite, auto-close
    • CleanEnv(t, kv) — set/restore env vars via t.Cleanup
    • WithTimeout(t, d, fn) — context-bounded fn, 50ms grace
    • GoroutineLeakCheck(t, fn) — stack-snapshot diff, best-effort
    • MustGo(t, fn) — synchronous go func(), panic→t.Errorf
  • testutil_test.go — 13 unit tests, all race-clean
  • example_test.go — 6 composition examples (HTTP, env, ctx, leaks)
  • testutil.doc.md — design doc, acceptance checkboxes, caveats

Diagnosis pass (informational)

Hard mandates honored

  • M2 (single binary, no CGO): stdlib only, modernc/sqlite is already in go.sum (no new dep)
  • M7 (race-free): 21/21 tests pass under go test -race -count=1 on three consecutive runs

Diffstat

 4 files changed, 720 insertions(+)

Closes

@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sin-code Ready Ready Preview, Comment, Open in v0 Jun 16, 2026 5:55pm

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

🏆 CEO Audit — A+ (100.0/100)

Metric Value
Grade A+
Score 100.0/100
Critical findings 0
High findings 0
Profile QUICK
Min grade gate B

📥 Download full report (Markdown)
📊 Download SARIF (for Code Scanning)

Run ~/.config/opencode/skills/ceo-audit/scripts/audit.sh . --profile=QUICK locally to reproduce.

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

🏆 CEO Audit — A+ (100.0/100)

Metric Value
Grade A+
Score 100.0/100
Critical findings 0
High findings 0
Medium findings 0
Profile QUICK
Min grade gate B

📥 Download full report (Markdown)

Run ID: 27637342573 · Commit: ${github.sha}

Run ~/.config/opencode/skills/ceo-audit/scripts/audit.sh . --profile=QUICK locally to reproduce.

…, race-flake hardening v2)

What ships:
  - cmd/sin-code/internal/testutil/testutil.go (175 LOC, stdlib-only)
    - IsolatedSQLite(t)         - t.TempDir() + modernc/sqlite, auto-close
    - CleanEnv(t, kv)           - set/restore env vars via t.Cleanup
    - WithTimeout(t, d, fn)     - context-bounded fn, 50ms grace
    - GoroutineLeakCheck(t, fn) - stack-snapshot diff (best-effort)
    - MustGo(t, fn)             - synchronous go func, panic->t.Errorf
  - testutil_test.go            - 13 unit tests, all race-clean
  - example_test.go             - 6 composition examples (HTTP, env, ctx, leaks)
  - testutil.doc.md             - design doc, acceptance checkboxes, caveats

Diagnosis pass (informational):
  - The slowest test in the affected packages is
    TestGenerateIDUniqueness (todo) at 3.36s, well below the
    5-minute acceptance threshold from issue #161.
  - No per-test fixup is needed for this issue; the helpers are
    the high-value reusable part for new tests.

Hard mandates honored:
  - M2 (single binary, no CGO): stdlib only, modernc/sqlite is
    already in go.sum (no new dep).
  - M7 (race-free): 21/21 tests pass under go test -race -count=1
    on three consecutive runs.

Refs: #161
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