Skip to content

Commit 3ef2d04

Browse files
committed
Fix tests and Linux support
## Changes - Fix unit tests. - Remove unnecessary Combine imports - Fix imports on Linux. - Fix unit tests on Linux + Add missing compile checks for `XCTExpectFailure` in Linux + Disable tests that use `@MainActor` on Linux because of an issue gathering tests: https://github.com/apple/swift-corelibs-xctest/issues/424 - Remove Swift installation from SwiftPM Linux job, as Swift is already included in `ubuntu-latest` (`ubuntu-20.04`): https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2004-Readme.md#language-and-runtime
1 parent 19cb15f commit 3ef2d04

File tree

40 files changed

+2192
-2151
lines changed

40 files changed

+2192
-2151
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,8 @@ jobs:
4545
name: SwiftPM Linux
4646
runs-on: ubuntu-latest
4747
steps:
48-
- name: Install Swift
49-
run: |
50-
eval "$(curl -sL https://swiftenv.fuller.li/install.sh)"
51-
- name: Checkout
52-
uses: actions/checkout@v2
53-
- name: Pull dependencies
54-
run: |
55-
swift package resolve
48+
- uses: actions/checkout@v2
49+
- name: Swift version
50+
run: swift --version
5651
- name: Test via SwiftPM
57-
run: |
58-
swift --version
59-
swift test --enable-test-discovery
52+
run: swift test --enable-test-discovery

Examples/CaseStudies/CaseStudies.xcodeproj/project.pbxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@
374374
DC4C6EA82450DD380066A05D /* UIKitCaseStudies */,
375375
DC4C6EBF2450DD390066A05D /* UIKitCaseStudiesTests */,
376376
);
377+
indentWidth = 2;
377378
sourceTree = "<group>";
378379
};
379380
DC89C41424460F95006900B9 /* Products */ = {

Examples/CaseStudies/SwiftUICaseStudiesTests/01-GettingStarted-AnimationsTests.swift

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import XCTest
66

77
@MainActor
88
class AnimationTests: XCTestCase {
9-
func testRainbow() {
9+
func testRainbow() async {
1010
let mainQueue = TestScheduler()
1111

1212
let store = TestStore(
@@ -17,44 +17,44 @@ class AnimationTests: XCTestCase {
1717
)
1818
)
1919

20-
store.send(.rainbowButtonTapped)
20+
await store.send(.rainbowButtonTapped)
2121

22-
store.receive(.setColor(.red)) {
22+
await store.receive(.setColor(.red)) {
2323
$0.circleColor = .red
2424
}
2525

2626
await mainQueue.advance(by: .seconds(1))
27-
store.receive(.setColor(.blue)) {
27+
await store.receive(.setColor(.blue)) {
2828
$0.circleColor = .blue
2929
}
3030

3131
await mainQueue.advance(by: .seconds(1))
32-
store.receive(.setColor(.green)) {
32+
await store.receive(.setColor(.green)) {
3333
$0.circleColor = .green
3434
}
3535

3636
await mainQueue.advance(by: .seconds(1))
37-
store.receive(.setColor(.orange)) {
37+
await store.receive(.setColor(.orange)) {
3838
$0.circleColor = .orange
3939
}
4040

4141
await mainQueue.advance(by: .seconds(1))
42-
store.receive(.setColor(.pink)) {
42+
await store.receive(.setColor(.pink)) {
4343
$0.circleColor = .pink
4444
}
4545

4646
await mainQueue.advance(by: .seconds(1))
47-
store.receive(.setColor(.purple)) {
47+
await store.receive(.setColor(.purple)) {
4848
$0.circleColor = .purple
4949
}
5050

5151
await mainQueue.advance(by: .seconds(1))
52-
store.receive(.setColor(.yellow)) {
52+
await store.receive(.setColor(.yellow)) {
5353
$0.circleColor = .yellow
5454
}
5555

5656
await mainQueue.advance(by: .seconds(1))
57-
store.receive(.setColor(.black)) {
57+
await store.receive(.setColor(.black)) {
5858
$0.circleColor = .black
5959
}
6060

@@ -63,41 +63,41 @@ class AnimationTests: XCTestCase {
6363
await mainQueue.advance(by: .seconds(10))
6464
}
6565

66-
func testReset() async {
67-
let mainQueue = TestScheduler()
66+
func testReset() async {
67+
let mainQueue = TestScheduler()
6868

69-
let store = TestStore(
70-
initialState: AnimationsState(),
71-
reducer: animationsReducer,
72-
environment: AnimationsEnvironment(
73-
mainQueue: mainQueue
74-
)
69+
let store = TestStore(
70+
initialState: AnimationsState(),
71+
reducer: animationsReducer,
72+
environment: AnimationsEnvironment(
73+
mainQueue: mainQueue
7574
)
75+
)
76+
77+
await store.send(.rainbowButtonTapped)
7678

77-
await store.send(.rainbowButtonTapped)
78-
79-
await store.receive(.setColor(.red)) {
80-
$0.circleColor = .red
81-
}
82-
83-
await mainQueue.advance(by: .seconds(1))
84-
await store.receive(.setColor(.blue)) {
85-
$0.circleColor = .blue
86-
}
87-
88-
await store.send(.resetButtonTapped) {
89-
$0.alert = AlertState(
90-
title: TextState("Reset state?"),
91-
primaryButton: .destructive(
92-
TextState("Reset"),
93-
action: .send(.resetConfirmationButtonTapped, animation: .default)
94-
),
95-
secondaryButton: .cancel(TextState("Cancel"))
96-
)
97-
}
98-
99-
await store.send(.resetConfirmationButtonTapped) {
100-
$0 = AnimationsState()
101-
}
79+
await store.receive(.setColor(.red)) {
80+
$0.circleColor = .red
10281
}
82+
83+
await mainQueue.advance(by: .seconds(1))
84+
await store.receive(.setColor(.blue)) {
85+
$0.circleColor = .blue
86+
}
87+
88+
await store.send(.resetButtonTapped) {
89+
$0.alert = AlertState(
90+
title: TextState("Reset state?"),
91+
primaryButton: .destructive(
92+
TextState("Reset"),
93+
action: .send(.resetConfirmationButtonTapped, animation: .default)
94+
),
95+
secondaryButton: .cancel(TextState("Cancel"))
96+
)
97+
}
98+
99+
await store.send(.resetConfirmationButtonTapped) {
100+
$0 = AnimationsState()
101+
}
102+
}
103103
}

Examples/Search/Search.xcodeproj/project.pbxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
CA86E49924253C2500357AD9 /* Search */,
8989
CA86E4B024253C2700357AD9 /* SearchTests */,
9090
);
91+
indentWidth = 2;
9192
sourceTree = "<group>";
9293
};
9394
CA86E49824253C2500357AD9 /* Products */ = {

Examples/Search/Search/WeatherClient.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ extension WeatherClient {
6565

6666
let (data, _) = try await URLSession.shared.data(from: components.url!)
6767
return try jsonDecoder.decode(Search.self, from: data)
68-
}
6968
}
7069
)
7170
}

Examples/SpeechRecognition/SpeechRecognition.xcodeproj/project.pbxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
CA23320C2447ACFA00B818EB /* SpeechRecognition */,
9696
CA2332232447ACFC00B818EB /* SpeechRecognitionTests */,
9797
);
98+
indentWidth = 2;
9899
sourceTree = "<group>";
99100
};
100101
CA23320B2447ACFA00B818EB /* Products */ = {

Examples/SpeechRecognition/SpeechRecognition/SpeechClient/Client.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import Combine
21
import Speech
32

43
struct SpeechClient {

Examples/SpeechRecognition/SpeechRecognition/SpeechClient/Live.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import ComposableArchitecture
2-
import ReactiveSwift
32
import Speech
43

54
extension SpeechClient {
@@ -79,7 +78,6 @@ private actor Speech {
7978
audioEngine.wrappedValue?.inputNode.removeTap(onBus: 0)
8079
recognitionTask.wrappedValue?.finish()
8180
}
82-
lifetime += cancellable
8381

8482
self.audioEngine?.inputNode.installTap(
8583
onBus: 0,

Examples/SpeechRecognition/SpeechRecognition/SpeechClient/Unimplemented.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import Combine
21
import ComposableArchitecture
32
import Speech
43
import XCTestDynamicOverlay

Examples/SpeechRecognition/SpeechRecognition/SpeechRecognition.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import ComposableArchitecture
2-
import ReactiveSwift
32
import Speech
43
@preconcurrency import SwiftUI
54

@@ -190,7 +189,7 @@ extension SpeechClient {
190189
}
191190
text += word + " "
192191
c.yield(
193-
value: .init(
192+
.init(
194193
bestTranscription: .init(
195194
formattedString: text,
196195
segments: []
@@ -200,8 +199,6 @@ extension SpeechClient {
200199
)
201200
)
202201
}
203-
204-
lifetime += disposable
205202
}
206203
}
207204
}

0 commit comments

Comments
 (0)