diff --git a/Sources/Core/Process+Execute.swift b/Sources/Core/Process+Execute.swift index 48bb6ff0..96012811 100644 --- a/Sources/Core/Process+Execute.swift +++ b/Sources/Core/Process+Execute.swift @@ -1,4 +1,4 @@ -#if !os(iOS) +#if !os(iOS) && !os(tvOS) && !os(watchOS) import NIO /// Different types of process output. @@ -97,7 +97,7 @@ extension Process { // will be set to false when the program is done var running = true - + // readabilityHandler doesn't work on linux, so we are left with this hack DispatchQueue.global().async { while running { diff --git a/Sources/Core/Thread+Async.swift b/Sources/Core/Thread+Async.swift index f1586535..e132730e 100644 --- a/Sources/Core/Thread+Async.swift +++ b/Sources/Core/Thread+Async.swift @@ -18,10 +18,10 @@ extension Thread { /// - parameters: /// - work: Closure to be called on new thread. public static func async(_ work: @escaping () -> Void) { - if #available(macOS 10.12, iOS 10.0, *) { + if #available(macOS 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *) { Thread.detachNewThread(work) } else { - fatalError("macOS 10.12/iOS 10.0 or later required to call Thread.async(_:)") + fatalError("macOS 10.12/iOS 10.0/tvOS 10.0/watchOS 3.0 or later required to call Thread.async(_:)") } } } diff --git a/Tests/CoreTests/CoreTests.swift b/Tests/CoreTests/CoreTests.swift index 63b336db..6bf5ff8a 100644 --- a/Tests/CoreTests/CoreTests.swift +++ b/Tests/CoreTests/CoreTests.swift @@ -3,15 +3,20 @@ import XCTest class CoreTests: XCTestCase { func testProcessExecute() throws { + #if !os(iOS) && !os(tvOS) && !os(watchOS) try XCTAssertEqual(Process.execute("/bin/echo", "hi"), "hi") + #endif } func testProcessExecuteCurl() throws { + #if !os(iOS) && !os(tvOS) && !os(watchOS) let res = try Process.execute("/usr/bin/curl", "--verbose", "https://vapor.codes") XCTAssertEqual(res.contains("Vapor"), true) + #endif } func testProcessAsyncExecute() throws { + #if !os(iOS) && !os(tvOS) && !os(watchOS) let eventLoop = MultiThreadedEventLoopGroup(numberOfThreads: 1) var lastOutput: ProcessOutput? let status = try Process.asyncExecute("/bin/echo", "hi", on: eventLoop) { output in @@ -26,10 +31,13 @@ class CoreTests: XCTestCase { } else { XCTFail("no output") } + #endif } func testProcessExecuteMissing() throws { + #if !os(iOS) && !os(tvOS) && !os(watchOS) XCTAssertThrowsError(try Process.execute("foo", "hi"), "hi") + #endif } func testBase64() {