summaryrefslogtreecommitdiff
path: root/std/fs
diff options
context:
space:
mode:
Diffstat (limited to 'std/fs')
-rw-r--r--std/fs/copy_test.ts5
-rw-r--r--std/fs/empty_dir_test.ts11
-rw-r--r--std/fs/ensure_dir_test.ts13
-rw-r--r--std/fs/ensure_file_test.ts13
-rw-r--r--std/fs/ensure_link_test.ts13
-rw-r--r--std/fs/ensure_symlink_test.ts13
-rw-r--r--std/fs/eol_test.ts11
-rw-r--r--std/fs/exists_test.ts15
-rw-r--r--std/fs/expand_glob_test.ts19
-rw-r--r--std/fs/move_test.ts29
-rw-r--r--std/fs/read_file_str_test.ts5
-rw-r--r--std/fs/read_json_test.ts25
-rw-r--r--std/fs/utils_test.ts5
-rw-r--r--std/fs/walk_test.ts7
-rw-r--r--std/fs/write_file_str_test.ts5
-rw-r--r--std/fs/write_json_test.ts21
16 files changed, 95 insertions, 115 deletions
diff --git a/std/fs/copy_test.ts b/std/fs/copy_test.ts
index 8134eb1d8..fb8827f0c 100644
--- a/std/fs/copy_test.ts
+++ b/std/fs/copy_test.ts
@@ -1,5 +1,4 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import { test } from "../testing/mod.ts";
import {
assertEquals,
assertThrows,
@@ -22,7 +21,7 @@ async function testCopy(
name: string,
cb: (tempDir: string) => Promise<void>
): Promise<void> {
- test({
+ Deno.test({
name,
async fn(): Promise<void> {
const tempDir = await Deno.makeTempDir({
@@ -35,7 +34,7 @@ async function testCopy(
}
function testCopySync(name: string, cb: (tempDir: string) => void): void {
- test({
+ Deno.test({
name,
fn: (): void => {
const tempDir = Deno.makeTempDirSync({
diff --git a/std/fs/empty_dir_test.ts b/std/fs/empty_dir_test.ts
index b9145767e..b27ebd033 100644
--- a/std/fs/empty_dir_test.ts
+++ b/std/fs/empty_dir_test.ts
@@ -1,5 +1,4 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import { test } from "../testing/mod.ts";
import {
assertEquals,
assertStrContains,
@@ -11,7 +10,7 @@ import { emptyDir, emptyDirSync } from "./empty_dir.ts";
const testdataDir = path.resolve("fs", "testdata");
-test(async function emptyDirIfItNotExist(): Promise<void> {
+Deno.test(async function emptyDirIfItNotExist(): Promise<void> {
const testDir = path.join(testdataDir, "empty_dir_test_1");
const testNestDir = path.join(testDir, "nest");
// empty a dir which not exist. then it will create new one
@@ -27,7 +26,7 @@ test(async function emptyDirIfItNotExist(): Promise<void> {
}
});
-test(function emptyDirSyncIfItNotExist(): void {
+Deno.test(function emptyDirSyncIfItNotExist(): void {
const testDir = path.join(testdataDir, "empty_dir_test_2");
const testNestDir = path.join(testDir, "nest");
// empty a dir which not exist. then it will create new one
@@ -43,7 +42,7 @@ test(function emptyDirSyncIfItNotExist(): void {
}
});
-test(async function emptyDirIfItExist(): Promise<void> {
+Deno.test(async function emptyDirIfItExist(): Promise<void> {
const testDir = path.join(testdataDir, "empty_dir_test_3");
const testNestDir = path.join(testDir, "nest");
// create test dir
@@ -86,7 +85,7 @@ test(async function emptyDirIfItExist(): Promise<void> {
}
});
-test(function emptyDirSyncIfItExist(): void {
+Deno.test(function emptyDirSyncIfItExist(): void {
const testDir = path.join(testdataDir, "empty_dir_test_4");
const testNestDir = path.join(testDir, "nest");
// create test dir
@@ -125,7 +124,7 @@ test(function emptyDirSyncIfItExist(): void {
}
});
-test(async function emptyDirPermission(): Promise<void> {
+Deno.test(async function emptyDirPermission(): Promise<void> {
interface Scenes {
read: boolean; // --allow-read
write: boolean; // --allow-write
diff --git a/std/fs/ensure_dir_test.ts b/std/fs/ensure_dir_test.ts
index 231196ae9..10c19c9c9 100644
--- a/std/fs/ensure_dir_test.ts
+++ b/std/fs/ensure_dir_test.ts
@@ -1,5 +1,4 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import { test } from "../testing/mod.ts";
import { assertThrows, assertThrowsAsync } from "../testing/asserts.ts";
import * as path from "../path/mod.ts";
import { ensureDir, ensureDirSync } from "./ensure_dir.ts";
@@ -7,7 +6,7 @@ import { ensureFile, ensureFileSync } from "./ensure_file.ts";
const testdataDir = path.resolve("fs", "testdata");
-test(async function ensureDirIfItNotExist(): Promise<void> {
+Deno.test(async function ensureDirIfItNotExist(): Promise<void> {
const baseDir = path.join(testdataDir, "ensure_dir_not_exist");
const testDir = path.join(baseDir, "test");
@@ -24,7 +23,7 @@ test(async function ensureDirIfItNotExist(): Promise<void> {
await Deno.remove(baseDir, { recursive: true });
});
-test(function ensureDirSyncIfItNotExist(): void {
+Deno.test(function ensureDirSyncIfItNotExist(): void {
const baseDir = path.join(testdataDir, "ensure_dir_sync_not_exist");
const testDir = path.join(baseDir, "test");
@@ -35,7 +34,7 @@ test(function ensureDirSyncIfItNotExist(): void {
Deno.removeSync(baseDir, { recursive: true });
});
-test(async function ensureDirIfItExist(): Promise<void> {
+Deno.test(async function ensureDirIfItExist(): Promise<void> {
const baseDir = path.join(testdataDir, "ensure_dir_exist");
const testDir = path.join(baseDir, "test");
@@ -55,7 +54,7 @@ test(async function ensureDirIfItExist(): Promise<void> {
await Deno.remove(baseDir, { recursive: true });
});
-test(function ensureDirSyncIfItExist(): void {
+Deno.test(function ensureDirSyncIfItExist(): void {
const baseDir = path.join(testdataDir, "ensure_dir_sync_exist");
const testDir = path.join(baseDir, "test");
@@ -72,7 +71,7 @@ test(function ensureDirSyncIfItExist(): void {
Deno.removeSync(baseDir, { recursive: true });
});
-test(async function ensureDirIfItAsFile(): Promise<void> {
+Deno.test(async function ensureDirIfItAsFile(): Promise<void> {
const baseDir = path.join(testdataDir, "ensure_dir_exist_file");
const testFile = path.join(baseDir, "test");
@@ -89,7 +88,7 @@ test(async function ensureDirIfItAsFile(): Promise<void> {
await Deno.remove(baseDir, { recursive: true });
});
-test(function ensureDirSyncIfItAsFile(): void {
+Deno.test(function ensureDirSyncIfItAsFile(): void {
const baseDir = path.join(testdataDir, "ensure_dir_exist_file_async");
const testFile = path.join(baseDir, "test");
diff --git a/std/fs/ensure_file_test.ts b/std/fs/ensure_file_test.ts
index a5d237e5f..92d5ac062 100644
--- a/std/fs/ensure_file_test.ts
+++ b/std/fs/ensure_file_test.ts
@@ -1,12 +1,11 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import { test } from "../testing/mod.ts";
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");
-test(async function ensureFileIfItNotExist(): Promise<void> {
+Deno.test(async function ensureFileIfItNotExist(): Promise<void> {
const testDir = path.join(testdataDir, "ensure_file_1");
const testFile = path.join(testDir, "test.txt");
@@ -23,7 +22,7 @@ test(async function ensureFileIfItNotExist(): Promise<void> {
await Deno.remove(testDir, { recursive: true });
});
-test(function ensureFileSyncIfItNotExist(): void {
+Deno.test(function ensureFileSyncIfItNotExist(): void {
const testDir = path.join(testdataDir, "ensure_file_2");
const testFile = path.join(testDir, "test.txt");
@@ -37,7 +36,7 @@ test(function ensureFileSyncIfItNotExist(): void {
Deno.removeSync(testDir, { recursive: true });
});
-test(async function ensureFileIfItExist(): Promise<void> {
+Deno.test(async function ensureFileIfItExist(): Promise<void> {
const testDir = path.join(testdataDir, "ensure_file_3");
const testFile = path.join(testDir, "test.txt");
@@ -57,7 +56,7 @@ test(async function ensureFileIfItExist(): Promise<void> {
await Deno.remove(testDir, { recursive: true });
});
-test(function ensureFileSyncIfItExist(): void {
+Deno.test(function ensureFileSyncIfItExist(): void {
const testDir = path.join(testdataDir, "ensure_file_4");
const testFile = path.join(testDir, "test.txt");
@@ -74,7 +73,7 @@ test(function ensureFileSyncIfItExist(): void {
Deno.removeSync(testDir, { recursive: true });
});
-test(async function ensureFileIfItExistAsDir(): Promise<void> {
+Deno.test(async function ensureFileIfItExistAsDir(): Promise<void> {
const testDir = path.join(testdataDir, "ensure_file_5");
await Deno.mkdir(testDir, { recursive: true });
@@ -90,7 +89,7 @@ test(async function ensureFileIfItExistAsDir(): Promise<void> {
await Deno.remove(testDir, { recursive: true });
});
-test(function ensureFileSyncIfItExistAsDir(): void {
+Deno.test(function ensureFileSyncIfItExistAsDir(): void {
const testDir = path.join(testdataDir, "ensure_file_6");
Deno.mkdirSync(testDir, { recursive: true });
diff --git a/std/fs/ensure_link_test.ts b/std/fs/ensure_link_test.ts
index daf216c49..6e9804152 100644
--- a/std/fs/ensure_link_test.ts
+++ b/std/fs/ensure_link_test.ts
@@ -1,6 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
// TODO(axetroy): Add test for Windows once symlink is implemented for Windows.
-import { test } from "../testing/mod.ts";
import {
assertEquals,
assertThrows,
@@ -11,7 +10,7 @@ import { ensureLink, ensureLinkSync } from "./ensure_link.ts";
const testdataDir = path.resolve("fs", "testdata");
-test(async function ensureLinkIfItNotExist(): Promise<void> {
+Deno.test(async function ensureLinkIfItNotExist(): Promise<void> {
const srcDir = path.join(testdataDir, "ensure_link_1");
const destDir = path.join(testdataDir, "ensure_link_1_2");
const testFile = path.join(srcDir, "test.txt");
@@ -26,7 +25,7 @@ test(async function ensureLinkIfItNotExist(): Promise<void> {
await Deno.remove(destDir, { recursive: true });
});
-test(function ensureLinkSyncIfItNotExist(): void {
+Deno.test(function ensureLinkSyncIfItNotExist(): void {
const testDir = path.join(testdataDir, "ensure_link_2");
const testFile = path.join(testDir, "test.txt");
const linkFile = path.join(testDir, "link.txt");
@@ -38,7 +37,7 @@ test(function ensureLinkSyncIfItNotExist(): void {
Deno.removeSync(testDir, { recursive: true });
});
-test(async function ensureLinkIfItExist(): Promise<void> {
+Deno.test(async function ensureLinkIfItExist(): Promise<void> {
const testDir = path.join(testdataDir, "ensure_link_3");
const testFile = path.join(testDir, "test.txt");
const linkFile = path.join(testDir, "link.txt");
@@ -85,7 +84,7 @@ test(async function ensureLinkIfItExist(): Promise<void> {
await Deno.remove(testDir, { recursive: true });
});
-test(function ensureLinkSyncIfItExist(): void {
+Deno.test(function ensureLinkSyncIfItExist(): void {
const testDir = path.join(testdataDir, "ensure_link_4");
const testFile = path.join(testDir, "test.txt");
const linkFile = path.join(testDir, "link.txt");
@@ -133,7 +132,7 @@ test(function ensureLinkSyncIfItExist(): void {
Deno.removeSync(testDir, { recursive: true });
});
-test(async function ensureLinkDirectoryIfItExist(): Promise<void> {
+Deno.test(async function ensureLinkDirectoryIfItExist(): Promise<void> {
const testDir = path.join(testdataDir, "ensure_link_origin_3");
const linkDir = path.join(testdataDir, "ensure_link_link_3");
const testFile = path.join(testDir, "test.txt");
@@ -153,7 +152,7 @@ test(async function ensureLinkDirectoryIfItExist(): Promise<void> {
Deno.removeSync(testDir, { recursive: true });
});
-test(function ensureLinkSyncDirectoryIfItExist(): void {
+Deno.test(function ensureLinkSyncDirectoryIfItExist(): void {
const testDir = path.join(testdataDir, "ensure_link_origin_3");
const linkDir = path.join(testdataDir, "ensure_link_link_3");
const testFile = path.join(testDir, "test.txt");
diff --git a/std/fs/ensure_symlink_test.ts b/std/fs/ensure_symlink_test.ts
index 0470af57e..8017bcebf 100644
--- a/std/fs/ensure_symlink_test.ts
+++ b/std/fs/ensure_symlink_test.ts
@@ -1,6 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
// TODO(axetroy): Add test for Windows once symlink is implemented for Windows.
-import { test } from "../testing/mod.ts";
import {
assertEquals,
assertThrows,
@@ -12,7 +11,7 @@ import { ensureSymlink, ensureSymlinkSync } from "./ensure_symlink.ts";
const testdataDir = path.resolve("fs", "testdata");
const isWindows = Deno.build.os === "win";
-test(async function ensureSymlinkIfItNotExist(): Promise<void> {
+Deno.test(async function ensureSymlinkIfItNotExist(): Promise<void> {
const testDir = path.join(testdataDir, "link_file_1");
const testFile = path.join(testDir, "test.txt");
@@ -31,7 +30,7 @@ test(async function ensureSymlinkIfItNotExist(): Promise<void> {
);
});
-test(function ensureSymlinkSyncIfItNotExist(): void {
+Deno.test(function ensureSymlinkSyncIfItNotExist(): void {
const testDir = path.join(testdataDir, "link_file_2");
const testFile = path.join(testDir, "test.txt");
@@ -45,7 +44,7 @@ test(function ensureSymlinkSyncIfItNotExist(): void {
});
});
-test(async function ensureSymlinkIfItExist(): Promise<void> {
+Deno.test(async function ensureSymlinkIfItExist(): Promise<void> {
const testDir = path.join(testdataDir, "link_file_3");
const testFile = path.join(testDir, "test.txt");
const linkFile = path.join(testDir, "link.txt");
@@ -74,7 +73,7 @@ test(async function ensureSymlinkIfItExist(): Promise<void> {
await Deno.remove(testDir, { recursive: true });
});
-test(function ensureSymlinkSyncIfItExist(): void {
+Deno.test(function ensureSymlinkSyncIfItExist(): void {
const testDir = path.join(testdataDir, "link_file_4");
const testFile = path.join(testDir, "test.txt");
const linkFile = path.join(testDir, "link.txt");
@@ -104,7 +103,7 @@ test(function ensureSymlinkSyncIfItExist(): void {
Deno.removeSync(testDir, { recursive: true });
});
-test(async function ensureSymlinkDirectoryIfItExist(): Promise<void> {
+Deno.test(async function ensureSymlinkDirectoryIfItExist(): Promise<void> {
const testDir = path.join(testdataDir, "link_file_origin_3");
const linkDir = path.join(testdataDir, "link_file_link_3");
const testFile = path.join(testDir, "test.txt");
@@ -136,7 +135,7 @@ test(async function ensureSymlinkDirectoryIfItExist(): Promise<void> {
await Deno.remove(testDir, { recursive: true });
});
-test(function ensureSymlinkSyncDirectoryIfItExist(): void {
+Deno.test(function ensureSymlinkSyncDirectoryIfItExist(): void {
const testDir = path.join(testdataDir, "link_file_origin_3");
const linkDir = path.join(testdataDir, "link_file_link_3");
const testFile = path.join(testDir, "test.txt");
diff --git a/std/fs/eol_test.ts b/std/fs/eol_test.ts
index 92306ce6b..aa2dcf395 100644
--- a/std/fs/eol_test.ts
+++ b/std/fs/eol_test.ts
@@ -1,5 +1,4 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import { test } from "../testing/mod.ts";
import { assertEquals } from "../testing/asserts.ts";
import { format, detect, EOL } from "./eol.ts";
@@ -9,28 +8,28 @@ const Mixedinput2 = "deno\r\nis not\nnode";
const LFinput = "deno\nis not\nnode";
const NoNLinput = "deno is not node";
-test({
+Deno.test({
name: "[EOL] Detect CR LF",
fn(): void {
assertEquals(detect(CRLFinput), EOL.CRLF);
}
});
-test({
+Deno.test({
name: "[EOL] Detect LF",
fn(): void {
assertEquals(detect(LFinput), EOL.LF);
}
});
-test({
+Deno.test({
name: "[EOL] Detect No New Line",
fn(): void {
assertEquals(detect(NoNLinput), null);
}
});
-test({
+Deno.test({
name: "[EOL] Detect Mixed",
fn(): void {
assertEquals(detect(Mixedinput), EOL.CRLF);
@@ -38,7 +37,7 @@ test({
}
});
-test({
+Deno.test({
name: "[EOL] Format",
fn(): void {
assertEquals(format(CRLFinput, EOL.LF), LFinput);
diff --git a/std/fs/exists_test.ts b/std/fs/exists_test.ts
index c7c7dc54e..06b908b9d 100644
--- a/std/fs/exists_test.ts
+++ b/std/fs/exists_test.ts
@@ -1,12 +1,11 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import { test } from "../testing/mod.ts";
import { assertEquals, assertStrContains } from "../testing/asserts.ts";
import * as path from "../path/mod.ts";
import { exists, existsSync } from "./exists.ts";
const testdataDir = path.resolve("fs", "testdata");
-test(async function existsFile(): Promise<void> {
+Deno.test(async function existsFile(): Promise<void> {
assertEquals(
await exists(path.join(testdataDir, "not_exist_file.ts")),
false
@@ -14,12 +13,12 @@ test(async function existsFile(): Promise<void> {
assertEquals(await existsSync(path.join(testdataDir, "0.ts")), true);
});
-test(function existsFileSync(): void {
+Deno.test(function existsFileSync(): void {
assertEquals(existsSync(path.join(testdataDir, "not_exist_file.ts")), false);
assertEquals(existsSync(path.join(testdataDir, "0.ts")), true);
});
-test(async function existsDirectory(): Promise<void> {
+Deno.test(async function existsDirectory(): Promise<void> {
assertEquals(
await exists(path.join(testdataDir, "not_exist_directory")),
false
@@ -27,7 +26,7 @@ test(async function existsDirectory(): Promise<void> {
assertEquals(existsSync(testdataDir), true);
});
-test(function existsDirectorySync(): void {
+Deno.test(function existsDirectorySync(): void {
assertEquals(
existsSync(path.join(testdataDir, "not_exist_directory")),
false
@@ -35,19 +34,19 @@ test(function existsDirectorySync(): void {
assertEquals(existsSync(testdataDir), true);
});
-test(function existsLinkSync(): void {
+Deno.test(function existsLinkSync(): void {
// TODO(axetroy): generate link file use Deno api instead of set a link file
// in repository
assertEquals(existsSync(path.join(testdataDir, "0-link.ts")), true);
});
-test(async function existsLink(): Promise<void> {
+Deno.test(async function existsLink(): Promise<void> {
// TODO(axetroy): generate link file use Deno api instead of set a link file
// in repository
assertEquals(await exists(path.join(testdataDir, "0-link.ts")), true);
});
-test(async function existsPermission(): Promise<void> {
+Deno.test(async function existsPermission(): Promise<void> {
interface Scenes {
read: boolean; // --allow-read
async: boolean;
diff --git a/std/fs/expand_glob_test.ts b/std/fs/expand_glob_test.ts
index 718c8183f..58da2c1bf 100644
--- a/std/fs/expand_glob_test.ts
+++ b/std/fs/expand_glob_test.ts
@@ -1,6 +1,5 @@
const { cwd, execPath, run } = Deno;
import { decode } from "../strings/mod.ts";
-import { test, runIfMain } from "../testing/mod.ts";
import { assert, assertEquals, assertStrContains } from "../testing/asserts.ts";
import {
isWindows,
@@ -52,7 +51,7 @@ const EG_OPTIONS: ExpandGlobOptions = {
globstar: false
};
-test(async function expandGlobWildcard(): Promise<void> {
+Deno.test(async function expandGlobWildcard(): Promise<void> {
const options = EG_OPTIONS;
assertEquals(await expandGlobArray("*", options), [
"abc",
@@ -62,12 +61,12 @@ test(async function expandGlobWildcard(): Promise<void> {
]);
});
-test(async function expandGlobTrailingSeparator(): Promise<void> {
+Deno.test(async function expandGlobTrailingSeparator(): Promise<void> {
const options = EG_OPTIONS;
assertEquals(await expandGlobArray("*/", options), ["subdir"]);
});
-test(async function expandGlobParent(): Promise<void> {
+Deno.test(async function expandGlobParent(): Promise<void> {
const options = EG_OPTIONS;
assertEquals(await expandGlobArray("subdir/../*", options), [
"abc",
@@ -77,7 +76,7 @@ test(async function expandGlobParent(): Promise<void> {
]);
});
-test(async function expandGlobExt(): Promise<void> {
+Deno.test(async function expandGlobExt(): Promise<void> {
const options = { ...EG_OPTIONS, extended: true };
assertEquals(await expandGlobArray("abc?(def|ghi)", options), [
"abc",
@@ -97,7 +96,7 @@ test(async function expandGlobExt(): Promise<void> {
assertEquals(await expandGlobArray("abc!(def|ghi)", options), ["abc"]);
});
-test(async function expandGlobGlobstar(): Promise<void> {
+Deno.test(async function expandGlobGlobstar(): Promise<void> {
const options = { ...EG_OPTIONS, globstar: true };
assertEquals(
await expandGlobArray(joinGlobs(["**", "abc"], options), options),
@@ -105,7 +104,7 @@ test(async function expandGlobGlobstar(): Promise<void> {
);
});
-test(async function expandGlobGlobstarParent(): Promise<void> {
+Deno.test(async function expandGlobGlobstarParent(): Promise<void> {
const options = { ...EG_OPTIONS, globstar: true };
assertEquals(
await expandGlobArray(joinGlobs(["subdir", "**", ".."], options), options),
@@ -113,12 +112,12 @@ test(async function expandGlobGlobstarParent(): Promise<void> {
);
});
-test(async function expandGlobIncludeDirs(): Promise<void> {
+Deno.test(async function expandGlobIncludeDirs(): Promise<void> {
const options = { ...EG_OPTIONS, includeDirs: false };
assertEquals(await expandGlobArray("subdir", options), []);
});
-test(async function expandGlobPermError(): Promise<void> {
+Deno.test(async function expandGlobPermError(): Promise<void> {
const exampleUrl = new URL("testdata/expand_wildcard.js", import.meta.url);
const p = run({
args: [execPath(), exampleUrl.toString()],
@@ -133,5 +132,3 @@ test(async function expandGlobPermError(): Promise<void> {
"Uncaught PermissionDenied"
);
});
-
-runIfMain(import.meta);
diff --git a/std/fs/move_test.ts b/std/fs/move_test.ts
index 795893509..b835e6dfa 100644
--- a/std/fs/move_test.ts
+++ b/std/fs/move_test.ts
@@ -1,5 +1,4 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import { test } from "../testing/mod.ts";
import {
assertEquals,
assertThrows,
@@ -13,7 +12,7 @@ import { exists, existsSync } from "./exists.ts";
const testdataDir = path.resolve("fs", "testdata");
-test(async function moveDirectoryIfSrcNotExists(): Promise<void> {
+Deno.test(async function moveDirectoryIfSrcNotExists(): Promise<void> {
const srcDir = path.join(testdataDir, "move_test_src_1");
const destDir = path.join(testdataDir, "move_test_dest_1");
// if src directory not exist
@@ -24,7 +23,7 @@ test(async function moveDirectoryIfSrcNotExists(): Promise<void> {
);
});
-test(async function moveDirectoryIfDestNotExists(): Promise<void> {
+Deno.test(async function moveDirectoryIfDestNotExists(): Promise<void> {
const srcDir = path.join(testdataDir, "move_test_src_2");
const destDir = path.join(testdataDir, "move_test_dest_2");
@@ -43,7 +42,7 @@ test(async function moveDirectoryIfDestNotExists(): Promise<void> {
await Deno.remove(destDir);
});
-test(async function moveFileIfSrcNotExists(): Promise<void> {
+Deno.test(async function moveFileIfSrcNotExists(): Promise<void> {
const srcFile = path.join(testdataDir, "move_test_src_3", "test.txt");
const destFile = path.join(testdataDir, "move_test_dest_3", "test.txt");
@@ -55,7 +54,7 @@ test(async function moveFileIfSrcNotExists(): Promise<void> {
);
});
-test(async function moveFileIfDestExists(): Promise<void> {
+Deno.test(async function moveFileIfDestExists(): Promise<void> {
const srcDir = path.join(testdataDir, "move_test_src_4");
const destDir = path.join(testdataDir, "move_test_dest_4");
const srcFile = path.join(srcDir, "test.txt");
@@ -105,7 +104,7 @@ test(async function moveFileIfDestExists(): Promise<void> {
]);
});
-test(async function moveDirectory(): Promise<void> {
+Deno.test(async function moveDirectory(): Promise<void> {
const srcDir = path.join(testdataDir, "move_test_src_5");
const destDir = path.join(testdataDir, "move_test_dest_5");
const srcFile = path.join(srcDir, "test.txt");
@@ -130,7 +129,7 @@ test(async function moveDirectory(): Promise<void> {
await Deno.remove(destDir, { recursive: true });
});
-test(async function moveIfSrcAndDestDirectoryExistsAndOverwrite(): Promise<
+Deno.test(async function moveIfSrcAndDestDirectoryExistsAndOverwrite(): Promise<
void
> {
const srcDir = path.join(testdataDir, "move_test_src_6");
@@ -165,7 +164,7 @@ test(async function moveIfSrcAndDestDirectoryExistsAndOverwrite(): Promise<
await Deno.remove(destDir, { recursive: true });
});
-test(async function moveIntoSubDir(): Promise<void> {
+Deno.test(async function moveIntoSubDir(): Promise<void> {
const srcDir = path.join(testdataDir, "move_test_src_7");
const destDir = path.join(srcDir, "nest");
@@ -181,7 +180,7 @@ test(async function moveIntoSubDir(): Promise<void> {
await Deno.remove(srcDir, { recursive: true });
});
-test(function moveSyncDirectoryIfSrcNotExists(): void {
+Deno.test(function moveSyncDirectoryIfSrcNotExists(): void {
const srcDir = path.join(testdataDir, "move_sync_test_src_1");
const destDir = path.join(testdataDir, "move_sync_test_dest_1");
// if src directory not exist
@@ -190,7 +189,7 @@ test(function moveSyncDirectoryIfSrcNotExists(): void {
});
});
-test(function moveSyncDirectoryIfDestNotExists(): void {
+Deno.test(function moveSyncDirectoryIfDestNotExists(): void {
const srcDir = path.join(testdataDir, "move_sync_test_src_2");
const destDir = path.join(testdataDir, "move_sync_test_dest_2");
@@ -209,7 +208,7 @@ test(function moveSyncDirectoryIfDestNotExists(): void {
Deno.removeSync(destDir);
});
-test(function moveSyncFileIfSrcNotExists(): void {
+Deno.test(function moveSyncFileIfSrcNotExists(): void {
const srcFile = path.join(testdataDir, "move_sync_test_src_3", "test.txt");
const destFile = path.join(testdataDir, "move_sync_test_dest_3", "test.txt");
@@ -219,7 +218,7 @@ test(function moveSyncFileIfSrcNotExists(): void {
});
});
-test(function moveSyncFileIfDestExists(): void {
+Deno.test(function moveSyncFileIfDestExists(): void {
const srcDir = path.join(testdataDir, "move_sync_test_src_4");
const destDir = path.join(testdataDir, "move_sync_test_dest_4");
const srcFile = path.join(srcDir, "test.txt");
@@ -266,7 +265,7 @@ test(function moveSyncFileIfDestExists(): void {
Deno.removeSync(destDir, { recursive: true });
});
-test(function moveSyncDirectory(): void {
+Deno.test(function moveSyncDirectory(): void {
const srcDir = path.join(testdataDir, "move_sync_test_src_5");
const destDir = path.join(testdataDir, "move_sync_test_dest_5");
const srcFile = path.join(srcDir, "test.txt");
@@ -289,7 +288,7 @@ test(function moveSyncDirectory(): void {
Deno.removeSync(destDir, { recursive: true });
});
-test(function moveSyncIfSrcAndDestDirectoryExistsAndOverwrite(): void {
+Deno.test(function moveSyncIfSrcAndDestDirectoryExistsAndOverwrite(): void {
const srcDir = path.join(testdataDir, "move_sync_test_src_6");
const destDir = path.join(testdataDir, "move_sync_test_dest_6");
const srcFile = path.join(srcDir, "test.txt");
@@ -316,7 +315,7 @@ test(function moveSyncIfSrcAndDestDirectoryExistsAndOverwrite(): void {
Deno.removeSync(destDir, { recursive: true });
});
-test(function moveSyncIntoSubDir(): void {
+Deno.test(function moveSyncIntoSubDir(): void {
const srcDir = path.join(testdataDir, "move_sync_test_src_7");
const destDir = path.join(srcDir, "nest");
diff --git a/std/fs/read_file_str_test.ts b/std/fs/read_file_str_test.ts
index 58c649322..c652fe096 100644
--- a/std/fs/read_file_str_test.ts
+++ b/std/fs/read_file_str_test.ts
@@ -1,18 +1,17 @@
-import { test } from "../testing/mod.ts";
import { assert } from "../testing/asserts.ts";
import * as path from "../path/mod.ts";
import { readFileStrSync, readFileStr } from "./read_file_str.ts";
const testdataDir = path.resolve("fs", "testdata");
-test(function testReadFileSync(): void {
+Deno.test(function testReadFileSync(): void {
const jsonFile = path.join(testdataDir, "json_valid_obj.json");
const strFile = readFileStrSync(jsonFile);
assert(typeof strFile === "string");
assert(strFile.length > 0);
});
-test(async function testReadFile(): Promise<void> {
+Deno.test(async function testReadFile(): Promise<void> {
const jsonFile = path.join(testdataDir, "json_valid_obj.json");
const strFile = await readFileStr(jsonFile);
assert(typeof strFile === "string");
diff --git a/std/fs/read_json_test.ts b/std/fs/read_json_test.ts
index c89006ec1..c394963b0 100644
--- a/std/fs/read_json_test.ts
+++ b/std/fs/read_json_test.ts
@@ -1,5 +1,4 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import { test } from "../testing/mod.ts";
import {
assertEquals,
assertThrowsAsync,
@@ -10,7 +9,7 @@ import { readJson, readJsonSync } from "./read_json.ts";
const testdataDir = path.resolve("fs", "testdata");
-test(async function readJsonFileNotExists(): Promise<void> {
+Deno.test(async function readJsonFileNotExists(): Promise<void> {
const emptyJsonFile = path.join(testdataDir, "json_not_exists.json");
await assertThrowsAsync(
@@ -20,7 +19,7 @@ test(async function readJsonFileNotExists(): Promise<void> {
);
});
-test(async function readEmptyJsonFile(): Promise<void> {
+Deno.test(async function readEmptyJsonFile(): Promise<void> {
const emptyJsonFile = path.join(testdataDir, "json_empty.json");
await assertThrowsAsync(
@@ -30,7 +29,7 @@ test(async function readEmptyJsonFile(): Promise<void> {
);
});
-test(async function readInvalidJsonFile(): Promise<void> {
+Deno.test(async function readInvalidJsonFile(): Promise<void> {
const invalidJsonFile = path.join(testdataDir, "json_invalid.json");
await assertThrowsAsync(
@@ -40,7 +39,7 @@ test(async function readInvalidJsonFile(): Promise<void> {
);
});
-test(async function readValidArrayJsonFile(): Promise<void> {
+Deno.test(async function readValidArrayJsonFile(): Promise<void> {
const invalidJsonFile = path.join(testdataDir, "json_valid_array.json");
const json = await readJson(invalidJsonFile);
@@ -48,7 +47,7 @@ test(async function readValidArrayJsonFile(): Promise<void> {
assertEquals(json, ["1", "2", "3"]);
});
-test(async function readValidObjJsonFile(): Promise<void> {
+Deno.test(async function readValidObjJsonFile(): Promise<void> {
const invalidJsonFile = path.join(testdataDir, "json_valid_obj.json");
const json = await readJson(invalidJsonFile);
@@ -56,13 +55,13 @@ test(async function readValidObjJsonFile(): Promise<void> {
assertEquals(json, { key1: "value1", key2: "value2" });
});
-test(async function readValidObjJsonFileWithRelativePath(): Promise<void> {
+Deno.test(async function readValidObjJsonFileWithRelativePath(): Promise<void> {
const json = await readJson("./fs/testdata/json_valid_obj.json");
assertEquals(json, { key1: "value1", key2: "value2" });
});
-test(function readJsonFileNotExistsSync(): void {
+Deno.test(function readJsonFileNotExistsSync(): void {
const emptyJsonFile = path.join(testdataDir, "json_not_exists.json");
assertThrows((): void => {
@@ -70,7 +69,7 @@ test(function readJsonFileNotExistsSync(): void {
});
});
-test(function readEmptyJsonFileSync(): void {
+Deno.test(function readEmptyJsonFileSync(): void {
const emptyJsonFile = path.join(testdataDir, "json_empty.json");
assertThrows((): void => {
@@ -78,7 +77,7 @@ test(function readEmptyJsonFileSync(): void {
});
});
-test(function readInvalidJsonFile(): void {
+Deno.test(function readInvalidJsonFile(): void {
const invalidJsonFile = path.join(testdataDir, "json_invalid.json");
assertThrows((): void => {
@@ -86,7 +85,7 @@ test(function readInvalidJsonFile(): void {
});
});
-test(function readValidArrayJsonFileSync(): void {
+Deno.test(function readValidArrayJsonFileSync(): void {
const invalidJsonFile = path.join(testdataDir, "json_valid_array.json");
const json = readJsonSync(invalidJsonFile);
@@ -94,7 +93,7 @@ test(function readValidArrayJsonFileSync(): void {
assertEquals(json, ["1", "2", "3"]);
});
-test(function readValidObjJsonFileSync(): void {
+Deno.test(function readValidObjJsonFileSync(): void {
const invalidJsonFile = path.join(testdataDir, "json_valid_obj.json");
const json = readJsonSync(invalidJsonFile);
@@ -102,7 +101,7 @@ test(function readValidObjJsonFileSync(): void {
assertEquals(json, { key1: "value1", key2: "value2" });
});
-test(function readValidObjJsonFileSyncWithRelativePath(): void {
+Deno.test(function readValidObjJsonFileSyncWithRelativePath(): void {
const json = readJsonSync("./fs/testdata/json_valid_obj.json");
assertEquals(json, { key1: "value1", key2: "value2" });
diff --git a/std/fs/utils_test.ts b/std/fs/utils_test.ts
index 751180177..93f4664e7 100644
--- a/std/fs/utils_test.ts
+++ b/std/fs/utils_test.ts
@@ -1,6 +1,5 @@
// Copyright the Browserify authors. MIT License.
-import { test } from "../testing/mod.ts";
import { assertEquals } from "../testing/asserts.ts";
import * as path from "../path/mod.ts";
import { isSubdir, getFileInfoType, PathType } from "./utils.ts";
@@ -9,7 +8,7 @@ import { ensureDirSync } from "./ensure_dir.ts";
const testdataDir = path.resolve("fs", "testdata");
-test(function _isSubdir(): void {
+Deno.test(function _isSubdir(): void {
const pairs = [
["", "", false, path.posix.sep],
["/first/second", "/first", false, path.posix.sep],
@@ -34,7 +33,7 @@ test(function _isSubdir(): void {
});
});
-test(function _getFileInfoType(): void {
+Deno.test(function _getFileInfoType(): void {
const pairs = [
[path.join(testdataDir, "file_type_1"), "file"],
[path.join(testdataDir, "file_type_dir_1"), "dir"]
diff --git a/std/fs/walk_test.ts b/std/fs/walk_test.ts
index 8f218eca6..4984546f2 100644
--- a/std/fs/walk_test.ts
+++ b/std/fs/walk_test.ts
@@ -3,12 +3,11 @@ const { remove } = Deno;
type ErrorKind = Deno.ErrorKind;
type DenoError = Deno.DenoError<ErrorKind>;
import { walk, walkSync, WalkOptions, WalkInfo } from "./walk.ts";
-import { test, TestFunction, runIfMain } from "../testing/mod.ts";
import { assertEquals, assertThrowsAsync } from "../testing/asserts.ts";
export async function testWalk(
setup: (arg0: string) => void | Promise<void>,
- t: TestFunction
+ t: Deno.TestFunction
): Promise<void> {
const name = t.name;
async function fn(): Promise<void> {
@@ -23,7 +22,7 @@ export async function testWalk(
remove(d, { recursive: true });
}
}
- test({ name, fn });
+ Deno.test({ name, fn });
}
function normalize({ filename }: WalkInfo): string {
@@ -275,5 +274,3 @@ testWalk(
}
);
*/
-
-runIfMain(import.meta);
diff --git a/std/fs/write_file_str_test.ts b/std/fs/write_file_str_test.ts
index f9cf760fe..279afe3d1 100644
--- a/std/fs/write_file_str_test.ts
+++ b/std/fs/write_file_str_test.ts
@@ -1,11 +1,10 @@
-import { test } from "../testing/mod.ts";
import { assertEquals } from "../testing/asserts.ts";
import * as path from "../path/mod.ts";
import { writeFileStr, writeFileStrSync } from "./write_file_str.ts";
const testdataDir = path.resolve("fs", "testdata");
-test(function testReadFileSync(): void {
+Deno.test(function testReadFileSync(): void {
const jsonFile = path.join(testdataDir, "write_file_1.json");
const content = "write_file_str_test";
writeFileStrSync(jsonFile, content);
@@ -21,7 +20,7 @@ test(function testReadFileSync(): void {
assertEquals(content, result);
});
-test(async function testReadFile(): Promise<void> {
+Deno.test(async function testReadFile(): Promise<void> {
const jsonFile = path.join(testdataDir, "write_file_2.json");
const content = "write_file_str_test";
await writeFileStr(jsonFile, content);
diff --git a/std/fs/write_json_test.ts b/std/fs/write_json_test.ts
index 5b1d88c5a..09fa05d60 100644
--- a/std/fs/write_json_test.ts
+++ b/std/fs/write_json_test.ts
@@ -1,5 +1,4 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import { test } from "../testing/mod.ts";
import {
assertEquals,
assertThrowsAsync,
@@ -10,7 +9,7 @@ import { writeJson, writeJsonSync } from "./write_json.ts";
const testdataDir = path.resolve("fs", "testdata");
-test(async function writeJsonIfNotExists(): Promise<void> {
+Deno.test(async function writeJsonIfNotExists(): Promise<void> {
const notExistsJsonFile = path.join(testdataDir, "file_not_exists.json");
await assertThrowsAsync(
@@ -29,7 +28,7 @@ test(async function writeJsonIfNotExists(): Promise<void> {
assertEquals(new TextDecoder().decode(content), `{"a":"1"}`);
});
-test(async function writeJsonIfExists(): Promise<void> {
+Deno.test(async function writeJsonIfExists(): Promise<void> {
const existsJsonFile = path.join(testdataDir, "file_write_exists.json");
await Deno.writeFile(existsJsonFile, new Uint8Array());
@@ -50,7 +49,7 @@ test(async function writeJsonIfExists(): Promise<void> {
assertEquals(new TextDecoder().decode(content), `{"a":"1"}`);
});
-test(async function writeJsonIfExistsAnInvalidJson(): Promise<void> {
+Deno.test(async function writeJsonIfExistsAnInvalidJson(): Promise<void> {
const existsInvalidJsonFile = path.join(
testdataDir,
"file_write_invalid.json"
@@ -75,7 +74,7 @@ test(async function writeJsonIfExistsAnInvalidJson(): Promise<void> {
assertEquals(new TextDecoder().decode(content), `{"a":"1"}`);
});
-test(async function writeJsonWithSpaces(): Promise<void> {
+Deno.test(async function writeJsonWithSpaces(): Promise<void> {
const existsJsonFile = path.join(testdataDir, "file_write_spaces.json");
const invalidJsonContent = new TextEncoder().encode();
@@ -97,7 +96,7 @@ test(async function writeJsonWithSpaces(): Promise<void> {
assertEquals(new TextDecoder().decode(content), `{\n "a": "1"\n}`);
});
-test(async function writeJsonWithReplacer(): Promise<void> {
+Deno.test(async function writeJsonWithReplacer(): Promise<void> {
const existsJsonFile = path.join(testdataDir, "file_write_replacer.json");
const invalidJsonContent = new TextEncoder().encode();
@@ -125,7 +124,7 @@ test(async function writeJsonWithReplacer(): Promise<void> {
assertEquals(new TextDecoder().decode(content), `{"a":"1"}`);
});
-test(function writeJsonSyncIfNotExists(): void {
+Deno.test(function writeJsonSyncIfNotExists(): void {
const notExistsJsonFile = path.join(testdataDir, "file_not_exists_sync.json");
assertThrows(
@@ -144,7 +143,7 @@ test(function writeJsonSyncIfNotExists(): void {
assertEquals(new TextDecoder().decode(content), `{"a":"1"}`);
});
-test(function writeJsonSyncIfExists(): void {
+Deno.test(function writeJsonSyncIfExists(): void {
const existsJsonFile = path.join(testdataDir, "file_write_exists_sync.json");
Deno.writeFileSync(existsJsonFile, new Uint8Array());
@@ -165,7 +164,7 @@ test(function writeJsonSyncIfExists(): void {
assertEquals(new TextDecoder().decode(content), `{"a":"1"}`);
});
-test(function writeJsonSyncIfExistsAnInvalidJson(): void {
+Deno.test(function writeJsonSyncIfExistsAnInvalidJson(): void {
const existsInvalidJsonFile = path.join(
testdataDir,
"file_write_invalid_sync.json"
@@ -190,7 +189,7 @@ test(function writeJsonSyncIfExistsAnInvalidJson(): void {
assertEquals(new TextDecoder().decode(content), `{"a":"1"}`);
});
-test(function writeJsonWithSpaces(): void {
+Deno.test(function writeJsonWithSpaces(): void {
const existsJsonFile = path.join(testdataDir, "file_write_spaces_sync.json");
const invalidJsonContent = new TextEncoder().encode();
@@ -212,7 +211,7 @@ test(function writeJsonWithSpaces(): void {
assertEquals(new TextDecoder().decode(content), `{\n "a": "1"\n}`);
});
-test(function writeJsonWithReplacer(): void {
+Deno.test(function writeJsonWithReplacer(): void {
const existsJsonFile = path.join(
testdataDir,
"file_write_replacer_sync.json"