|
1 |
| -CONFIG = debug |
2 |
| -PLATFORM_IOS = iOS Simulator,id=$(call udid_for,iOS 17.2,iPhone \d\+ Pro [^M]) |
3 |
| -PLATFORM_MACOS = macOS |
4 |
| -PLATFORM_MAC_CATALYST = macOS,variant=Mac Catalyst |
5 |
| -PLATFORM_TVOS = tvOS Simulator,id=$(call udid_for,tvOS 17,TV) |
6 |
| -PLATFORM_WATCHOS = watchOS Simulator,id=$(call udid_for,watchOS 10,Watch) |
| 1 | +default: |
| 2 | + $(error Missing command) |
| 3 | + @exit 1 |
7 | 4 |
|
8 |
| -default: test-all |
| 5 | +%: |
| 6 | + $(error Unknown command: $@) |
| 7 | + @exit 1 |
| 8 | + |
| 9 | +TEST_RUNNER_CI ?= $(CI) |
| 10 | +MAKEFILE_PATH ?= "./swift-package-action/Makefile" |
| 11 | + |
| 12 | +SCHEME ?= Interception |
| 13 | +PLATFORM ?= iOS |
| 14 | +CONFIG ?= Debug |
| 15 | + |
| 16 | +DERIVED_DATA="./DerivedData" |
| 17 | + |
| 18 | +BOLD=\033[1m |
| 19 | +RESET=\033[0m |
9 | 20 |
|
10 | 21 | test-all:
|
11 |
| - $(MAKE) test |
| 22 | + $(MAKE) test-library |
| 23 | + $(MAKE) test-library-macros |
12 | 24 | $(MAKE) test-docs
|
13 | 25 |
|
14 |
| -test: |
15 |
| - $(MAKE) CONFIG=debug test-library |
16 |
| - $(MAKE) CONFIG=debug test-library-macros |
17 |
| - $(MAKE) test-macros |
18 |
| - |
19 | 26 | test-library:
|
20 |
| - for platform in "$(PLATFORM_IOS)" "$(PLATFORM_MACOS)" "$(PLATFORM_MAC_CATALYST)" "$(PLATFORM_TVOS)" "$(PLATFORM_WATCHOS)"; do \ |
21 |
| - echo "\nTesting library on $$platform\n" && \ |
22 |
| - (xcodebuild test \ |
23 |
| - -skipMacroValidation \ |
24 |
| - -configuration $(CONFIG) \ |
25 |
| - -workspace .github/package.xcworkspace \ |
26 |
| - -scheme InterceptionTests \ |
27 |
| - -destination platform="$$platform" | xcpretty && exit 0 \ |
28 |
| - ) \ |
29 |
| - || exit 1; \ |
30 |
| - done; |
| 27 | + @make loop-platforms \ |
| 28 | + -f $(MAKEFILE_PATH) \ |
| 29 | + PLATFORMS="iOS,macOS,macCatalyst,watchOS,tvOS" \ |
| 30 | + GOAL="xcodebuild" \ |
| 31 | + COMMAND=test \ |
| 32 | + SCHEME=$(SCHEME) \ |
| 33 | + CONFIG=$(CONFIG) \ |
| 34 | + DERIVED_DATA=$(DERIVED_DATA) |
31 | 35 |
|
32 | 36 | test-library-macros:
|
33 |
| - for platform in "$(PLATFORM_IOS)" "$(PLATFORM_MACOS)" "$(PLATFORM_MAC_CATALYST)" "$(PLATFORM_TVOS)" "$(PLATFORM_WATCHOS)"; do \ |
34 |
| - echo "\nTesting library-macros on $$platform\n" && \ |
35 |
| - (xcodebuild test \ |
36 |
| - -skipMacroValidation \ |
37 |
| - -configuration $(CONFIG) \ |
38 |
| - -workspace .github/package.xcworkspace \ |
39 |
| - -scheme InterceptionMacrosTests \ |
40 |
| - -destination platform="$$platform" | xcpretty && exit 0 \ |
| 37 | + @for platform in "iOS" "macOS" "macCatalyst" "watchOS" "tvOS"; do \ |
| 38 | + echo "\n$(BOLD)Testing library macros on $$platform$(RESET)\n" && \ |
| 39 | + ( \ |
| 40 | + make xcodebuild-macros \ |
| 41 | + COMMAND=test \ |
| 42 | + DERIVED_DATA=$(DERIVED_DATA) \ |
| 43 | + CONFIG=$(CONFIG) \ |
| 44 | + SCHEME="(SCHEME) \ |
| 45 | + PLATFORM="$$platform" \ |
41 | 46 | ) \
|
42 |
| - || exit 1; \ |
43 | 47 | done;
|
| 48 | + $(MAKE) xcodebuild-macros-plugin COMMAND=test PLATFORM=macOS |
| 49 | + |
| 50 | +xcodebuild: |
| 51 | + @make xcodebuild \ |
| 52 | + -f $(MAKEFILE_PATH) \ |
| 53 | + COMMAND=$(COMMAND) \ |
| 54 | + DERIVED_DATA=$(DERIVED_DATA) \ |
| 55 | + CONFIG=$(CONFIG) \ |
| 56 | + SCHEME=$(SCHEME) \ |
| 57 | + PLATFORM=$(PLATFORM) |
| 58 | + |
| 59 | +xcodebuild-macros: |
| 60 | + @make xcodebuild-macros \ |
| 61 | + -f $(MAKEFILE_PATH) \ |
| 62 | + COMMAND=$(COMMAND) \ |
| 63 | + DERIVED_DATA=$(DERIVED_DATA) \ |
| 64 | + CONFIG=$(CONFIG) \ |
| 65 | + SCHEME="$(SCHEME)" \ |
| 66 | + PLATFORM=$(PLATFORM) |
| 67 | + |
| 68 | +xcodebuild-macros-plugin: |
| 69 | + @make xcodebuild-macros-plugin \ |
| 70 | + -f $(MAKEFILE_PATH) \ |
| 71 | + COMMAND=$(COMMAND) \ |
| 72 | + DERIVED_DATA=$(DERIVED_DATA) \ |
| 73 | + CONFIG=$(CONFIG) \ |
| 74 | + SCHEME="$(SCHEME)" \ |
| 75 | + PLATFORM=$(PLATFORM) |
| 76 | + |
| 77 | +build-for-library-evolution: |
| 78 | + @make build-for-library-evolution \ |
| 79 | + -f $(MAKEFILE_PATH) \ |
| 80 | + SCHEME="$(SCHEME)" |
44 | 81 |
|
45 |
| -test-macros: |
46 |
| - echo "\nTesting macros\n" && \ |
47 |
| - (xcodebuild test \ |
48 |
| - -skipMacroValidation \ |
49 |
| - -configuration $(CONFIG) \ |
50 |
| - -workspace .github/package.xcworkspace \ |
51 |
| - -scheme InterceptionMacrosPluginTests \ |
52 |
| - -destination platform=macOS | xcpretty && exit 0 \ |
53 |
| - ) \ |
54 |
| - || exit 1; |
55 |
| - |
56 |
| -DOC_WARNINGS = $(shell xcodebuild clean docbuild \ |
57 |
| - -scheme Interception \ |
58 |
| - -destination platform="$(PLATFORM_IOS)" \ |
59 |
| - -quiet \ |
60 |
| - 2>&1 \ |
61 |
| - | grep "couldn't be resolved to known documentation" \ |
62 |
| - | sed 's|$(PWD)|.|g' \ |
63 |
| - | tr '\n' '\1') |
64 | 82 | test-docs:
|
65 |
| - @test "$(DOC_WARNINGS)" = "" \ |
66 |
| - || (echo "xcodebuild docbuild failed:\n\n$(DOC_WARNINGS)" | tr '\1' '\n' \ |
67 |
| - && exit 1) |
| 83 | + @make test-docs \ |
| 84 | + -f $(MAKEFILE_PATH) \ |
| 85 | + SCHEME="$(SCHEME)" \ |
| 86 | + PLATFORM=$(PLATFORM) |
| 87 | + |
| 88 | +test-example: |
| 89 | + @make test-example \ |
| 90 | + -f $(MAKEFILE_PATH) \ |
| 91 | + DERIVED_DATA=$(DERIVED_DATA) \ |
| 92 | + SCHEME="$(SCHEME)" \ |
| 93 | + PLATFORM=$(PLATFORM) |
| 94 | + |
| 95 | +test-integration: |
| 96 | + @make test-integration \ |
| 97 | + -f $(MAKEFILE_PATH) \ |
| 98 | + SCHEME="Integration" \ |
| 99 | + PLATFORM=$(PLATFORM) |
| 100 | + |
| 101 | +benchmark: |
| 102 | + @make benchmark -f $(MAKEFILE_PATH) |
68 | 103 |
|
69 |
| -define udid_for |
70 |
| -$(shell xcrun simctl list devices available '$(1)' | grep '$(2)' | sort -r | head -1 | awk -F '[()]' '{ print $$(NF-3) }') |
71 |
| -endef |
| 104 | +format: |
| 105 | + @make format -f $(MAKEFILE_PATH) |
0 commit comments