Files
SQLWorkbench/scripts/run-tests.sh
2026-10-19 09:54:57 +01:00

37 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Compatible with bash and zsh, whether launched directly or via /bin/zsh.
set -uo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
if [ ! -d "$ROOT/DBSyn.xcodeproj" ]; then
echo "ERROR: DBSyn.xcodeproj not found at $ROOT" >&2
exit 2
fi
if ! command -v xcodebuild >/dev/null 2>&1; then
echo 'ERROR: xcodebuild requires Xcode on macOS.' >&2
exit 2
fi
cd "$ROOT" || exit 2
mkdir -p "$ROOT/test-results"
STAMP="$(date +%Y%m%d-%H%M%S)-$$"
RESULT="$ROOT/test-results/DBSyn-$STAMP.xcresult"
LOG="$ROOT/test-results/DBSyn-$STAMP.log"
echo "Running DBSyn XCTest suite. Log: $LOG"
# pipefail preserves xcodebuild's failure even though output is piped to tee.
# Avoid PIPESTATUS, which is Bash-specific and fails under zsh with nounset.
set +e
xcodebuild test \
-project "$ROOT/DBSyn.xcodeproj" \
-scheme DBSyn \
-configuration Debug \
-destination 'platform=macOS,arch=arm64' \
-derivedDataPath "$ROOT/build" \
-resultBundlePath "$RESULT" \
ONLY_ACTIVE_ARCH=YES \
ENABLE_TESTABILITY=YES \
SWIFT_ENABLE_EXPLICIT_MODULES=NO \
CODE_SIGNING_ALLOWED=NO 2>&1 | tee "$LOG"
STATUS=$?
printf '\nTest log: %s\nTest results: %s\n' "$LOG" "$RESULT"
exit "$STATUS"