Skip to content

Commit

Permalink
Additional make targets to run KnobDemo
Browse files Browse the repository at this point in the history
  • Loading branch information
bradhowes committed Mar 27, 2024
1 parent 96ef8c4 commit 16e2265
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,8 @@ iOSInjectionProject/

coverage.txt
percentage.txt
coverage-ui.txt
percentage-ui.txt
.DerivedData-macOS/
.DerivedData-macOS-ui/
.DerivedData-iOS/
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ test-macos:
-destination platform="$(PLATFORM_MACOS)" \
-enableCodeCoverage YES

test-macos-ui:
xcodebuild clean \
-project KnobDemo/KnobDemo.xcodeproj \
-scheme KnobDemo_macOS \
-derivedDataPath "$(PWD)/.DerivedData-macos-ui" \
-destination platform="$(PLATFORM_MACOS)"
xcodebuild test \
-project KnobDemo/KnobDemo.xcodeproj \
-scheme KnobDemo_macOS \
-derivedDataPath "$(PWD)/.DerivedData-macos-ui" \
-destination platform="$(PLATFORM_MACOS)" \
-enableCodeCoverage YES

test-linux:
docker build -t swiftlang -f swiftlang.dockerfile .
docker run \
Expand All @@ -45,6 +58,10 @@ coverage: test-macos
$(COV) Knob-macOS $(PWD)/.DerivedData-macos/Logs/Test/*.xcresult > coverage.txt
cat coverage.txt

coverage-ui: test-macos-ui
$(COV) Knob-macOS $(PWD)/.DerivedData-macos-ui/Logs/Test/*.xcresult > coverage-ui.txt
cat coverage-ui.txt

# Visit each line in coverage report that starts with a number, and add the coverage percentage
# (skipping the one that involves the SwiftUI containers). Print the average at the end.
AWK_CMD = 'END {print sum / count;} /^[1-9]/ { if ($$2 !~ /KnobView/) { sum+=$$4; count+=1; } }'
Expand All @@ -53,6 +70,10 @@ percentage: coverage
awk $(AWK_CMD) coverage.txt > percentage.txt
cat percentage.txt

percentage-ui: coverage-ui
awk $(AWK_CMD) coverage-ui.txt > percentage-ui.txt
cat percentage-ui.txt

test: test-ios test-tvos percentage

.PHONY: test test-ios test-macos test-tvos coverage percentage test-linux test-swift

0 comments on commit 16e2265

Please sign in to comment.