Skip to content

Commit c63a84f

Browse files
Rename USE_SWIFT_CONCURRENCY_WAITER to DISABLE_XCTWAITER
To make the semantics of the option clearer.
1 parent 99a5c70 commit c63a84f

11 files changed

+39
-39
lines changed

CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ project(XCTest LANGUAGES Swift)
88
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
99
option(USE_FOUNDATION_FRAMEWORK "Use Foundation.framework on Darwin" NO)
1010

11-
set(USE_SWIFT_CONCURRENCY_WAITER_default NO)
11+
set(DISABLE_XCTWAITER_default NO)
1212

1313
if(CMAKE_SYSTEM_PROCESSOR STREQUAL wasm32)
14-
set(USE_SWIFT_CONCURRENCY_WAITER_default ON)
14+
set(DISABLE_XCTWAITER_default ON)
1515
endif()
1616

17-
option(USE_SWIFT_CONCURRENCY_WAITER "Use Swift Concurrency-based waiter implementation" "${USE_SWIFT_CONCURRENCY_WAITER_default}")
17+
option(DISABLE_XCTWAITER "Disable XCTWaiter" "${DISABLE_XCTWAITER_default}")
1818

19-
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin AND NOT USE_SWIFT_CONCURRENCY_WAITER)
19+
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin AND NOT DISABLE_XCTWAITER)
2020
find_package(dispatch CONFIG REQUIRED)
2121
find_package(Foundation CONFIG REQUIRED)
2222
endif()
@@ -59,9 +59,9 @@ add_library(XCTest
5959
Sources/XCTest/Public/Asynchronous/XCTestCase+Asynchronous.swift
6060
Sources/XCTest/Public/Asynchronous/XCTestExpectation.swift)
6161

62-
if(USE_SWIFT_CONCURRENCY_WAITER)
62+
if(DISABLE_XCTWAITER)
6363
target_compile_definitions(XCTest PRIVATE
64-
USE_SWIFT_CONCURRENCY_WAITER)
64+
DISABLE_XCTWAITER)
6565
endif()
6666

6767
if(USE_FOUNDATION_FRAMEWORK)

Sources/XCTest/Private/WaiterManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//
1010
// WaiterManager.swift
1111
//
12-
#if !USE_SWIFT_CONCURRENCY_WAITER
12+
#if !DISABLE_XCTWAITER
1313

1414
internal protocol ManageableWaiter: AnyObject, Equatable {
1515
var isFinished: Bool { get }

Sources/XCTest/Private/XCTestCase.TearDownBlocksState.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extension XCTestCase {
1212
/// Supports async and sync throwing methods.
1313
final class TeardownBlocksState {
1414

15-
#if USE_SWIFT_CONCURRENCY_WAITER
15+
#if DISABLE_XCTWAITER
1616
typealias TeardownBlock = @Sendable () async throws -> Void
1717
#else
1818
typealias TeardownBlock = () throws -> Void
@@ -27,7 +27,7 @@ extension XCTestCase {
2727
// Because of this, we chose the unusual decision to forgo overloading (which is a super sweet language feature <3) to prevent this issue from surprising any contributors to corelibs-xctest
2828
@available(macOS 12.0, *)
2929
func appendAsync(_ block: @Sendable @escaping () async throws -> Void) {
30-
#if USE_SWIFT_CONCURRENCY_WAITER
30+
#if DISABLE_XCTWAITER
3131
XCTWaiter.subsystemQueue.sync {
3232
precondition(wasFinalized == false, "API violation -- attempting to add a teardown block after teardown blocks have been dequeued")
3333
blocks.append(block)

Sources/XCTest/Public/Asynchronous/XCTNSNotificationExpectation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// XCTNSNotificationExpectation.swift
1111
//
1212

13-
#if !USE_SWIFT_CONCURRENCY_WAITER
13+
#if !DISABLE_XCTWAITER
1414

1515
/// Expectation subclass for waiting on a condition defined by a Foundation Notification instance.
1616
open class XCTNSNotificationExpectation: XCTestExpectation {

Sources/XCTest/Public/Asynchronous/XCTNSPredicateExpectation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// XCTNSPredicateExpectation.swift
1111
//
1212

13-
#if !USE_SWIFT_CONCURRENCY_WAITER
13+
#if !DISABLE_XCTWAITER
1414

1515
/// Expectation subclass for waiting on a condition defined by an NSPredicate and an optional object.
1616
open class XCTNSPredicateExpectation: XCTestExpectation {

Sources/XCTest/Public/Asynchronous/XCTWaiter.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ open class XCTWaiter {
117117
private var state = State.ready
118118
internal var timeout: TimeInterval = 0
119119
internal var waitSourceLocation: SourceLocation?
120-
#if !USE_SWIFT_CONCURRENCY_WAITER
120+
#if !DISABLE_XCTWAITER
121121
private weak var manager: WaiterManager<XCTWaiter>?
122122
#endif
123123
private var runLoop: RunLoop?
@@ -189,14 +189,14 @@ open class XCTWaiter {
189189
/// these environments. To ensure compatibility of tests between
190190
/// swift-corelibs-xctest and Apple XCTest, it is not recommended to pass
191191
/// explicit values for `file` and `line`.
192-
#if USE_SWIFT_CONCURRENCY_WAITER
192+
#if DISABLE_XCTWAITER
193193
@available(*, unavailable, message: "Expectation-based waiting is not available when using the Swift concurrency waiter.")
194194
#else
195195
@available(*, noasync, message: "Use await fulfillment(of:timeout:enforceOrder:) instead.")
196196
#endif
197197
@discardableResult
198198
open func wait(for expectations: [XCTestExpectation], timeout: TimeInterval, enforceOrder: Bool = false, file: StaticString = #file, line: Int = #line) -> Result {
199-
#if USE_SWIFT_CONCURRENCY_WAITER
199+
#if DISABLE_XCTWAITER
200200
fatalError("This method is not available when using the Swift concurrency waiter.")
201201
#else
202202
precondition(Set(expectations).count == expectations.count, "API violation - each expectation can appear only once in the 'expectations' parameter.")
@@ -286,14 +286,14 @@ open class XCTWaiter {
286286
/// these environments. To ensure compatibility of tests between
287287
/// swift-corelibs-xctest and Apple XCTest, it is not recommended to pass
288288
/// explicit values for `file` and `line`.
289-
#if USE_SWIFT_CONCURRENCY_WAITER
289+
#if DISABLE_XCTWAITER
290290
@available(*, unavailable, message: "Expectation-based waiting is not available when using the Swift concurrency waiter.")
291291
#else
292292
@available(macOS 12.0, *)
293293
#endif
294294
@discardableResult
295295
open func fulfillment(of expectations: [XCTestExpectation], timeout: TimeInterval, enforceOrder: Bool = false, file: StaticString = #file, line: Int = #line) async -> Result {
296-
#if USE_SWIFT_CONCURRENCY_WAITER
296+
#if DISABLE_XCTWAITER
297297
fatalError("This method is not available when using the Swift concurrency waiter.")
298298
#else
299299
return await withCheckedContinuation { continuation in
@@ -324,13 +324,13 @@ open class XCTWaiter {
324324
/// expectations are not fulfilled before the given timeout. Default is the line
325325
/// number of the call to this method in the calling file. It is rare to
326326
/// provide this parameter when calling this method.
327-
#if USE_SWIFT_CONCURRENCY_WAITER
327+
#if DISABLE_XCTWAITER
328328
@available(*, unavailable, message: "Expectation-based waiting is not available when using the Swift concurrency waiter.")
329329
#else
330330
@available(*, noasync, message: "Use await fulfillment(of:timeout:enforceOrder:) instead.")
331331
#endif
332332
open class func wait(for expectations: [XCTestExpectation], timeout: TimeInterval, enforceOrder: Bool = false, file: StaticString = #file, line: Int = #line) -> Result {
333-
#if USE_SWIFT_CONCURRENCY_WAITER
333+
#if DISABLE_XCTWAITER
334334
fatalError("This method is not available when using the Swift concurrency waiter.")
335335
#else
336336
return XCTWaiter().wait(for: expectations, timeout: timeout, enforceOrder: enforceOrder, file: file, line: line)
@@ -353,13 +353,13 @@ open class XCTWaiter {
353353
/// expectations are not fulfilled before the given timeout. Default is the line
354354
/// number of the call to this method in the calling file. It is rare to
355355
/// provide this parameter when calling this method.
356-
#if USE_SWIFT_CONCURRENCY_WAITER
356+
#if DISABLE_XCTWAITER
357357
@available(*, unavailable, message: "Expectation-based waiting is not available when using the Swift concurrency waiter.")
358358
#else
359359
@available(macOS 12.0, *)
360360
#endif
361361
open class func fulfillment(of expectations: [XCTestExpectation], timeout: TimeInterval, enforceOrder: Bool = false, file: StaticString = #file, line: Int = #line) async -> Result {
362-
#if USE_SWIFT_CONCURRENCY_WAITER
362+
#if DISABLE_XCTWAITER
363363
fatalError("This method is not available when using the Swift concurrency waiter.")
364364
#else
365365
return await XCTWaiter().fulfillment(of: expectations, timeout: timeout, enforceOrder: enforceOrder, file: file, line: line)
@@ -372,7 +372,7 @@ open class XCTWaiter {
372372
}
373373
}
374374

375-
#if !USE_SWIFT_CONCURRENCY_WAITER
375+
#if !DISABLE_XCTWAITER
376376
private func queue_configureExpectations(_ expectations: [XCTestExpectation]) {
377377
dispatchPrecondition(condition: .onQueue(XCTWaiter.subsystemQueue))
378378

@@ -452,7 +452,7 @@ open class XCTWaiter {
452452

453453
}
454454

455-
#if !USE_SWIFT_CONCURRENCY_WAITER
455+
#if !DISABLE_XCTWAITER
456456
private extension XCTWaiter {
457457
func primitiveWait(using runLoop: RunLoop, duration timeout: TimeInterval) {
458458
// The contract for `primitiveWait(for:)` explicitly allows waiting for a shorter period than requested
@@ -491,7 +491,7 @@ extension XCTWaiter: CustomStringConvertible {
491491
}
492492
}
493493

494-
#if !USE_SWIFT_CONCURRENCY_WAITER
494+
#if !DISABLE_XCTWAITER
495495
extension XCTWaiter: ManageableWaiter {
496496
var isFinished: Bool {
497497
return XCTWaiter.subsystemQueue.sync {

Sources/XCTest/Public/Asynchronous/XCTestCase+Asynchronous.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// Methods on XCTestCase for testing asynchronous operations
1212
//
1313

14-
#if !USE_SWIFT_CONCURRENCY_WAITER
14+
#if !DISABLE_XCTWAITER
1515

1616
public extension XCTestCase {
1717

Sources/XCTest/Public/XCAbstractTest.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ open class XCTest {
3636
/// testRunClass. If the test has not yet been run, this will be nil.
3737
open private(set) var testRun: XCTestRun? = nil
3838

39-
#if USE_SWIFT_CONCURRENCY_WAITER
39+
#if DISABLE_XCTWAITER
4040
internal var performTask: Task<Void, Never>?
4141

4242
internal func _performAsync(_ run: XCTestRun) async {
@@ -53,7 +53,7 @@ open class XCTest {
5353

5454
/// The method through which tests are executed. Must be overridden by
5555
/// subclasses.
56-
#if USE_SWIFT_CONCURRENCY_WAITER
56+
#if DISABLE_XCTWAITER
5757
@available(*, unavailable)
5858
#endif
5959
open func perform(_ run: XCTestRun) {
@@ -62,11 +62,11 @@ open class XCTest {
6262

6363
/// Creates an instance of the `testRunClass` and passes it as a parameter
6464
/// to `perform()`.
65-
#if USE_SWIFT_CONCURRENCY_WAITER
65+
#if DISABLE_XCTWAITER
6666
@available(*, unavailable)
6767
#endif
6868
open func run() {
69-
#if !USE_SWIFT_CONCURRENCY_WAITER
69+
#if !DISABLE_XCTWAITER
7070
guard let testRunType = testRunClass as? XCTestRun.Type else {
7171
fatalError("XCTest.testRunClass must be a kind of XCTestRun.")
7272
}

Sources/XCTest/Public/XCTestCase.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ open class XCTestCase: XCTest {
3636

3737
private var skip: XCTSkip?
3838

39-
#if USE_SWIFT_CONCURRENCY_WAITER
39+
#if DISABLE_XCTWAITER
4040
/// A task that ends when the test closure has actually finished running.
4141
/// This is used to ensure that all async work has completed.
4242
fileprivate var testClosureTask: Task<Void, Error>?
@@ -95,7 +95,7 @@ open class XCTestCase: XCTest {
9595
return XCTestCaseRun.self
9696
}
9797

98-
#if USE_SWIFT_CONCURRENCY_WAITER
98+
#if DISABLE_XCTWAITER
9999
override func _performAsync(_ run: XCTestRun) async {
100100
guard let testRun = run as? XCTestCaseRun else {
101101
fatalError("Wrong XCTestRun class.")
@@ -135,7 +135,7 @@ open class XCTestCase: XCTest {
135135
self.testClosure = testClosure
136136
}
137137

138-
#if USE_SWIFT_CONCURRENCY_WAITER
138+
#if DISABLE_XCTWAITER
139139
@MainActor internal func _invokeTestAsync() async {
140140
await performSetUpSequence()
141141

@@ -170,11 +170,11 @@ open class XCTestCase: XCTest {
170170

171171
/// Invoking a test performs its setUp, invocation, and tearDown. In
172172
/// general this should not be called directly.
173-
#if USE_SWIFT_CONCURRENCY_WAITER
173+
#if DISABLE_XCTWAITER
174174
@available(*, unavailable)
175175
#endif
176176
open func invokeTest() {
177-
#if !USE_SWIFT_CONCURRENCY_WAITER
177+
#if !DISABLE_XCTWAITER
178178
performSetUpSequence()
179179

180180
do {
@@ -310,7 +310,7 @@ open class XCTestCase: XCTest {
310310
}
311311
}
312312

313-
#if USE_SWIFT_CONCURRENCY_WAITER
313+
#if DISABLE_XCTWAITER
314314
@MainActor private func runTeardownBlocks() async {
315315
for block in self.teardownBlocksState.finalize().reversed() {
316316
do {
@@ -425,7 +425,7 @@ private func test<T: XCTestCase>(_ testFunc: @escaping (T) -> () throws -> Void)
425425
public func asyncTest<T: XCTestCase>(
426426
_ testClosureGenerator: @escaping (T) -> () async throws -> Void
427427
) -> (T) -> () throws -> Void {
428-
#if USE_SWIFT_CONCURRENCY_WAITER
428+
#if DISABLE_XCTWAITER
429429
return { (testType: T) in
430430
let testClosure = testClosureGenerator(testType)
431431
return {
@@ -445,7 +445,7 @@ public func asyncTest<T: XCTestCase>(
445445
#endif
446446
}
447447

448-
#if !USE_SWIFT_CONCURRENCY_WAITER
448+
#if !DISABLE_XCTWAITER
449449
@available(macOS 12.0, *)
450450
func awaitUsingExpectation(
451451
_ closure: @escaping () async throws -> Void

Sources/XCTest/Public/XCTestMain.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
/// - Returns: The exit code to use when the process terminates. `EXIT_SUCCESS`
7070
/// indicates success, while any other value (including `EXIT_FAILURE`)
7171
/// indicates failure.
72-
#if USE_SWIFT_CONCURRENCY_WAITER
72+
#if DISABLE_XCTWAITER
7373
@_disfavoredOverload
7474
public func XCTMain(
7575
_ testCases: [XCTestCaseEntry],
@@ -201,7 +201,7 @@ internal func XCTMainMisc(
201201
}
202202
}
203203

204-
#if USE_SWIFT_CONCURRENCY_WAITER
204+
#if DISABLE_XCTWAITER
205205
// @available(*, deprecated, message: "Call the overload of XCTMain() that returns an exit code instead.")
206206
public func XCTMain(_ testCases: [XCTestCaseEntry]) async -> Never {
207207
exit(await XCTMain(testCases, arguments: CommandLine.arguments, observers: nil) as CInt)

0 commit comments

Comments
 (0)