Repository Public License
1#!/usr/bin/env bash2# ORIX Navigator — UI tests.3#4# scripts/uitest.sh ios [-only-testing:NavigatoriOSUITests/Class/test] runs on the project iPhone simulator5# ORIX_ALLOW_MAC_UITEST=1 scripts/uitest.sh mac takes over keyboard and pointer6#7# A static server serves Apps/UITests/Fixtures on 127.0.0.1 for the duration of the run.8set -euo pipefail910ROOT="$(cd "$(dirname "$0")/.." && pwd)"11DD="$ROOT/build/dd-${ORIX_BUILD_NAME:-shell}"12# A free port chosen by the system, unless one is imposed.13PORT="${ORIX_FIXTURE_PORT:-$(python3 -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1",0)); print(s.getsockname()[1])')}"14platform="${1:-}"; shift || true1516if [ "$platform" = "mac" ] && [ "${ORIX_ALLOW_MAC_UITEST:-0}" != "1" ]; then17 echo "Mac UI tests drive the real keyboard and pointer and bring the app to the front." >&218 echo "Run them on a machine nobody is using: ORIX_ALLOW_MAC_UITEST=1 scripts/uitest.sh mac" >&219 exit 320fi2122python3 -m http.server "$PORT" --bind 127.0.0.1 --directory "$ROOT/Apps/UITests/Fixtures" >/dev/null 2>&1 &23server=$!24sleep 125curl -fsS -o /dev/null "http://127.0.0.1:$PORT/one.html" || { echo "the fixture server did not start" >&2; exit 1; }26trap 'kill "$server" 2>/dev/null || true' EXIT2728(cd "$ROOT" && "${XCODEGEN:-/opt/homebrew/bin/xcodegen}" generate --quiet)29export TEST_RUNNER_ORIX_FIXTURE_URL="http://127.0.0.1:$PORT"30# ORIX_CAPTURE_DIR=<dir> makes testCaptureScreens write screenshots there (it is skipped otherwise).31export TEST_RUNNER_ORIX_CAPTURE_DIR="${ORIX_CAPTURE_DIR:-}"32case "$platform" in33 ios)34 udid="$("$ROOT/scripts/build.sh" sim "${ORIX_UITEST_DEVICE:-iphone}")"35 xcrun simctl list devices | grep -F "$udid" | grep -q Booted || xcrun simctl boot "$udid"36 xcodebuild -project "$ROOT/ORIXNavigator.xcodeproj" -scheme NavigatoriOS -configuration Debug \37 -destination "id=$udid" -derivedDataPath "$DD" -resultBundlePath "$ROOT/build/uitest-ios-$(date +%H%M%S).xcresult" \38 -parallel-testing-enabled NO "$@" test 2>&1 \39 | grep -E "(error:|warning: |Test Case .* (passed|failed)|Executed [0-9]+ tests|TEST (SUCCEEDED|FAILED)|XCTAssert|failed -)" | awk '!seen[$0]++' ;;40 mac)41 xcodebuild -project "$ROOT/ORIXNavigator.xcodeproj" -scheme NavigatorMac -configuration Debug \42 -destination 'platform=macOS,arch=arm64' -derivedDataPath "$DD" "$@" test 2>&1 \43 | grep -E "(error:|Test Case .* (passed|failed)|Executed [0-9]+ tests|TEST (SUCCEEDED|FAILED))" ;;44 *) sed -n '2,7p' "$0"; exit 2 ;;45esac46