Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions Scripts/check_coverage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import sys
import json
import os


files_to_check = set()

COVERAGE_THRESHOLD=90

IGNORED_PATHS = [
"UnitTests"
]

GREEN = "\033[92m"
RED = "\033[91m"
RESET = "\033[0m"

def is_ignored(path):
for ignore in IGNORED_PATHS:
if ignore in path:
return True

return False

with open("./build/coverage.json") as f:
data = json.load(f)

failed_files = []

def matched_file_list(full_path):
return any(full_path.endwith(check_path) for check_path in files_to_check)

for target in data.get("targets", []):
for file in target.get("files", []):
path = file.get("path", file["name"])

if files_to_check and not matched_file_list(path):
continue

if is_ignored(path):
continue

coverage = file.get("lineCoverage", 0) * 100

if coverage == 100:
color = GREEN
continue
elif coverage >= COVERAGE_THRESHOLD:
color = GREEN
else:
color = RED
failed_files.append((path, coverage))

print(f"{color}{path}: {coverage:.3f}%{RESET}")
16 changes: 16 additions & 0 deletions Scripts/check_coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
SCHEME="mParticle-Apple-SDK"
DESTINATION="platform=iOS Simulator,name=iPhone 16 Pro,OS=latest"
RESULT_BUNDLE_PATH="./build/TestResults.xcresult"

rm -rf "$RESULT_BUNDLE_PATH"

xcodebuild test \
-project ../mParticle-Apple-SDK.xcodeproj \
-scheme "$SCHEME" \
-destination "$DESTINATION" \
-enableCodeCoverage YES \
-resultBundlePath "$RESULT_BUNDLE_PATH" \

xcrun xccov view --report --json "$RESULT_BUNDLE_PATH" > ./build/coverage.json

python3 check_coverage.py
Loading