Skip to content

test: run the fake xcrun once before timing it - #67

Merged
Interlap01 merged 1 commit into
mainfrom
fix/flaky-launchd-retry-test
Nov 4, 2026
Merged

Interlap01 merged 1 commit into
mainfrom
fix/flaky-launchd-retry-test

Conversation

@Interlap01

Copy link
Copy Markdown
Contributor

TestReadLaunchdRetriesATimedOutRead failed intermittently with launchctl print-disabled: signal: killed: 16 of 30 runs on this Mac, on main as well as on branches.

Cause

macOS vets a newly written executable on its first exec. For the fake xcrun that took up to 767 ms here; later runs take about 9 ms. The test gives each spawn 200 ms, and its first attempt is the one meant to consume the hang-once marker and hang. That attempt was often killed during the macOS check, before the script ran, so the marker stayed. The retry then hung as well and the test failed. The retry logic in readLaunchd was fine.

Fix

newBatchFake now runs the fake once right after writing it, with FAKE_LOG set to /dev/null so the call counts tests assert on are unchanged. Short timeouts then measure the fake instead of the first-exec check. The change is test-only.

Results

TestReadLaunchdRetriesATimedOutRead Before After
30 runs in isolation 16 failed 0 failed
100 runs during a parallel full-suite run, with TestLaunchdSpawnsDoNotHangOnAHeldPipe — 0 of 200 failed

make check passes.

macOS vets a newly written executable on its first exec, which took up to
767ms here. TestReadLaunchdRetriesATimedOutRead gives each spawn 200ms, so
the first, deliberately hanging attempt was often killed during that check
before the script could remove its hang-once marker; the retry then hung
too and the test failed (16 of 30 runs). newBatchFake now runs the fake
once with its log sent to /dev/null, so short timeouts measure the fake.
@Interlap01
Interlap01 merged commit 7e374b3 into main Nov 4, 2026
1 check passed
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