Skip to content

feat(testing): Support reusable prepared test artifacts#475

Open
cameroncooke wants to merge 16 commits into
mainfrom
codex/feat/issue-450-build-for-testing
Open

feat(testing): Support reusable prepared test artifacts#475
cameroncooke wants to merge 16 commits into
mainfrom
codex/feat/issue-450-build-for-testing

Conversation

@cameroncooke

Copy link
Copy Markdown
Collaborator

Why

Agents and CI workflows need to prepare tests once and execute them later without falling back to raw xcodebuild. The existing build tools always finished with a normal build action, so they could not expose the reusable products produced by build-for-testing.

What Changed

  • Extend the existing simulator, device, and macOS build tools with buildForTesting and optional testProductsPath inputs.
  • Return managed .xctestproducts bundles and discovered .xctestrun files as structured build artifacts.
  • Let test tools execute either prepared .xctestproducts bundles or advanced .xctestrun inputs without rebuilding, while returning the new .xcresult produced by the run.
  • Move conditional next-step selection into tool manifests so normal builds and prepared-test builds advertise the appropriate follow-up without changing existing output behavior.
  • Add unit, schema, lifecycle, and MCP/CLI snapshot coverage for successful and failing prepared-test workflows.

Fixes #450

Extend existing build and test tools to prepare, return, and consume reusable test artifacts while preserving normal build behavior.

Fixes #450
Move conditional next-step selection into tool manifests and preserve the behavior across MCP, CLI, daemon, and snapshot outputs.

Refs #450
@pkg-pr-new

pkg-pr-new Bot commented Jul 16, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/xcodebuildmcp@475

commit: 191b74e

@cameroncooke
cameroncooke marked this pull request as ready for review July 16, 2026 16:19
Comment thread src/snapshot-tests/__fixtures__/cli/text/macos/test--failure.txt
Comment thread src/utils/test-common.ts
Keep source-only xcodebuild arguments out of the generated test-without-building phase and sort final test failures independently of emission order.
Comment thread src/mcp/tools/device/build_device.ts
Comment thread src/mcp/tools/device/build_device.ts
Comment thread src/utils/test-common.ts Outdated
Comment thread src/utils/test-common.ts
Share per-test environment setup and cleanup across snapshot suites, cache suite-level simulator builds, and normalize volatile output so fixtures remain stable. Update non-environmental fixtures and add coverage for cleanup and normalization behavior.
Comment thread src/snapshot-tests/preflight/simulator.ts Fixed
Comment thread src/utils/test-source.ts
Comment thread src/utils/test-common.ts
Comment thread src/snapshot-tests/__fixtures__/cli/json/swift-package/run--success.json Outdated
Comment thread src/snapshot-tests/__fixtures__/cli/text/macos/stop--success.txt
Prevent session defaults and selectors from leaking into prepared test runs, remove a useless simulator state initializer, and align volatile snapshot fixtures across CLI and MCP.
Comment thread src/utils/test-source.ts
Comment thread src/mcp/tools/macos/build_macos.ts
Keep only-testing and skip-testing arguments in the prepared test phase while retaining session-default conflict filtering.
Comment thread src/mcp/tools/device/build_device.ts
Comment thread src/snapshot-tests/__fixtures__/cli/json/ui-automation/long-press--success.json Outdated
Comment thread src/utils/workspace-filesystem-lifecycle.ts
Comment thread src/mcp/tools/device/build_device.ts
Comment thread src/mcp/tools/device/build_device.ts
Comment thread src/utils/test-common.ts
Comment thread src/utils/typed-tool-factory.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cda637e. Configure here.

Comment thread src/mcp/tools/device/build_device.ts
"screenHash": "<SCREEN_HASH>",
"seq": 1,
"count": 28,
"count": 99999,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tap--success fixture count changed to implausible 99999 unrelated to PR scope

The count field was changed from 28 to 99999 in a UI-automation tap fixture, which is unrelated to the prepared-test-artifacts feature and does not reflect a plausible real output.

Evidence
  • PR scope is buildForTesting/testProductsPath build and test tools; this fixture is ui-automation/tap--success.json.
  • count changed from 28 to 99999 while the targets array still lists only 19 entries, so 99999 does not correspond to observed data.
  • The identical value appears in both the CLI and MCP fixtures, indicating a hand-patched constant rather than a captured snapshot value.
  • If count is volatile it should be normalized in code like screenHash<SCREEN_HASH>, not hard-coded to an arbitrary literal.
Also found at 2 additional locations
  • src/snapshot-tests/__fixtures__/cli/json/ui-automation/tap--success-verbose.json:611-617
  • src/snapshot-tests/__fixtures__/cli/json/ui-automation/tap--success.json:48

Identified by Warden xcodebuildmcp-snapshot-fixture-review · G2H-E5J

"error": null,
"data": {
"simulators": [
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simulator-list fixture expanded with environment-specific entries unrelated to prepared-test feature

This fixture is regrown with many machine-specific simulators (watchOS Series 11, iPhone 17 family, etc.) that don't relate to the PR's prepared-test-artifacts change; simulator names and the device count are not normalized and reflect the installed Xcode on one machine, so this looks like a regeneration to match a local environment rather than an intentional behavior change.

Evidence
  • json-normalize.ts only normalizes state (line 83), runtime version (lines 95-97), and UUIDs; simulator name and the number of simulators entries are emitted verbatim.
  • The added entries (Apple Watch Series 11, iPhone 17 Pro, iPad Pro (M5), etc.) are literal device names tied to a specific installed simulator set, making them volatile across machines.
  • The PR scope is reusable prepared test artifacts (buildForTesting/testProductsPath), which has no bearing on the output of the simulator-list tool.

Identified by Warden xcodebuildmcp-snapshot-fixture-review · UXY-GFK

Comment on lines +28 to +34
"Fetching https://github.com/apple/swift-argument-parser.git from cache",
"Fetched https://github.com/apple/swift-argument-parser.git from cache (<DURATION>)",
"Computing version for https://github.com/apple/swift-argument-parser.git",
"Computed https://github.com/apple/swift-argument-parser.git at 1.5.1 (<DURATION>)",
"Computed https://github.com/apple/swift-argument-parser.git at 1.5.1 (<DURATION>)",
"Creating working copy for https://github.com/apple/swift-argument-parser.git",
"Working copy of https://github.com/apple/swift-argument-parser.git resolved at 1.5.1",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLI JSON run--success stderr diverges from MCP JSON fixture for the same scenario

The CLI JSON fixture (cli/json/swift-package/run--success.json) records seven SPM dependency-resolution stderr lines (Fetching/Fetched/Computing/Computed/Creating/Working copy) that the MCP JSON fixture (mcp/json/swift-package/run--success.json) does not contain. Both fixtures capture the same deterministic xcodebuildmcp.output.build-run-result scenario, so their data.output.stderr arrays should match. The divergence indicates the CLI fixture was regenerated against a different dependency-cache state (cold vs. warm) rather than kept aligned, breaking the MCP/CLI/JSON fixture alignment guardrail.

Evidence
  • cli/json/swift-package/run--success.json stderr begins with Fetching .../swift-argument-parser.git from cache through Working copy ... resolved at 1.5.1, then Building for debugging....
  • mcp/json/swift-package/run--success.json stderr for the identical scenario starts directly at Building for debugging... with none of those seven lines (grep for Fetching https://github.com/apple/swift-argument-parser matches only the CLI file).
  • Text fixtures (cli/text and mcp/text run--success.txt) surface no stderr detail, so the mismatch is isolated to the JSON envelopes.
  • The extra lines reflect volatile dependency-cache state (cold fetch/resolve) that is inconsistently captured between transports rather than normalized identically.
Also found at 1 additional location
  • src/snapshot-tests/__fixtures__/cli/json/swift-package/run--success.json:31-32

Identified by Warden xcodebuildmcp-snapshot-fixture-review · 7LW-6HX

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.

Add explicit build-for-testing action

1 participant