diff options
author | Casper Beyer <caspervonb@pm.me> | 2020-09-10 02:57:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-09 20:57:49 +0200 |
commit | 5b89e82164f997da863f92c829ff026beabf5abe (patch) | |
tree | 60461ce91f3f3976115a7535dd2bc6b9fe3a5f81 /std/examples/test.ts | |
parent | 25053f92ffcefa7659ac8c7b1aa2d80986942c4f (diff) |
test(std/examples): make tests runnable from any directory (#7399)
Diffstat (limited to 'std/examples/test.ts')
-rw-r--r-- | std/examples/test.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/std/examples/test.ts b/std/examples/test.ts index 20db3fb1d..a8ac8c74e 100644 --- a/std/examples/test.ts +++ b/std/examples/test.ts @@ -1,5 +1,8 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { assertEquals } from "../testing/asserts.ts"; +import { dirname, relative, resolve, fromFileUrl } from "../path/mod.ts"; + +const moduleDir = dirname(fromFileUrl(import.meta.url)); /** Example of how to do basic tests */ Deno.test("t1", function (): void { @@ -17,8 +20,8 @@ Deno.test("catSmoke", async function (): Promise<void> { Deno.execPath(), "run", "--allow-read", - "examples/cat.ts", - "README.md", + relative(Deno.cwd(), resolve(moduleDir, "cat.ts")), + relative(Deno.cwd(), resolve(moduleDir, "..", "README.md")), ], stdout: "null", stderr: "null", |