open-standards/wai/wai-sink-swift/scripts/test-simulator.sh
Transaction Science 850eeefe64
Some checks failed
wai-web wasm32 / does this change touch it (pull_request) Has been cancelled
wai-web wasm32 / wai-web wasm32 build · corpus, menu and writers (pull_request) Has been cancelled
wai-web reach builds / wai-web reach · does this change touch it (pull_request) Has been cancelled
wai-web reach builds / wai-web reach builds · the package of record, every output as recorded (pull_request) Has been cancelled
wai-web reach builds / wai-web reach builds · this tree's wai-web, every rung on its engine line (pull_request) Has been cancelled
WAI mbt2018_mean integer decode (regenerated vectors) / does this change touch it (pull_request) Has been cancelled
WAI mbt2018_mean integer decode (regenerated vectors) / regenerate mbt2018_mean integer vectors → Rust decode, required (pull_request) Has been cancelled
wai-sink-swift native sink package / does this change touch it (pull_request) Has been cancelled
wai-sink-swift native sink package / libwai slices, desktop tests, simulator tests · macos (pull_request) Has been cancelled
wai-quantum WebGPU member / does this change touch it (pull_request) Has been cancelled
wai-quantum WebGPU member / shader checks · browser build · wasip2 inertness · MSRV (pull_request) Has been cancelled
wai-quantum WebGPU member / member · software Vulkan (linux) (pull_request) Has been cancelled
wai-quantum WebGPU member / member · Metal (macos) (pull_request) Has been cancelled
wai-quantum WebGPU member / member · discrete GPU, Vulkan (jetson-hub) (pull_request) Has been cancelled
wai-quantum WebGPU member / member · integrated GPU, Vulkan (framework-128gb) (pull_request) Has been cancelled
wai-quantum WebGPU member / member · browser WebGPU (macos) (pull_request) Has been cancelled
wai-quantum studio and desktop / does this change touch it (pull_request) Has been cancelled
wai-quantum studio and desktop / studio · browser (pull_request) Has been cancelled
wai-quantum studio and desktop / desktop app · macos (pull_request) Has been cancelled
wai-quantum WebGPU member / member · DX12 and Vulkan (cbio-windows) (pull_request) Has been cancelled
wai-pack / wai-pack · does this change touch it (pull_request) Has been cancelled
wai-pack / wai-pack · linux (pull_request) Has been cancelled
wai-pack / wai-pack · linux-arm64 (pull_request) Has been cancelled
wai-pack / wai-pack · macos (pull_request) Has been cancelled
wai-pack / wai-pack · independent verifier (Python) (pull_request) Has been cancelled
wai-pack / wai-pack · the floor through a media prober (pull_request) Has been cancelled
wai-pack / wai-pack · dependency licences (pull_request) Has been cancelled
wai-ops-gpu integer operators on GPUs / does this change touch it (pull_request) Has been cancelled
wai-ops-gpu integer operators on GPUs / builds · no adapter is not a pass (linux) (pull_request) Has been cancelled
wai-ops-gpu integer operators on GPUs / Metal GPU and browser WebGPU (macos) (pull_request) Has been cancelled
WAI neural sink gates / does this change touch it (pull_request) Has been cancelled
WAI neural sink gates / model-free refusals of the neural sink (pull_request) Has been cancelled
WAI JPEG-AI whole decode (pinned inputs, required) / does this change touch it (pull_request) Has been cancelled
WAI JPEG-AI whole decode (pinned inputs, required) / fetch pinned JPEG-AI inputs → whole decode + pixel hash, required (pull_request) Has been cancelled
WAI energy receipts / does this change touch it (pull_request) Has been cancelled
WAI energy receipts / energy receipts · linux (pull_request) Has been cancelled
WAI energy receipts / energy receipts · linux-arm64 (pull_request) Has been cancelled
WAI energy receipts / energy receipts · macos (pull_request) Has been cancelled
WAI conformance / does this change touch it (pull_request) Has been cancelled
WAI conformance / cargo-class corpora · linux (pull_request) Has been cancelled
WAI conformance / cargo-class corpora · linux-arm64 (pull_request) Has been cancelled
WAI conformance / cargo-class corpora · macos (pull_request) Has been cancelled
WAI conformance / quantum core and corpus under wasm32-wasip2 (wasmtime) (pull_request) Has been cancelled
WAI conformance / v2 vocabulary · manifests validate as stated (pull_request) Has been cancelled
WAI conformance / independent verifiers · claims, JWP, key discovery and integer payloads (Python) (pull_request) Has been cancelled
WAI conformance / delivery telemetry · CMCD and CMSD against an independent library (pull_request) Has been cancelled
WAI conformance / cross-arch byte-equality · linux (pull_request) Has been cancelled
WAI conformance / cross-arch byte-equality · linux-arm64 (pull_request) Has been cancelled
WAI conformance / cross-arch byte-equality · macos (pull_request) Has been cancelled
WAI conformance / codec wrappers · fuzz smoke, text decode limits, C entry points, provenance, the semantic path (pull_request) Has been cancelled
WAI conformance / C2PA manifest emission · signed, read back, validated (pull_request) Has been cancelled
wai-audit collector and player integration / collector · linux (pull_request) Has been cancelled
wai-audit collector and player integration / collector, player integration and the browser end to end · macos (pull_request) Has been cancelled
standards workspaces build + test / macOS energy backends (pull_request) Has been cancelled
joule-moq-web browser client / joule-moq-web · does this change touch it (pull_request) Has been cancelled
joule-moq-web browser client / joule-moq-web · browser end-to-end (macos) (pull_request) Has been cancelled
joule-moq-room room service / joule-moq-room · does this change touch it (pull_request) Has been cancelled
joule-moq-room room service / joule-moq-room, every target (pull_request) Has been cancelled
wai-audit collector and player integration / does this change touch it (pull_request) Has been cancelled
standards workspaces build + test / which workspaces this change touches (pull_request) Has been cancelled
repository checks / lockfiles, advisories, tests in CI, workflow hygiene, spec and section references, public text (pull_request) Has been cancelled
wai-sink-swift: simulator tests hosted in TestHost, in a fresh simulator, every step bounded
scripts/test-simulator.sh no longer spawns the XCTest agent through simctl, which hangs
once the host's simulator service is current. It runs the tests the way a device does:
it creates a fresh simulator (the newest installed runtime of the platform, the first
device type of its family), boots it, builds the test host for it (build-for-testing)
and runs the tests hosted in it (test-without-building), then shuts the simulator down
and deletes it however the run ends. Each step has a hard limit (boot 300 s, build 900 s,
tests 600 s by default) and fails, naming the step, when it passes it. TestHost now
builds for phones, tablets and televisions, so the television simulator runs the same
tests. wai-sink-swift.yml bounds each step as well.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 15:35:48 -04:00

92 lines
5.1 KiB
Shell
Executable file

#!/usr/bin/env bash
# Run the package's tests in a simulator, hosted in TestHost/ as on a device, with every step bounded.
#
# scripts/test-simulator.sh ios|tvos
#
# A fresh simulator is created for the run (the newest installed runtime of the platform, its first
# device type of the family), booted, and shut down and deleted at the end, however the run ends.
# The test host is built for it (`build-for-testing`) and the tests run in it
# (`test-without-building`). Each step has a hard limit and fails, saying which, when it passes it:
# a step that does not finish is a failure, never a wait. Needs build/WaiFFI.xcframework with the
# platform's simulator slice (scripts/build-xcframework.sh).
#
# Limits, in seconds, from the environment: WAI_SIM_BOOT_S (300), WAI_SIM_BUILD_S (900),
# WAI_SIM_TEST_S (600).
set -uo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
plat="${1:-}"
case "$plat" in
ios) family="iPhone"; runtime_prefix="com.apple.CoreSimulator.SimRuntime.iOS-"; dest="iOS Simulator"; slice="ios-arm64_x86_64-simulator" ;;
tvos) family="Apple TV"; runtime_prefix="com.apple.CoreSimulator.SimRuntime.tvOS-"; dest="tvOS Simulator"; slice="tvos-arm64-simulator" ;; # allow-name: the simulator device family simctl lists, by its name
*) echo "usage: test-simulator.sh ios|tvos" >&2; exit 2 ;;
esac
BOOT_S="${WAI_SIM_BOOT_S:-300}"; BUILD_S="${WAI_SIM_BUILD_S:-900}"; TEST_S="${WAI_SIM_TEST_S:-600}"
mkdir -p .build
LOGS="$(pwd)/.build/sim-$plat"; rm -rf "$LOGS"; mkdir -p "$LOGS"
DD="$(pwd)/.build/xc-host-$plat"
# bounded <seconds> <what> <command…>: the command's status, or 142 with an error when the limit
# passes. The alarm survives exec, so the command itself is ended at the limit.
bounded() {
local secs="$1" what="$2"; shift 2
perl -e 'alarm shift @ARGV; exec @ARGV or die "exec: $!"' "$secs" "$@"
local rc=$?
if [ $rc -eq 142 ]; then echo "::error::$what did not finish within ${secs} s; the run is failed, not waited on" >&2; fi
return $rc
}
[ -d "build/WaiFFI.xcframework/$slice" ] || { echo "::error::build/WaiFFI.xcframework has no $slice slice: run scripts/build-xcframework.sh" >&2; exit 1; }
cp ../live-conformance/native-sink/vectors.json Tests/WaiSinkTests/Resources/vectors.json
# The newest installed runtime of the platform, and its first device type of the family.
read -r RUNTIME DEVTYPE < <(bounded 60 "listing simulator runtimes" xcrun simctl list -j runtimes available 2>/dev/null | python3 -c '
import json, sys
prefix, family = sys.argv[1], sys.argv[2]
rts = [r for r in json.load(sys.stdin)["runtimes"] if r.get("isAvailable") and r["identifier"].startswith(prefix)]
rts.sort(key=lambda r: [int(x) for x in r["version"].split(".")])
if rts:
r = rts[-1]
dts = [d for d in r.get("supportedDeviceTypes", []) if d.get("productFamily") == family]
if dts:
print(r["identifier"], dts[0]["identifier"])
' "$runtime_prefix" "$family")
[ -n "${RUNTIME:-}" ] && [ -n "${DEVTYPE:-}" ] || { echo "::error::no available $plat simulator runtime with a $family device type" >&2; exit 1; }
UDID=$(bounded 120 "creating the simulator" xcrun simctl create "wai-sink-test-$plat-$$" "$DEVTYPE" "$RUNTIME" 2>"$LOGS/create.err")
[ -n "$UDID" ] || { echo "::error::could not create a $plat simulator: $(head -2 "$LOGS/create.err")" >&2; exit 1; }
cleanup() {
perl -e 'alarm 120; exec @ARGV' xcrun simctl shutdown "$UDID" >/dev/null 2>&1
perl -e 'alarm 120; exec @ARGV' xcrun simctl delete "$UDID" >/dev/null 2>&1
echo "simulator $UDID shut down and deleted"
}
trap cleanup EXIT
echo "simulator $UDID: $DEVTYPE on $RUNTIME"
t0=$(date +%s)
bounded "$BOOT_S" "booting the simulator" xcrun simctl boot "$UDID" > "$LOGS/boot.log" 2>&1
bounded "$BOOT_S" "waiting for the simulator to finish booting" xcrun simctl bootstatus "$UDID" -b > "$LOGS/bootstatus.log" 2>&1 \
|| { echo "::error::the simulator did not boot: $(tail -2 "$LOGS/bootstatus.log")" >&2; exit 1; }
t1=$(date +%s)
echo "booted in $((t1 - t0)) s"
rm -rf "$DD"
bounded "$BUILD_S" "building the test host for the $plat simulator" \
xcodebuild build-for-testing -project TestHost/WaiSinkTestHost.xcodeproj -scheme WaiSinkTestHost \
-destination "platform=$dest,id=$UDID" -derivedDataPath "$DD" > "$LOGS/build.log" 2>&1
rc=$?
grep -E "\*\* .* \*\*|error:" "$LOGS/build.log" | sort -u | cut -c1-300 | head -20
[ $rc -eq 0 ] || { echo "::error::the test host did not build for the $plat simulator (exit $rc)" >&2; exit 1; }
t2=$(date +%s)
echo "built in $((t2 - t1)) s"
XR=$(ls "$DD"/Build/Products/*.xctestrun | head -1)
bounded "$TEST_S" "the tests in the $plat simulator" \
xcodebuild test-without-building -xctestrun "$XR" -destination "platform=$dest,id=$UDID" \
-resultBundlePath "$LOGS/result.xcresult" > "$LOGS/test.log" 2>&1
rc=$?
t3=$(date +%s)
grep -E "WAI-SINK|Test Case .*(passed|failed)|error:|Executed [0-9]+ tests?|\*\* TEST" "$LOGS/test.log" | cut -c1-260
echo "tests ran in $((t3 - t2)) s (exit $rc); boot, build and tests $((t3 - t0)) s"
# A run passes when xcodebuild exits 0 and said every test passed.
[ $rc -eq 0 ] && grep -qE "Executed [1-9][0-9]* tests?, with 0 failures" "$LOGS/test.log" \
|| { echo "::error::the $plat simulator tests did not pass" >&2; exit 1; }