summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmkiley <jordan.kiley@mapbox.com>2019-02-28 14:38:48 -0800
committerjmkiley <jordan.kiley@mapbox.com>2019-03-11 12:54:48 -0700
commite46ea37e7a355b1d1beecfae7efb81bf77c91549 (patch)
tree2f5e08db274f7d2b9f653a496494fb002774fadd
parent60ceac5efc3d77199f773f08400fe1d53d5a1b90 (diff)
downloadqtlocation-mapboxgl-e46ea37e7a355b1d1beecfae7efb81bf77c91549.tar.gz
[ios] Generate code coverage, print percentage
-rw-r--r--platform/ios/scripts/code-coverage.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/platform/ios/scripts/code-coverage.sh b/platform/ios/scripts/code-coverage.sh
new file mode 100644
index 0000000000..27a8a06e59
--- /dev/null
+++ b/platform/ios/scripts/code-coverage.sh
@@ -0,0 +1,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 \ No newline at end of file