diff options
author | Jordan Kiley <jmkiley@users.noreply.github.com> | 2019-03-13 12:58:24 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-13 12:58:24 -0700 |
commit | fb0b0d5a2bb89a6a7d5137e0c610e2c5105c26d3 (patch) | |
tree | c21d8cc0cbd9aadf63f9c245b7cc79e8533af4ed /platform | |
parent | 979433eddb5a8f2180aba134befb08b222718bc8 (diff) | |
download | qtlocation-mapboxgl-fb0b0d5a2bb89a6a7d5137e0c610e2c5105c26d3.tar.gz |
[ios] Generate iOS code coverage for metrics (#14015)
Diffstat (limited to 'platform')
-rw-r--r-- | platform/ios/ios.xcodeproj/xcshareddata/xcschemes/CI.xcscheme | 11 | ||||
-rwxr-xr-x | platform/ios/scripts/ios-code-coverage.sh | 31 |
2 files changed, 42 insertions, 0 deletions
diff --git a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/CI.xcscheme b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/CI.xcscheme index 6b018e1337..7d59c4edee 100644 --- a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/CI.xcscheme +++ b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/CI.xcscheme @@ -54,7 +54,18 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + codeCoverageEnabled = "YES" + onlyGenerateCoverageForSpecifiedTargets = "YES" shouldUseLaunchSchemeArgsEnv = "NO"> + <CodeCoverageTargets> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "DA8847D11CBAF91600AB86E3" + BuildableName = "Mapbox.framework" + BlueprintName = "dynamic" + ReferencedContainer = "container:ios.xcodeproj"> + </BuildableReference> + </CodeCoverageTargets> <Testables> <TestableReference skipped = "NO"> diff --git a/platform/ios/scripts/ios-code-coverage.sh b/platform/ios/scripts/ios-code-coverage.sh new file mode 100755 index 0000000000..8b8adb423a --- /dev/null +++ b/platform/ios/scripts/ios-code-coverage.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +# +# Get code coverage report, then convert it to JSON. +# The coverage reports end up in different locations based on whether coverage +# is generated via CI or locally. +# +cov_result=""; +if [ -f build/ios/Logs/Test/*.xcresult/*_Test/*.xccovreport ]; then + cov_result=build/ios/Logs/Test/*.xcresult/*_Test/*.xccovreport +elif [ -f build/ios/ios/Logs/Test/*.xcresult/*_Test/*.xccovreport ]; then + cov_result=build/ios/ios/Logs/Test/*.xcresult/*_Test/*.xccovreport +else + echo "Coverage file does not exist. Please run tests before executing" + exit 1 +fi + +xcrun xccov view $cov_result --json > output.json + +# +# Convert the line coverage for the dynamic target to a percentage. Currently, +# only CI tests are included when calculated code coverage. +# +percentage=`node -e "console.log(require('./output.json').lineCoverage)"` +cov=$(printf "%.2f" $(echo "$percentage*100" | bc -l)) + +# Generate a formatted JSON file and upload it to S3. +./././scripts/code-coverage.sh $cov "iOS" "$1" |