From bee36a4de8516aa222bbb2b6650974bdd7cb57f4 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Mon, 14 Sep 2020 18:58:43 +0800 Subject: test(std/http): make tests runnable from any directory (#7441) This makes std/http tests runnable from any directory by spawning test processes in the module directory resolved from import.meta.url and resolving test data relative to the same module directory. --- std/http/racing_server_test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'std/http/racing_server_test.ts') diff --git a/std/http/racing_server_test.ts b/std/http/racing_server_test.ts index 8daf7c4dc..88ef3ab2f 100644 --- a/std/http/racing_server_test.ts +++ b/std/http/racing_server_test.ts @@ -1,11 +1,15 @@ import { assert, assertEquals } from "../testing/asserts.ts"; import { BufReader, BufWriter } from "../io/bufio.ts"; import { TextProtoReader } from "../textproto/mod.ts"; +import { dirname, fromFileUrl } from "../path/mod.ts"; + +const moduleDir = dirname(fromFileUrl(import.meta.url)); let server: Deno.Process; async function startServer(): Promise { server = Deno.run({ - cmd: [Deno.execPath(), "run", "-A", "http/racing_server.ts"], + cmd: [Deno.execPath(), "run", "-A", "racing_server.ts"], + cwd: moduleDir, stdout: "piped", }); // Once racing server is ready it will write to its stdout. -- cgit v1.2.3