@@ -9,6 +9,7 @@ SCRIPTDIR=$(dirname ${BASH_SOURCE[0]})
99SRCDIR=$SCRIPTDIR /../..
1010ROOTDIR=$SRCDIR /..
1111PACKAGES=$ROOTDIR /packages
12+ COVERAGEDIR=$ROOTDIR /BuildOutput/ProjFS.Mac/Coverage
1213
1314PROJFS=$SRCDIR /ProjFS.Mac
1415
2122
2223# Run Tests and put output into a xml file
2324set -o pipefail
24- xcodebuild -configuration $CONFIGURATION -project $PROJFS /PrjFS.xcodeproj -scheme ' Build All' test | xcpretty -r junit --output $PROJFS /TestResultJunit.xml || exit 1
25+ xcodebuild -configuration $CONFIGURATION -enableCodeCoverage YES - project $PROJFS /PrjFS.xcodeproj -derivedDataPath $COVERAGEDIR -scheme ' Build All' test | xcpretty -r junit --output $PROJFS /TestResultJunit.xml || exit 1
2526set +o pipefail
2627
28+ while read -rd $' \0' file; do
29+ COVERAGE_FILE=" $file "
30+ done < <( find $COVERAGEDIR -name " *xccovreport" -print0)
31+
32+ if [[ $COVERAGE_FILE == " " ]]; then
33+ echo " Error: No coverage file found"
34+ exit 1
35+ fi
36+
37+ # xcperfect will display pretty output for code coverage. The terminal output isn't supported by our build system yet, but a bug has been filed. Once support is added we'll switch to the prettier format.
38+ # if !(gem list --local | grep xcperfect); then
39+ # echo "Attempting to run 'sudo gem install xcperfect'. This may ask you for your password to gain admin privileges"
40+ # sudo gem install xcperfect
41+ # fi
42+ # xcrun xccov view "$COVERAGE_FILE" --json | TERM=xterm-256color xcperfect
43+
44+ printf " \n\nCode Coverage Report\n"
45+ xcrun xccov view " $COVERAGE_FILE " | tee $PROJFS /CoverageResult.txt
46+
47+ # Fail on any line that doesn't show %100 coverage and isn't on the exclusion list or hpp/cpp
48+ while read line; do
49+ if [[ $line != * " 100.00%" * ]] &&
50+ [[ $line == * " %" * ]] &&
51+ [[ $line != * " KauthHandler_Init" * ]] &&
52+ [[ $line != * " KauthHandler_Cleanup" * ]] &&
53+ [[ $line != * " UseMainForkIfNamedStream" * ]] && # SHOULD ADD COVERAGE
54+ [[ $line != * " HandleVnodeOperation" * ]] && # SHOULD ADD COVERAGE
55+ [[ $line != * " HandleFileOpOperation" * ]] && # SHOULD ADD COVERAGE
56+ [[ $line != * " TryGetVirtualizationRoot" * ]] && # SHOULD ADD COVERAGE
57+ [[ $line != * " CurrentProcessWasSpawnedByRegularUser" * ]] && # SHOULD ADD COVERAGE
58+ [[ $line != * " ShouldHandleFileOpEvent" * ]] && # SHOULD ADD COVERAGE
59+ [[ $line != * " ShouldIgnoreVnodeType" * ]] && # SHOULD ADD COVERAGE
60+ [[ $line != * " WaitForListenerCompletion" * ]] &&
61+ [[ $line != * " KextLog_" * ]] &&
62+ [[ $line != * " Definition" * ]] &&
63+ [[ $line != * " PerfTracer" * ]] &&
64+ [[ $line != * " VirtualizationRoot_GetActiveProvider" * ]] && # SHOULD ADD COVERAGE
65+ [[ $line != * " VirtualizationRoots_Init" * ]] &&
66+ [[ $line != * " VirtualizationRoots_Cleanup" * ]] &&
67+ [[ $line != * " FindOrDetectRootAtVnode" * ]] && # SHOULD ADD COVERAGE
68+ [[ $line != * " FindUnusedIndexOrGrow_Locked" * ]] && # SHOULD ADD COVERAGE
69+ [[ $line != * " FindRootAtVnode_Locked" * ]] && # SHOULD ADD COVERAGE
70+ [[ $line != * " ActiveProvider_" * ]] &&
71+ [[ $line != * " GetRelativePath" * ]] &&
72+ [[ $line != * " VirtualizationRoot_GetRootRelativePath" * ]] &&
73+ [[ $line != * " MockCalls" * ]] &&
74+ [[ $line != * " PerfTracing_" * ]] &&
75+ [[ $line != * " proc_" * ]] &&
76+ [[ $line != * " ParentPathString" * ]] &&
77+ [[ $line != * " SetAndRegisterPath" * ]] &&
78+ [[ $line != * " vn_" * ]] &&
79+ [[ $line != * " vnode_lookup" * ]] &&
80+ [[ $line != * " RetainIOCount" * ]] &&
81+ [[ $line != * " ProviderMessaging_" * ]] &&
82+ [[ $line != * " RWLock_DropExclusiveToShared" * ]] &&
83+ [[ $line != * " .xctest" * ]] &&
84+ [[ $line != * " .cpp" * ]] &&
85+ [[ $line != * " .hpp" * ]]; then
86+ printf " \nError: Not at 100% Code Coverage: $line "
87+ exit 1
88+ fi
89+ done < $PROJFS /CoverageResult.txt
90+
2791# If we're building the Profiling(Release) configuration, remove Profiling() for building .NET code
2892if [ " $CONFIGURATION " == " Profiling(Release)" ]; then
2993 CONFIGURATION=Release
0 commit comments