mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
* fix(replay-ui): size overlay viewBox from hierarchy root bounds
Tap points are recorded in the hierarchy's coordinate space (iOS points,
Android pixels, web CSS px) while screenshots are device pixels, so the
overlay rendered at 1/3 position on iOS 3x screens. Derive the viewBox
from the root element bounds; natural image size stays the fallback.
* fix(runner): derive trace tap point from resolveCoordinates
stampSelectorTarget preferred possibly-stale action X/Y while dispatch
preferred the fresh tree-resolved center, so the trace could record a
different point than the one tapped. Both now share resolveCoordinates.
* fix(runner): settle after InputText focus tap before key events
The focus tap raises the keyboard; with no settle the keyboard
animation races the erase/type key events on iOS, landing them in the
wrong field or dropping them. Wait for idle after a successful focus
tap, bounded by the run's idle timeout.
* fix(driver): skip pre-erase for replace-on-input drivers
The web driver's InputText already replaces content via select-all, so
the runner's unconditional EraseText was a redundant round-trip on
every InputText. A new optional TextReplacer capability lets a driver
assert replace semantics; the runner skips the erase when asserted.
* fix(hierarchy): rank spatial-fallback matches by specificity
The bounds-containment fallback returned the first pre-order match, so
a screen-sized container could win over the intended small element.
Matches are now ordered smallest-area first; equal-area matches keep
pre-order, preserving the iOS-flat equal-bounds sibling pattern.
* fix(runner): treat an unchanging transitional tree as settled
A UI persistently showing two route-level Screen ids (overlay, both
route ids alive at rest) burned the full retry budget every step and
skipped the verifier forever. A tree byte-identical to the previous
attempt now breaks the retry loop as settled; genuine cross-fades
differ between attempts and keep the retry/skip behavior.
* fix(replay-ui): skip synthetic zero-bounds root in deviceSpaceOf
The iOS hierarchy prepends a zero-bounds node before the real root
window, so elements[0] returned undefined and the overlay fell back to
the screenshot's pixel size. Take the first element with positive
extent instead; pre-order puts the root window before any content.
Verified against a real iOS trace in the replay UI.
* fix(sidecar): never replay non-idempotent actions after reconnect
A dropped connection mid-action (e.g. a read timeout while the device
is still typing) re-ran the whole block after reconnecting, typing the
text twice and double-firing taps. Non-idempotent actions now reconnect
for the next RPC's benefit but surface UNAVAILABLE, which the runner
already treats as transient; idempotent reads keep the replay.
* fix(sidecar): land the second double-tap sequentially on gesture collision
The overlapped second tap can hit the XCTest runner while the first
gesture is still executing ('only one gesture can be performed at a
time'), failing the step. The second tap now waits the first out and
retries once, keeping the tight gap on the happy path.
* fix(sidecar): map non-Exception throwables to INTERNAL status
The vendored iOS client throws failures that do not extend Exception;
runRpc missed them, killing the RPC as a channel-level Unknown the
runner cannot classify. Catch Throwable instead.
* feat(sidecar): close the driver and app under test on shutdown
* test(sidecar): cover service shutdown paths
* fix(testrun): stop the sidecar with SIGTERM before killing
* fix(sidecar): reap orphaned XCTest runner sessions at iOS init
* fix(sidecar): probe channel liveness before restarting the XCTest runner
* test(sidecar): cover WdaRecovery restart and retry policy
* fix(sidecar): absorb first-leg double-tap collision sequentially
* fix(runner): scope WDA-drop detection and cap consecutive transient failures
* chore(sidecar): silence vendored loggers on expected failure paths
* fix(runner): absorb one-off apply errors; only an unbroken streak aborts
* fix(folio): install the current build before the Android fuzz run
* chore(sidecar): silence absorbed view-hierarchy poll noise in Android runs
The driver logs an ERROR for every on-device view-hierarchy fetch that the
device-side server cancels or times out while the UI animates. The stability
poll fetches the hierarchy on a sub-second cadence and swallows those throws
to keep polling, so each line is advisory with no effect on the run. Real
failures still reach the runner as gRPC status errors, so nothing is lost.
174 lines
6.0 KiB
Makefile
174 lines
6.0 KiB
Makefile
set shell := ["bash", "-cu"]
|
|
set dotenv-load := true
|
|
|
|
sanderling := env_var_or_default("SANDERLING", "sanderling")
|
|
avd := env_var_or_default("AVD", "")
|
|
duration := env_var_or_default("DURATION", "1m")
|
|
seed := env_var_or_default("SEED", "0")
|
|
output := env_var_or_default("OUTPUT", justfile_directory() / "sanderling" / "runs")
|
|
ios_device := env_var_or_default("IOS_DEVICE", "iPhone 17 Pro")
|
|
|
|
default:
|
|
@just --list
|
|
|
|
# Resolve ANDROID_HOME from the env or a short list of canonical install
|
|
# locations, so Gradle can find the Android SDK without the user having to
|
|
# export anything.
|
|
_android-home:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
if [[ -n "${ANDROID_HOME:-}" && -d "$ANDROID_HOME" ]]; then
|
|
echo "$ANDROID_HOME"; exit 0
|
|
fi
|
|
if [[ -n "${ANDROID_SDK_ROOT:-}" && -d "$ANDROID_SDK_ROOT" ]]; then
|
|
echo "$ANDROID_SDK_ROOT"; exit 0
|
|
fi
|
|
for candidate in \
|
|
"$HOME/Library/Android/sdk" \
|
|
"$HOME/Android/Sdk" \
|
|
"/opt/homebrew/share/android-commandlinetools" \
|
|
"/usr/local/share/android-commandlinetools"; do
|
|
if [[ -d "$candidate" ]]; then
|
|
echo "$candidate"; exit 0
|
|
fi
|
|
done
|
|
echo "could not locate Android SDK (set ANDROID_HOME)" >&2
|
|
exit 1
|
|
|
|
# Ensure an Android device is online. If none is connected and no AVD is
|
|
# provided, boot the first AVD whose system image is actually installed
|
|
# (headless) and wait for it to finish booting.
|
|
_ensure-device:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
sdk="$(just _android-home)"
|
|
adb="$sdk/platform-tools/adb"
|
|
if "$adb" devices | awk 'NR>1 && $2=="device"{f=1} END{exit !f}'; then
|
|
exit 0
|
|
fi
|
|
if [[ -n "{{avd}}" ]]; then
|
|
exit 0 # sanderling boots the named AVD itself
|
|
fi
|
|
emulator="$sdk/emulator/emulator"
|
|
avd=""
|
|
for candidate in $("$emulator" -list-avds); do
|
|
# The AVD directory is named in <name>.ini's path= field, which is not
|
|
# always "<name>.avd" (e.g. Medium_Phone_API_36.0 -> Medium_Phone.avd).
|
|
avddir="$(sed -n 's/^path=//p' "$HOME/.android/avd/$candidate.ini" 2>/dev/null || true)"
|
|
[[ -n "$avddir" ]] || avddir="$HOME/.android/avd/$candidate.avd"
|
|
sysdir="$(sed -n 's/^image\.sysdir\.1=//p' "$avddir/config.ini" 2>/dev/null || true)"
|
|
if [[ -n "$sysdir" && -d "$sdk/$sysdir" ]]; then avd="$candidate"; break; fi
|
|
done
|
|
if [[ -z "$avd" ]]; then
|
|
echo "no bootable AVD found (no installed system image); create one or set AVD=" >&2
|
|
exit 1
|
|
fi
|
|
echo "booting emulator: $avd"
|
|
ANDROID_SDK_ROOT="$sdk" ANDROID_HOME="$sdk" nohup "$emulator" -avd "$avd" \
|
|
-no-window -no-snapshot -gpu swiftshader_indirect -no-audio >/tmp/folio-emulator.log 2>&1 &
|
|
for _ in $(seq 1 150); do
|
|
if [[ "$("$adb" shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')" == "1" ]]; then
|
|
echo "emulator ready"; exit 0
|
|
fi
|
|
sleep 2
|
|
done
|
|
echo "emulator did not finish booting in time (see /tmp/folio-emulator.log)" >&2
|
|
exit 1
|
|
|
|
# Build and install the folio APK on a running emulator/device.
|
|
install: _ensure-device
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
export ANDROID_HOME="$(just _android-home)"
|
|
./gradlew :app:androidApp:installDebug
|
|
|
|
# Remove the folio APK from the connected device.
|
|
uninstall:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
export ANDROID_HOME="$(just _android-home)"
|
|
./gradlew :app:androidApp:uninstallDebug
|
|
|
|
# Remove gradle + iOS build directories.
|
|
clean:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
export ANDROID_HOME="$(just _android-home)"
|
|
./gradlew clean
|
|
rm -rf app/iosApp/build
|
|
|
|
# Regenerate iosApp.xcodeproj from project.yml.
|
|
ios-gen:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
cd app/iosApp && xcodegen generate
|
|
|
|
# Build + install + launch on a booted iOS simulator (boots IOS_DEVICE if none).
|
|
ios:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
export ANDROID_HOME="$(just _android-home)"
|
|
if ! xcrun simctl list devices booted | grep -q Booted; then
|
|
xcrun simctl boot "{{ios_device}}"
|
|
open -a Simulator
|
|
sleep 3
|
|
fi
|
|
just ios-gen
|
|
xcodebuild -project app/iosApp/iosApp.xcodeproj -scheme iosApp \
|
|
-destination 'platform=iOS Simulator,name={{ios_device}}' \
|
|
-derivedDataPath app/iosApp/build \
|
|
build | tail -5
|
|
xcrun simctl install booted app/iosApp/build/Build/Products/Debug-iphonesimulator/iosApp.app
|
|
xcrun simctl launch booted app.folio
|
|
|
|
# Run 'sanderling test' against the folio app. Uses a connected device if one is
|
|
# online; otherwise boots AVD=<name> when provided, or auto-boots a bootable AVD.
|
|
# Depends on install so the run always fuzzes the current build, matching
|
|
# test-ios which rebuilds and reinstalls the app first.
|
|
test: install
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
avd_flag=()
|
|
if [[ -n "{{avd}}" ]]; then
|
|
avd_flag=(--avd "{{avd}}")
|
|
fi
|
|
"{{sanderling}}" test \
|
|
--spec "{{justfile_directory()}}/sanderling/spec.ts" \
|
|
--bundle-id app.folio \
|
|
"${avd_flag[@]}" \
|
|
--duration "{{duration}}" \
|
|
--seed "{{seed}}" \
|
|
--output "{{output}}"
|
|
|
|
# Serve the wasmJs web app from a webpack dev server with COOP/COEP headers.
|
|
web:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
export ANDROID_HOME="$(just _android-home)"
|
|
./gradlew :app:webApp:wasmJsBrowserDevelopmentRun --continuous
|
|
|
|
# Produce a webpack distributable bundle for the web app.
|
|
web-build:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
export ANDROID_HOME="$(just _android-home)"
|
|
./gradlew :app:webApp:wasmJsBrowserDevelopmentExecutableDistribution
|
|
|
|
# Build + install + run sanderling spec on iOS simulator.
|
|
test-ios:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
just ios
|
|
ios_device_flag=()
|
|
if [[ -n "{{ios_device}}" ]]; then
|
|
ios_device_flag=(--ios-device "{{ios_device}}")
|
|
fi
|
|
"{{sanderling}}" test \
|
|
--platform ios \
|
|
--spec "{{justfile_directory()}}/sanderling/spec.ts" \
|
|
--bundle-id app.folio \
|
|
"${ios_device_flag[@]}" \
|
|
--duration "{{duration}}" \
|
|
--seed "{{seed}}" \
|
|
--output "{{output}}"
|