Skip to content

Catch SwiftLint's size limits and unexplained wall-clock test waits before CI - #404

Merged
alexkroman merged 2 commits into
mainfrom
claude/wonderful-archimedes-wshy4s
Nov 25, 2026
Merged

alexkroman merged 2 commits into
mainfrom
claude/wonderful-archimedes-wshy4s

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

What & why

A review of the multi-commit PRs in #350–#401 found two causes behind most follow-up CI runs. Both can be checked without a macOS toolchain.

SwiftLint's size limits. #358, #363, #364, #368, #378 and #380 each spent a ~37-minute run only to split a file or test suite. Twice it happened because two PRs that each fit merged into one that didn't (#363 + #357, #378 + #365).

Tests that wait on real time. These caused the flakes behind #353, #357, #370, #379, #380, #396 and #399–#401, which mostly failed other PRs.

  • scripts/check-test-clock.sh fails any fixed sleep or real clock in a test without a // wall-clock-ok: <reason> marker.
  • The marker goes at the end of the line, or on the line above where a trailing comment would pass 120 columns.

Test fixes. Of the 56 existing waits, 6 waited for something that must happen within a limit a stalled runner can outlast. They now get waitUntil's 30-second limit, which only catches a hang:

Test Limit before
ProtocolTests.relayCancelledTakesResultBack (now uses until) 1 s
MemoryLeakTests.expectNoLeak 1 s
SimulatorFaultTests.next 3 s
waitForMicStart 5 s
CommandFixtureApp.state(until:) 2 s
ReadyViewUITests pasteboard check 5 s

The other 48 are marked with their reason. Twelve of them are checks that sleep and then assert nothing happened. A slow runner can't make those fail, but it can let them pass without catching anything; making them deterministic is left for a change that can run the tests.

Also in this PR:

How it was tested

  • scripts/check.sh --portable passes in a Linux sandbox, including both new scripts' self-tests.

  • The size check passes on today's tree, and I tested the hook on a file pushed over 400 lines, a new unmarked sleep and a non-Swift file. The pbxproj check fails on a worktree-named folder.

  • Not built or tested: the Swift changes are all in test targets and need CI on macOS.

  • scripts/check.sh passes (or CI will, if I'm not on a Mac)

  • I read AGENTS.md and this doesn't reintroduce anything deliberately removed

  • Docs updated if behavior changed


Generated by Claude Code

A review of the multi-commit PRs in #350-#401 found two causes behind most
follow-up CI runs, and both are checkable without a macOS toolchain:

- SwiftLint's file_length (400) and type_body_length (250): #358, #363,
  #364, #368, #378 and #380 each spent a ~37-minute run only to split a
  file or suite, twice because two PRs that fit alone overflowed together.
  scripts/check-swift-size.sh counts both (the type body as an estimate,
  ignoring strings and comments), fails past a limit, and notes files
  within 20 lines of one. Checked against the historical failures: it
  flags #358's 452-line file, #364's 404-line file and #368's suite.
- Tests waiting on real time, the flakes behind #353, #357, #370, #379,
  #380, #396 and #399-#401: scripts/check-test-clock.sh is a ratchet over
  test-clock-baseline.txt, so no test file gains a fixed sleep or a real
  clock without a `// wall-clock-ok: <reason>`.

Both run in check.sh --portable and, for the edited file, in a new
PostToolUse hook (swift-budgets.sh) that works in the web sandbox. check.sh
also checks the Mac pbxproj's repo-root folder is named `blurt`, the drift
#392 hit after regenerating in a worktree. AGENTS.md adds the file-split
import advice from #392.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1VCs8R8Y7JjnpdVdsa
…ther wait

check-test-clock.sh flagged 56 fixed sleeps and real clocks in the tests.
Six were real flake sources, each waiting for something that must happen
within a bound a stalled runner can outlast. They now take waitUntil's
30 s, which only catches a hang (a passing test never waits it out):

- ProtocolTests.relayCancelledTakesResultBack polled 1 s for the result;
  it now waits with `until`.
- MemoryLeakTests.expectNoLeak gave a winding-down task 1 s to deallocate.
- SimulatorFaultTests.next gave each event 3 s (the suite's one-minute
  limit still bounds the whole run).
- waitForMicStart gave the fixture's mic 5 s, and fell through silently.
- CommandFixtureApp.state(until:) gave the live fixture 2 s.
- ReadyViewUITests gave the cross-process pasteboard write 5 s.

Every remaining wait says why with `// wall-clock-ok: <reason>`: a poll's
own tick, a fake that hangs until released or cancelled, a delay a test
asks a fake for, the production clock where timers aren't the subject,
real time being measured, a live-device or UI suite, and twelve absence
checks (sleep, then assert nothing happened), which a slow runner can only
make pass. With none left unmarked, the ratchet's baseline is gone:
check-test-clock.sh now fails any unmarked wait, and the marker may sit on
the line above where a trailing comment would pass 120 columns. The
pattern reaches awk through the environment, so BSD and GNU awk read its
backslashes alike.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1VCs8R8Y7JjnpdVdsa
@alexkroman
alexkroman added this pull request to the merge queue Nov 25, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 25, 2026
@alexkroman
alexkroman added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 9172dd7 Nov 25, 2026
16 checks passed
@alexkroman
alexkroman deleted the claude/wonderful-archimedes-wshy4s branch November 25, 2026 17:16
alexkroman pushed a commit that referenced this pull request Nov 25, 2026
Two conflicts:
- check.yml's required check job: #405 added mac-static, ios-audits and
  ios-static; this adds live-tests. It now needs and asserts all of them.
- CommandFixtureApp: #404 raised state(until:)'s bound from 2 s to 30 s
  for every caller, which covers the fixture's slow first launch, so the
  within: parameter this branch added is dropped and the launch uses the
  plain call. The menu-bar wait gets #404's wall-clock-ok note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1TXn83VM7ihZ3iFgU5
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.

2 participants