summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2020-09-07 17:32:24 +0800
committerGitHub <noreply@github.com>2020-09-07 11:32:24 +0200
commit7a8b27aa25b419a9daef976793c59bd22d35551a (patch)
tree18d6e1687a973177013035d7d2992190a0c2a4eb
parentf57a2c1e85387afe48b7bdb57176dafb156bb86e (diff)
test(std/hash): make tests runnable from any directory (#7376)
-rw-r--r--std/hash/sha1_test.ts5
-rw-r--r--std/hash/sha256_test.ts5
-rw-r--r--std/hash/sha512_test.ts5
3 files changed, 9 insertions, 6 deletions
diff --git a/std/hash/sha1_test.ts b/std/hash/sha1_test.ts
index 25571947f..89c60fe52 100644
--- a/std/hash/sha1_test.ts
+++ b/std/hash/sha1_test.ts
@@ -1,9 +1,10 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "../testing/asserts.ts";
import { Sha1, Message } from "./sha1.ts";
-import { join, resolve } from "../path/mod.ts";
+import { dirname, join, resolve, fromFileUrl } from "../path/mod.ts";
-const testdataDir = resolve("hash", "testdata");
+const moduleDir = dirname(fromFileUrl(import.meta.url));
+const testdataDir = resolve(moduleDir, "testdata");
/** Handy function to convert an array/array buffer to a string of hex values. */
function toHexString(value: number[] | ArrayBuffer): string {
diff --git a/std/hash/sha256_test.ts b/std/hash/sha256_test.ts
index ba7efe4d1..fd9c227f4 100644
--- a/std/hash/sha256_test.ts
+++ b/std/hash/sha256_test.ts
@@ -1,9 +1,10 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { Sha256, HmacSha256, Message } from "./sha256.ts";
import { assertEquals } from "../testing/asserts.ts";
-import { join, resolve } from "../path/mod.ts";
+import { dirname, join, resolve, fromFileUrl } from "../path/mod.ts";
-const testdataDir = resolve("hash", "testdata");
+const moduleDir = dirname(fromFileUrl(import.meta.url));
+const testdataDir = resolve(moduleDir, "testdata");
/** Handy function to convert an array/array buffer to a string of hex values. */
function toHexString(value: number[] | ArrayBuffer): string {
diff --git a/std/hash/sha512_test.ts b/std/hash/sha512_test.ts
index d8d69a923..ee49a229d 100644
--- a/std/hash/sha512_test.ts
+++ b/std/hash/sha512_test.ts
@@ -1,9 +1,10 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { Sha512, HmacSha512, Message } from "./sha512.ts";
import { assertEquals } from "../testing/asserts.ts";
-import { join, resolve } from "../path/mod.ts";
+import { dirname, join, resolve, fromFileUrl } from "../path/mod.ts";
-const testdataDir = resolve("hash", "testdata");
+const moduleDir = dirname(fromFileUrl(import.meta.url));
+const testdataDir = resolve(moduleDir, "testdata");
/** Handy function to convert an array/array buffer to a string of hex values. */
function toHexString(value: number[] | ArrayBuffer): string {