@@ -120,76 +120,81 @@ import XCTest
120
120
_ = XCTWaiter . wait ( for: [ . init( ) ] , timeout: 2 )
121
121
}
122
122
123
- @MainActor
124
- func testEffectEmitMainThread( ) async throws {
125
- try XCTSkipIf ( ProcessInfo . processInfo. environment [ " CI " ] != nil )
126
- XCTExpectFailure {
127
- [
128
- """
129
- An effect completed on a non-main thread. …
130
-
131
- Effect returned from:
132
- Action.response
133
-
134
- Make sure to use " .receive(on:) " on any effects that execute on background threads to \
135
- receive their output on the main thread.
136
-
137
- The " Store " class is not thread-safe, and so all interactions with an instance of " Store " \
138
- (including all of its scopes and derived view stores) must be done on the main thread.
139
- """ ,
140
- """
141
- An effect completed on a non-main thread. …
142
-
143
- Effect returned from:
144
- Action.tap
145
-
146
- Make sure to use " .receive(on:) " on any effects that execute on background threads to \
147
- receive their output on the main thread.
148
-
149
- The " Store " class is not thread-safe, and so all interactions with an instance of " Store " \
150
- (including all of its scopes and derived view stores) must be done on the main thread.
151
- """ ,
152
- """
153
- An effect published an action on a non-main thread. …
154
-
155
- Effect published:
156
- Action.response
157
-
158
- Effect returned from:
159
- Action.tap
160
-
161
- Make sure to use " .receive(on:) " on any effects that execute on background threads to \
162
- receive their output on the main thread.
163
-
164
- The " Store " class is not thread-safe, and so all interactions with an instance of " Store " \
165
- (including all of its scopes and derived view stores) must be done on the main thread.
166
- """ ,
167
- ]
168
- . contains ( $0. compactDescription)
169
- }
170
-
171
- enum Action { case tap, response }
172
- let store = Store (
173
- initialState: 0 ,
174
- reducer: Reducer< Int, Action, Void> { state, action, _ in
175
- switch action {
176
- case . tap:
177
- return . run { observer in
178
- Thread . detachNewThread {
179
- XCTAssertFalse ( Thread . isMainThread, " Effect should send on non-main thread. " )
180
- observer. send ( value: . response)
181
- observer. sendCompleted ( )
123
+ #if os(macOS)
124
+ @MainActor
125
+ func testEffectEmitMainThread( ) async throws {
126
+ try XCTSkipIf ( ProcessInfo . processInfo. environment [ " CI " ] != nil )
127
+ XCTExpectFailure {
128
+ [
129
+ """
130
+ An effect completed on a non-main thread. …
131
+
132
+ Effect returned from:
133
+ Action.response
134
+
135
+ Make sure to use " .receive(on:) " on any effects that execute on background threads to \
136
+ receive their output on the main thread.
137
+
138
+ The " Store " class is not thread-safe, and so all interactions with an instance of \
139
+ " Store " (including all of its scopes and derived view stores) must be done on the main \
140
+ thread.
141
+ """ ,
142
+ """
143
+ An effect completed on a non-main thread. …
144
+
145
+ Effect returned from:
146
+ Action.tap
147
+
148
+ Make sure to use " .receive(on:) " on any effects that execute on background threads to \
149
+ receive their output on the main thread.
150
+
151
+ The " Store " class is not thread-safe, and so all interactions with an instance of \
152
+ " Store " (including all of its scopes and derived view stores) must be done on the main \
153
+ thread.
154
+ """ ,
155
+ """
156
+ An effect published an action on a non-main thread. …
157
+
158
+ Effect published:
159
+ Action.response
160
+
161
+ Effect returned from:
162
+ Action.tap
163
+
164
+ Make sure to use " .receive(on:) " on any effects that execute on background threads to \
165
+ receive their output on the main thread.
166
+
167
+ The " Store " class is not thread-safe, and so all interactions with an instance of \
168
+ " Store " (including all of its scopes and derived view stores) must be done on the main \
169
+ thread.
170
+ """ ,
171
+ ]
172
+ . contains ( $0. compactDescription)
173
+ }
174
+
175
+ enum Action { case tap, response }
176
+ let store = Store (
177
+ initialState: 0 ,
178
+ reducer: Reducer< Int, Action, Void> { state, action, _ in
179
+ switch action {
180
+ case . tap:
181
+ return . run { observer in
182
+ Thread . detachNewThread {
183
+ XCTAssertFalse ( Thread . isMainThread, " Effect should send on non-main thread. " )
184
+ observer. send ( value: . response)
185
+ observer. sendCompleted ( )
186
+ }
187
+ return AnyDisposable { }
182
188
}
183
- return AnyDisposable { }
189
+ case . response:
190
+ return . none
184
191
}
185
- case . response:
186
- return . none
187
- }
188
- } ,
189
- environment: ( )
190
- )
191
- await ViewStore ( store) . send ( . tap) . finish ( )
192
- }
192
+ } ,
193
+ environment: ( )
194
+ )
195
+ await ViewStore ( store) . send ( . tap) . finish ( )
196
+ }
197
+ #endif
193
198
194
199
func testBindingUnhandledAction( ) {
195
200
struct State : Equatable {
0 commit comments