summaryrefslogtreecommitdiff
path: root/platform/ios/scripts/code-coverage.sh
blob: 27a8a06e59db9a48c6b099e498d77bf500eb78f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env bash

set -e
set -o pipefail

# Get code coverage, then convert it to JSON.
cov_result=build/ios/Logs/Test/*.xcresult/*_Test/*.xccovreport
xcrun xccov view $cov_result --json > output.json

# Access the overall line coverage for the dynamic build.
percentage=`node -e "console.log(require('./output.json').lineCoverage)"`

# Convert the coverage from "0.x" format to a percentage.
cov=$(printf "%.2f" $(echo "$percentage*100" | bc -l))
echo $cov

# Clean up files.
rm -rf build/ios/ios/Logs/Test/*.xcresult/
rm -f output.json