Skip to content

Commit 705acaf

Browse files
committed
Added Code Coverage to build
1 parent c55503f commit 705acaf

1 file changed

Lines changed: 65 additions & 1 deletion

File tree

ProjFS.Mac/Scripts/Build.sh

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ SCRIPTDIR=$(dirname ${BASH_SOURCE[0]})
99
SRCDIR=$SCRIPTDIR/../..
1010
ROOTDIR=$SRCDIR/..
1111
PACKAGES=$ROOTDIR/packages
12+
COVERAGEDIR=$ROOTDIR/BuildOutput/ProjFS.Mac/Coverage
1213

1314
PROJFS=$SRCDIR/ProjFS.Mac
1415

@@ -21,9 +22,72 @@ fi
2122

2223
# Run Tests and put output into a xml file
2324
set -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
2526
set +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+
#if !(gem list --local | grep xcperfect); then
38+
# echo "Attempting to run 'sudo gem install xcperfect'. This may ask you for your password to gain admin privileges"
39+
# sudo gem install xcperfect
40+
#fi
41+
42+
#xcrun xccov view "$COVERAGE_FILE" --json | TERM=xterm-256color xcperfect
43+
44+
# Example the latest code coverage file
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"* ]] &&
54+
[[ $line != *"HandleVnodeOperation"* ]] &&
55+
[[ $line != *"HandleFileOpOperation"* ]] &&
56+
[[ $line != *"TryGetVirtualizationRoot"* ]] &&
57+
[[ $line != *"CurrentProcessWasSpawnedByRegularUser"* ]] &&
58+
[[ $line != *"ShouldHandleFileOpEvent"* ]] &&
59+
[[ $line != *"ShouldIgnoreVnodeType"* ]] &&
60+
[[ $line != *"WaitForListenerCompletion"* ]] &&
61+
[[ $line != *"KextLog_"* ]] &&
62+
[[ $line != *"Definition"* ]] &&
63+
[[ $line != *"PerfTracer"* ]] &&
64+
[[ $line != *"VirtualizationRoot_GetActiveProvider"* ]] &&
65+
[[ $line != *"VirtualizationRoots_Init"* ]] &&
66+
[[ $line != *"VirtualizationRoots_Cleanup"* ]] &&
67+
[[ $line != *"FindOrDetectRootAtVnode"* ]] &&
68+
[[ $line != *"FindUnusedIndexOrGrow_Locked"* ]] &&
69+
[[ $line != *"FindRootAtVnode_Locked"* ]] &&
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+
echo "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
2892
if [ "$CONFIGURATION" == "Profiling(Release)" ]; then
2993
CONFIGURATION=Release

0 commit comments

Comments
 (0)