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")/.."
23PROJECT="DomainDig.xcodeproj" 23PROJECT="DomainDig.xcodeproj"
24SCHEME="DomainDig" 24SCHEME="DomainDig"
25TIER="${1:-both}" 25TIER="${1:-both}"
26MAX_LAUNCH_ATTEMPTS=3
26 27
27# shellcheck source=lib/simulators.sh 28# shellcheck source=lib/simulators.sh
28source "$(dirname "$0")/lib/simulators.sh" 29source "$(dirname "$0")/lib/simulators.sh"
@@ -42,6 +43,7 @@ echo " deployment target: $DEPLOYMENT_TARGET (rank $FLOOR_RANK)"
42run_tier() { 43run_tier() {
43 local which="$1" 44 local which="$1"
44 local sim udid label 45 local sim udid label
46 local attempt=1
45 47
46 sim=$(select_sim "$which") 48 sim=$(select_sim "$which")
47 if [[ -z "$sim" ]]; then 49 if [[ -z "$sim" ]]; then
@@ -61,22 +63,50 @@ run_tier() {
61 echo " deployment target, so this is not true floor coverage." 63 echo " deployment target, so this is not true floor coverage."
62 fi 64 fi
63 65
64 # Boot and wait before handing the destination to xcodebuild. Left to 66 local log
65 # xcodebuild, a cold device races its own boot: the test host fails to launch 67 log=$(mktemp -t "domaindig-test-$which")
66 # with "Application launch did not return a process handle" (NSPOSIXErrorDomain 68
67 # Code=3), no test reports, and the run stalls about 380 seconds before it 69 while :; do
68 # calls that a failure. `bootstatus -b` boots if needed and blocks until the 70 # Boot and wait rather than letting xcodebuild race its own boot.
69 # device is ready, which is the whole fix. 71 xcrun simctl bootstatus "$udid" -b > /dev/null 2>&1 || true
70 echo " booting and waiting for the device" 72
71 xcrun simctl bootstatus "$udid" -b > /dev/null 2>&1 || true 73 set +e
72 74 xcodebuild test \
73 set -o pipefail 75 -project "$PROJECT" \
74 xcodebuild test \ 76 -scheme "$SCHEME" \
75 -project "$PROJECT" \ 77 -destination "id=$udid" \
76 -scheme "$SCHEME" \ 78 -only-testing:DomainDigTests > "$log" 2>&1
77 -destination "id=$udid" \ 79 local code=$?
78 -only-testing:DomainDigTests 2>&1 \ 80 set -e
79 | grep -E 'Executed [0-9]+ test|\*\* TEST (SUCCEEDED|FAILED)|error:|malloc: \*\*\*|^Test Case .* failed' 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"
80} 110}
81 111
82status=0 112status=0