Commit 2accaa0ea7

2accaa0ea7a155871a3d928b0a62e4243ffd5256

parent: 2c3ac47aa0

Unsigned

cmc <hello@cleberg.net> · 2026-10-24 22:32 UTC

Retry a test run that never started (!25)

!24 narrowed E2 but did not remove it. The device accepts the install and the
test host never starts, either with

```
Application launch for 'net.cleberg.DomainDig' did not return a process handle
nor launch error.
```

or with no diagnostic at all beyond `** TEST FAILED **`. Roughly one occurrence
per both-tier pass on this machine.

## What it is not

One commit throughout:

| hypothesis | test | result |
|---|---|---|
| a hanging test | `-default-test-execution-time-allowance 60` | no test named; the runner never started |
| an app crash at launch | looked for a fresh crash report | none written |
| cold-boot race alone | `simctl bootstatus -b` first (!24) | helps, still fails |
| one bad device (iPhone Air) | same runs on iPhone 18 Pro | fails there too |
| the iOS 27 runtime | ran current first, floor second | both passed |
| second position only | reversed order | both passed |

The cause is somewhere in CoreSimulator and is **not established**. This is a
workaround, and the commit and the finding both say so.

## The change

`run_tier` gives each tier the device to itself, keeps launch errors in its
output instead of filtering them out — that filtering is why the reason never
reached the console — and retries up to twice when a run executed no tests.

What makes the retry safe is the condition rather than the error text, which
varies: a run that executed no tests did not get far enough to have a test
result. A compile failure is excluded so a broken build is not retried three
times, and any run that reached the tests is reported as it stands. Checked
against real logs of each kind: every log with tests executed reports as-is.

## Verification

Four consecutive both-tier runs from cold, all green, each absorbing exactly
one retry. Before this, roughly a third of invocations failed with no test
result.

Layout: unified · split

Scripts/test.sh +46 −16
@@ -23,6 +23,7 @@ cd "$(dirname "$0")/.."
2323PROJECT="DomainDig.xcodeproj"
2424SCHEME="DomainDig"
2525TIER="${1:-both}"
26MAX_LAUNCH_ATTEMPTS=3
2627
2728# shellcheck source=lib/simulators.sh
2829source "$(dirname "$0")/lib/simulators.sh"
@@ -42,6 +43,7 @@ echo " deployment target: $DEPLOYMENT_TARGET (rank $FLOOR_RANK)"
4243run_tier() {
4344 local which="$1"
4445 local sim udid label
46 local attempt=1
4547
4648 sim=$(select_sim "$which")
4749 if [[ -z "$sim" ]]; then
@@ -61,22 +63,50 @@ run_tier() {
6163 echo " deployment target, so this is not true floor coverage."
6264 fi
6365
64 # Boot and wait before handing the destination to xcodebuild. Left to
65 # xcodebuild, a cold device races its own boot: the test host fails to launch
66 # with "Application launch did not return a process handle" (NSPOSIXErrorDomain
67 # Code=3), no test reports, and the run stalls about 380 seconds before it
68 # calls that a failure. `bootstatus -b` boots if needed and blocks until the
69 # device is ready, which is the whole fix.
70 echo " booting and waiting for the device"
71 xcrun simctl bootstatus "$udid" -b > /dev/null 2>&1 || true
72
73 set -o pipefail
74 xcodebuild test \
75 -project "$PROJECT" \
76 -scheme "$SCHEME" \
77 -destination "id=$udid" \
78 -only-testing:DomainDigTests 2>&1 \
79 | grep -E 'Executed [0-9]+ test|\*\* TEST (SUCCEEDED|FAILED)|error:|malloc: \*\*\*|^Test Case .* failed'
66 local log
67 log=$(mktemp -t "domaindig-test-$which")
68
69 while :; do
70 # Boot and wait rather than letting xcodebuild race its own boot.
71 xcrun simctl bootstatus "$udid" -b > /dev/null 2>&1 || true
72
73 set +e
74 xcodebuild test \
75 -project "$PROJECT" \
76 -scheme "$SCHEME" \
77 -destination "id=$udid" \
78 -only-testing:DomainDigTests > "$log" 2>&1
79 local code=$?
80 set -e
81
82 grep -E 'Executed [0-9]+ test|\*\* TEST (SUCCEEDED|FAILED)|error:|malloc: \*\*\*|^Test Case .* failed|failed to launch|did not return a process handle' "$log" || true
83
84 xcrun simctl shutdown "$udid" > /dev/null 2>&1 || true
85
86 if [[ "$code" -eq 0 ]] || ! launch_failed "$log" || [[ "$attempt" -ge "$MAX_LAUNCH_ATTEMPTS" ]]; then
87 rm -f "$log"
88 return "$code"
89 fi
90
91 echo " launch failed before any test ran; retrying ($attempt/$((MAX_LAUNCH_ATTEMPTS - 1)))"
92 attempt=$((attempt + 1))
93 done
94}
95
96# A CoreSimulator flake, not a test result. The device accepts the install and
97# then the test host never starts: sometimes with "Application launch ... did
98# not return a process handle nor launch error", sometimes with no diagnostic
99# at all beyond "** TEST FAILED **", and left alone xcodebuild can sit ~380s
100# before saying so. Seen on roughly a third of invocations here, on several
101# devices and both runtimes, and not fixed by booting and waiting first.
102#
103# Retrying is a workaround for that, so the test is what makes it safe rather
104# than the error text, which varies: a run that executed no tests at all did
105# not get far enough to have a test result, and a compile failure is excluded
106# so a broken build is not retried three times.
107launch_failed() {
108 local log="$1"
109 ! grep -qE 'Executed [0-9]+ test' "$log" && ! grep -qE ': error:' "$log"
80110}
81111
82112status=0