Skip to content

Fix flaky link-up reconfigure test by parking the retry poll - #20

Merged
dpdev69 merged 1 commit into
mainfrom
fix/flaky-linkup-reconfigure-test
Oct 21, 2026
Merged

dpdev69 merged 1 commit into
mainfrom
fix/flaky-linkup-reconfigure-test

Conversation

@dpdev69

@dpdev69 dpdev69 commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Requested by Boss

What and why

Before: the Build workflow on main has been red since #19. ControllerTests.testLinkUpAndWirelessStatusTogetherReconfigureOnce failed with 8 reporting writes instead of 4, although nothing in #19 touched UprightKit.

After: the test only measures what it is about, and the suite passes.

The test checks that a wake burst (the receiver's 0x41 link-up plus the mouse's 0x1D4B reconnect) leads to one reconfiguration. But the retry poll armed when the link dropped kept running with 0.1 to 0.2 s delays. On a slow runner a poll could fire after the mouse woke, reconfigure it on its own (4 writes), and then the debounced link-up reconfiguration ran as well (4 more). The fix parks the retry poll in this test, as the neighbouring wake tests already do, so the burst is the only thing that can reconfigure. No sleep was lengthened and nothing is skipped.

How I tested it

  • swift test in UprightKit passes twice in a row: 395 tests, 0 failures each run
  • make app builds (no app or project changes)
  • Simulator only (no hardware). Reproduced the race on the old test by delaying the wake burst 0.15 s so the retry poll fires first: it fails (6 writes instead of 4). With the fix the same forced race passes 5 of 5. Plain runs under full CPU load passed 40 of 40, which is why CI only catches it sometimes.
  • macOS version: 27.0.1

Checklist

  • Code outside Platform/ uses Foundation only (test-only change)
  • Every test method in a @MainActor test class is async
  • Added a line under Unreleased in CHANGELOG.md (test-only, no user-facing change)

🤖 Generated with Claude Code

testLinkUpAndWirelessStatusTogetherReconfigureOnce counts the reporting
writes a wake burst (0x41 link-up plus 0x1D4B reconnect) causes. The retry
poll armed at link loss kept running with 0.1-0.2 s delays, so on a slow
runner a poll could reconfigure the woken mouse before the debounced
reconfiguration ran, doubling the count (8 instead of 4). Park the poll
like the neighbouring wake tests do, so the burst is the only source.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@dpdev69 dpdev69 self-assigned this Oct 21, 2026
@dpdev69
dpdev69 merged commit 55cf2c8 into main Oct 21, 2026
4 checks passed
@dpdev69
dpdev69 deleted the fix/flaky-linkup-reconfigure-test branch October 21, 2026 11:21
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