From 600b9819bc1c30ff05be9ae46742a9c884962d91 Mon Sep 17 00:00:00 2001 From: Josh Wright Date: Tue, 21 Sep 2021 10:08:25 -0700 Subject: [PATCH 1/4] Switch up compiler directives for concurrency --- Sources/Lifecycle/Lifecycle.swift | 8 ++++---- Tests/LifecycleTests/ComponentLifecycleTests.swift | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Sources/Lifecycle/Lifecycle.swift b/Sources/Lifecycle/Lifecycle.swift index 304069f..3c0a700 100644 --- a/Sources/Lifecycle/Lifecycle.swift +++ b/Sources/Lifecycle/Lifecycle.swift @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5) +#if canImport(_Concurrency) import _Concurrency #endif @@ -99,7 +99,7 @@ public struct LifecycleHandler { } } -#if compiler(>=5.5) +#if canImport(_Concurrency) @available(macOS 12.0, *) extension LifecycleHandler { public init(_ handler: @escaping () async throws -> Void) { @@ -163,7 +163,7 @@ public struct LifecycleStartHandler { } } -#if compiler(>=5.5) +#if canImport(_Concurrency) @available(macOS 12.0, *) extension LifecycleStartHandler { public init(_ handler: @escaping () async throws -> State) { @@ -225,7 +225,7 @@ public struct LifecycleShutdownHandler { } } -#if compiler(>=5.5) +#if canImport(_Concurrency) @available(macOS 12.0, *) extension LifecycleShutdownHandler { public init(_ handler: @escaping (State) async throws -> Void) { diff --git a/Tests/LifecycleTests/ComponentLifecycleTests.swift b/Tests/LifecycleTests/ComponentLifecycleTests.swift index b155bdf..3875cff 100644 --- a/Tests/LifecycleTests/ComponentLifecycleTests.swift +++ b/Tests/LifecycleTests/ComponentLifecycleTests.swift @@ -1401,7 +1401,7 @@ final class ComponentLifecycleTests: XCTestCase { func testAsyncAwait() throws { #if compiler(<5.2) return - #elseif compiler(<5.5) + #elseif !canImport(_Concurrency) throw XCTSkip() #else guard #available(macOS 12.0, *) else { @@ -1435,7 +1435,7 @@ final class ComponentLifecycleTests: XCTestCase { func testAsyncAwaitStateful() throws { #if compiler(<5.2) return - #elseif compiler(<5.5) + #elseif !canImport(_Concurrency) throw XCTSkip() #else guard #available(macOS 12.0, *) else { @@ -1473,7 +1473,7 @@ final class ComponentLifecycleTests: XCTestCase { func testAsyncAwaitErrorOnStart() throws { #if compiler(<5.2) return - #elseif compiler(<5.5) + #elseif !canImport(_Concurrency) throw XCTSkip() #else guard #available(macOS 12.0, *) else { @@ -1509,7 +1509,7 @@ final class ComponentLifecycleTests: XCTestCase { func testAsyncAwaitErrorOnStartShutdownRequested() throws { #if compiler(<5.2) return - #elseif compiler(<5.5) + #elseif !canImport(_Concurrency) throw XCTSkip() #else guard #available(macOS 12.0, *) else { @@ -1545,7 +1545,7 @@ final class ComponentLifecycleTests: XCTestCase { func testAsyncAwaitErrorOnShutdown() throws { #if compiler(<5.2) return - #elseif compiler(<5.5) + #elseif !canImport(_Concurrency) throw XCTSkip() #else guard #available(macOS 12.0, *) else { From 8ca52579b93bc8cdfe1f97dd9c593acbc6cebb91 Mon Sep 17 00:00:00 2001 From: Josh Wright Date: Tue, 21 Sep 2021 14:03:51 -0700 Subject: [PATCH 2/4] Also check for Swift 5.5 --- Sources/Lifecycle/Lifecycle.swift | 8 ++++---- Tests/LifecycleTests/ComponentLifecycleTests.swift | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Sources/Lifecycle/Lifecycle.swift b/Sources/Lifecycle/Lifecycle.swift index 3c0a700..d91dbaa 100644 --- a/Sources/Lifecycle/Lifecycle.swift +++ b/Sources/Lifecycle/Lifecycle.swift @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -#if canImport(_Concurrency) +#if compiler(>=5.5) && canImport(_Concurrency) import _Concurrency #endif @@ -99,7 +99,7 @@ public struct LifecycleHandler { } } -#if canImport(_Concurrency) +#if compiler(>=5.5) && canImport(_Concurrency) @available(macOS 12.0, *) extension LifecycleHandler { public init(_ handler: @escaping () async throws -> Void) { @@ -163,7 +163,7 @@ public struct LifecycleStartHandler { } } -#if canImport(_Concurrency) +#if compiler(>=5.5) && canImport(_Concurrency) @available(macOS 12.0, *) extension LifecycleStartHandler { public init(_ handler: @escaping () async throws -> State) { @@ -225,7 +225,7 @@ public struct LifecycleShutdownHandler { } } -#if canImport(_Concurrency) +#if compiler(>=5.5) && canImport(_Concurrency) @available(macOS 12.0, *) extension LifecycleShutdownHandler { public init(_ handler: @escaping (State) async throws -> Void) { diff --git a/Tests/LifecycleTests/ComponentLifecycleTests.swift b/Tests/LifecycleTests/ComponentLifecycleTests.swift index 3875cff..1e051d9 100644 --- a/Tests/LifecycleTests/ComponentLifecycleTests.swift +++ b/Tests/LifecycleTests/ComponentLifecycleTests.swift @@ -1401,7 +1401,7 @@ final class ComponentLifecycleTests: XCTestCase { func testAsyncAwait() throws { #if compiler(<5.2) return - #elseif !canImport(_Concurrency) + #elseif compiler(<5.5) || !canImport(_Concurrency) throw XCTSkip() #else guard #available(macOS 12.0, *) else { @@ -1435,7 +1435,7 @@ final class ComponentLifecycleTests: XCTestCase { func testAsyncAwaitStateful() throws { #if compiler(<5.2) return - #elseif !canImport(_Concurrency) + #elseif compiler(<5.5) || !canImport(_Concurrency) throw XCTSkip() #else guard #available(macOS 12.0, *) else { @@ -1473,7 +1473,7 @@ final class ComponentLifecycleTests: XCTestCase { func testAsyncAwaitErrorOnStart() throws { #if compiler(<5.2) return - #elseif !canImport(_Concurrency) + #elseif compiler(<5.5) || !canImport(_Concurrency) throw XCTSkip() #else guard #available(macOS 12.0, *) else { @@ -1509,7 +1509,7 @@ final class ComponentLifecycleTests: XCTestCase { func testAsyncAwaitErrorOnStartShutdownRequested() throws { #if compiler(<5.2) return - #elseif !canImport(_Concurrency) + #elseif compiler(<5.5) || !canImport(_Concurrency) throw XCTSkip() #else guard #available(macOS 12.0, *) else { @@ -1545,7 +1545,7 @@ final class ComponentLifecycleTests: XCTestCase { func testAsyncAwaitErrorOnShutdown() throws { #if compiler(<5.2) return - #elseif !canImport(_Concurrency) + #elseif compiler(<5.5) || !canImport(_Concurrency) throw XCTSkip() #else guard #available(macOS 12.0, *) else { From 73fe501f8dcaf02aea9ca231d2ccf1c76f4597a6 Mon Sep 17 00:00:00 2001 From: Josh Wright Date: Tue, 21 Sep 2021 17:10:29 -0700 Subject: [PATCH 3/4] Kill import --- Sources/Lifecycle/Lifecycle.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Sources/Lifecycle/Lifecycle.swift b/Sources/Lifecycle/Lifecycle.swift index d91dbaa..ce2176a 100644 --- a/Sources/Lifecycle/Lifecycle.swift +++ b/Sources/Lifecycle/Lifecycle.swift @@ -12,10 +12,6 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5) && canImport(_Concurrency) -import _Concurrency -#endif - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) import Darwin #else From 0bb93f5878bd89edbe5f10bd21966aedbe5a8374 Mon Sep 17 00:00:00 2001 From: Josh Wright Date: Tue, 21 Sep 2021 21:48:49 -0700 Subject: [PATCH 4/4] Break up conditional --- .../ComponentLifecycleTests.swift | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Tests/LifecycleTests/ComponentLifecycleTests.swift b/Tests/LifecycleTests/ComponentLifecycleTests.swift index 1e051d9..2f6df3c 100644 --- a/Tests/LifecycleTests/ComponentLifecycleTests.swift +++ b/Tests/LifecycleTests/ComponentLifecycleTests.swift @@ -1401,7 +1401,9 @@ final class ComponentLifecycleTests: XCTestCase { func testAsyncAwait() throws { #if compiler(<5.2) return - #elseif compiler(<5.5) || !canImport(_Concurrency) + #elseif compiler(<5.5) + throw XCTSkip() + #elseif !canImport(_Concurrency) throw XCTSkip() #else guard #available(macOS 12.0, *) else { @@ -1435,7 +1437,9 @@ final class ComponentLifecycleTests: XCTestCase { func testAsyncAwaitStateful() throws { #if compiler(<5.2) return - #elseif compiler(<5.5) || !canImport(_Concurrency) + #elseif compiler(<5.5) + throw XCTSkip() + #elseif !canImport(_Concurrency) throw XCTSkip() #else guard #available(macOS 12.0, *) else { @@ -1473,7 +1477,9 @@ final class ComponentLifecycleTests: XCTestCase { func testAsyncAwaitErrorOnStart() throws { #if compiler(<5.2) return - #elseif compiler(<5.5) || !canImport(_Concurrency) + #elseif compiler(<5.5) + throw XCTSkip() + #elseif !canImport(_Concurrency) throw XCTSkip() #else guard #available(macOS 12.0, *) else { @@ -1509,7 +1515,9 @@ final class ComponentLifecycleTests: XCTestCase { func testAsyncAwaitErrorOnStartShutdownRequested() throws { #if compiler(<5.2) return - #elseif compiler(<5.5) || !canImport(_Concurrency) + #elseif compiler(<5.5) + throw XCTSkip() + #elseif !canImport(_Concurrency) throw XCTSkip() #else guard #available(macOS 12.0, *) else { @@ -1545,7 +1553,9 @@ final class ComponentLifecycleTests: XCTestCase { func testAsyncAwaitErrorOnShutdown() throws { #if compiler(<5.2) return - #elseif compiler(<5.5) || !canImport(_Concurrency) + #elseif compiler(<5.5) + throw XCTSkip() + #elseif !canImport(_Concurrency) throw XCTSkip() #else guard #available(macOS 12.0, *) else {