Skip to content

fix: coaching test temp-dir race under nextest (Windows CI flake) - #405

Merged
getappz merged 1 commit into
masterfrom
fix/coaching-test-temp-dir-race
Aug 8, 2026
Merged

fix: coaching test temp-dir race under nextest (Windows CI flake)#405
getappz merged 1 commit into
masterfrom
fix/coaching-test-temp-dir-race

Conversation

@getappz

@getappz getappz commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Summary

Found while chasing an unrelated Windows CI failure on another PR: coaching::rule::tests::parse_old_file_without_enforce_line_defaults_to_false fails intermittently on windows-latest.

Root cause: temp_dir_for_test()'s uniqueness came from an in-process static AtomicU64 counter. nextest (adopted in #399) runs each test in its own process, so every process's counter starts back at 0 — every test in this module that calls the helper resolves to the exact same temp directory path. Windows' stricter file locking turns that race into a hard failure; Unix mostly tolerates it silently, which is why this only ever surfaced on windows-latest.

Fix: mix std::process::id() into the path so concurrent test processes never collide. Counter stays, still covers multiple calls within one process.

Test plan

  • cargo test -p agentflare coaching::rule:: — 21 passed
  • cargo fmt --check clean

Summary by CodeRabbit

  • Bug Fixes
    • Improved test isolation by preventing temporary-directory name collisions when tests run concurrently.
    • Preserved unique temporary-directory names across repeated calls within the same process.

…in-process

temp_dir_for_test()'s uniqueness came from an in-process atomic counter,
but nextest runs each test in its own process -- every process's counter
starts back at 0, so every test using this helper collided on the exact
same temp path. Windows' stricter file locking turns that race into a
hard failure (parse_old_file_without_enforce_line_defaults_to_false
failing intermittently in CI); Unix mostly tolerates it silently. Mixes
in the pid so concurrent test processes never share a path.
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bb4d0442-d0a5-4d0f-a381-251525f742bb

📥 Commits

Reviewing files that changed from the base of the PR and between 048f369 and 9a06149.

📒 Files selected for processing (1)
  • src/coaching/rule.rs

📝 Walkthrough

Walkthrough

The test temporary-directory helper now includes the process ID and an atomic counter in generated paths. This prevents collisions across concurrent processes and preserves uniqueness within each process.

Changes

Test directory isolation

Layer / File(s) Summary
Process-aware temporary paths
src/coaching/rule.rs
temp_dir_for_test includes the process ID and atomic counter when generating temporary-directory paths.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the Windows CI temp-directory race and the fix.
Description check ✅ Passed The description explains the root cause, fix, and validation, but omits the Notes for reviewers section and clippy check.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/coaching-test-temp-dir-race

Comment @coderabbitai help to get the list of available commands.

@getappz
getappz merged commit 2533791 into master Aug 8, 2026
18 checks passed
@getappz
getappz deleted the fix/coaching-test-temp-dir-race branch August 8, 2026 08:20
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