diff options
author | Casper Beyer <caspervonb@pm.me> | 2020-09-14 18:58:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-14 12:58:43 +0200 |
commit | bee36a4de8516aa222bbb2b6650974bdd7cb57f4 (patch) | |
tree | 68abd673e6fa3e1fbcf68772e79eb904680e4d16 /std/http/racing_server_test.ts | |
parent | f874b83aa06c183400bbe04bc35e87acbaad9699 (diff) |
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.
Diffstat (limited to 'std/http/racing_server_test.ts')
-rw-r--r-- | std/http/racing_server_test.ts | 6 |
1 files changed, 5 insertions, 1 deletions
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<Deno.RunOptions & { stdout: "piped" }>; async function startServer(): Promise<void> { 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. |