Erase the test simulators before running the tests

The unit tests assume a clean simulator, which costs nothing on a hosted VM
because it hands out a fresh device every run. This runner reuses the same two
devices, so app containers, caches and logs survive between runs and six suites
fail on the previous run's leftovers rather than on anything in the code.
LoggingTests is the clearest: it expects no log files and finds nine, in the same
device container each time.

Only the two devices the tooling pins are erased, resolved by UDID. A blanket
erase would take out simulator state belonging to other work on a machine the
release pipeline shares.
This commit is contained in:
2026-07-16 09:25:01 +02:00
parent 728ace6f81
commit 7a37282d0b
+28
View File
@@ -71,6 +71,34 @@ jobs:
# of which Xcode built a given run.
xcodebuild -version
- name: Reset the test simulators
# HealthChat: a hosted VM hands out a fresh simulator every run; this runner reuses the same
# devices, so app containers, caches and logs survive between runs. Suites asserting on clean
# state then fail on the previous run's leftovers — LoggingTests expects no log files and
# finds nine, in the same device container each time.
#
# Only the two devices the tooling pins are erased (UnitTests.swift, PreviewTests.swift,
# CI.swift), never `simctl erase all`: this machine is shared with the release pipeline, and
# a blanket wipe would take out simulator state that has nothing to do with this job. A
# missing device is not an error — the tooling creates it.
run: |
set -eu
for device in "iPhone 17" "iPhone SE (3rd generation)"; do
# Match on a trailing "(" so "iPhone 17" cannot also match "iPhone 17 Pro" — the same
# guard the tooling uses when it resolves a device.
udid=$(xcrun simctl list devices "iOS 26.5" available \
| grep -F "$device (" \
| grep -oE '[0-9A-F]{8}(-[0-9A-F]{4}){3}-[0-9A-F]{12}' \
| head -1 || true)
if [ -n "$udid" ]; then
echo "Erasing $device ($udid)"
xcrun simctl shutdown "$udid" 2>/dev/null || true
xcrun simctl erase "$udid"
else
echo "$device not present — the tooling will create it"
fi
done
- name: Run tests
# HealthChat: previews are skipped. PreviewTests renders a snapshot for every preview in the
# app and was the entire reason this job could not fit in an hour — it never once finished,