Skip to content

Commit 63e22f8

Browse files
abueideclaude
andcommitted
feat(rn): apply detach behavior to all-e2e test suite
Apply same changes to test-suite-all-e2e.yaml: - Detach emulator/simulator in dev mode after ready - Simplify app verification to use built-in status commands Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 67ba125 commit 63e22f8

1 file changed

Lines changed: 46 additions & 92 deletions

File tree

examples/react-native/tests/test-suite-all-e2e.yaml

Lines changed: 46 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,30 @@ processes:
6969
device="${ANDROID_DEFAULT_DEVICE:-max}"
7070
7171
if [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
72+
# Pure mode: foreground
7273
echo "Starting fresh Android emulator (pure mode): $device"
7374
android.sh emulator start --pure "$device"
75+
tail -f /dev/null
7476
else
77+
# Dev mode: start, wait for ready, then detach
7578
echo "Starting Android emulator: $device"
7679
unset ANDROID_EMULATOR_FOREGROUND
7780
android.sh emulator start "$device"
81+
82+
echo "Waiting for emulator to be ready..."
83+
max_wait=120
84+
elapsed=0
85+
while ! android.sh emulator ready; do
86+
sleep 3
87+
elapsed=$((elapsed + 3))
88+
if [ $elapsed -ge $max_wait ]; then
89+
echo "ERROR: Emulator did not become ready within ${max_wait}s" >&2
90+
exit 1
91+
fi
92+
done
93+
echo "✓ Emulator ready and running in background (dev mode)"
94+
exit 0
7895
fi
79-
# Keep process alive for readiness probe (process-compose services pattern)
80-
tail -f /dev/null
8196
availability:
8297
restart: "no"
8398
readiness_probe:
@@ -94,12 +109,27 @@ processes:
94109
command: |
95110
set -e
96111
if [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
112+
# Pure mode: foreground
97113
ios.sh simulator start --pure ${IOS_DEVICE}
114+
tail -f /dev/null
98115
else
116+
# Dev mode: start, wait for ready, then detach
99117
ios.sh simulator start ${IOS_DEVICE}
118+
119+
echo "Waiting for simulator to be ready..."
120+
max_wait=60
121+
elapsed=0
122+
while ! ios.sh simulator ready; do
123+
sleep 2
124+
elapsed=$((elapsed + 2))
125+
if [ $elapsed -ge $max_wait ]; then
126+
echo "ERROR: Simulator did not become ready within ${max_wait}s" >&2
127+
exit 1
128+
fi
129+
done
130+
echo "✓ Simulator ready and running in background (dev mode)"
131+
exit 0
100132
fi
101-
# Keep process alive for readiness probe (process-compose services pattern)
102-
tail -f /dev/null
103133
depends_on:
104134
sync-simulators:
105135
condition: process_completed_successfully
@@ -181,127 +211,51 @@ processes:
181211
availability:
182212
restart: "no"
183213

184-
# Phase 7a: Verify Android app and Metro connection
214+
# Phase 7a: Verify Android app
185215
verify-android-running:
186216
command: |
187-
state_dir="${ANDROID_STATE_DIR:-${ANDROID_USER_HOME:-${HOME}/.local/share/android}}"
188-
app_id=""
189-
if [ -f "$state_dir/app-id.txt" ]; then
190-
app_id="$(cat "$state_dir/app-id.txt")"
191-
fi
192-
if [ -z "$app_id" ]; then
193-
echo "ERROR: No app ID found" >&2
194-
exit 1
195-
fi
196-
197-
serial=""
198-
if [ -f "$state_dir/emulator-serial.txt" ]; then
199-
serial="$(cat "$state_dir/emulator-serial.txt")"
200-
fi
201-
if [ -z "$serial" ]; then
202-
serial="emulator-${EMU_PORT:-5554}"
203-
fi
204-
205-
echo "Waiting for Android app to start and connect to Metro..."
217+
echo "Waiting for Android app to start..."
206218
max_attempts=15
207219
attempt=0
208220
while [ $attempt -lt $max_attempts ]; do
209-
if ! android.sh app status; then
210-
attempt=$((attempt + 1))
211-
echo " Attempt $attempt/$max_attempts: App not running yet..."
212-
sleep 2
213-
continue
214-
fi
215-
216-
echo " App process is running, checking Metro connection..."
217-
log_output=$(adb -s "$serial" logcat -d -s ReactNativeJS:* ReactNative:* -t 50 2>/dev/null || true)
218-
219-
if echo "$log_output" | grep -qi "fatal\|exception\|error.*metro\|failed.*connect"; then
220-
echo "ERROR: Android app encountered errors:" >&2
221-
echo "$log_output" | grep -i "fatal\|exception\|error\|failed" | tail -10 >&2
222-
exit 1
223-
fi
224-
225-
if echo "$log_output" | grep -qi "running.*application\|bundle.*loaded"; then
226-
echo "✓ Android app is running and connected to Metro"
221+
if android.sh app status; then
222+
echo "✓ Android app is running"
227223
mkdir -p reports
228224
touch reports/.e2e-android-passed
229225
exit 0
230226
fi
231-
232227
attempt=$((attempt + 1))
233-
echo " Attempt $attempt/$max_attempts: Waiting for Metro connection..."
228+
echo " Attempt $attempt/$max_attempts: App not running yet..."
234229
sleep 2
235230
done
236231
237-
echo "ERROR: Android app started but did not connect to Metro" >&2
238-
adb -s "$serial" logcat -d -s ReactNativeJS:* ReactNative:* -t 20 >&2
232+
echo "ERROR: Android app did not start within timeout" >&2
239233
exit 1
240234
depends_on:
241235
deploy-android:
242236
condition: process_completed_successfully
243237
availability:
244238
restart: "no"
245239

246-
# Phase 7b: Verify iOS app and Metro connection (parallel with Android)
240+
# Phase 7b: Verify iOS app (parallel with Android)
247241
verify-ios-running:
248242
command: |
249-
state_dir="${IOS_STATE_DIR:-${HOME}/.local/share/ios}"
250-
bundle_id=""
251-
if [ -f "$state_dir/bundle-id.txt" ]; then
252-
bundle_id="$(cat "$state_dir/bundle-id.txt")"
253-
fi
254-
if [ -z "$bundle_id" ]; then
255-
echo "ERROR: No bundle ID found" >&2
256-
exit 1
257-
fi
258-
259-
udid=""
260-
if [ -f "$state_dir/simulator-udid.txt" ]; then
261-
udid="$(cat "$state_dir/simulator-udid.txt")"
262-
fi
263-
if [ -z "$udid" ]; then
264-
udid="$(xcrun simctl list devices -j | jq -r '.devices[]?[]? | select(.state == "Booted") | .udid' | head -n1 || true)"
265-
fi
266-
if [ -z "$udid" ]; then
267-
echo "ERROR: No booted simulator found" >&2
268-
exit 1
269-
fi
270-
271-
echo "Waiting for iOS app to start and connect to Metro..."
243+
echo "Waiting for iOS app to start..."
272244
max_attempts=15
273245
attempt=0
274246
while [ $attempt -lt $max_attempts ]; do
275-
if ! ios.sh app status; then
276-
attempt=$((attempt + 1))
277-
echo " Attempt $attempt/$max_attempts: App not running yet..."
278-
sleep 2
279-
continue
280-
fi
281-
282-
echo " App process is running, checking Metro connection..."
283-
log_output=$(xcrun simctl spawn "$udid" log show --predicate 'processImagePath contains "ReactNativeExample"' --last 30s --style compact 2>/dev/null || true)
284-
285-
if echo "$log_output" | grep -qi "fatal\|crashed\|exception.*metro\|failed.*connect.*metro"; then
286-
echo "ERROR: iOS app encountered errors:" >&2
287-
echo "$log_output" | grep -i "fatal\|crashed\|exception\|failed" | tail -10 >&2
288-
exit 1
289-
fi
290-
291-
if pgrep -f "react-native start.*8091" >/dev/null 2>&1; then
292-
echo "✓ iOS app is running and Metro is serving"
247+
if ios.sh app status; then
248+
echo "✓ iOS app is running"
293249
mkdir -p reports
294250
touch reports/.e2e-ios-passed
295251
exit 0
296252
fi
297-
298253
attempt=$((attempt + 1))
299-
echo " Attempt $attempt/$max_attempts: Waiting for Metro connection..."
254+
echo " Attempt $attempt/$max_attempts: App not running yet..."
300255
sleep 2
301256
done
302257
303-
echo "ERROR: iOS app started but did not connect to Metro" >&2
304-
xcrun simctl spawn "$udid" log show --predicate 'processImagePath contains "ReactNativeExample"' --last 10s --style compact >&2
258+
echo "ERROR: iOS app did not start within timeout" >&2
305259
exit 1
306260
depends_on:
307261
deploy-ios:

0 commit comments

Comments
 (0)