Files
Kordant/iOS/scripts/get_coverage
2026-05-26 09:38:54 -04:00

42 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# Generate code coverage report for Lendair iOS project.
# Finds the most recent xcresult file and produces a JSON report.
#
# Usage: ./scripts/get_coverage
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
REPORTS_DIR="$PROJECT_DIR/reports"
XCRESULT=$(find ~/Library/Developer/Xcode/DerivedData -name "*Lendair*" -path "*/Test/*.xcresult" -type d 2>/dev/null | sort -r | head -1)
if [ -z "$XCRESULT" ]; then
echo "Error: No xcresult file found for Lendair project" >&2
echo "" >&2
echo "Make sure you've run tests with coverage enabled:" >&2
echo " ./run test -c" >&2
exit 1
fi
echo "Using xcresult: $XCRESULT"
TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")
mkdir -p "$REPORTS_DIR/$TIMESTAMP"
xcrun xccov view --report "$XCRESULT" --json > "$REPORTS_DIR/$TIMESTAMP/code_coverage.json"
echo ""
echo "Code coverage report generated:"
echo " $REPORTS_DIR/$TIMESTAMP/code_coverage.json"
# Also symlink latest
ln -sf "$TIMESTAMP" "$REPORTS_DIR/latest" 2>/dev/null || true
cp "$REPORTS_DIR/$TIMESTAMP/code_coverage.json" "$REPORTS_DIR/code_coverage.json" 2>/dev/null || true
# Print a quick summary
echo ""
echo "=== Coverage Summary ==="
xcrun xccov view --report "$XCRESULT" 2>/dev/null | head -30 || true