Skip to content

test: create an iPhone simulator when the runner has none - #19

Merged
esnunes merged 2 commits into
mainfrom
test/create-simulator
Oct 4, 2026
Merged

esnunes merged 2 commits into
mainfrom
test/create-simulator

Conversation

@esnunes

@esnunes esnunes commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

Fixes the "Test on macOS" failure on #16, which comes from the runner, not from #16's README change.

The failure

On one tuist-macos-26-3 runner, xcodebuild -showdestinations listed only the placeholder for iOS simulators, so the test found no iPhone:

{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }

That placeholder appears without an error, which means the iOS simulator runtime is installed. There were just no simulators created on that machine. #18 passed on another runner of the same profile that did have them, so the images apparently differ in whether simulators are pre-created.

The fix

When Xcode lists no iPhone, the test now creates one: simctl create "TestCoverageAttribution iPhone" on the newest iOS runtime from simctl list runtimes available --json, with the first iPhone model that runtime supports. It then asks Xcode again, so it still only uses a device the selected Xcode can run. If even that fails, the message includes Xcode's destination list, as it did before, since that list is what diagnosed this failure.

execute now returns the process's standard output, kept separate from standard error so simctl's JSON parses cleanly. Its callers no longer manage temporary log files, which also covers the cleanup the review of #15 noted.

Verification

  • Creation path. In a copy that skips the first lookup and only accepts the created device, the helper created the simulator, Xcode listed it, and all three runners of attributesEachTestToTheCountersItMoved passed on it. I deleted that simulator afterwards.
  • Locally. mise run test (8 tests) and mise run lint pass.

Once this merges, #16 needs a rebase to pick it up.

Code review

Fixed:

  • Destination list in the failure message. The final message had dropped Xcode's destination list. It's back, which I checked by forcing the failure.

Not changed:

  • Newest runtime. The device is created on the newest runtime, even if the selected Xcode can't run it. This doesn't reproduce here: Xcode 26.3 also runs devices on the newer 26.5 runtime. If it ever happens, the failure message shows it.
  • Leftover simulators. Created simulators accumulate when Xcode doesn't list them, which only follows from the case above.
  • CI coverage. CI only exercises the creation path on runners without simulators.
  • Separate output streams. Standard output and standard error are now separate in failure messages instead of interleaved.

🤖 Generated with Claude Code

#16's Test on macOS failed on a tuist-macos-26-3 runner whose image has
the iOS simulator runtime but no simulators: Xcode listed only the "Any
iOS Simulator Device" placeholder. #18 had passed on another runner of
the same profile that did have them.

When Xcode lists no iPhone, the test now creates one with simctl on the
newest iOS runtime installed, using an iPhone model it supports, and
asks Xcode again.

execute now returns standard output, kept apart from standard error,
which drops the temporary log files its callers managed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@esnunes
esnunes requested a review from a team as a code owner October 4, 2026 02:22
@esnunes
esnunes requested review from fortmarek and removed request for a team October 4, 2026 02:22
The message before this PR printed them, and they are what diagnosed
#16's failure: they showed the iOS platform installed with no simulator
on it. The lookup now returns them alongside the simulator it found.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@esnunes
esnunes merged commit fd59626 into main Oct 4, 2026
7 checks passed
@esnunes
esnunes deleted the test/create-simulator branch October 4, 2026 02:35
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