From bf82d9a84e935e6d9e6642faf5bb54b870905bd6 Mon Sep 17 00:00:00 2001 From: Adam Fowler Date: Fri, 26 Nov 2021 10:59:40 +0000 Subject: [PATCH] Disable Async Tests for macOS CI (#115) --- .../FileTests+async.swift | 8 +++++ .../HummingbirdJobsTests.swift | 4 +++ Tests/HummingbirdTests/AsyncAwaitTests.swift | 16 ++++++++++ .../HummingbirdTests/PersistTests+async.swift | 32 +++++++++++++++++++ 4 files changed, 60 insertions(+) diff --git a/Tests/HummingbirdFoundationTests/FileTests+async.swift b/Tests/HummingbirdFoundationTests/FileTests+async.swift index 36214b6ac..ee7da76f9 100644 --- a/Tests/HummingbirdFoundationTests/FileTests+async.swift +++ b/Tests/HummingbirdFoundationTests/FileTests+async.swift @@ -29,6 +29,10 @@ class HummingbirdAsyncFilesTests: XCTestCase { } func testRead() throws { + #if os(macOS) + // disable macOS tests in CI. GH Actions are currently running this when they shouldn't + guard HBEnvironment().get("CI") != "true" else { throw XCTSkip() } + #endif let app = HBApplication(testing: .live) app.router.get("test.jpg") { request -> HBResponse in let fileIO = HBFileIO(application: request.application) @@ -50,6 +54,10 @@ class HummingbirdAsyncFilesTests: XCTestCase { } func testWrite() throws { + #if os(macOS) + // disable macOS tests in CI. GH Actions are currently running this when they shouldn't + guard HBEnvironment().get("CI") != "true" else { throw XCTSkip() } + #endif let filename = "testWrite.txt" let app = HBApplication(testing: .live) app.router.put("store") { request -> HTTPResponseStatus in diff --git a/Tests/HummingbirdJobsTests/HummingbirdJobsTests.swift b/Tests/HummingbirdJobsTests/HummingbirdJobsTests.swift index 05c335d7e..6fb52afbf 100644 --- a/Tests/HummingbirdJobsTests/HummingbirdJobsTests.swift +++ b/Tests/HummingbirdJobsTests/HummingbirdJobsTests.swift @@ -270,6 +270,10 @@ final class HummingbirdJobsTests: XCTestCase { @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) func testAsyncJob() throws { + #if os(macOS) + // disable macOS tests in CI. GH Actions are currently running this when they shouldn't + guard HBEnvironment().get("CI") != "true" else { throw XCTSkip() } + #endif struct TestAsyncJob: HBAsyncJob { static let name = "testAsyncJob" static let expectation = XCTestExpectation(description: "Jobs Completed") diff --git a/Tests/HummingbirdTests/AsyncAwaitTests.swift b/Tests/HummingbirdTests/AsyncAwaitTests.swift index 21bec9c09..5eec8a8b2 100644 --- a/Tests/HummingbirdTests/AsyncAwaitTests.swift +++ b/Tests/HummingbirdTests/AsyncAwaitTests.swift @@ -32,6 +32,10 @@ final class AsyncAwaitTests: XCTestCase { } func testAsyncRoute() throws { + #if os(macOS) + // disable macOS tests in CI. GH Actions are currently running this when they shouldn't + guard HBEnvironment().get("CI") != "true" else { throw XCTSkip() } + #endif let app = HBApplication(testing: .live) app.router.get("/hello") { request -> ByteBuffer in return await self.getBuffer(request: request) @@ -48,6 +52,10 @@ final class AsyncAwaitTests: XCTestCase { } func testAsyncMiddleware() throws { + #if os(macOS) + // disable macOS tests in CI. GH Actions are currently running this when they shouldn't + guard HBEnvironment().get("CI") != "true" else { throw XCTSkip() } + #endif struct AsyncTestMiddleware: HBAsyncMiddleware { func apply(to request: HBRequest, next: HBResponder) async throws -> HBResponse { var response = try await next.respond(to: request) @@ -69,6 +77,10 @@ final class AsyncAwaitTests: XCTestCase { } func testAsyncRouteHandler() throws { + #if os(macOS) + // disable macOS tests in CI. GH Actions are currently running this when they shouldn't + guard HBEnvironment().get("CI") != "true" else { throw XCTSkip() } + #endif struct AsyncTest: HBAsyncRouteHandler { let name: String init(from request: HBRequest) throws { @@ -93,6 +105,10 @@ final class AsyncAwaitTests: XCTestCase { /// Test streaming of requests via AsyncSequence func testStreaming() throws { + #if os(macOS) + // disable macOS tests in CI. GH Actions are currently running this when they shouldn't + guard HBEnvironment().get("CI") != "true" else { throw XCTSkip() } + #endif let app = HBApplication(testing: .live) app.router.post("size", options: .streamBody) { request -> String in guard let stream = request.body.stream else { diff --git a/Tests/HummingbirdTests/PersistTests+async.swift b/Tests/HummingbirdTests/PersistTests+async.swift index 9c806fe39..87fce1588 100644 --- a/Tests/HummingbirdTests/PersistTests+async.swift +++ b/Tests/HummingbirdTests/PersistTests+async.swift @@ -50,6 +50,10 @@ final class AsyncPersistTests: XCTestCase { } func testSetGet() throws { + #if os(macOS) + // disable macOS tests in CI. GH Actions are currently running this when they shouldn't + guard HBEnvironment().get("CI") != "true" else { throw XCTSkip() } + #endif let app = try createApplication() try app.XCTStart() defer { app.XCTStop() } @@ -62,6 +66,10 @@ final class AsyncPersistTests: XCTestCase { } func testCreateGet() throws { + #if os(macOS) + // disable macOS tests in CI. GH Actions are currently running this when they shouldn't + guard HBEnvironment().get("CI") != "true" else { throw XCTSkip() } + #endif let app = try createApplication() app.router.put("/create/:tag") { request -> HTTPResponseStatus in guard let buffer = request.body.buffer else { throw HBHTTPError(.badRequest) } @@ -80,6 +88,10 @@ final class AsyncPersistTests: XCTestCase { } func testDoubleCreateFail() throws { + #if os(macOS) + // disable macOS tests in CI. GH Actions are currently running this when they shouldn't + guard HBEnvironment().get("CI") != "true" else { throw XCTSkip() } + #endif let app = try createApplication() app.router.put("/create/:tag") { request -> HTTPResponseStatus in guard let buffer = request.body.buffer else { throw HBHTTPError(.badRequest) } @@ -103,6 +115,10 @@ final class AsyncPersistTests: XCTestCase { } func testSetTwice() throws { + #if os(macOS) + // disable macOS tests in CI. GH Actions are currently running this when they shouldn't + guard HBEnvironment().get("CI") != "true" else { throw XCTSkip() } + #endif let app = try createApplication() try app.XCTStart() defer { app.XCTStop() } @@ -119,6 +135,10 @@ final class AsyncPersistTests: XCTestCase { } func testExpires() throws { + #if os(macOS) + // disable macOS tests in CI. GH Actions are currently running this when they shouldn't + guard HBEnvironment().get("CI") != "true" else { throw XCTSkip() } + #endif let app = try createApplication() try app.XCTStart() defer { app.XCTStop() } @@ -139,6 +159,10 @@ final class AsyncPersistTests: XCTestCase { } func testCodable() throws { + #if os(macOS) + // disable macOS tests in CI. GH Actions are currently running this when they shouldn't + guard HBEnvironment().get("CI") != "true" else { throw XCTSkip() } + #endif struct TestCodable: Codable { let buffer: String } @@ -166,6 +190,10 @@ final class AsyncPersistTests: XCTestCase { } func testRemove() throws { + #if os(macOS) + // disable macOS tests in CI. GH Actions are currently running this when they shouldn't + guard HBEnvironment().get("CI") != "true" else { throw XCTSkip() } + #endif let app = try createApplication() try app.XCTStart() defer { app.XCTStop() } @@ -179,6 +207,10 @@ final class AsyncPersistTests: XCTestCase { } func testExpireAndAdd() throws { + #if os(macOS) + // disable macOS tests in CI. GH Actions are currently running this when they shouldn't + guard HBEnvironment().get("CI") != "true" else { throw XCTSkip() } + #endif let app = try createApplication() try app.XCTStart() defer { app.XCTStop() }