summaryrefslogtreecommitdiff
path: root/std/fs
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2020-09-08 17:43:43 +0800
committerGitHub <noreply@github.com>2020-09-08 11:43:43 +0200
commitc5d50737f05f6b1999d1973ba5bd260473aadcbd (patch)
treef26e7c101a199f3a4df5f9f119ce68011a5bf370 /std/fs
parent334ed0e2f42f146b68aa996d26b1fe34f751fe3e (diff)
test(std/fs): make tests runnable from any directory (#7388)
Diffstat (limited to 'std/fs')
-rw-r--r--std/fs/_util_test.ts3
-rw-r--r--std/fs/copy_test.ts3
-rw-r--r--std/fs/empty_dir_test.ts3
-rw-r--r--std/fs/ensure_dir_test.ts3
-rw-r--r--std/fs/ensure_file_test.ts3
-rw-r--r--std/fs/ensure_link_test.ts3
-rw-r--r--std/fs/ensure_symlink_test.ts3
-rw-r--r--std/fs/exists_test.ts3
-rw-r--r--std/fs/move_test.ts3
9 files changed, 18 insertions, 9 deletions
diff --git a/std/fs/_util_test.ts b/std/fs/_util_test.ts
index a05f2cb2d..b5fdfe40b 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 d21524505..db9451200 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 b71ae16f8..851fe37b9 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<void> {
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 c24e14d1a..29a7913b1 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<void> {
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 d87de0051..ee21e7b88 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<void> {
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 d4f2f30c2..2b4cfc66c 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<void> {
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 bc0741fed..4461f8f87 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<void> {
const testDir = path.join(testdataDir, "link_file_1");
diff --git a/std/fs/exists_test.ts b/std/fs/exists_test.ts
index 5f3c85650..f4088e03a 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<void> {
assertEquals(
diff --git a/std/fs/move_test.ts b/std/fs/move_test.ts
index 73a96ce46..7bc7e8fee 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<void> {
const srcDir = path.join(testdataDir, "move_test_src_1");