Skip to content

Commit

Permalink
loop over test schemes
Browse files Browse the repository at this point in the history
  • Loading branch information
watt committed Jun 19, 2024
1 parent 77cb96f commit 50e8a73
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 51 deletions.
31 changes: 2 additions & 29 deletions .github/workflows/swift.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,35 +85,8 @@ jobs:
- name: Switch Xcode
run: sudo xcode-select -s /Applications/Xcode_${XCODE_VERSION}.app

- name: Install XcodeGen
run: brew install xcodegen

- name: Generate Xcode project
run: xcodegen generate

# Macros are only built for the compiler platform, so we cannot run macro tests on iOS. Instead
# we target the "Tests" scheme from project.yml which selectively includes all the other tests.
- name: Tests - iOS
run: |
xcodebuild \
-project Workflow.xcodeproj \
-scheme "Tests" \
-destination "$IOS_DESTINATION" \
-skipMacroValidation \
test
- name: Dump schemes
run: xcodebuild -list -project Workflow.xcodeproj

# On macOS we can run all tests, including macro tests.
- name: Tests - macOS
run: |
xcodebuild \
-project Workflow.xcodeproj \
-scheme "Workflow-Package" \
-destination "platform=macOS" \
-skipMacroValidation \
test
- name: Run Tests
run: .github/workflows/test.sh

tutorial:
runs-on: macos-latest
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
!#/bin/bash

set -eux -o pipefail

echo Dumping package information
swift package describe --type json > package.json
cat package.json

echo Extracting test schemes
cat package.json | jq -r '.targets[] | select(.type == "test") | .name' > test_schemes.txt
cat test_schemes.txt

echo loading vars
ALL_TEST_SCHEMES=$(cat test_schemes.txt)
echo $ALL_TEST_SCHEMES

echo loading ios
which grep
grep --version
grep foo test_schemes.txt || true
grep Reactive test_schemes.txt || true
grep -v Macro test_schemes.txt || true

echo now into the var
IOS_TEST_SCHEMES=$(grep -v Macro test_schemes.txt || true)
echo done

# Macros are only built for the compiler platform, so we cannot run macro tests on iOS.
for TEST_SCHEME in $IOS_TEST_SCHEMES; do
xcodebuild \
-scheme $TEST_SCHEME \
-destination "$IOS_DESTINATION" \
-skipMacroValidation \
test
done

# On macOS we can run all tests, including macro tests.
for TEST_SCHEME in $ALL_TEST_SCHEMES; do
xcodebuild \
-scheme $TEST_SCHEME \
-destination "platform=macOS" \
-skipMacroValidation \
test
done
22 changes: 0 additions & 22 deletions project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,6 @@ targets:
UILaunchScreen:
UIColorName: ""

# This is a scheme for all tests except for macros.
Tests:
platform: iOS
type: bundle.unit-test
info:
path: TestingSupport/AppHost/App/Info.plist
scheme:
testTargets:
- package: Workflow/WorkflowCombineTestingTests
- package: Workflow/WorkflowCombineTests
- package: Workflow/WorkflowConcurrencyTestingTests
- package: Workflow/WorkflowConcurrencyTests
- package: Workflow/WorkflowReactiveSwiftTestingTests
- package: Workflow/WorkflowReactiveSwiftTests
- package: Workflow/WorkflowRxSwiftTestingTests
- package: Workflow/WorkflowRxSwiftTests
- package: Workflow/WorkflowSwiftUIExperimentalTests
- package: Workflow/WorkflowSwiftUITests
- package: Workflow/WorkflowTestingTests
- package: Workflow/WorkflowTests
- package: Workflow/WorkflowUITests

# to add app-hosted test targets:

# ViewEnvironmentUI-Tests:
Expand Down

0 comments on commit 50e8a73

Please sign in to comment.