Skip to content

Commit 8c75a97

Browse files
authored
Fix testing script (#169)
1 parent eb44c7e commit 8c75a97

File tree

2 files changed

+65
-48
lines changed

2 files changed

+65
-48
lines changed

.github/workflows/test.yml

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,55 @@ on:
1111

1212
env:
1313
DEVELOPER_DIR: /Applications/Xcode_16.1.app
14+
IOS_SIMULATOR: '"platform=iOS Simulator,name=iPhone 16 Pro"'
15+
IOS_SIMULATOR_XCODE_15: '"platform=iOS Simulator,name=iPhone 15 Pro"'
16+
MACOS: '"platform=macOS"'
17+
TVOS_SIMULATOR: '"platform=tvOS Simulator,name=Apple TV 4K (3rd generation)"'
18+
WATCHOS_SIMULATOR: '"platform=watchOS Simulator,name=Apple Watch Ultra 2 (49mm)"'
1419

1520
jobs:
1621
test:
1722
name: Test
1823
runs-on: macos-14
19-
strategy:
20-
matrix:
21-
xcode_version:
22-
- 15.4
23-
- 16.1
24-
platform:
25-
- ios
26-
- macos
27-
- tvos
28-
- watchos
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Test library iOS
27+
run: scripts/test.sh library -destinations ${{ env.IOS_SIMULATOR }}
28+
- name: Test library macOS
29+
run: scripts/test.sh library -destinations ${{ env.MACOS }}
30+
- name: Test library tvOS
31+
run: scripts/test.sh library -destinations ${{ env.TVOS_SIMULATOR }}
32+
- name: Test library watchOS
33+
run: scripts/test.sh library -destinations ${{ env.WATCHOS_SIMULATOR }}
34+
35+
test_with_xcode_15:
36+
name: Test with Xcode 15
37+
runs-on: macos-14
2938
env:
30-
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app
39+
DEVELOPER_DIR: /Applications/Xcode_15.4.app
3140
steps:
3241
- uses: actions/checkout@v4
33-
- name: Test library
34-
run: scripts/test.sh library ${{ matrix.platform }}
42+
- name: Test library iOS
43+
run: scripts/test.sh library -destinations ${{ env.IOS_SIMULATOR_XCODE_15 }}
44+
- name: Test library macOS
45+
run: scripts/test.sh library -destinations ${{ env.MACOS }}
46+
- name: Test library tvOS
47+
run: scripts/test.sh library -destinations ${{ env.TVOS_SIMULATOR }}
48+
- name: Test library watchOS
49+
run: scripts/test.sh library -destinations ${{ env.WATCHOS_SIMULATOR }}
3550

3651
test_examples:
3752
name: Test examples
3853
runs-on: macos-14
3954
steps:
4055
- uses: actions/checkout@v4
4156
- name: Test example iOS
42-
run: scripts/test.sh example-ios ios
43-
- name: Test example macOS
44-
run: scripts/test.sh example-cross-platform macos
45-
- name: Test example tvOS
46-
run: scripts/test.sh example-cross-platform tvos
57+
run: scripts/test.sh example-ios -destinations ${{ env.IOS_SIMULATOR }}
58+
- name: Test example cross platform
59+
run: |
60+
scripts/test.sh example-cross-platform -destinations \
61+
${{ env.MACOS }} \
62+
${{ env.TVOS_SIMULATOR }}
4763
4864
test_upcoming_features:
4965
name: Test upcoming features with Xcode 15
@@ -53,7 +69,7 @@ jobs:
5369
steps:
5470
- uses: actions/checkout@v4
5571
- name: Test upcoming features
56-
run: ENABLE_UPCOMING_FEATURES=1 scripts/test.sh library ios
72+
run: ENABLE_UPCOMING_FEATURES=1 scripts/test.sh library -destinations ${{ env.IOS_SIMULATOR_XCODE_15 }}
5773

5874
test_language_mode:
5975
name: Test Swift 5 language mode
@@ -66,15 +82,15 @@ jobs:
6682
steps:
6783
- uses: actions/checkout@v4
6884
- name: Test Swift 5 language mode
69-
run: ENABLE_UPCOMING_FEATURES=${{ matrix.enable_upcoming_features }} scripts/test.sh library ios SWIFT_VERSION=5
85+
run: ENABLE_UPCOMING_FEATURES=${{ matrix.enable_upcoming_features }} scripts/test.sh library SWIFT_VERSION=5 -destinations ${{ env.IOS_SIMULATOR }}
7086

7187
benchmark:
7288
name: Benchmark
7389
runs-on: macos-14
7490
steps:
7591
- uses: actions/checkout@v4
7692
- name: Run benchmark test
77-
run: scripts/test.sh benchmark ios
93+
run: scripts/test.sh benchmark -destinations ${{ env.IOS_SIMULATOR }}
7894

7995
validation:
8096
name: Validation

scripts/test.sh

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,46 @@
22

33
set -eu
44

5-
TARGET=$1
6-
PLATFORM=$2
7-
ARGS=${@:3}
8-
95
pushd "$(cd $(dirname $0)/.. && pwd)" &>/dev/null
106

11-
case $PLATFORM in
12-
ios)
13-
platform="iOS Simulator,name=iPhone 15 Pro"
14-
;;
15-
macos)
16-
platform="macOS"
17-
;;
18-
tvos)
19-
platform="tvOS Simulator,name=Apple TV 4K (3rd generation)"
20-
;;
21-
watchos)
22-
platform="watchOS Simulator,name=Apple Watch Ultra 2 (49mm)"
23-
;;
24-
esac
25-
26-
clean_test() {
27-
xcodebuild clean test "$@" $ARGS
28-
}
7+
target=$1
8+
options=()
9+
args=()
2910

30-
case $TARGET in
11+
case $target in
3112
library)
32-
clean_test -scheme swiftui-atom-properties -destination platform="$platform"
13+
options+=("-scheme swiftui-atom-properties")
3314
;;
3415
example-ios)
3516
cd Examples/Packages/iOS
36-
clean_test -scheme iOSExamples -destination platform="$platform"
17+
options+=("-scheme iOSExamples")
3718
;;
3819
example-cross-platform)
3920
cd Examples/Packages/CrossPlatform
40-
clean_test -scheme CrossPlatformExamples -destination platform="$platform"
21+
options+=("-scheme CrossPlatformExamples")
4122
;;
4223
benchmark)
4324
cd Benchmarks
44-
clean_test -scheme BenchmarkTests -destination platform="$platform"
25+
options+=("-scheme BenchmarkTests")
4526
;;
4627
esac
28+
29+
shift
30+
31+
while [[ $# -gt 0 ]]; do
32+
case "$1" in
33+
-destinations)
34+
shift
35+
while [[ $# -gt 0 && ! "$1" =~ ^- ]]; do
36+
options+=("-destination \"$1\"")
37+
shift
38+
done
39+
;;
40+
*)
41+
args+=("$1")
42+
shift
43+
;;
44+
esac
45+
done
46+
47+
eval xcodebuild clean test "${options[@]-}" "${args[@]-}"

0 commit comments

Comments
 (0)