Skip to content

test: run freshly written stand-in executables once before relying on them - #317

Merged
sunerpy merged 1 commit into
mainfrom
test/fresh-script-busy
Oct 3, 2026
Merged

sunerpy merged 1 commit into
mainfrom
test/fresh-script-busy

Conversation

@sunerpy

@sunerpy sunerpy commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Summary

Main's Coverage job on 81bd7c7 (run 37143381765) failed once in
git_pending::tests::a_system_attributes_file_is_a_conversion_risk: left: None, right: Some(false). The cause is
an ETXTBSY race in the test helper, not in conversion_risk. The Coverage job is informational, and the required
CI Success passed.

The race:

  1. The test writes a fake git shell script and runs it at once.
  2. If another thread of the same test binary forks while the script is still open for writing, the child keeps the
    inherited descriptor until it execs.
  3. Running the script meanwhile fails with ETXTBSY ("Text file busy").
  4. git() maps a failed start to None, so conversion_risk returned None.

Two other tests share the pattern:

  • git_pending_fast_path's hanging git. A failed start declines exactly the way the timeout does, so the test could
    pass without its timeout ever running.
  • cli_ui's stand-in browser. If codegraph ui could not start it, the test would fail.

Each helper now starts the freshly written script once, retrying while the error is
io::ErrorKind::ExecutableFileBusy. Once a start succeeds no writer is left, so the test's own runs cannot hit it.

  • The hanging git now runs exec sleep 30, so stopping it leaves no orphan.
  • Its test now also checks that the 300 ms timeout elapsed.
  • No product code changes.

Verification

  • The mechanism, reproduced with a scratch program on this Linux host: 8 threads fork /bin/true while the main
    thread writes 3,000 fresh scripts and runs each at once. 313 of the 3,000 fail to start with ETXTBSY.
  • The warm-up: with the start-once retry, 202 of 1,500 scripts needed a retry, and the 7,500 starts that
    followed had 0 ETXTBSY.
  • The affected tests pass: codegraph-watch lib git_pending (1), --test git_pending_fast_path (27), and
    codegraph-rs --test cli_ui (15).
  • The pre-push gate (make pre-ci) passed on this head: all Rust tests, 569 frontend tests, docs-check, clippy
    -D warnings with all features, and the archive smoke.

🤖 Generated with Claude Code

… them

Three tests write a shell script and run it at once: git_pending's fake git,
git_pending_fast_path's hanging git and cli_ui's stand-in browser. When another
thread of the same test binary forks while the script is still open for
writing, the child keeps the inherited descriptor until it execs, and running
the script meanwhile fails with ETXTBSY. Main's Coverage job on 81bd7c7 failed
that way: `git` read the failed start as a failed git and conversion_risk
returned None. The hanging-git test could pass the same way without its
timeout ever running.

Each helper now starts the script once, retrying while the error is
ExecutableFileBusy. Once a start succeeds no writer is left, so the test's own
runs cannot hit it. The hanging git uses `exec sleep 30`, so stopping it leaves
no orphan, and the test checks that the timeout actually elapsed.
@codecov

codecov Bot commented Oct 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.15789% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/codegraph-watch/src/git_pending.rs 63.15% 7 Missing ⚠️

❌ Your patch check has failed because the patch coverage (63.15%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #317      +/-   ##
==========================================
- Coverage   95.07%   95.07%   -0.01%     
==========================================
  Files         198      198              
  Lines      109014   109033      +19     
==========================================
+ Hits       103647   103659      +12     
- Misses       5367     5374       +7     
Files with missing lines Coverage Δ
crates/codegraph-watch/src/git_pending.rs 95.46% <63.15%> (-1.21%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sunerpy
sunerpy merged commit aef4efb into main Oct 3, 2026
11 checks passed
@sunerpy
sunerpy deleted the test/fresh-script-busy branch October 3, 2026 19:04
sunerpy added a commit that referenced this pull request Oct 3, 2026
The release record for #314: the release PR merge and its tag SHA, the
workflow run, the published digest, and the black-box acceptance against
v0.53.2, plus dated entries for the padded kind column and for the stand-in
executable warm-up in #317. Current alignment lists v0.53.3.

Co-authored-by: CodeGraph Test <codegraph@example.invalid>
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