Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation and examples to use Swift Testing #3413

Merged
merged 25 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 30 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,35 @@ jobs:
strategy:
matrix:
command: [test, '']
platform: [iOS, macOS, tvOS, watchOS, visionOS, macCatalyst]
platform: [IOS, MAC_CATALYST, MACOS, TVOS, VISIONOS, WATCHOS]
xcode: [15.2, 15.4, '16.0']
exclude:
- {xcode: 15.2, command: test}
- {xcode: 15.4, command: ''}
- {xcode: 15.2, platform: macCatalyst}
- {xcode: 15.2, platform: tvOS}
- {xcode: 15.2, platform: visionOS}
- {xcode: 15.2, platform: watchOS}
- {xcode: 15.2, platform: MAC_CATALYST}
- {xcode: 15.2, platform: TVOS}
- {xcode: 15.2, platform: VISIONOS}
- {xcode: 15.2, platform: WATCHOS}
- {xcode: '16.0', command: ''}
- {xcode: '16.0', platform: macCatalyst}
- {xcode: '16.0', platform: tvOS}
- {xcode: '16.0', platform: visionOS}
- {xcode: '16.0', platform: watchOS}
- {xcode: '16.0', platform: MAC_CATALYST}
- {xcode: '16.0', platform: TVOS}
- {xcode: '16.0', platform: VISIONOS}
- {xcode: '16.0', platform: WATCHOS}
include:
- {xcode: 15.2, skip_release: 1}
steps:
- uses: actions/checkout@v4
- name: Select Xcode ${{ matrix.xcode }}
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
- name: Install visionOS runtime
if: matrix.platform == 'visionOS'
run: |
sudo xcodebuild -runFirstLaunch
sudo xcrun simctl list
sudo xcodebuild -downloadPlatform visionOS
sudo xcodebuild -runFirstLaunch
- name: List available devices
run: xcrun simctl list devices available
- name: Cache derived data
uses: actions/cache@v3
with:
Expand All @@ -49,15 +58,15 @@ jobs:
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift') }}
restore-keys: |
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-
- name: Set IgnoreFileSystemDeviceInodeChanges flag
- name: Set IgnoreFileSystemDeviceInodeChanges flag
run: defaults write com.apple.dt.XCBuild IgnoreFileSystemDeviceInodeChanges -bool YES
- name: Update mtime for incremental builds
- name: Update mtime for incremental builds
uses: chetan/git-restore-mtime-action@v2
- name: Debug
run: make COMMAND="${{ matrix.command }}" CONFIG=Debug PLATFORM="${{ matrix.platform }}" xcodebuild
run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Debug PLATFORM="${{ matrix.platform }}" WORKSPACE=.github/package.xcworkspace xcodebuild
- name: Release
if: matrix.skip_release != '1'
run: make COMMAND="${{ matrix.command }}" CONFIG=Release PLATFORM="${{ matrix.platform }}" xcodebuild
run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Release PLATFORM="${{ matrix.platform }}" WORKSPACE=.github/package.xcworkspace xcodebuild

library-evolution:
name: Library (evolution)
Expand Down Expand Up @@ -89,18 +98,18 @@ jobs:
- name: Update mtime for incremental builds
uses: chetan/git-restore-mtime-action@v2
- name: CaseStudies (SwiftUI)
run: make SCHEME="CaseStudies (SwiftUI)" test-example
run: make DERIVED_DATA_PATH=~/.derivedData SCHEME="CaseStudies (SwiftUI)" xcodebuild
- name: CaseStudies (UIKit)
run: make SCHEME="CaseStudies (UIKit)" test-example
run: make DERIVED_DATA_PATH=~/.derivedData SCHEME="CaseStudies (UIKit)" xcodebuild
- name: Search
run: make SCHEME="Search" test-example
run: make DERIVED_DATA_PATH=~/.derivedData SCHEME="Search" xcodebuild
- name: SyncUps
run: make SCHEME="SyncUps" test-example
run: make DERIVED_DATA_PATH=~/.derivedData SCHEME="SyncUps" xcodebuild
- name: SpeechRecognition
run: make SCHEME="SpeechRecognition" test-example
run: make DERIVED_DATA_PATH=~/.derivedData SCHEME="SpeechRecognition" xcodebuild
- name: TicTacToe
run: make SCHEME="TicTacToe" test-example
run: make DERIVED_DATA_PATH=~/.derivedData SCHEME="TicTacToe" xcodebuild
- name: Todos
run: make SCHEME="Todos" test-example
run: make DERIVED_DATA_PATH=~/.derivedData SCHEME="Todos" xcodebuild
- name: VoiceMemos
run: make SCHEME="VoiceMemos" test-example
run: make DERIVED_DATA_PATH=~/.derivedData SCHEME="VoiceMemos" xcodebuild
15 changes: 0 additions & 15 deletions .github/workflows/scheduled-ci.yml

This file was deleted.

14 changes: 2 additions & 12 deletions Examples/CaseStudies/CaseStudies.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,6 @@
PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.tvOSCaseStudies;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 3;
};
name = Debug;
Expand All @@ -872,7 +871,6 @@
PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.tvOSCaseStudies;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 3;
};
name = Release;
Expand All @@ -891,7 +889,6 @@
PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.tvOSCaseStudiesTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 3;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/tvOSCaseStudies.app/tvOSCaseStudies";
};
Expand All @@ -911,7 +908,6 @@
PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.tvOSCaseStudiesTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 3;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/tvOSCaseStudies.app/tvOSCaseStudies";
};
Expand All @@ -931,7 +927,6 @@
);
PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.UIKitCaseStudies;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -950,7 +945,6 @@
);
PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.UIKitCaseStudies;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -968,7 +962,6 @@
);
PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.UIKitCaseStudiesTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/UIKitCaseStudies.app/UIKitCaseStudies";
};
Expand All @@ -987,7 +980,6 @@
);
PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.UIKitCaseStudiesTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/UIKitCaseStudies.app/UIKitCaseStudies";
};
Expand Down Expand Up @@ -1053,6 +1045,7 @@
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 6.0;
};
name = Debug;
};
Expand Down Expand Up @@ -1109,6 +1102,7 @@
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 6.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -1126,7 +1120,6 @@
);
PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.SwiftUICaseStudies;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -1144,7 +1137,6 @@
);
PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.SwiftUICaseStudies;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -1162,7 +1154,6 @@
);
PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.SwiftUICaseStudiesTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftUICaseStudies.app/SwiftUICaseStudies";
};
Expand All @@ -1181,7 +1172,6 @@
);
PRODUCT_BUNDLE_IDENTIFIER = co.pointfree.SwiftUICaseStudiesTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftUICaseStudies.app/SwiftUICaseStudies";
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import ComposableArchitecture
import XCTest
import Testing

@testable import SwiftUICaseStudies

final class AlertsAndConfirmationDialogsTests: XCTestCase {
func testAlert() async {
let store = await TestStore(initialState: AlertAndConfirmationDialog.State()) {
@MainActor
struct AlertsAndConfirmationDialogsTests {
@Test
func alert() async {
let store = TestStore(initialState: AlertAndConfirmationDialog.State()) {
AlertAndConfirmationDialog()
}

Expand All @@ -32,8 +34,9 @@ final class AlertsAndConfirmationDialogsTests: XCTestCase {
}
}

func testConfirmationDialog() async {
let store = await TestStore(initialState: AlertAndConfirmationDialog.State()) {
@Test
func confirmationDialog() async {
let store = TestStore(initialState: AlertAndConfirmationDialog.State()) {
AlertAndConfirmationDialog()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import Clocks
import ComposableArchitecture
import XCTest
import Testing

@testable import SwiftUICaseStudies

final class AnimationTests: XCTestCase {
func testRainbow() async {
@MainActor
struct AnimationTests {
@Test
func rainbow() async {
let clock = TestClock()

let store = await TestStore(initialState: Animations.State()) {
let store = TestStore(initialState: Animations.State()) {
Animations()
} withDependencies: {
$0.continuousClock = clock
Expand Down Expand Up @@ -57,10 +59,11 @@ final class AnimationTests: XCTestCase {
await clock.run()
}

func testReset() async {
@Test
func reset() async {
let clock = TestClock()

let store = await TestStore(initialState: Animations.State()) {
let store = TestStore(initialState: Animations.State()) {
Animations()
} withDependencies: {
$0.continuousClock = clock
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import ComposableArchitecture
import XCTest
import Testing

@testable import SwiftUICaseStudies

final class BindingFormTests: XCTestCase {
func testBasics() async {
let store = await TestStore(initialState: BindingForm.State()) {
@MainActor
struct BindingFormTests {
@Test
func basics() async {
let store = TestStore(initialState: BindingForm.State()) {
BindingForm()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import ComposableArchitecture
import XCTest
import Testing

@testable import SwiftUICaseStudies

final class SharedStateFileStorageTests: XCTestCase {
func testTabSelection() async {
let store = await TestStore(initialState: SharedStateFileStorage.State()) {
@MainActor
struct SharedStateFileStorageTests {
@Test
func tabSelection() async {
let store = TestStore(initialState: SharedStateFileStorage.State()) {
SharedStateFileStorage()
}

Expand All @@ -17,8 +19,9 @@ final class SharedStateFileStorageTests: XCTestCase {
}
}

func testSharedCounts() async {
let store = await TestStore(initialState: SharedStateFileStorage.State()) {
@Test
func sharedCounts() async {
let store = TestStore(initialState: SharedStateFileStorage.State()) {
SharedStateFileStorage()
}

Expand All @@ -35,8 +38,9 @@ final class SharedStateFileStorageTests: XCTestCase {
}
}

func testAlert() async {
let store = await TestStore(initialState: SharedStateFileStorage.State()) {
@Test
func alert() async {
let store = TestStore(initialState: SharedStateFileStorage.State()) {
SharedStateFileStorage()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import ComposableArchitecture
import XCTest
import Testing

@testable import SwiftUICaseStudies

final class SharedStateInMemoryTests: XCTestCase {
func testTabSelection() async {
let store = await TestStore(initialState: SharedStateInMemory.State()) {
@MainActor
struct SharedStateInMemoryTests {
@Test
func tabSelection() async {
let store = TestStore(initialState: SharedStateInMemory.State()) {
SharedStateInMemory()
}

Expand All @@ -17,8 +19,9 @@ final class SharedStateInMemoryTests: XCTestCase {
}
}

func testSharedCounts() async {
let store = await TestStore(initialState: SharedStateInMemory.State()) {
@Test
func sharedCounts() async {
let store = TestStore(initialState: SharedStateInMemory.State()) {
SharedStateInMemory()
}

Expand All @@ -35,8 +38,9 @@ final class SharedStateInMemoryTests: XCTestCase {
}
}

func testAlert() async {
let store = await TestStore(initialState: SharedStateInMemory.State()) {
@Test
func alert() async {
let store = TestStore(initialState: SharedStateInMemory.State()) {
SharedStateInMemory()
}

Expand Down
Loading
Loading