build(package): stop shipping Swift test sources
Merged
TH
1d ago+519+519+012345678901234567890123456789-31-31-01234567890123456789
Summary
The npm package shipped apple/macos-helper/Tests/**, but that Swift never compiles into the helper.
- The tests move back into the shipped manifest's tree:
apple/macos-helper/Package.swiftdeclares the test targets andpackage.jsonfilesexcludesapple/macos-helper/Tests/**from the pack. - The pack keeps exactly one
PackStub.swiftper test target: SwiftPM refuses to load a package whose declared test target has no sources, and the install-timeswift buildruns on the packed tree, so the stubs are load-bearing. An earlier iteration shipped a manifest without test targets behind aSourcessymlink in a dev-only test package; the symlink broke Stryker's sandbox copy (EISDIR, run 39045124618) and any tool that copies the tree, and SwiftPM rejects sources outside a package root, so no split layout avoids it. - The publish guard (
scripts/size-report-package.mjs) derives the declared test targets from the shipped manifest and requires each target'sPackStub.swiftin the pack; the repo guard asserts the same invariant against the realnpm pack --dry-runfile list, so no test source can leak back in and no stub can go missing. - Rejected alternatives: a
FileManager.fileExistscheck in the shipped manifest (depends on the manifest's working directory and sandbox); a dev-only test package compiling the shipped sources (needs a directory symlink or an out-of-rootpath:, both rejected by tooling/SwiftPM).
Validation
- Packed tree:
npm pack, extracted into a clean dir, thenswift build -c release --package-path apple/macos-helper→Build complete. The pack holds no test sources beyondTests/AgentDeviceMacOSHelperTests/PackStub.swiftandTests/AgentDeviceMacOSInputTests/PackStub.swift. - Size delta vs main (
npm pack --dry-run --json --ignore-scripts, identical builds): 525 → 523 files, tarball 1,435,877 → 1,433,786 B (−2,091 B), unpacked 4,661,050 → 4,653,755 B (−7,295 B). pnpm test:macos-helper→ 8 XCTest cases (6 Input + 2+1+5 Helper), 0 failures. Repo guard, publish-guard, and size-report tests pass.- Mutation:
pnpm gate mutation --modules snapshot-occlusionlocally → Stryker sandbox copy passes (no EISDIR), initial test run succeeded, lane envelope pass at stage complete. No repo tool copies a directory symlink anymore; theregularFileguard inscripts/lib/repo-git.tsstays as the general fix for non-blob diff sides. pnpm check:affected --run --head 563d35e6ea→[passed] exactCommit=true, all runnable checks green; receipt.tmp/validation/run-zVw3OY/receipt.json.