diff --git a/std/fs/_util_test.ts b/std/fs/_util_test.ts index a05f2cb2d0..b5fdfe40b7 100644 --- a/std/fs/_util_test.ts +++ b/std/fs/_util_test.ts @@ -6,7 +6,8 @@ import { isSubdir, getFileInfoType, PathType } from "./_util.ts"; import { ensureFileSync } from "./ensure_file.ts"; import { ensureDirSync } from "./ensure_dir.ts"; -const testdataDir = path.resolve("fs", "testdata"); +const moduleDir = path.dirname(path.fromFileUrl(import.meta.url)); +const testdataDir = path.resolve(moduleDir, "testdata"); Deno.test("_isSubdir", function (): void { const pairs = [ diff --git a/std/fs/copy_test.ts b/std/fs/copy_test.ts index d215245050..db94512004 100644 --- a/std/fs/copy_test.ts +++ b/std/fs/copy_test.ts @@ -12,7 +12,8 @@ import { ensureDir, ensureDirSync } from "./ensure_dir.ts"; import { ensureFile, ensureFileSync } from "./ensure_file.ts"; import { ensureSymlink, ensureSymlinkSync } from "./ensure_symlink.ts"; -const testdataDir = path.resolve("fs", "testdata"); +const moduleDir = path.dirname(path.fromFileUrl(import.meta.url)); +const testdataDir = path.resolve(moduleDir, "testdata"); function testCopy( name: string, diff --git a/std/fs/empty_dir_test.ts b/std/fs/empty_dir_test.ts index b71ae16f8d..851fe37b96 100644 --- a/std/fs/empty_dir_test.ts +++ b/std/fs/empty_dir_test.ts @@ -9,7 +9,8 @@ import { import * as path from "../path/mod.ts"; import { emptyDir, emptyDirSync } from "./empty_dir.ts"; -const testdataDir = path.resolve("fs", "testdata"); +const moduleDir = path.dirname(path.fromFileUrl(import.meta.url)); +const testdataDir = path.resolve(moduleDir, "testdata"); Deno.test("emptyDirIfItNotExist", async function (): Promise { const testDir = path.join(testdataDir, "empty_dir_test_1"); diff --git a/std/fs/ensure_dir_test.ts b/std/fs/ensure_dir_test.ts index c24e14d1a1..29a7913b1a 100644 --- a/std/fs/ensure_dir_test.ts +++ b/std/fs/ensure_dir_test.ts @@ -4,7 +4,8 @@ import * as path from "../path/mod.ts"; import { ensureDir, ensureDirSync } from "./ensure_dir.ts"; import { ensureFile, ensureFileSync } from "./ensure_file.ts"; -const testdataDir = path.resolve("fs", "testdata"); +const moduleDir = path.dirname(path.fromFileUrl(import.meta.url)); +const testdataDir = path.resolve(moduleDir, "testdata"); Deno.test("ensureDirIfItNotExist", async function (): Promise { const baseDir = path.join(testdataDir, "ensure_dir_not_exist"); diff --git a/std/fs/ensure_file_test.ts b/std/fs/ensure_file_test.ts index d87de00518..ee21e7b882 100644 --- a/std/fs/ensure_file_test.ts +++ b/std/fs/ensure_file_test.ts @@ -3,7 +3,8 @@ import { assertThrows, assertThrowsAsync } from "../testing/asserts.ts"; import * as path from "../path/mod.ts"; import { ensureFile, ensureFileSync } from "./ensure_file.ts"; -const testdataDir = path.resolve("fs", "testdata"); +const moduleDir = path.dirname(path.fromFileUrl(import.meta.url)); +const testdataDir = path.resolve(moduleDir, "testdata"); Deno.test("ensureFileIfItNotExist", async function (): Promise { const testDir = path.join(testdataDir, "ensure_file_1"); diff --git a/std/fs/ensure_link_test.ts b/std/fs/ensure_link_test.ts index d4f2f30c28..2b4cfc66c3 100644 --- a/std/fs/ensure_link_test.ts +++ b/std/fs/ensure_link_test.ts @@ -8,7 +8,8 @@ import { import * as path from "../path/mod.ts"; import { ensureLink, ensureLinkSync } from "./ensure_link.ts"; -const testdataDir = path.resolve("fs", "testdata"); +const moduleDir = path.dirname(path.fromFileUrl(import.meta.url)); +const testdataDir = path.resolve(moduleDir, "testdata"); Deno.test("ensureLinkIfItNotExist", async function (): Promise { const srcDir = path.join(testdataDir, "ensure_link_1"); diff --git a/std/fs/ensure_symlink_test.ts b/std/fs/ensure_symlink_test.ts index bc0741fed6..4461f8f87f 100644 --- a/std/fs/ensure_symlink_test.ts +++ b/std/fs/ensure_symlink_test.ts @@ -8,7 +8,8 @@ import { import * as path from "../path/mod.ts"; import { ensureSymlink, ensureSymlinkSync } from "./ensure_symlink.ts"; -const testdataDir = path.resolve("fs", "testdata"); +const moduleDir = path.dirname(path.fromFileUrl(import.meta.url)); +const testdataDir = path.resolve(moduleDir, "testdata"); Deno.test("ensureSymlinkIfItNotExist", async function (): Promise { const testDir = path.join(testdataDir, "link_file_1"); diff --git a/std/fs/exists_test.ts b/std/fs/exists_test.ts index 5f3c856508..f4088e03a3 100644 --- a/std/fs/exists_test.ts +++ b/std/fs/exists_test.ts @@ -3,7 +3,8 @@ import { assertEquals, assertStringContains } from "../testing/asserts.ts"; import * as path from "../path/mod.ts"; import { exists, existsSync } from "./exists.ts"; -const testdataDir = path.resolve("fs", "testdata"); +const moduleDir = path.dirname(path.fromFileUrl(import.meta.url)); +const testdataDir = path.resolve(moduleDir, "testdata"); Deno.test("[fs] existsFile", async function (): Promise { assertEquals( diff --git a/std/fs/move_test.ts b/std/fs/move_test.ts index 73a96ce465..7bc7e8fee8 100644 --- a/std/fs/move_test.ts +++ b/std/fs/move_test.ts @@ -10,7 +10,8 @@ import { ensureFile, ensureFileSync } from "./ensure_file.ts"; import { ensureDir, ensureDirSync } from "./ensure_dir.ts"; import { exists, existsSync } from "./exists.ts"; -const testdataDir = path.resolve("fs", "testdata"); +const moduleDir = path.dirname(path.fromFileUrl(import.meta.url)); +const testdataDir = path.resolve(moduleDir, "testdata"); Deno.test("moveDirectoryIfSrcNotExists", async function (): Promise { const srcDir = path.join(testdataDir, "move_test_src_1");