#!/bin/zsh set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" mkdir -p "$ROOT/.build/build-logs" LOG="$ROOT/.build/build-logs/test-$(date +%Y%m%d-%H%M%S).log" exec > >(tee "$LOG") 2>&1 print '=== OrionToolbar tests ===' # A successful compile is the minimum regression check. "$ROOT/scripts/build.sh" APP="$ROOT/.build/Build/Products/Debug/OrionToolbar.app" plutil -lint "$APP/Contents/Info.plist" # Verify that the Parallels executable and JSON discovery work independently of SwiftUI. PRLCTL='' for candidate in /usr/local/bin/prlctl '/Applications/Parallels Desktop.app/Contents/MacOS/prlctl'; do if [[ -x "$candidate" ]]; then PRLCTL="$candidate"; break; fi done if [[ -n "$PRLCTL" ]]; then "$PRLCTL" list -a -j | python3 -c ' import json,sys v=json.load(sys.stdin) assert isinstance(v,list), "Expected Parallels JSON array" for item in v: assert isinstance(item,dict), "Invalid VM record" assert item.get("name"), "VM without name" assert item.get("uuid"), "VM without UUID" print("Parallels discovery OK: {} VM(s)".format(len(v))) ' else echo 'SKIP: Parallels CLI not installed' fi if [[ -d "$ROOT/tests" ]] && find "$ROOT/tests" -name 'test_*.py' -print -quit | grep -q .; then python3 -m unittest discover -s "$ROOT/tests" -v fi # Run Xcode tests only if a test plan is configured for this scheme. if [[ "${RUN_XCODE_TESTS:-0}" == 1 ]]; then xcodebuild -project "$ROOT/OrionToolbar.xcodeproj" -scheme OrionToolbar -configuration Debug -destination 'platform=macOS' -derivedDataPath "$ROOT/.build" CODE_SIGNING_ALLOWED=NO test else echo 'XCTest not run (set RUN_XCODE_TESTS=1 if the scheme has a test target).' fi print "Tests complete. Log: $LOG"