From 3780e04b6f64f387364d1061ef41dc287d0fc79a Mon Sep 17 00:00:00 2001 From: keroxp Date: Sun, 22 Mar 2020 16:10:54 +0900 Subject: [PATCH 1/4] fix: re-enable chast server example tests - fixes #4108 --- std/examples/chat/server_test.ts | 7 +------ std/http/server_test.ts | 6 +++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/std/examples/chat/server_test.ts b/std/examples/chat/server_test.ts index e09771e5208c6a..190b13cc06d98d 100644 --- a/std/examples/chat/server_test.ts +++ b/std/examples/chat/server_test.ts @@ -8,7 +8,7 @@ import { delay } from "../../util/async.ts"; const port = randomPort(); -const { test, build } = Deno; +const { test } = Deno; async function startServer(): Promise { const server = Deno.run({ @@ -35,11 +35,7 @@ async function startServer(): Promise { return server; } -// TODO: https://github.com/denoland/deno/issues/4108 -const ignore = build.os == "win"; - test({ - ignore, name: "GET / should serve html", async fn() { const server = await startServer(); @@ -58,7 +54,6 @@ test({ }); test({ - ignore, name: "GET /ws should upgrade conn to ws", async fn() { const server = await startServer(); diff --git a/std/http/server_test.ts b/std/http/server_test.ts index d9ce3ba970849a..9572604566dc77 100644 --- a/std/http/server_test.ts +++ b/std/http/server_test.ts @@ -473,10 +473,10 @@ test({ await req.respond({ body: new TextEncoder().encode(req.url) }); } } - - const server = serve(":8123"); + const port = randomPort(); + const server = serve({ port }); const p = iteratorReq(server); - const conn = await Deno.connect({ hostname: "127.0.0.1", port: 8123 }); + const conn = await Deno.connect({ hostname: "127.0.0.1", port }); await Deno.writeAll( conn, new TextEncoder().encode("GET /hello HTTP/1.1\r\n\r\n") From baccc2e6df22e1d701220e85b2116584305706ad Mon Sep 17 00:00:00 2001 From: keroxp Date: Sun, 22 Mar 2020 16:44:04 +0900 Subject: [PATCH 2/4] Update server_test.ts --- std/examples/chat/server_test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/examples/chat/server_test.ts b/std/examples/chat/server_test.ts index 190b13cc06d98d..d8c15f3f28b59e 100644 --- a/std/examples/chat/server_test.ts +++ b/std/examples/chat/server_test.ts @@ -16,7 +16,7 @@ async function startServer(): Promise { Deno.execPath(), "--allow-net", "--allow-read", - "server.ts", + "examples/chat/server.ts", `127.0.0.1:${port}` ], cwd: "examples/chat", From ce39064495a456d2f15d0975ff38f158ee8b049c Mon Sep 17 00:00:00 2001 From: keroxp Date: Sun, 22 Mar 2020 17:18:35 +0900 Subject: [PATCH 3/4] Update server_test.ts --- std/examples/chat/server_test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/examples/chat/server_test.ts b/std/examples/chat/server_test.ts index d8c15f3f28b59e..dd03658f55f7e2 100644 --- a/std/examples/chat/server_test.ts +++ b/std/examples/chat/server_test.ts @@ -16,7 +16,7 @@ async function startServer(): Promise { Deno.execPath(), "--allow-net", "--allow-read", - "examples/chat/server.ts", + "./server.ts", `127.0.0.1:${port}` ], cwd: "examples/chat", From eb416afe2dc8ddeebbb9a0320e30d3616c807702 Mon Sep 17 00:00:00 2001 From: keroxp Date: Sun, 22 Mar 2020 17:36:44 +0900 Subject: [PATCH 4/4] Update server.ts --- std/examples/chat/server.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/std/examples/chat/server.ts b/std/examples/chat/server.ts index d28f9f43fc324e..e6b8cd9b005cee 100644 --- a/std/examples/chat/server.ts +++ b/std/examples/chat/server.ts @@ -1,4 +1,5 @@ import { listenAndServe } from "../../http/server.ts"; +import * as path from "../../path/mod.ts"; import { acceptWebSocket, acceptable, @@ -48,7 +49,7 @@ listenAndServe(addr, async req => { }); } else { // server launched by deno run ./server.ts - const file = await Deno.open(u.pathname); + const file = await Deno.open(path.resolve(u.href)); req.respond({ status: 200, headers: new Headers({