From 7a8b27aa25b419a9daef976793c59bd22d35551a Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Mon, 7 Sep 2020 17:32:24 +0800 Subject: test(std/hash): make tests runnable from any directory (#7376) --- std/hash/sha1_test.ts | 5 +++-- std/hash/sha256_test.ts | 5 +++-- std/hash/sha512_test.ts | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) (limited to 'std/hash') 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 { -- cgit v1.2.3