|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +DERIVED_DATA_DIR="$HOME/.derivedData" |
| 6 | +DESTINATION="platform=iOS Simulator,name=IPhone 14" |
| 7 | +SCHEME="AtalaPRISMSDK-Package" |
| 8 | +LCOV_DIR="$DERIVED_DATA_DIR/lcov" |
| 9 | + |
| 10 | +echo "Derived data directory: $DERIVED_DATA_DIR" |
| 11 | +echo "lcov partials directory: $LCOV_DIR" |
| 12 | + |
| 13 | +# Clean derived data dir |
| 14 | +echo "Cleaning derived data directory" |
| 15 | +rm -rf "$DERIVED_DATA_DIR" |
| 16 | +mkdir "$DERIVED_DATA_DIR" |
| 17 | + |
| 18 | +# Clean lcov dir |
| 19 | +echo "Cleaning lcov partials directory" |
| 20 | +rm -rf "$LCOV_DIR" |
| 21 | +mkdir "$LCOV_DIR" |
| 22 | + |
| 23 | +# Run build and test |
| 24 | +echo "Running build and test" |
| 25 | +xcodebuild -scheme "AtalaPRISMSDK-Package" \ |
| 26 | + -destination "$DESTINATION" \ |
| 27 | + -derivedDataPath "$DERIVED_DATA_DIR" \ |
| 28 | + -enableCodeCoverage YES \ |
| 29 | + clean build test | xcpretty |
| 30 | +echo "Execution completed" |
| 31 | + |
| 32 | +# Find profdata |
| 33 | +PROF_DATA=$(find "$DERIVED_DATA_DIR" -name Coverage.profdata) |
| 34 | +echo "Profdata found: $PROF_DATA" |
| 35 | + |
| 36 | +# Find all binaries |
| 37 | +BINARIES=$(find ~/.derivedData -type f -name "*Tests") |
| 38 | + |
| 39 | +# Print all binaries found |
| 40 | +for BINARY in $BINARIES; do |
| 41 | + echo "Binary found: $BINARY" |
| 42 | +done |
| 43 | + |
| 44 | +# Generate lcov for each target |
| 45 | +for BINARY in $BINARIES; do |
| 46 | + BASE_NAME=$(basename "$BINARY") |
| 47 | + echo "Generating coverage for $BASE_NAME" |
| 48 | + LCOV_NAME="${BASE_NAME}.lcov" |
| 49 | + xcrun llvm-cov export --format=lcov \ |
| 50 | + -instr-profile "$PROF_DATA" "$BINARY" > "$LCOV_DIR/$LCOV_NAME" |
| 51 | +done |
| 52 | + |
| 53 | +# Merge all coverage |
| 54 | +echo "Merging partials to lcov.info" |
| 55 | +lcov -o lcov.info -a "$LCOV_DIR/*.lcov" --include AtalaPrismSDK/ --exclude Tests > /dev/null |
0 commit comments