diff options
author | jmkiley <jordan.kiley@mapbox.com> | 2019-02-28 14:21:10 -0800 |
---|---|---|
committer | jmkiley <jordan.kiley@mapbox.com> | 2019-03-14 13:01:06 -0700 |
commit | 91a83d1222c82c1a5f4620115958c936a412ad2f (patch) | |
tree | 51cbcb5f5d47de26d37334581047cd1b514d0139 | |
parent | 51d2900948274f253a17978db0e7e672f8c246b0 (diff) |
[ios] Get percentage
-rwxr-xr-x | platform/ios/scripts/code-coverage.sh | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/platform/ios/scripts/code-coverage.sh b/platform/ios/scripts/code-coverage.sh index 49d81bbe2..27a8a06e5 100755 --- a/platform/ios/scripts/code-coverage.sh +++ b/platform/ios/scripts/code-coverage.sh @@ -2,22 +2,18 @@ set -e set -o pipefail -# Get code coverage -# xcodebuild -workspace platform/ios/ios.xcworkspace -scheme CI -enableCodeCoverage YES build test -destination 'platform=iOS Simulator,name=iPhone 6,OS=latest' test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO - -# echo build/Logs/Test/*.xcresult -# result= -# echo ${result}*_Test/*.xccovreport +# Get code coverage, then convert it to JSON. cov_result=build/ios/Logs/Test/*.xcresult/*_Test/*.xccovreport -echo $cov_result xcrun xccov view $cov_result --json > output.json -# json +# Access the overall line coverage for the dynamic build. percentage=`node -e "console.log(require('./output.json').lineCoverage)"` -# not sure how to round -cov="${percentage:2:2}.${percentage:3:4}" +# 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 |