Repository Public
1#!/usr/bin/env bash2# SP Music iOS3# File: Scripts/test.sh4# Description: Runs the unit, integration and interface test suites.5#6# Author: Simon-Pierre Boucher7# Contact: contact@spboucher.ai8# SP Music iOS — runs the test suites.9# Scripts/test.sh core unit tests of SPMusicCore on the Mac (no network)10# Scripts/test.sh app [iPad] integration tests on the simulator against the disposable backend11# Scripts/test.sh ui [iPad] interface tests (same backend); screenshots land in build/shots/12set -euo pipefail13cd "$(dirname "$0")/.."14DEVICE="SPMusic iPhone"; [ "${2:-}" = "iPad" ] && DEVICE="SPMusic iPad"15case "${1:-}" in16core) (cd Core && swift test) ;;17app|ui)18 Scripts/test-server.sh creds >/dev/null # recovery codes are single-use: fresh ones for every run19 set -a; . "$HOME/.config/spmusic-ios-test/credentials.env"; set +a20 curl -fsS -m 5 "$SPMUSIC_TEST_URL/api/health" >/dev/null || { echo "test backend unreachable: run Scripts/test-server.sh up (or: tunnel)"; exit 1; }21 xcodegen generate >/dev/null22 ONLY=SPMusicTests; [ "$1" = ui ] && ONLY=SPMusicUITests23 export TEST_RUNNER_SPMUSIC_TEST_URL="$SPMUSIC_TEST_URL" TEST_RUNNER_SPMUSIC_TEST_SESSION="$SPMUSIC_TEST_SESSION" TEST_RUNNER_SPMUSIC_TEST_RECOVERY_1="$SPMUSIC_TEST_RECOVERY_1" TEST_RUNNER_SPMUSIC_TEST_RECOVERY_2="$SPMUSIC_TEST_RECOVERY_2"24 export TEST_RUNNER_SPMUSIC_BASE_URL="$SPMUSIC_TEST_URL" TEST_RUNNER_SPMUSIC_MUTE=1 TEST_RUNNER_SPMUSIC_SHOTS="$PWD/build/shots"25 rm -rf "build/$1-$DEVICE.xcresult"26 xcodebuild test -project SPMusic.xcodeproj -scheme SPMusic -destination "platform=iOS Simulator,name=$DEVICE" -derivedDataPath build/dd \27 -only-testing:"$ONLY" -resultBundlePath "build/$1-$DEVICE.xcresult" -parallel-testing-enabled NO 2>&1 \28 | grep -E "error:|✔|✘|Test (run|case)|passed|failed|recorded|NOTE:|TEST (SUCCEEDED|FAILED)|BUILD FAILED" | sed "s|$PWD/||" ;;29*) echo "usage: $0 core|app|ui [iPad]"; exit 2 ;;30esac31