Repository navigation
test: fix flaky tests that run a script right after writing it - #106
Merged
Merged
Conversation
Tests that write a stand-in CLI and run it at once failed now and then
with ETXTBSY ("Text file busy"): a process another test starts holds
copies of the test binary's open files until it execs, so the script can
still be open for writing when the test runs it. fctl-host's driver takes
that for a missing image and carries on, which made
the_docker_vm_is_measured_in_a_short_lived_container and
the_host_leaves_a_current_build_as_it_is fail on main.
The scripts are now written by sh (write_script), so the test binary
never has them open.
kalaspuff
approved these changes
Oct 19, 2026
kalaspuff
deleted the
fctl/51-the-ci-workflow-for-fctl-seems-to-have-f
branch
October 19, 2026 19:13
2 of 3 tasks
fctl-sh
Bot
restored the
fctl/51-the-ci-workflow-for-fctl-seems-to-have-f
branch
October 19, 2026 19:20
kalaspuff
deleted the
fctl/51-the-ci-workflow-for-fctl-seems-to-have-f
branch
October 20, 2026 09:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cargo xtask checkfailed onmaintwice in two days, each time in an fctl-host test that drives a stand-indockerCLI, on a commit that didn't touch the host. The next run on the same code passed both times.driver::container::tests::the_docker_vm_is_measured_in_a_short_lived_container(log)refresh::tests::the_host_leaves_a_current_build_as_it_is(log)Why they failed
The tests write the stand-in, a shell script, and run it right away. A test binary runs its tests on many threads, and a process that another test starts holds copies of the binary's open files until it execs. When one starts while a test is writing its script, that copy keeps the script open for writing a moment longer, and running the script fails with ETXTBSY ("Text file busy"). The driver reads that failure as "the image isn't here" and carries on, so the test sees other calls than it expects.
Both failures show it: the stand-in's first call is missing from its log, and the calls after it are there. In the refresh test, the failed
image inspectsentrefreshdown its path for a missing image, which runs exactly theimage inspect --format {{.Id}} …:latestandpull …:0.7.0that CI logged.#84 fixed the same kind of race in the agent's socket test.
What changed
Tests write their scripts with
write_script, which hasshwrite the file, so the test binary never has it open. fctl-host's stand-in CLI (FakeCli) anddisk_cliuse it. So do fctl-agent's two stand-ins for Claude Code (insessions_need_a_recent_claude_codeand the supervisor tests'stub_claude), which wrote and ran their scripts the same way. They haven't failed on CI yet, but they fail the same way when the machine is busy (below).Only tests change. The one script fctl itself writes and runs, the agent's git credential helper, runs well after it is written.
How I verified it
the_host_leaves_a_current_build_as_it_isamong them with the same calls as on CI. After: none failed./tmp/.tmpwoGJFM/cli: Text file busy (os error 26).supervisor::tests::turns_claude_starts_while_paused_or_stopping_are_interruptedwithstarting /tmp/.tmpasfbTp/claude (is Claude Code installed?), caused byText file busy (os error 26). After the fix, none of 1,000 such runs failed.cargo xtask check --quickpasses.Also
The failed run skipped
Pin fctl.sh to these docs, and the release commit's run found nodocs/change since 65dcbe1, so fctl.sh still shows the docs from before #103 and #104. hyperstructure/fctl-site#25 pins them, and #105 is about making the job catch up after a failed run.Session: https://app.fctl.sh/s/ses_01M5AFQJTX6FENQJJZWRD5AP5K