From 932ab4ab80346219d3341551bf13628d573356af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Fri, 23 Feb 2024 11:57:33 +0100 Subject: [PATCH] Fix test cases for Windows. --- tests/vibe.http.client.1389/source/app.d | 13 +++++++++---- tests/vibe.http.client.1426/source/app.d | 7 +++++-- tests/vibe.http.server.listenHTTP/source/app.d | 6 ++++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/tests/vibe.http.client.1389/source/app.d b/tests/vibe.http.client.1389/source/app.d index a506055..761983e 100644 --- a/tests/vibe.http.client.1389/source/app.d +++ b/tests/vibe.http.client.1389/source/app.d @@ -30,10 +30,15 @@ shared static this() auto url = "http://"~serverAddr.toString; logInfo(url); - auto cs = new HTTPClientSettings; - cs.networkInterface = resolveHost("127.0.0.1"); - auto res = requestHTTP(url, null, cs).bodyReader.readAllUTF8(); - assert(res == "local", "Unexpected reply: "~res); + string res; + + version (Windows) {} + else { + auto cs = new HTTPClientSettings; + cs.networkInterface = resolveHost("127.0.0.1"); + res = requestHTTP(url, null, cs).bodyReader.readAllUTF8(); + assert(res == "local", "Unexpected reply: "~res); + } auto cs2 = new HTTPClientSettings; cs2.networkInterface = resolveHost(externalAddr.toAddressString()); diff --git a/tests/vibe.http.client.1426/source/app.d b/tests/vibe.http.client.1426/source/app.d index bfb1072..6b50478 100644 --- a/tests/vibe.http.client.1426/source/app.d +++ b/tests/vibe.http.client.1426/source/app.d @@ -9,8 +9,11 @@ extern(C) __gshared string[] rt_options = [ "gcopt=parallel:0" ]; int main () { immutable serverAddr = listenTCP(0, (TCPConnection c) @safe nothrow { - try c.write("HTTP/1.1 200 OK\r\nConnection: Close\r\n\r\nqwerty"); - catch (Exception e) assert(0, e.msg); + try { + // skip request + c.readUntil(cast(immutable(ubyte)[])"\r\n\r\n"); + c.write("HTTP/1.1 200 OK\r\nConnection: Close\r\n\r\nqwerty"); + } catch (Exception e) assert(0, e.msg); }, "127.0.0.1").bindAddress; runTask({ diff --git a/tests/vibe.http.server.listenHTTP/source/app.d b/tests/vibe.http.server.listenHTTP/source/app.d index 32bfc39..0bdbd71 100644 --- a/tests/vibe.http.server.listenHTTP/source/app.d +++ b/tests/vibe.http.server.listenHTTP/source/app.d @@ -9,9 +9,11 @@ import std.socket : AddressFamily; shared static this() { - immutable serverAddr = listenHTTP(":0", (scope req, scope res) { + immutable serverPort = listenHTTP(":0", (scope req, scope res) { res.writeBody("Hello world."); - }).bindAddresses.find!(addr => addr.family == AddressFamily.INET).front; + }).bindAddresses.find!(addr => addr.family == AddressFamily.INET).front.port; + auto serverAddr = resolveHost("127.0.0.1"); + serverAddr.port = serverPort; runTask({ scope (exit) exitEventLoop();