Skip to content

test(ios-readplace): add a per-file code-coverage gate to make test#920

Merged
FagnerMartinsBrack merged 1 commit into
ios/independent-contract-fixesfrom
ios/coverage-gate
Jul 5, 2026
Merged

test(ios-readplace): add a per-file code-coverage gate to make test#920
FagnerMartinsBrack merged 1 commit into
ios/independent-contract-fixesfrom
ios/coverage-gate

Conversation

@FagnerMartinsBrack

Copy link
Copy Markdown
Member

Stacked on #919 (base = ios/independent-contract-fixes). Review/merge after it.

Purpose

The rest of the monorepo enforces a 100% coverage gate, but the iOS suite ran xcodebuild test with no coverage measurement and no threshold at all — a structural exemption from the repo's coverage doctrine. Nothing stopped iOS logic from landing untested.

This wires a real coverage gate into make test (which the CI ios-tests job runs), so iOS coverage is measured and enforced on every run.

What it solves & the value

  • Measures coverage: make test now runs with -enableCodeCoverage YES -resultBundlePath build/TestResults.xcresult.
  • Enforces a per-file floor: scripts/check-coverage.py reads the .xcresult and fails the build if any source file drops below its recorded floor. A file with no floor must be 100%, so a newly added logic file cannot land untested.
  • Ratchet, not big-bang: the repo's flat 100% isn't met by iOS today (views/OS-glue at 0–5%, logic files at 57–99%), so scripts/coverage-baseline.json seeds each file's floor at today's coverage and excludes pure SwiftUI views and WebKit/OS-boundary glue (the Swift analog of the repo's whole-file OS-boundary exclusion). The later E-series PRs raise these floors toward 100% and move ShareURLExtractor out of the exclusions once it becomes testable.
  • No new CI toolchain: the checker uses only the system python3 + xcrun, so the ios-tests job (which only installs xcodegen) needs no extra setup.

Design notes

  • Floors carry a deliberate ~1% headroom against minor coverage drift across Xcode versions; the checker only nudges a ratchet once a file sits ≥2% above its floor.
  • A Shared file compiles into both the app and extension targets; the checker dedupes by basename and takes the higher coverage.
  • A config entry for a file that's no longer measured is a warning, not a hard failure, so config drift never blocks an unrelated PR.

Testing

Full suite green with the gate active locally (207 tests, iOS coverage gate passed: 19 files at or above floor, 10 excluded), plus the STAGING smoke pass. Run as CI runs make test.

The rest of the repo enforces a 100% coverage gate, but the iOS suite ran with
no coverage measurement or threshold at all — a structural blind spot. `make
test` now runs with `-enableCodeCoverage` and fails if any source file drops
below its recorded floor (`scripts/check-coverage.py`).

The gate is a ratchet, not an all-at-once 100%: `scripts/coverage-baseline.json`
excludes pure SwiftUI views and WebKit/OS-boundary glue (the Swift analog of the
repo's whole-file OS-boundary exclusion) and records a per-file floor for every
other file, seeded at today's coverage. A file with no floor must be 100%, so a
new logic file cannot land untested. Later PRs raise the floors toward 100% and
move ShareURLExtractor out of the exclusions once it is testable.

The checker uses only the system python3 + xcrun, so the CI ios-tests job needs
no extra toolchain setup.
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