From b82a6001b7b65c907940d33f7ced8020cbb05b49 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 10 Feb 2023 12:54:41 -0800 Subject: [PATCH 1/3] Revert "[Wrangle] Temporarily revert noasync annotation" This reverts commit 3d75b96ef9359dc23eb897642e211626ee46ff28. --- Sources/TSCBasic/Await.swift | 12 ++++----- Sources/TSCBasic/Process.swift | 36 +++++++++++++------------- Sources/TSCBasic/ProcessSet.swift | 6 ++--- Tests/TSCBasicTests/ProcessTests.swift | 12 ++++----- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Sources/TSCBasic/Await.swift b/Sources/TSCBasic/Await.swift index d61fd4e3..1ee921e4 100644 --- a/Sources/TSCBasic/Await.swift +++ b/Sources/TSCBasic/Await.swift @@ -14,16 +14,16 @@ /// should be passed to the async method's completion handler. /// - Returns: The value wrapped by the async method's result. /// - Throws: The error wrapped by the async method's result -//#if compiler(>=5.8) -//@available(*, noasync) -//#endif +#if compiler(>=5.8) +@available(*, noasync) +#endif public func tsc_await(_ body: (@escaping (Result) -> Void) -> Void) throws -> T { return try tsc_await(body).get() } -//#if compiler(>=5.8) -//@available(*, noasync) -//#endif +#if compiler(>=5.8) +@available(*, noasync) +#endif public func tsc_await(_ body: (@escaping (T) -> Void) -> Void) -> T { let condition = Condition() var result: T? = nil diff --git a/Sources/TSCBasic/Process.swift b/Sources/TSCBasic/Process.swift index 6a7a4d43..6242106f 100644 --- a/Sources/TSCBasic/Process.swift +++ b/Sources/TSCBasic/Process.swift @@ -835,9 +835,9 @@ public final class Process { } /// Blocks the calling process until the subprocess finishes execution. -// #if compiler(>=5.8) -// @available(*, noasync) -// #endif + #if compiler(>=5.8) + @available(*, noasync) + #endif @discardableResult public func waitUntilExit() throws -> ProcessResult { let group = DispatchGroup() @@ -1060,9 +1060,9 @@ extension Process { /// - loggingHandler: Handler for logging messages /// - queue: Queue to use for callbacks /// - completion: A completion handler to return the process result -// #if compiler(>=5.8) -// @available(*, noasync) -// #endif + #if compiler(>=5.8) + @available(*, noasync) + #endif static public func popen( arguments: [String], environment: [String: String] = ProcessEnv.vars, @@ -1097,9 +1097,9 @@ extension Process { /// will be inherited. /// - loggingHandler: Handler for logging messages /// - Returns: The process result. -// #if compiler(>=5.8) -// @available(*, noasync) -// #endif + #if compiler(>=5.8) + @available(*, noasync) + #endif @discardableResult static public func popen( arguments: [String], @@ -1124,9 +1124,9 @@ extension Process { /// will be inherited. /// - loggingHandler: Handler for logging messages /// - Returns: The process result. -// #if compiler(>=5.8) -// @available(*, noasync) -// #endif + #if compiler(>=5.8) + @available(*, noasync) + #endif @discardableResult static public func popen( args: String..., @@ -1144,9 +1144,9 @@ extension Process { /// will be inherited. /// - loggingHandler: Handler for logging messages /// - Returns: The process output (stdout + stderr). -// #if compiler(>=5.8) -// @available(*, noasync) -// #endif + #if compiler(>=5.8) + @available(*, noasync) + #endif @discardableResult static public func checkNonZeroExit( arguments: [String], @@ -1176,9 +1176,9 @@ extension Process { /// will be inherited. /// - loggingHandler: Handler for logging messages /// - Returns: The process output (stdout + stderr). -// #if compiler(>=5.8) -// @available(*, noasync) -// #endif + #if compiler(>=5.8) + @available(*, noasync) + #endif @discardableResult static public func checkNonZeroExit( args: String..., diff --git a/Sources/TSCBasic/ProcessSet.swift b/Sources/TSCBasic/ProcessSet.swift index 724f6e32..2b519144 100644 --- a/Sources/TSCBasic/ProcessSet.swift +++ b/Sources/TSCBasic/ProcessSet.swift @@ -64,9 +64,9 @@ public final class ProcessSet { /// Terminate all the processes. This method blocks until all processes in the set are terminated. /// /// A process set cannot be used once it has been asked to terminate. -// #if compiler(>=5.8) -// @available(*, noasync) -// #endif + #if compiler(>=5.8) + @available(*, noasync) + #endif public func terminate() { // Mark a process set as cancelled. serialQueue.sync { diff --git a/Tests/TSCBasicTests/ProcessTests.swift b/Tests/TSCBasicTests/ProcessTests.swift index 1b329059..7ffc680d 100644 --- a/Tests/TSCBasicTests/ProcessTests.swift +++ b/Tests/TSCBasicTests/ProcessTests.swift @@ -479,9 +479,9 @@ fileprivate extension Process { self.init(arguments: [Self.script(scriptName)] + arguments, environment: Self.env(), outputRedirection: outputRedirection) } -// #if compiler(>=5.8) -// @available(*, noasync) -// #endif + #if compiler(>=5.8) + @available(*, noasync) + #endif static func checkNonZeroExit( scriptName: String, environment: [String: String] = ProcessEnv.vars, @@ -498,9 +498,9 @@ fileprivate extension Process { return try await checkNonZeroExit(args: script(scriptName), environment: environment, loggingHandler: loggingHandler) } -// #if compiler(>=5.8) -// @available(*, noasync) -// #endif + #if compiler(>=5.8) + @available(*, noasync) + #endif @discardableResult static func popen( scriptName: String, From 7bcb2bbce9a2a6f282a5d13324f3d577322822aa Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 10 Feb 2023 12:43:07 -0800 Subject: [PATCH 2/3] Fix iOS/tvOS/watchOS build by adding missing availability annotations --- Sources/TSCBasic/Process.swift | 8 ++++---- Tests/TSCBasicTests/ProcessTests.swift | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Sources/TSCBasic/Process.swift b/Sources/TSCBasic/Process.swift index 6242106f..f2dac50f 100644 --- a/Sources/TSCBasic/Process.swift +++ b/Sources/TSCBasic/Process.swift @@ -976,7 +976,7 @@ extension Process { /// - environment: The environment to pass to subprocess. By default the current process environment /// will be inherited. /// - loggingHandler: Handler for logging messages - @available(macOS 10.15, *) + @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) static public func popen( arguments: [String], environment: [String: String] = ProcessEnv.vars, @@ -999,7 +999,7 @@ extension Process { /// - environment: The environment to pass to subprocess. By default the current process environment /// will be inherited. /// - loggingHandler: Handler for logging messages - @available(macOS 10.15, *) + @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) static public func popen( args: String..., environment: [String: String] = ProcessEnv.vars, @@ -1016,7 +1016,7 @@ extension Process { /// will be inherited. /// - loggingHandler: Handler for logging messages /// - Returns: The process output (stdout + stderr). - @available(macOS 10.15, *) + @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) @discardableResult static public func checkNonZeroExit( arguments: [String], @@ -1039,7 +1039,7 @@ extension Process { /// will be inherited. /// - loggingHandler: Handler for logging messages /// - Returns: The process output (stdout + stderr). - @available(macOS 10.15, *) + @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) @discardableResult static public func checkNonZeroExit( args: String..., diff --git a/Tests/TSCBasicTests/ProcessTests.swift b/Tests/TSCBasicTests/ProcessTests.swift index 7ffc680d..fefcbb9f 100644 --- a/Tests/TSCBasicTests/ProcessTests.swift +++ b/Tests/TSCBasicTests/ProcessTests.swift @@ -89,6 +89,7 @@ class ProcessTests: XCTestCase { } } + @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) func testPopenAsync() async throws { #if os(Windows) let args = ["where.exe", "where"] @@ -122,6 +123,7 @@ class ProcessTests: XCTestCase { } } + @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) func testCheckNonZeroExitAsync() async throws { do { let output = try await Process.checkNonZeroExit(args: "echo", "hello") @@ -344,6 +346,7 @@ class ProcessTests: XCTestCase { } } + @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) func testStdoutStdErrAsync() async throws { // A simple script to check that stdout and stderr are captured separatly. do { @@ -490,6 +493,7 @@ fileprivate extension Process { return try checkNonZeroExit(args: script(scriptName), environment: environment, loggingHandler: loggingHandler) } + @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) static func checkNonZeroExit( scriptName: String, environment: [String: String] = ProcessEnv.vars, @@ -510,6 +514,7 @@ fileprivate extension Process { return try popen(arguments: [script(scriptName)], environment: Self.env(), loggingHandler: loggingHandler) } + @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) @discardableResult static func popen( scriptName: String, From 45e1b9921eb893f85ed5c73d76da3e65a3137630 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 10 Feb 2023 12:54:56 -0800 Subject: [PATCH 3/3] Revert "Revert "[Wrangle] Temporarily revert noasync annotation"" This reverts commit b82a6001b7b65c907940d33f7ced8020cbb05b49. --- Sources/TSCBasic/Await.swift | 12 ++++----- Sources/TSCBasic/Process.swift | 36 +++++++++++++------------- Sources/TSCBasic/ProcessSet.swift | 6 ++--- Tests/TSCBasicTests/ProcessTests.swift | 12 ++++----- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Sources/TSCBasic/Await.swift b/Sources/TSCBasic/Await.swift index 1ee921e4..d61fd4e3 100644 --- a/Sources/TSCBasic/Await.swift +++ b/Sources/TSCBasic/Await.swift @@ -14,16 +14,16 @@ /// should be passed to the async method's completion handler. /// - Returns: The value wrapped by the async method's result. /// - Throws: The error wrapped by the async method's result -#if compiler(>=5.8) -@available(*, noasync) -#endif +//#if compiler(>=5.8) +//@available(*, noasync) +//#endif public func tsc_await(_ body: (@escaping (Result) -> Void) -> Void) throws -> T { return try tsc_await(body).get() } -#if compiler(>=5.8) -@available(*, noasync) -#endif +//#if compiler(>=5.8) +//@available(*, noasync) +//#endif public func tsc_await(_ body: (@escaping (T) -> Void) -> Void) -> T { let condition = Condition() var result: T? = nil diff --git a/Sources/TSCBasic/Process.swift b/Sources/TSCBasic/Process.swift index f2dac50f..8d7111d4 100644 --- a/Sources/TSCBasic/Process.swift +++ b/Sources/TSCBasic/Process.swift @@ -835,9 +835,9 @@ public final class Process { } /// Blocks the calling process until the subprocess finishes execution. - #if compiler(>=5.8) - @available(*, noasync) - #endif +// #if compiler(>=5.8) +// @available(*, noasync) +// #endif @discardableResult public func waitUntilExit() throws -> ProcessResult { let group = DispatchGroup() @@ -1060,9 +1060,9 @@ extension Process { /// - loggingHandler: Handler for logging messages /// - queue: Queue to use for callbacks /// - completion: A completion handler to return the process result - #if compiler(>=5.8) - @available(*, noasync) - #endif +// #if compiler(>=5.8) +// @available(*, noasync) +// #endif static public func popen( arguments: [String], environment: [String: String] = ProcessEnv.vars, @@ -1097,9 +1097,9 @@ extension Process { /// will be inherited. /// - loggingHandler: Handler for logging messages /// - Returns: The process result. - #if compiler(>=5.8) - @available(*, noasync) - #endif +// #if compiler(>=5.8) +// @available(*, noasync) +// #endif @discardableResult static public func popen( arguments: [String], @@ -1124,9 +1124,9 @@ extension Process { /// will be inherited. /// - loggingHandler: Handler for logging messages /// - Returns: The process result. - #if compiler(>=5.8) - @available(*, noasync) - #endif +// #if compiler(>=5.8) +// @available(*, noasync) +// #endif @discardableResult static public func popen( args: String..., @@ -1144,9 +1144,9 @@ extension Process { /// will be inherited. /// - loggingHandler: Handler for logging messages /// - Returns: The process output (stdout + stderr). - #if compiler(>=5.8) - @available(*, noasync) - #endif +// #if compiler(>=5.8) +// @available(*, noasync) +// #endif @discardableResult static public func checkNonZeroExit( arguments: [String], @@ -1176,9 +1176,9 @@ extension Process { /// will be inherited. /// - loggingHandler: Handler for logging messages /// - Returns: The process output (stdout + stderr). - #if compiler(>=5.8) - @available(*, noasync) - #endif +// #if compiler(>=5.8) +// @available(*, noasync) +// #endif @discardableResult static public func checkNonZeroExit( args: String..., diff --git a/Sources/TSCBasic/ProcessSet.swift b/Sources/TSCBasic/ProcessSet.swift index 2b519144..724f6e32 100644 --- a/Sources/TSCBasic/ProcessSet.swift +++ b/Sources/TSCBasic/ProcessSet.swift @@ -64,9 +64,9 @@ public final class ProcessSet { /// Terminate all the processes. This method blocks until all processes in the set are terminated. /// /// A process set cannot be used once it has been asked to terminate. - #if compiler(>=5.8) - @available(*, noasync) - #endif +// #if compiler(>=5.8) +// @available(*, noasync) +// #endif public func terminate() { // Mark a process set as cancelled. serialQueue.sync { diff --git a/Tests/TSCBasicTests/ProcessTests.swift b/Tests/TSCBasicTests/ProcessTests.swift index fefcbb9f..cb5f98df 100644 --- a/Tests/TSCBasicTests/ProcessTests.swift +++ b/Tests/TSCBasicTests/ProcessTests.swift @@ -482,9 +482,9 @@ fileprivate extension Process { self.init(arguments: [Self.script(scriptName)] + arguments, environment: Self.env(), outputRedirection: outputRedirection) } - #if compiler(>=5.8) - @available(*, noasync) - #endif +// #if compiler(>=5.8) +// @available(*, noasync) +// #endif static func checkNonZeroExit( scriptName: String, environment: [String: String] = ProcessEnv.vars, @@ -502,9 +502,9 @@ fileprivate extension Process { return try await checkNonZeroExit(args: script(scriptName), environment: environment, loggingHandler: loggingHandler) } - #if compiler(>=5.8) - @available(*, noasync) - #endif +// #if compiler(>=5.8) +// @available(*, noasync) +// #endif @discardableResult static func popen( scriptName: String,