Skip to content

test(daemon): stop reading the stub engine's argv before it is written - #264

Merged
outofcoffee merged 1 commit into
mainfrom
fix/stub-engine-args-race
Oct 7, 2026
Merged

outofcoffee merged 1 commit into
mainfrom
fix/stub-engine-args-race

Conversation

@outofcoffee

Copy link
Copy Markdown
Collaborator

TestCmdDaemon_StartCarriesDeployConfig failed intermittently on CI because the daemon tests could read the stub engine's argv file while it was still empty. This removes the race.

Summary

  • The stub engine writes its argv to a sibling file and renames it into place, so the file only exists complete. A plain > file redirection creates and truncates the file before printf writes, and a test that waited only for the file to exist could read it in between.
  • waitForFile now waits for non-empty content, and a new waitForFileContaining waits for the exact text a test goes on to assert on. The tests that read the engine log use it too, since the daemon opens the log before its first line is written and they had the same gap.
  • Regression tests: the stub's argv file is never visible empty, and the wait helper skips an empty or partial file.

Implementation details

  • With the old redirection put back, the new stub test fails on essentially every run (30 of 30 invocations, usually on the first iteration), so the race is easy to hit and the test catches it.
  • Waiting for the asserted text, not just for non-empty content, covers a file that is written in more than one step. The assertions after each wait are unchanged.
  • Only test files change.

The stub engine wrote its argv with a shell redirection, which creates and
truncates the file before printf writes to it. Tests that waited only for the
file to exist could read it empty and fail. The stub now writes to a sibling
file and renames it, and the wait helper waits for the text each test goes on
to assert on, which also covers the engine log being opened before its first
line is written.
@outofcoffee outofcoffee added the bug Something isn't working label Oct 6, 2026
@outofcoffee
outofcoffee merged commit d51d654 into main Oct 7, 2026
5 checks passed
@outofcoffee
outofcoffee deleted the fix/stub-engine-args-race branch October 7, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant