From 45f51db3ffdefc1436a7aefe8b9990bec45fa0f5 Mon Sep 17 00:00:00 2001 From: Tim <0xtimc@gmail.com> Date: Tue, 30 Apr 2024 12:55:44 +0100 Subject: [PATCH 1/2] Stop test failing on Linux --- Tests/VaporTests/PipelineTests.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Tests/VaporTests/PipelineTests.swift b/Tests/VaporTests/PipelineTests.swift index 063fe242dd..6cc2e85b2d 100644 --- a/Tests/VaporTests/PipelineTests.swift +++ b/Tests/VaporTests/PipelineTests.swift @@ -86,7 +86,9 @@ final class PipelineTests: XCTestCase { })) } - try app.start() + app.environment.arguments = ["serve"] + app.http.server.configuration.port = 0 + try await app.startup() guard let localAddress = app.http.server.shared.localAddress, @@ -96,7 +98,7 @@ final class PipelineTests: XCTestCase { return } - let client = HTTPClient(eventLoopGroupProvider: .createNew) + let client = HTTPClient() let chunks = [ "1\r\n", From fea72c4db3227670a2476552964bd5b0a9829618 Mon Sep 17 00:00:00 2001 From: Tim <0xtimc@gmail.com> Date: Tue, 30 Apr 2024 12:58:08 +0100 Subject: [PATCH 2/2] Fix Sendable warning in tests --- Tests/VaporTests/PipelineTests.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Tests/VaporTests/PipelineTests.swift b/Tests/VaporTests/PipelineTests.swift index 6cc2e85b2d..c000b477c1 100644 --- a/Tests/VaporTests/PipelineTests.swift +++ b/Tests/VaporTests/PipelineTests.swift @@ -4,6 +4,7 @@ import XCTest import AsyncHTTPClient import NIOEmbedded import NIOCore +import NIOConcurrencyHelpers final class PipelineTests: XCTestCase { var app: Application! @@ -113,14 +114,15 @@ final class PipelineTests: XCTestCase { ] let response = try await client.post(url: "http://localhost:\(port)/echo", body: .stream { writer in + let box = UnsafeMutableTransferBox(writer) @Sendable func write(chunks: [String]) -> EventLoopFuture { var chunks = chunks let chunk = chunks.removeFirst() if chunks.isEmpty { - return writer.write(.byteBuffer(ByteBuffer(string: chunk))) + return box.wrappedValue.write(.byteBuffer(ByteBuffer(string: chunk))) } else { - return writer.write(.byteBuffer(ByteBuffer(string: chunk))).flatMap { [chunks] in + return box.wrappedValue.write(.byteBuffer(ByteBuffer(string: chunk))).flatMap { [chunks] in return write(chunks: chunks) } }