Skip to content

Commit cf63ab3

Browse files
committed
fix(package): keep the macOS helper tests in the shipped package without a symlink
The dev-only package apple/macos-helper-tests compiled the helper sources through a committed symlink to ../macos-helper/Sources. A symlink to a directory breaks every tool that copies the tree: Stryker's sandbox dies on copyfile (EISDIR), which failed both mutation jobs on this branch (run 39045124618), and it breaks Windows checkouts. SwiftPM rejects sources outside a package root, so no split-package layout avoids the link. Put the tests back under apple/macos-helper/Tests and keep them out of the pack with files exclusions; ship one PackStub.swift per test target, because SwiftPM refuses to load a package whose declared test target has no sources, and the install-time swift build runs on exactly that packed tree. Proof on the packed tree: swift build -c release succeeds; pnpm test:macos-helper runs all 8 XCTest cases from the checkout; the Stryker sandbox copy and full lane pass locally (snapshot-occlusion, envelope pass).
1 parent 0bde27b commit cf63ab3

14 files changed

Lines changed: 90 additions & 90 deletions

File tree

‎apple/macos-helper-tests/Package.swift‎

Lines changed: 0 additions & 29 deletions
This file was deleted.

‎apple/macos-helper-tests/Sources‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎apple/macos-helper/Package.swift‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// swift-tools-version: 5.9
22
import PackageDescription
33

4-
// The npm package ships this directory and builds it on the user's machine, so it declares only
5-
// what the helper binary needs. SwiftPM refuses to build a package whose declared test target has
6-
// no sources, and the tests are not shipped; apple/macos-helper-tests is the manifest that owns
7-
// them and compiles these same sources with them.
4+
// The npm package ships this directory and builds it on the user's machine. The tests under
5+
// Tests/ stay out of the tarball through `files`, except one PackStub.swift per test target:
6+
// SwiftPM refuses any load of a package whose declared test target has no sources, so the
7+
// shipped tree needs a source per test target for the install-time `swift build` to succeed.
88
let package = Package(
99
name: "agent-device-macos-helper",
1010
platforms: [.macOS(.v13)],
@@ -22,5 +22,13 @@ let package = Package(
2222
name: "AgentDeviceMacOSHelper",
2323
dependencies: ["AgentDeviceMacOSInput"]
2424
),
25+
.testTarget(
26+
name: "AgentDeviceMacOSInputTests",
27+
dependencies: ["AgentDeviceMacOSInput"]
28+
),
29+
.testTarget(
30+
name: "AgentDeviceMacOSHelperTests",
31+
dependencies: ["AgentDeviceMacOSHelper"]
32+
),
2533
]
2634
)

apple/macos-helper-tests/Tests/AgentDeviceMacOSHelperTests/BackgroundInteractionTests.swift renamed to apple/macos-helper/Tests/AgentDeviceMacOSHelperTests/BackgroundInteractionTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private struct HelperOutcomesFixture: Decodable {
2828
let deliveryMechanisms: [String]
2929
}
3030

31-
/// `#filePath` is `<repo>/apple/macos-helper-tests/Tests/AgentDeviceMacOSHelperTests/<file>`.
31+
/// `#filePath` is `<repo>/apple/macos-helper/Tests/AgentDeviceMacOSHelperTests/<file>`.
3232
private let repoRoot = URL(fileURLWithPath: #filePath)
3333
.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
3434
.deletingLastPathComponent().deletingLastPathComponent()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// The npm package ships this one file and nothing else under the test targets (see `files` in
2+
// package.json). SwiftPM refuses to load a package whose declared test target has no sources, so
3+
// the install-time `swift build` of the packed tree needs a source here; the real tests for this
4+
// target live beside it and are excluded from the pack.
5+
import XCTest
6+
7+
final class AgentDeviceMacOSHelperPackStubTests: XCTestCase {}

apple/macos-helper-tests/Tests/AgentDeviceMacOSHelperTests/RectResponseTests.swift renamed to apple/macos-helper/Tests/AgentDeviceMacOSHelperTests/RectResponseTests.swift

File renamed without changes.

apple/macos-helper-tests/Tests/AgentDeviceMacOSHelperTests/ScreenshotResponseTests.swift renamed to apple/macos-helper/Tests/AgentDeviceMacOSHelperTests/ScreenshotResponseTests.swift

File renamed without changes.

apple/macos-helper-tests/Tests/AgentDeviceMacOSInputTests/MouseClickScheduleTests.swift renamed to apple/macos-helper/Tests/AgentDeviceMacOSInputTests/MouseClickScheduleTests.swift

File renamed without changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// The npm package ships this one file and nothing else under the test targets (see `files` in
2+
// package.json). SwiftPM refuses to load a package whose declared test target has no sources, so
3+
// the install-time `swift build` of the packed tree needs a source here; the real tests for this
4+
// target live beside it and are excluded from the pack.
5+
import XCTest
6+
7+
final class AgentDeviceMacOSInputPackStubTests: XCTestCase {}

‎package.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
"package:android-ime-helper:npm": "rm -rf android/ime-helper/dist && AGENT_DEVICE_ANDROID_HELPER=ime sh ./scripts/package-android-helper.sh $(node -p \"require('./package.json').version\") android/ime-helper/dist",
117117
"build:macos-helper": "node --experimental-strip-types scripts/swift-toolchain-tmpdir.ts swift build -c release --package-path apple/macos-helper",
118118
"build:macos-helper:clean": "node --experimental-strip-types scripts/swift-toolchain-tmpdir.ts swift package --package-path apple/macos-helper clean && pnpm build:macos-helper",
119-
"test:macos-helper": "node --experimental-strip-types scripts/swift-toolchain-tmpdir.ts swift test --package-path apple/macos-helper-tests",
119+
"test:macos-helper": "node --experimental-strip-types scripts/swift-toolchain-tmpdir.ts swift test --package-path apple/macos-helper",
120120
"check:macos-helper": "pnpm build:macos-helper && pnpm test:macos-helper",
121121
"prepare:publish-assets": "node scripts/prepare-publish-assets.mjs",
122122
"build:package": "pnpm build && pnpm package:xcuitest && pnpm build:macos-helper:clean && pnpm prepare:publish-assets",
@@ -222,6 +222,9 @@
222222
"dist",
223223
"apple/macos-helper",
224224
"!apple/macos-helper/**/.build",
225+
"!apple/macos-helper/Tests/**",
226+
"apple/macos-helper/Tests/AgentDeviceMacOSHelperTests/PackStub.swift",
227+
"apple/macos-helper/Tests/AgentDeviceMacOSInputTests/PackStub.swift",
225228
"apple/snapshot-bridge",
226229
"apple/fold-helper",
227230
"android/snapshot-helper/dist",

0 commit comments

Comments
 (0)