Skip to content

build: local pre-commit cargo test 180s cap is unachievable on macOS (~449s clean run, dominated by simlin-serve fsevents/e2e tests; cap also covers compile) #703

Closed

Description

@bpowers

Problem

The local pre-commit hook (scripts/pre-commit, symlinked from .git/hooks/pre-commit) cannot pass on macOS because its Rust pipeline runs a full cargo test under a 180s wall-clock cap that covers BOTH compilation and the test run, but a clean full cargo test on a macOS dev machine takes ~449s (measured uncapped, exit 0, all tests passing).

The cap is at scripts/pre-commit:140:

RUST_BACKTRACE=1 "$TIMEOUT_CMD" --kill-after=30 180 cargo test > "$TEST_TMP" 2>&1 &

Net effect: every local commit on this Mac fails with cargo test exceeded the 180s wall-clock cap (exit 124) (the diagnostic at scripts/pre-commit:160-165). Since CLAUDE.md forbids --no-verify, the only ways to land a commit are (a) open a PR where CI gates instead, or (b) somehow make the local suite fit 180s.

This is deterministic, every-time, on a warm cache. It is NOT the cold-cache lock-contention flake tracked in #629 (see "Distinct from" below).

Root cause / mechanism

The ~449s is cumulative across many test binaries and is dominated by simlin-serve's filesystem-watcher / websocket / e2e integration tests, which are wall-clock/timing-bound and slow on macOS fsevents:

  • tests/watcher_merge.rs alone: ~34.3s
  • watcher_smoke: ~11.9s
  • plus e2e_live_update, ws_updates, and similar timing-bound suites

These tests sleep/poll on real filesystem event delivery, which is materially slower under macOS FSEvents than under Linux inotify.

Why CI is NOT affected (this is a local-hook-only gap)

.github/workflows/ci.yaml is structured to avoid exactly this:

  1. cargo test --workspace --no-run runs FIRST (compile, untimed) at ci.yaml:49.
  2. Only THEN cargo test --workspace runs under timeout-minutes: 3 at ci.yaml:62-63, on fast Linux runners where the fsevents/timing tests are also faster.

So CI's 3-minute budget is post-compile and on hardware where these tests are cheap. The local hook has no separate pre-compile step and runs on macOS, so its 180s budget must absorb compilation AND the slow timing tests AND the macOS fsevents penalty. The hook's own comment (scripts/pre-commit:130-137) claims a healthy run is "well under a minute on dev machines and ~60s on CI" -- that is now badly stale for macOS.

Why it matters

  • Developer experience / blocked workflow: a developer on macOS literally cannot produce a clean local commit through the sanctioned path; they are forced into the PR-only flow even for trivial changes, and --no-verify is prohibited.
  • The misleading diagnostic ("Individual unit tests should complete in a few seconds") points the developer at per-test budgets when the real problem is a handful of inherently timing-bound integration suites plus uncounted compile time on slower hardware.

Component(s) affected

  • scripts/pre-commit (Pipeline A: Rust -- the 180s cargo test cap that includes compilation)
  • src/simlin-serve tests: tests/watcher_merge.rs, watcher_smoke, e2e_live_update, ws_updates (the wall-clock-dominant, macOS-fsevents-sensitive suites)

Possible approaches for resolution (for maintainers to weigh; not prescribing)

  1. Mirror CI in the local hook: run cargo test --no-run (or cargo build --all-targets) before the timed cargo test, so the 180s budget measures test execution, not compilation. This is the smallest change and brings the local hook in line with ci.yaml:49 + ci.yaml:62. (This same warm-up step is also proposed in build: pre-commit Rust pipeline spuriously fails on a cold cache (parallel clippy --all-features + capped cargo test contend on package-cache lock) #629 option 3 for the cold-cache case, so the two issues share a candidate fix even though the failure modes differ.)
  2. Raise the local cap to match measured reality (e.g. 600s) or make it configurable via an env var, with the comment updated to reflect macOS timings.
  3. Speed up or #[ignore] (run-on-CI-only) the slow simlin-serve watcher/e2e tests for the pre-commit fast path, so the local hook exercises the fast unit suite and CI carries the timing-bound integration tests. (Note: the macOS watcher correctness gaps already documented in tech-debt.md build(deps): bump dns-packet from 1.3.1 to 1.3.4 #37 are a separate concern from these tests' wall-clock cost.)
  4. Adopt cargo-nextest for faster parallel local runs.

Whatever the fix, it should preserve the original intent of the cap -- guarding against the PR #461 pathological-runtime regression class (a single test binary taking 44 minutes) -- rather than removing the guard rail.

How it was discovered

Found while attempting a local commit on the user's macOS (darwin) dev machine: the pre-commit hook's Rust pipeline tripped the 180s cap (exit 124) every time, while an uncapped cargo test completed in ~449s with all tests passing. Per-binary timing then isolated the cost to the simlin-serve fsevents/websocket/e2e suites.

Distinct from (checked for duplicates)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions