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

Lower macOS availability of async APIs from 12.0 to 10.15 #421

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension XCTestCase {
// which can unexpectedly change their semantics in difficult to track down ways.
//
// 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
@available(macOS 12.0, *)
@available(macOS 10.15, *)
func appendAsync(_ block: @Sendable @escaping () async throws -> Void) {
self.append {
try awaitUsingExpectation { try await block() }
Expand Down
4 changes: 2 additions & 2 deletions Sources/XCTest/Public/XCAbstractTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ open class XCTest {
}

/// Async setup method called before the invocation of `setUpWithError` for each test method in the class.
@available(macOS 12.0, *)
@available(macOS 10.15, *)
open func setUp() async throws {}
/// Setup method called before the invocation of `setUp` and the test method
/// for each test method in the class.
Expand All @@ -73,7 +73,7 @@ open class XCTest {

/// Async teardown method which is called after the invocation of `tearDownWithError`
/// for each test method in the class.
@available(macOS 12.0, *)
@available(macOS 10.15, *)
open func tearDown() async throws {}
// FIXME: This initializer is required due to a Swift compiler bug on Linux.
// It should be removed once the bug is fixed.
Expand Down
10 changes: 5 additions & 5 deletions Sources/XCTest/Public/XCTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ open class XCTestCase: XCTest {

/// Registers a block of teardown code to be run after the current test
/// method ends.
@available(macOS 12.0, *)
@available(macOS 10.15, *)
public func addTeardownBlock(_ block: @Sendable @escaping () async throws -> Void) {
teardownBlocksState.appendAsync(block)
}
Expand All @@ -227,7 +227,7 @@ open class XCTestCase: XCTest {
}

do {
if #available(macOS 12.0, *) {
if #available(macOS 10.15, *) {
try awaitUsingExpectation {
try await self.setUp()
}
Expand Down Expand Up @@ -273,7 +273,7 @@ open class XCTestCase: XCTest {
}

do {
if #available(macOS 12.0, *) {
if #available(macOS 10.15, *) {
try awaitUsingExpectation {
try await self.tearDown()
}
Expand Down Expand Up @@ -321,7 +321,7 @@ private func test<T: XCTestCase>(_ testFunc: @escaping (T) -> () throws -> Void)
}
}

@available(macOS 12.0, *)
@available(macOS 10.15, *)
public func asyncTest<T: XCTestCase>(
_ testClosureGenerator: @escaping (T) -> () async throws -> Void
) -> (T) -> () throws -> Void {
Expand All @@ -333,7 +333,7 @@ public func asyncTest<T: XCTestCase>(
}
}

@available(macOS 12.0, *)
@available(macOS 10.15, *)
func awaitUsingExpectation(
_ closure: @escaping () async throws -> Void
) throws -> Void {
Expand Down