mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -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 { ensureFileSync } from "./ensure_file.ts";
|
||||||
import { ensureDirSync } from "./ensure_dir.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 {
|
Deno.test("_isSubdir", function (): void {
|
||||||
const pairs = [
|
const pairs = [
|
||||||
|
|
|
@ -12,7 +12,8 @@ import { ensureDir, ensureDirSync } from "./ensure_dir.ts";
|
||||||
import { ensureFile, ensureFileSync } from "./ensure_file.ts";
|
import { ensureFile, ensureFileSync } from "./ensure_file.ts";
|
||||||
import { ensureSymlink, ensureSymlinkSync } from "./ensure_symlink.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(
|
function testCopy(
|
||||||
name: string,
|
name: string,
|
||||||
|
|
|
@ -9,7 +9,8 @@ import {
|
||||||
import * as path from "../path/mod.ts";
|
import * as path from "../path/mod.ts";
|
||||||
import { emptyDir, emptyDirSync } from "./empty_dir.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> {
|
Deno.test("emptyDirIfItNotExist", async function (): Promise<void> {
|
||||||
const testDir = path.join(testdataDir, "empty_dir_test_1");
|
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 { ensureDir, ensureDirSync } from "./ensure_dir.ts";
|
||||||
import { ensureFile, ensureFileSync } from "./ensure_file.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> {
|
Deno.test("ensureDirIfItNotExist", async function (): Promise<void> {
|
||||||
const baseDir = path.join(testdataDir, "ensure_dir_not_exist");
|
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 * as path from "../path/mod.ts";
|
||||||
import { ensureFile, ensureFileSync } from "./ensure_file.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> {
|
Deno.test("ensureFileIfItNotExist", async function (): Promise<void> {
|
||||||
const testDir = path.join(testdataDir, "ensure_file_1");
|
const testDir = path.join(testdataDir, "ensure_file_1");
|
||||||
|
|
|
@ -8,7 +8,8 @@ import {
|
||||||
import * as path from "../path/mod.ts";
|
import * as path from "../path/mod.ts";
|
||||||
import { ensureLink, ensureLinkSync } from "./ensure_link.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> {
|
Deno.test("ensureLinkIfItNotExist", async function (): Promise<void> {
|
||||||
const srcDir = path.join(testdataDir, "ensure_link_1");
|
const srcDir = path.join(testdataDir, "ensure_link_1");
|
||||||
|
|
|
@ -8,7 +8,8 @@ import {
|
||||||
import * as path from "../path/mod.ts";
|
import * as path from "../path/mod.ts";
|
||||||
import { ensureSymlink, ensureSymlinkSync } from "./ensure_symlink.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> {
|
Deno.test("ensureSymlinkIfItNotExist", async function (): Promise<void> {
|
||||||
const testDir = path.join(testdataDir, "link_file_1");
|
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 * as path from "../path/mod.ts";
|
||||||
import { exists, existsSync } from "./exists.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> {
|
Deno.test("[fs] existsFile", async function (): Promise<void> {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
|
|
|
@ -10,7 +10,8 @@ import { ensureFile, ensureFileSync } from "./ensure_file.ts";
|
||||||
import { ensureDir, ensureDirSync } from "./ensure_dir.ts";
|
import { ensureDir, ensureDirSync } from "./ensure_dir.ts";
|
||||||
import { exists, existsSync } from "./exists.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> {
|
Deno.test("moveDirectoryIfSrcNotExists", async function (): Promise<void> {
|
||||||
const srcDir = path.join(testdataDir, "move_test_src_1");
|
const srcDir = path.join(testdataDir, "move_test_src_1");
|
||||||
|
|
Loading…
Reference in a new issue