test(build-driver): the work-folder removal test waits out a lock another test's child still holds for a moment #2534

Merged
HumanBean merged 1 commit from HumanBean/Longshot:push-vqrtyovmxmnp into main 2026-11-25 17:27:16 +00:00
Owner

Summary

layout::tests::a_work_folder_goes_whole_unless_a_build_holds_it failed once in a full cargo test run of the workspace, then passed alone. The cause: File::try_lock is flock, which belongs to the open file. When another test in the same process forks a child at that moment, the child holds the lock's file until its exec closes it. So the lock outlives drop(held) for a moment, and remove_work sees the folder still held.

The test now retries remove_work for up to 5 s after letting go of the lock. Only the test changes: a builder never forks while it removes a work folder it held itself. Read builder/crates/build-driver/src/layout.rs, the test.

Testing

Tested: Linux (CachyOS), cargo test -p build-driver --lib a_work_folder_goes_whole passes. The change is in a #[cfg(test)] module, so no game run applies (opened with --force at the maintainer's request).

Still to test: None.

Measurements

Nothing to measure: the change is in a test only.

Risks

None for players: test code only. If the retry hid a real failure to remove the folder, the test still fails after 5 s.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says. (test code only: the game runs none of it; the test passes)
  • mise run test passes (any failure that also fails on main is named). (not yet run: queued with the next batched build-mode job)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary `layout::tests::a_work_folder_goes_whole_unless_a_build_holds_it` failed once in a full `cargo test` run of the workspace, then passed alone. The cause: `File::try_lock` is `flock`, which belongs to the open file. When another test in the same process forks a child at that moment, the child holds the lock's file until its exec closes it. So the lock outlives `drop(held)` for a moment, and `remove_work` sees the folder still held. The test now retries `remove_work` for up to 5 s after letting go of the lock. Only the test changes: a builder never forks while it removes a work folder it held itself. Read `builder/crates/build-driver/src/layout.rs`, the test. ## Testing **Tested:** Linux (CachyOS), `cargo test -p build-driver --lib a_work_folder_goes_whole` passes. The change is in a `#[cfg(test)]` module, so no game run applies (opened with `--force` at the maintainer's request). **Still to test:** None. ## Measurements Nothing to measure: the change is in a test only. ## Risks None for players: test code only. If the retry hid a real failure to remove the folder, the test still fails after 5 s. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. (test code only: the game runs none of it; the test passes) - [ ] `mise run test` passes (any failure that also fails on `main` is named). (not yet run: queued with the next batched build-mode job) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
test(build-driver): the work-folder removal test waits out a lock another test's child still holds for a moment
Some checks failed
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
CI / Workflow lint (actionlint) (pull_request) Successful in 12s
Guide screenshots / Guide images and local UI source review (pull_request) Successful in 12s
CI / Website build and checks (pull_request) Failing after 13s
Third-party parts / As their notes say (pull_request) Successful in 14s
CI / longshot-builder end to end (synthetic game) (pull_request) Successful in 2m29s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 3m3s
CI / Rust (rustfmt, clippy, cargo test) (pull_request) Failing after 4m21s
PR description / Description follows the template (pull_request_target) Failing after 8s
35f3733437
flock belongs to the open file: a test of the same process forking a child at that moment keeps the dropped
lock until the child's exec closes it, so remove_work right after drop(held) could see the folder held.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member

Possibly related, for context:

  • PR #804 test(build): the make_game checks let go of the work folder's lock, so Windows can delete their temporary folders — Earlier merged work on work-folder lock handling
Possibly related, for context: - PR #804 test(build): the make_game checks let go of the work folder's lock, so Windows can delete their temporary folders — Earlier merged work on work-folder lock handling
HumanBean changed title from WIP: test(build-driver): the work-folder removal test waits out a lock another test's child still holds for a moment to test(build-driver): the work-folder removal test waits out a lock another test's child still holds for a moment 2026-11-25 17:27:09 +00:00
HumanBean deleted branch push-vqrtyovmxmnp 2026-11-25 17:27:17 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2534
No description provided.