mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 15:06:54 -05:00
test(std/fs): make tests runnable from any directory (#7388)
This commit is contained in:
parent
334ed0e2f4
commit
c5d50737f0
9 changed files with 18 additions and 9 deletions
|
@ -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 = [
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue