summaryrefslogtreecommitdiff
path: root/cli/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/unit')
-rw-r--r--cli/tests/unit/README.md2
-rw-r--r--cli/tests/unit/body_test.ts2
-rw-r--r--cli/tests/unit/broadcast_channel_test.ts5
-rw-r--r--cli/tests/unit/fetch_test.ts48
-rw-r--r--cli/tests/unit/files_test.ts26
-rw-r--r--cli/tests/unit/http_test.ts6
-rw-r--r--cli/tests/unit/read_dir_test.ts12
-rw-r--r--cli/tests/unit/read_file_test.ts22
-rw-r--r--cli/tests/unit/read_text_file_test.ts14
-rw-r--r--cli/tests/unit/real_path_test.ts8
-rw-r--r--cli/tests/unit/resources_test.ts2
-rw-r--r--cli/tests/unit/stat_test.ts54
-rw-r--r--cli/tests/unit/tls_test.ts72
-rw-r--r--cli/tests/unit/tty_test.ts4
-rw-r--r--cli/tests/unit/wasm_test.ts2
-rw-r--r--cli/tests/unit/webgpu_test.ts9
16 files changed, 155 insertions, 133 deletions
diff --git a/cli/tests/unit/README.md b/cli/tests/unit/README.md
index 114bbc043..e1197fe9b 100644
--- a/cli/tests/unit/README.md
+++ b/cli/tests/unit/README.md
@@ -26,7 +26,7 @@ unitTest(
## Running tests
-There are three ways to run `unit_test_runner.ts`:
+There are two ways to run `unit_test_runner.ts`:
```sh
# Run all tests.
diff --git a/cli/tests/unit/body_test.ts b/cli/tests/unit/body_test.ts
index 78da2a9d4..fe0bbe25c 100644
--- a/cli/tests/unit/body_test.ts
+++ b/cli/tests/unit/body_test.ts
@@ -57,7 +57,7 @@ unitTest(
{ perms: { net: true } },
async function bodyURLEncodedFormData() {
const response = await fetch(
- "http://localhost:4545/cli/tests/subdir/form_urlencoded.txt",
+ "http://localhost:4545/subdir/form_urlencoded.txt",
);
assert(response.body instanceof ReadableStream);
diff --git a/cli/tests/unit/broadcast_channel_test.ts b/cli/tests/unit/broadcast_channel_test.ts
index cfa62c856..33a8aaba0 100644
--- a/cli/tests/unit/broadcast_channel_test.ts
+++ b/cli/tests/unit/broadcast_channel_test.ts
@@ -6,7 +6,10 @@ Deno.test("broadcastchannel worker", async () => {
const intercom = new BroadcastChannel("intercom");
let count = 0;
- const url = new URL("../workers/broadcast_channel.ts", import.meta.url);
+ const url = new URL(
+ "../testdata/workers/broadcast_channel.ts",
+ import.meta.url,
+ );
const worker = new Worker(url.href, { type: "module", name: "worker" });
worker.onmessage = () => intercom.postMessage(++count);
diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts
index 24825c653..6e2b1a5d6 100644
--- a/cli/tests/unit/fetch_test.ts
+++ b/cli/tests/unit/fetch_test.ts
@@ -94,40 +94,40 @@ unitTest(
);
unitTest({ perms: { net: true } }, async function fetchJsonSuccess() {
- const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
+ const response = await fetch("http://localhost:4545/fixture.json");
const json = await response.json();
assertEquals(json.name, "deno");
});
unitTest(async function fetchPerm() {
await assertThrowsAsync(async () => {
- await fetch("http://localhost:4545/cli/tests/fixture.json");
+ await fetch("http://localhost:4545/fixture.json");
}, Deno.errors.PermissionDenied);
});
unitTest({ perms: { net: true } }, async function fetchUrl() {
- const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
- assertEquals(response.url, "http://localhost:4545/cli/tests/fixture.json");
+ const response = await fetch("http://localhost:4545/fixture.json");
+ assertEquals(response.url, "http://localhost:4545/fixture.json");
const _json = await response.json();
});
unitTest({ perms: { net: true } }, async function fetchURL() {
const response = await fetch(
- new URL("http://localhost:4545/cli/tests/fixture.json"),
+ new URL("http://localhost:4545/fixture.json"),
);
- assertEquals(response.url, "http://localhost:4545/cli/tests/fixture.json");
+ assertEquals(response.url, "http://localhost:4545/fixture.json");
const _json = await response.json();
});
unitTest({ perms: { net: true } }, async function fetchHeaders() {
- const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
+ const response = await fetch("http://localhost:4545/fixture.json");
const headers = response.headers;
assertEquals(headers.get("Content-Type"), "application/json");
const _json = await response.json();
});
unitTest({ perms: { net: true } }, async function fetchBlob() {
- const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
+ const response = await fetch("http://localhost:4545/fixture.json");
const headers = response.headers;
const blob = await response.blob();
assertEquals(blob.type, headers.get("Content-Type"));
@@ -138,7 +138,7 @@ unitTest(
{ perms: { net: true } },
async function fetchBodyUsedReader() {
const response = await fetch(
- "http://localhost:4545/cli/tests/fixture.json",
+ "http://localhost:4545/fixture.json",
);
assert(response.body !== null);
@@ -156,7 +156,7 @@ unitTest(
{ perms: { net: true } },
async function fetchBodyUsedCancelStream() {
const response = await fetch(
- "http://localhost:4545/cli/tests/fixture.json",
+ "http://localhost:4545/fixture.json",
);
assert(response.body !== null);
@@ -168,7 +168,7 @@ unitTest(
);
unitTest({ perms: { net: true } }, async function fetchAsyncIterator() {
- const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
+ const response = await fetch("http://localhost:4545/fixture.json");
const headers = response.headers;
assert(response.body !== null);
@@ -182,7 +182,7 @@ unitTest({ perms: { net: true } }, async function fetchAsyncIterator() {
});
unitTest({ perms: { net: true } }, async function fetchBodyReader() {
- const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
+ const response = await fetch("http://localhost:4545/fixture.json");
const headers = response.headers;
assert(response.body !== null);
const reader = response.body.getReader();
@@ -221,7 +221,7 @@ unitTest(
);
unitTest({ perms: { net: true } }, async function responseClone() {
- const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
+ const response = await fetch("http://localhost:4545/fixture.json");
const response1 = response.clone();
assert(response !== response1);
assertEquals(response.status, response1.status);
@@ -272,7 +272,7 @@ unitTest(
{ perms: { net: true } },
async function fetchURLEncodedFormDataSuccess() {
const response = await fetch(
- "http://localhost:4545/cli/tests/subdir/form_urlencoded.txt",
+ "http://localhost:4545/subdir/form_urlencoded.txt",
);
const formData = await response.formData();
assert(formData.has("field_1"));
@@ -360,12 +360,12 @@ unitTest(
perms: { net: true },
},
async function fetchWithRedirection() {
- const response = await fetch("http://localhost:4546/README.md");
+ const response = await fetch("http://localhost:4546/hello.txt");
assertEquals(response.status, 200);
assertEquals(response.statusText, "OK");
- assertEquals(response.url, "http://localhost:4545/README.md");
+ assertEquals(response.url, "http://localhost:4545/hello.txt");
const body = await response.text();
- assert(body.includes("Deno"));
+ assert(body.includes("Hello world!"));
},
);
@@ -375,7 +375,7 @@ unitTest(
},
async function fetchWithRelativeRedirection() {
const response = await fetch(
- "http://localhost:4545/cli/tests/001_hello.js",
+ "http://localhost:4545/001_hello.js",
);
assertEquals(response.status, 200);
assertEquals(response.statusText, "OK");
@@ -411,7 +411,7 @@ unitTest(
},
async function fetchWithInfRedirection() {
await assertThrowsAsync(
- () => fetch("http://localhost:4549/cli/tests"),
+ () => fetch("http://localhost:4549"),
TypeError,
"redirect",
);
@@ -450,7 +450,7 @@ unitTest(
{ perms: { net: true } },
async function fetchSeparateInit() {
// related to: https://github.com/denoland/deno/issues/10396
- const req = new Request("http://localhost:4545/cli/tests/001_hello.js");
+ const req = new Request("http://localhost:4545/001_hello.js");
const init = {
method: "GET",
};
@@ -815,7 +815,7 @@ unitTest(async function responseWithoutBody() {
});
unitTest({ perms: { net: true } }, async function fetchBodyReadTwice() {
- const response = await fetch("http://localhost:4545/cli/tests/fixture.json");
+ const response = await fetch("http://localhost:4545/fixture.json");
// Read body
const _json = await response.json();
@@ -839,7 +839,7 @@ unitTest(
{ perms: { net: true } },
async function fetchBodyReaderAfterRead() {
const response = await fetch(
- "http://localhost:4545/cli/tests/fixture.json",
+ "http://localhost:4545/fixture.json",
);
assert(response.body !== null);
const reader = await response.body.getReader();
@@ -919,7 +919,7 @@ unitTest(
unitTest(
{ perms: { net: true } },
async function fetchResourceCloseAfterStreamCancel() {
- const res = await fetch("http://localhost:4545/cli/tests/fixture.json");
+ const res = await fetch("http://localhost:4545/fixture.json");
assert(res.body !== null);
// After ReadableStream.cancel is called, resource handle must be closed
@@ -1047,7 +1047,7 @@ MNf4EgWfK+tZMnuqfpfO9740KzfcVoMNo4QJD4yn5YxroUOO/Azi
},
);
const response = await fetch(
- "https://localhost:5545/cli/tests/fixture.json",
+ "https://localhost:5545/fixture.json",
{ client },
);
const json = await response.json();
diff --git a/cli/tests/unit/files_test.ts b/cli/tests/unit/files_test.ts
index a409434c1..fed7c3252 100644
--- a/cli/tests/unit/files_test.ts
+++ b/cli/tests/unit/files_test.ts
@@ -17,7 +17,7 @@ unitTest(function filesStdioFileDescriptors() {
});
unitTest({ perms: { read: true } }, async function filesCopyToStdout() {
- const filename = "cli/tests/fixture.json";
+ const filename = "cli/tests/testdata/fixture.json";
const file = await Deno.open(filename);
assert(file.rid > 2);
const bytesWritten = await copy(file, Deno.stdout);
@@ -27,7 +27,7 @@ unitTest({ perms: { read: true } }, async function filesCopyToStdout() {
});
unitTest({ perms: { read: true } }, async function filesIter() {
- const filename = "cli/tests/hello.txt";
+ const filename = "cli/tests/testdata/hello.txt";
const file = await Deno.open(filename);
let totalSize = 0;
@@ -42,7 +42,7 @@ unitTest({ perms: { read: true } }, async function filesIter() {
unitTest(
{ perms: { read: true } },
async function filesIterCustomBufSize() {
- const filename = "cli/tests/hello.txt";
+ const filename = "cli/tests/testdata/hello.txt";
const file = await Deno.open(filename);
let totalSize = 0;
@@ -59,7 +59,7 @@ unitTest(
);
unitTest({ perms: { read: true } }, function filesIterSync() {
- const filename = "cli/tests/hello.txt";
+ const filename = "cli/tests/testdata/hello.txt";
const file = Deno.openSync(filename);
let totalSize = 0;
@@ -74,7 +74,7 @@ unitTest({ perms: { read: true } }, function filesIterSync() {
unitTest(
{ perms: { read: true } },
function filesIterSyncCustomBufSize() {
- const filename = "cli/tests/hello.txt";
+ const filename = "cli/tests/testdata/hello.txt";
const file = Deno.openSync(filename);
let totalSize = 0;
@@ -264,7 +264,7 @@ unitTest(
);
unitTest(async function openOptions() {
- const filename = "cli/tests/fixture.json";
+ const filename = "cli/tests/testdata/fixture.json";
await assertThrowsAsync(
async () => {
await Deno.open(filename, { write: false });
@@ -532,7 +532,7 @@ unitTest(
);
unitTest({ perms: { read: true } }, async function seekStart() {
- const filename = "cli/tests/hello.txt";
+ const filename = "cli/tests/testdata/hello.txt";
const file = await Deno.open(filename);
const seekPosition = 6;
// Deliberately move 1 step forward
@@ -549,7 +549,7 @@ unitTest({ perms: { read: true } }, async function seekStart() {
});
unitTest({ perms: { read: true } }, function seekSyncStart() {
- const filename = "cli/tests/hello.txt";
+ const filename = "cli/tests/testdata/hello.txt";
const file = Deno.openSync(filename);
const seekPosition = 6;
// Deliberately move 1 step forward
@@ -566,7 +566,7 @@ unitTest({ perms: { read: true } }, function seekSyncStart() {
});
unitTest({ perms: { read: true } }, async function seekCurrent() {
- const filename = "cli/tests/hello.txt";
+ const filename = "cli/tests/testdata/hello.txt";
const file = await Deno.open(filename);
// Deliberately move 1 step forward
await file.read(new Uint8Array(1)); // "H"
@@ -583,7 +583,7 @@ unitTest({ perms: { read: true } }, async function seekCurrent() {
});
unitTest({ perms: { read: true } }, function seekSyncCurrent() {
- const filename = "cli/tests/hello.txt";
+ const filename = "cli/tests/testdata/hello.txt";
const file = Deno.openSync(filename);
// Deliberately move 1 step forward
file.readSync(new Uint8Array(1)); // "H"
@@ -600,7 +600,7 @@ unitTest({ perms: { read: true } }, function seekSyncCurrent() {
});
unitTest({ perms: { read: true } }, async function seekEnd() {
- const filename = "cli/tests/hello.txt";
+ const filename = "cli/tests/testdata/hello.txt";
const file = await Deno.open(filename);
const seekPosition = -6;
// seek from end of file that has 12 chars, 12 - 6 = 6
@@ -614,7 +614,7 @@ unitTest({ perms: { read: true } }, async function seekEnd() {
});
unitTest({ perms: { read: true } }, function seekSyncEnd() {
- const filename = "cli/tests/hello.txt";
+ const filename = "cli/tests/testdata/hello.txt";
const file = Deno.openSync(filename);
const seekPosition = -6;
// seek from end of file that has 12 chars, 12 - 6 = 6
@@ -628,7 +628,7 @@ unitTest({ perms: { read: true } }, function seekSyncEnd() {
});
unitTest({ perms: { read: true } }, async function seekMode() {
- const filename = "cli/tests/hello.txt";
+ const filename = "cli/tests/testdata/hello.txt";
const file = await Deno.open(filename);
await assertThrowsAsync(
async () => {
diff --git a/cli/tests/unit/http_test.ts b/cli/tests/unit/http_test.ts
index 4cdd84902..d762a6497 100644
--- a/cli/tests/unit/http_test.ts
+++ b/cli/tests/unit/http_test.ts
@@ -208,8 +208,8 @@ unitTest(
const listener = Deno.listenTls({
hostname,
port,
- certFile: "cli/tests/tls/localhost.crt",
- keyFile: "cli/tests/tls/localhost.key",
+ certFile: "cli/tests/testdata/tls/localhost.crt",
+ keyFile: "cli/tests/testdata/tls/localhost.key",
});
const conn = await listener.accept();
const httpConn = Deno.serveHttp(conn);
@@ -226,7 +226,7 @@ unitTest(
listener.close();
})();
- const caData = Deno.readTextFileSync("cli/tests/tls/RootCA.pem");
+ const caData = Deno.readTextFileSync("cli/tests/testdata/tls/RootCA.pem");
const client = Deno.createHttpClient({ caData });
const resp = await fetch(`https://${hostname}:${port}/`, {
client,
diff --git a/cli/tests/unit/read_dir_test.ts b/cli/tests/unit/read_dir_test.ts
index 2e4370153..4f02fae9b 100644
--- a/cli/tests/unit/read_dir_test.ts
+++ b/cli/tests/unit/read_dir_test.ts
@@ -22,12 +22,14 @@ function assertSameContent(files: Deno.DirEntry[]) {
}
unitTest({ perms: { read: true } }, function readDirSyncSuccess() {
- const files = [...Deno.readDirSync("cli/tests/")];
+ const files = [...Deno.readDirSync("cli/tests/testdata")];
assertSameContent(files);
});
unitTest({ perms: { read: true } }, function readDirSyncWithUrl() {
- const files = [...Deno.readDirSync(pathToAbsoluteFileUrl("cli/tests"))];
+ const files = [
+ ...Deno.readDirSync(pathToAbsoluteFileUrl("cli/tests/testdata")),
+ ];
assertSameContent(files);
});
@@ -39,7 +41,7 @@ unitTest({ perms: { read: false } }, function readDirSyncPerm() {
unitTest({ perms: { read: true } }, function readDirSyncNotDir() {
assertThrows(() => {
- Deno.readDirSync("cli/tests/fixture.json");
+ Deno.readDirSync("cli/tests/testdata/fixture.json");
}, Error);
});
@@ -51,7 +53,7 @@ unitTest({ perms: { read: true } }, function readDirSyncNotFound() {
unitTest({ perms: { read: true } }, async function readDirSuccess() {
const files = [];
- for await (const dirEntry of Deno.readDir("cli/tests/")) {
+ for await (const dirEntry of Deno.readDir("cli/tests/testdata")) {
files.push(dirEntry);
}
assertSameContent(files);
@@ -60,7 +62,7 @@ unitTest({ perms: { read: true } }, async function readDirSuccess() {
unitTest({ perms: { read: true } }, async function readDirWithUrl() {
const files = [];
for await (
- const dirEntry of Deno.readDir(pathToAbsoluteFileUrl("cli/tests"))
+ const dirEntry of Deno.readDir(pathToAbsoluteFileUrl("cli/tests/testdata"))
) {
files.push(dirEntry);
}
diff --git a/cli/tests/unit/read_file_test.ts b/cli/tests/unit/read_file_test.ts
index f638c7a7c..7dd2b5621 100644
--- a/cli/tests/unit/read_file_test.ts
+++ b/cli/tests/unit/read_file_test.ts
@@ -9,7 +9,7 @@ import {
} from "./test_util.ts";
unitTest({ perms: { read: true } }, function readFileSyncSuccess() {
- const data = Deno.readFileSync("cli/tests/fixture.json");
+ const data = Deno.readFileSync("cli/tests/testdata/fixture.json");
assert(data.byteLength > 0);
const decoder = new TextDecoder("utf-8");
const json = decoder.decode(data);
@@ -19,7 +19,7 @@ unitTest({ perms: { read: true } }, function readFileSyncSuccess() {
unitTest({ perms: { read: true } }, function readFileSyncUrl() {
const data = Deno.readFileSync(
- pathToAbsoluteFileUrl("cli/tests/fixture.json"),
+ pathToAbsoluteFileUrl("cli/tests/testdata/fixture.json"),
);
assert(data.byteLength > 0);
const decoder = new TextDecoder("utf-8");
@@ -30,7 +30,7 @@ unitTest({ perms: { read: true } }, function readFileSyncUrl() {
unitTest({ perms: { read: false } }, function readFileSyncPerm() {
assertThrows(() => {
- Deno.readFileSync("cli/tests/fixture.json");
+ Deno.readFileSync("cli/tests/testdata/fixture.json");
}, Deno.errors.PermissionDenied);
});
@@ -42,7 +42,7 @@ unitTest({ perms: { read: true } }, function readFileSyncNotFound() {
unitTest({ perms: { read: true } }, async function readFileUrl() {
const data = await Deno.readFile(
- pathToAbsoluteFileUrl("cli/tests/fixture.json"),
+ pathToAbsoluteFileUrl("cli/tests/testdata/fixture.json"),
);
assert(data.byteLength > 0);
const decoder = new TextDecoder("utf-8");
@@ -52,7 +52,7 @@ unitTest({ perms: { read: true } }, async function readFileUrl() {
});
unitTest({ perms: { read: true } }, async function readFileSuccess() {
- const data = await Deno.readFile("cli/tests/fixture.json");
+ const data = await Deno.readFile("cli/tests/testdata/fixture.json");
assert(data.byteLength > 0);
const decoder = new TextDecoder("utf-8");
const json = decoder.decode(data);
@@ -62,13 +62,13 @@ unitTest({ perms: { read: true } }, async function readFileSuccess() {
unitTest({ perms: { read: false } }, async function readFilePerm() {
await assertThrowsAsync(async () => {
- await Deno.readFile("cli/tests/fixture.json");
+ await Deno.readFile("cli/tests/testdata/fixture.json");
}, Deno.errors.PermissionDenied);
});
unitTest({ perms: { read: true } }, function readFileSyncLoop() {
for (let i = 0; i < 256; i++) {
- Deno.readFileSync("cli/tests/fixture.json");
+ Deno.readFileSync("cli/tests/testdata/fixture.json");
}
});
@@ -96,7 +96,9 @@ unitTest(
const ac = new AbortController();
queueMicrotask(() => ac.abort());
await assertThrowsAsync(async () => {
- await Deno.readFile("cli/tests/fixture.json", { signal: ac.signal });
+ await Deno.readFile("cli/tests/testdata/fixture.json", {
+ signal: ac.signal,
+ });
});
},
);
@@ -107,7 +109,9 @@ unitTest(
const ac = new AbortController();
queueMicrotask(() => ac.abort());
await assertThrowsAsync(async () => {
- await Deno.readTextFile("cli/tests/fixture.json", { signal: ac.signal });
+ await Deno.readTextFile("cli/tests/testdata/fixture.json", {
+ signal: ac.signal,
+ });
});
},
);
diff --git a/cli/tests/unit/read_text_file_test.ts b/cli/tests/unit/read_text_file_test.ts
index a7eb1a730..3d7ccfaa6 100644
--- a/cli/tests/unit/read_text_file_test.ts
+++ b/cli/tests/unit/read_text_file_test.ts
@@ -8,7 +8,7 @@ import {
} from "./test_util.ts";
unitTest({ perms: { read: true } }, function readTextFileSyncSuccess() {
- const data = Deno.readTextFileSync("cli/tests/fixture.json");
+ const data = Deno.readTextFileSync("cli/tests/testdata/fixture.json");
assert(data.length > 0);
const pkg = JSON.parse(data);
assertEquals(pkg.name, "deno");
@@ -16,7 +16,7 @@ unitTest({ perms: { read: true } }, function readTextFileSyncSuccess() {
unitTest({ perms: { read: true } }, function readTextFileSyncByUrl() {
const data = Deno.readTextFileSync(
- pathToAbsoluteFileUrl("cli/tests/fixture.json"),
+ pathToAbsoluteFileUrl("cli/tests/testdata/fixture.json"),
);
assert(data.length > 0);
const pkg = JSON.parse(data);
@@ -25,7 +25,7 @@ unitTest({ perms: { read: true } }, function readTextFileSyncByUrl() {
unitTest({ perms: { read: false } }, function readTextFileSyncPerm() {
assertThrows(() => {
- Deno.readTextFileSync("cli/tests/fixture.json");
+ Deno.readTextFileSync("cli/tests/testdata/fixture.json");
}, Deno.errors.PermissionDenied);
});
@@ -38,7 +38,7 @@ unitTest({ perms: { read: true } }, function readTextFileSyncNotFound() {
unitTest(
{ perms: { read: true } },
async function readTextFileSuccess() {
- const data = await Deno.readTextFile("cli/tests/fixture.json");
+ const data = await Deno.readTextFile("cli/tests/testdata/fixture.json");
assert(data.length > 0);
const pkg = JSON.parse(data);
assertEquals(pkg.name, "deno");
@@ -47,7 +47,7 @@ unitTest(
unitTest({ perms: { read: true } }, async function readTextFileByUrl() {
const data = await Deno.readTextFile(
- pathToAbsoluteFileUrl("cli/tests/fixture.json"),
+ pathToAbsoluteFileUrl("cli/tests/testdata/fixture.json"),
);
assert(data.length > 0);
const pkg = JSON.parse(data);
@@ -56,13 +56,13 @@ unitTest({ perms: { read: true } }, async function readTextFileByUrl() {
unitTest({ perms: { read: false } }, async function readTextFilePerm() {
await assertThrowsAsync(async () => {
- await Deno.readTextFile("cli/tests/fixture.json");
+ await Deno.readTextFile("cli/tests/testdata/fixture.json");
}, Deno.errors.PermissionDenied);
});
unitTest({ perms: { read: true } }, function readTextFileSyncLoop() {
for (let i = 0; i < 256; i++) {
- Deno.readTextFileSync("cli/tests/fixture.json");
+ Deno.readTextFileSync("cli/tests/testdata/fixture.json");
}
});
diff --git a/cli/tests/unit/real_path_test.ts b/cli/tests/unit/real_path_test.ts
index b84b0c0df..8c0728ca9 100644
--- a/cli/tests/unit/real_path_test.ts
+++ b/cli/tests/unit/real_path_test.ts
@@ -10,7 +10,7 @@ import {
} from "./test_util.ts";
unitTest({ perms: { read: true } }, function realPathSyncSuccess() {
- const relative = "cli/tests/fixture.json";
+ const relative = "cli/tests/testdata/fixture.json";
const realPath = Deno.realPathSync(relative);
if (Deno.build.os !== "windows") {
assert(realPath.startsWith("/"));
@@ -22,7 +22,7 @@ unitTest({ perms: { read: true } }, function realPathSyncSuccess() {
});
unitTest({ perms: { read: true } }, function realPathSyncUrl() {
- const relative = "cli/tests/fixture.json";
+ const relative = "cli/tests/testdata/fixture.json";
const url = pathToAbsoluteFileUrl(relative);
assertEquals(Deno.realPathSync(relative), Deno.realPathSync(url));
});
@@ -61,7 +61,7 @@ unitTest({ perms: { read: true } }, function realPathSyncNotFound() {
});
unitTest({ perms: { read: true } }, async function realPathSuccess() {
- const relativePath = "cli/tests/fixture.json";
+ const relativePath = "cli/tests/testdata/fixture.json";
const realPath = await Deno.realPath(relativePath);
if (Deno.build.os !== "windows") {
assert(realPath.startsWith("/"));
@@ -75,7 +75,7 @@ unitTest({ perms: { read: true } }, async function realPathSuccess() {
unitTest(
{ perms: { read: true } },
async function realPathUrl() {
- const relative = "cli/tests/fixture.json";
+ const relative = "cli/tests/testdata/fixture.json";
const url = pathToAbsoluteFileUrl(relative);
assertEquals(await Deno.realPath(relative), await Deno.realPath(url));
},
diff --git a/cli/tests/unit/resources_test.ts b/cli/tests/unit/resources_test.ts
index ea183a068..e2ca4116d 100644
--- a/cli/tests/unit/resources_test.ts
+++ b/cli/tests/unit/resources_test.ts
@@ -37,7 +37,7 @@ unitTest({ perms: { net: true } }, async function resourcesNet() {
unitTest({ perms: { read: true } }, async function resourcesFile() {
const resourcesBefore = Deno.resources();
- const f = await Deno.open("cli/tests/hello.txt");
+ const f = await Deno.open("cli/tests/testdata/hello.txt");
const resourcesAfter = Deno.resources();
f.close();
diff --git a/cli/tests/unit/stat_test.ts b/cli/tests/unit/stat_test.ts
index 4b663e5b9..7db9dee71 100644
--- a/cli/tests/unit/stat_test.ts
+++ b/cli/tests/unit/stat_test.ts
@@ -41,11 +41,11 @@ unitTest({ perms: { read: true } }, async function fstatSuccess() {
unitTest(
{ perms: { read: true, write: true } },
function statSyncSuccess() {
- const packageInfo = Deno.statSync("README.md");
- assert(packageInfo.isFile);
- assert(!packageInfo.isSymlink);
+ const readmeInfo = Deno.statSync("README.md");
+ assert(readmeInfo.isFile);
+ assert(!readmeInfo.isSymlink);
- const modulesInfo = Deno.statSync("cli/tests/symlink_to_subdir");
+ const modulesInfo = Deno.statSync("cli/tests/testdata/symlink_to_subdir");
assert(modulesInfo.isDirectory);
assert(!modulesInfo.isSymlink);
@@ -62,12 +62,12 @@ unitTest(
tempInfo.birthtime === null || now - tempInfo.birthtime.valueOf() < 1000,
);
- const packageInfoByUrl = Deno.statSync(pathToAbsoluteFileUrl("README.md"));
- assert(packageInfoByUrl.isFile);
- assert(!packageInfoByUrl.isSymlink);
+ const readmeInfoByUrl = Deno.statSync(pathToAbsoluteFileUrl("README.md"));
+ assert(readmeInfoByUrl.isFile);
+ assert(!readmeInfoByUrl.isSymlink);
const modulesInfoByUrl = Deno.statSync(
- pathToAbsoluteFileUrl("cli/tests/symlink_to_subdir"),
+ pathToAbsoluteFileUrl("cli/tests/testdata/symlink_to_subdir"),
);
assert(modulesInfoByUrl.isDirectory);
assert(!modulesInfoByUrl.isSymlink);
@@ -122,12 +122,12 @@ unitTest({ perms: { read: true } }, function lstatSyncSuccess() {
assert(packageInfoByUrl.isFile);
assert(!packageInfoByUrl.isSymlink);
- const modulesInfo = Deno.lstatSync("cli/tests/symlink_to_subdir");
+ const modulesInfo = Deno.lstatSync("cli/tests/testdata/symlink_to_subdir");
assert(!modulesInfo.isDirectory);
assert(modulesInfo.isSymlink);
const modulesInfoByUrl = Deno.lstatSync(
- pathToAbsoluteFileUrl("cli/tests/symlink_to_subdir"),
+ pathToAbsoluteFileUrl("cli/tests/testdata/symlink_to_subdir"),
);
assert(!modulesInfoByUrl.isDirectory);
assert(modulesInfoByUrl.isSymlink);
@@ -143,7 +143,7 @@ unitTest({ perms: { read: true } }, function lstatSyncSuccess() {
unitTest({ perms: { read: false } }, function lstatSyncPerm() {
assertThrows(() => {
- Deno.lstatSync("README.md");
+ Deno.lstatSync("hello.txt");
}, Deno.errors.PermissionDenied);
});
@@ -156,22 +156,22 @@ unitTest({ perms: { read: true } }, function lstatSyncNotFound() {
unitTest(
{ perms: { read: true, write: true } },
async function statSuccess() {
- const packageInfo = await Deno.stat("README.md");
- assert(packageInfo.isFile);
- assert(!packageInfo.isSymlink);
+ const readmeInfo = await Deno.stat("README.md");
+ assert(readmeInfo.isFile);
+ assert(!readmeInfo.isSymlink);
- const packageInfoByUrl = await Deno.stat(
+ const readmeInfoByUrl = await Deno.stat(
pathToAbsoluteFileUrl("README.md"),
);
- assert(packageInfoByUrl.isFile);
- assert(!packageInfoByUrl.isSymlink);
+ assert(readmeInfoByUrl.isFile);
+ assert(!readmeInfoByUrl.isSymlink);
- const modulesInfo = await Deno.stat("cli/tests/symlink_to_subdir");
+ const modulesInfo = await Deno.stat("cli/tests/testdata/symlink_to_subdir");
assert(modulesInfo.isDirectory);
assert(!modulesInfo.isSymlink);
const modulesInfoByUrl = await Deno.stat(
- pathToAbsoluteFileUrl("cli/tests/symlink_to_subdir"),
+ pathToAbsoluteFileUrl("cli/tests/testdata/symlink_to_subdir"),
);
assert(modulesInfoByUrl.isDirectory);
assert(!modulesInfoByUrl.isSymlink);
@@ -234,20 +234,20 @@ unitTest({ perms: { read: true } }, async function statNotFound() {
});
unitTest({ perms: { read: true } }, async function lstatSuccess() {
- const packageInfo = await Deno.lstat("README.md");
- assert(packageInfo.isFile);
- assert(!packageInfo.isSymlink);
+ const readmeInfo = await Deno.lstat("README.md");
+ assert(readmeInfo.isFile);
+ assert(!readmeInfo.isSymlink);
- const packageInfoByUrl = await Deno.lstat(pathToAbsoluteFileUrl("README.md"));
- assert(packageInfoByUrl.isFile);
- assert(!packageInfoByUrl.isSymlink);
+ const readmeInfoByUrl = await Deno.lstat(pathToAbsoluteFileUrl("README.md"));
+ assert(readmeInfoByUrl.isFile);
+ assert(!readmeInfoByUrl.isSymlink);
- const modulesInfo = await Deno.lstat("cli/tests/symlink_to_subdir");
+ const modulesInfo = await Deno.lstat("cli/tests/testdata/symlink_to_subdir");
assert(!modulesInfo.isDirectory);
assert(modulesInfo.isSymlink);
const modulesInfoByUrl = await Deno.lstat(
- pathToAbsoluteFileUrl("cli/tests/symlink_to_subdir"),
+ pathToAbsoluteFileUrl("cli/tests/testdata/symlink_to_subdir"),
);
assert(!modulesInfoByUrl.isDirectory);
assert(modulesInfoByUrl.isSymlink);
diff --git a/cli/tests/unit/tls_test.ts b/cli/tests/unit/tls_test.ts
index 8472d93e0..12fe9bd50 100644
--- a/cli/tests/unit/tls_test.ts
+++ b/cli/tests/unit/tls_test.ts
@@ -37,8 +37,8 @@ unitTest(
const listener = await Deno.listenTls({
hostname: "localhost",
port: 3567,
- certFile: "cli/tests/tls/localhost.crt",
- keyFile: "cli/tests/tls/localhost.key",
+ certFile: "cli/tests/testdata/tls/localhost.crt",
+ keyFile: "cli/tests/testdata/tls/localhost.key",
});
await assertThrowsAsync(async () => {
@@ -54,7 +54,7 @@ unitTest(async function connectTLSCertFileNoReadPerm() {
await Deno.connectTls({
hostname: "deno.land",
port: 443,
- certFile: "cli/tests/tls/RootCA.crt",
+ certFile: "cli/tests/testdata/tls/RootCA.crt",
});
}, Deno.errors.PermissionDenied);
});
@@ -65,8 +65,8 @@ unitTest(
const options = {
hostname: "localhost",
port: 3500,
- certFile: "cli/tests/tls/localhost.crt",
- keyFile: "cli/tests/tls/localhost.key",
+ certFile: "cli/tests/testdata/tls/localhost.crt",
+ keyFile: "cli/tests/testdata/tls/localhost.key",
};
assertThrows(() => {
@@ -90,8 +90,8 @@ unitTest({ perms: { net: true } }, function listenTLSNoReadPerm() {
Deno.listenTls({
hostname: "localhost",
port: 3500,
- certFile: "cli/tests/tls/localhost.crt",
- keyFile: "cli/tests/tls/localhost.key",
+ certFile: "cli/tests/testdata/tls/localhost.crt",
+ keyFile: "cli/tests/testdata/tls/localhost.key",
});
}, Deno.errors.PermissionDenied);
});
@@ -104,8 +104,8 @@ unitTest(
const options = {
hostname: "localhost",
port: 3500,
- certFile: "cli/tests/tls/localhost.crt",
- keyFile: "cli/tests/tls/localhost.key",
+ certFile: "cli/tests/testdata/tls/localhost.crt",
+ keyFile: "cli/tests/testdata/tls/localhost.key",
};
const testDir = Deno.makeTempDirSync();
@@ -129,8 +129,8 @@ unitTest(
const options = {
hostname: "localhost",
port: 3500,
- certFile: "cli/tests/tls/localhost.crt",
- keyFile: "cli/tests/tls/localhost.key",
+ certFile: "cli/tests/testdata/tls/localhost.crt",
+ keyFile: "cli/tests/testdata/tls/localhost.key",
};
const testDir = Deno.makeTempDirSync();
@@ -158,8 +158,8 @@ unitTest(
const listener = Deno.listenTls({
hostname,
port,
- certFile: "cli/tests/tls/localhost.crt",
- keyFile: "cli/tests/tls/localhost.key",
+ certFile: "cli/tests/testdata/tls/localhost.crt",
+ keyFile: "cli/tests/testdata/tls/localhost.key",
});
const response = encoder.encode(
@@ -182,7 +182,7 @@ unitTest(
const conn = await Deno.connectTls({
hostname,
port,
- certFile: "cli/tests/tls/RootCA.pem",
+ certFile: "cli/tests/testdata/tls/RootCA.pem",
});
assert(conn.rid > 0);
const w = new BufWriter(conn);
@@ -222,15 +222,15 @@ async function tlsPair(): Promise<[Deno.Conn, Deno.Conn]> {
const listener = Deno.listenTls({
hostname: "localhost",
port,
- certFile: "cli/tests/tls/localhost.crt",
- keyFile: "cli/tests/tls/localhost.key",
+ certFile: "cli/tests/testdata/tls/localhost.crt",
+ keyFile: "cli/tests/testdata/tls/localhost.key",
});
const acceptPromise = listener.accept();
const connectPromise = Deno.connectTls({
hostname: "localhost",
port,
- certFile: "cli/tests/tls/RootCA.pem",
+ certFile: "cli/tests/testdata/tls/RootCA.pem",
});
const endpoints = await Promise.all([acceptPromise, connectPromise]);
@@ -553,8 +553,8 @@ async function tlsWithTcpFailureTestImpl(
const tlsListener = Deno.listenTls({
hostname: "localhost",
port: tlsPort,
- certFile: "cli/tests/tls/localhost.crt",
- keyFile: "cli/tests/tls/localhost.key",
+ certFile: "cli/tests/testdata/tls/localhost.crt",
+ keyFile: "cli/tests/testdata/tls/localhost.key",
});
const tcpPort = getPort();
@@ -570,7 +570,7 @@ async function tlsWithTcpFailureTestImpl(
Deno.connectTls({
hostname: "localhost",
port: tcpPort,
- certFile: "cli/tests/tls/RootCA.crt",
+ certFile: "cli/tests/testdata/tls/RootCA.crt",
}),
]);
@@ -845,8 +845,8 @@ function createHttpsListener(port: number): Deno.Listener {
const listener = Deno.listenTls({
hostname: "localhost",
port,
- certFile: "./cli/tests/tls/localhost.crt",
- keyFile: "./cli/tests/tls/localhost.key",
+ certFile: "./cli/tests/testdata/tls/localhost.crt",
+ keyFile: "./cli/tests/testdata/tls/localhost.key",
});
serve(listener);
@@ -995,7 +995,9 @@ unitTest(
hostname: "deno.land",
port: 443,
certChain: "bad data",
- privateKey: await Deno.readTextFile("cli/tests/tls/localhost.key"),
+ privateKey: await Deno.readTextFile(
+ "cli/tests/testdata/tls/localhost.key",
+ ),
});
}, Deno.errors.InvalidData);
},
@@ -1008,7 +1010,9 @@ unitTest(
await Deno.connectTls({
hostname: "deno.land",
port: 443,
- certChain: await Deno.readTextFile("cli/tests/tls/localhost.crt"),
+ certChain: await Deno.readTextFile(
+ "cli/tests/testdata/tls/localhost.crt",
+ ),
privateKey: "bad data",
});
}, Deno.errors.InvalidData);
@@ -1022,7 +1026,9 @@ unitTest(
await Deno.connectTls({
hostname: "deno.land",
port: 443,
- certChain: await Deno.readTextFile("cli/tests/tls/localhost.crt"),
+ certChain: await Deno.readTextFile(
+ "cli/tests/testdata/tls/localhost.crt",
+ ),
privateKey: "",
});
}, Deno.errors.InvalidData);
@@ -1034,15 +1040,19 @@ unitTest(
async function connectWithClientCert() {
// The test_server running on port 4552 responds with 'PASS' if client
// authentication was successful. Try it by running test_server and
- // curl --key cli/tests/tls/localhost.key \
- // --cert cli/tests/tls/localhost.crt \
- // --cacert cli/tests/tls/RootCA.crt https://localhost:4552/
+ // curl --key cli/tests/testdata/tls/localhost.key \
+ // --cert cli/tests/testdata/tls/localhost.crt \
+ // --cacert cli/tests/testdata/tls/RootCA.crt https://localhost:4552/
const conn = await Deno.connectTls({
hostname: "localhost",
port: 4552,
- certChain: await Deno.readTextFile("cli/tests/tls/localhost.crt"),
- privateKey: await Deno.readTextFile("cli/tests/tls/localhost.key"),
- certFile: "cli/tests/tls/RootCA.crt",
+ certChain: await Deno.readTextFile(
+ "cli/tests/testdata/tls/localhost.crt",
+ ),
+ privateKey: await Deno.readTextFile(
+ "cli/tests/testdata/tls/localhost.key",
+ ),
+ certFile: "cli/tests/testdata/tls/RootCA.crt",
});
const result = decoder.decode(await readAll(conn));
assertEquals(result, "PASS");
diff --git a/cli/tests/unit/tty_test.ts b/cli/tests/unit/tty_test.ts
index a9f1105f6..b45a43f1a 100644
--- a/cli/tests/unit/tty_test.ts
+++ b/cli/tests/unit/tty_test.ts
@@ -4,7 +4,7 @@ import { assert, assertThrows, unitTest } from "./test_util.ts";
// Note tests for Deno.setRaw is in integration tests.
unitTest({ perms: { read: true } }, function consoleSizeFile() {
- const file = Deno.openSync("cli/tests/hello.txt");
+ const file = Deno.openSync("cli/tests/testdata/hello.txt");
assertThrows(() => {
Deno.consoleSize(file.rid);
}, Error);
@@ -20,7 +20,7 @@ unitTest(function consoleSizeError() {
unitTest({ perms: { read: true } }, function isatty() {
// CI not under TTY, so cannot test stdin/stdout/stderr.
- const f = Deno.openSync("cli/tests/hello.txt");
+ const f = Deno.openSync("cli/tests/testdata/hello.txt");
assert(!Deno.isatty(f.rid));
f.close();
});
diff --git a/cli/tests/unit/wasm_test.ts b/cli/tests/unit/wasm_test.ts
index 66fcacade..c2180db3c 100644
--- a/cli/tests/unit/wasm_test.ts
+++ b/cli/tests/unit/wasm_test.ts
@@ -74,7 +74,7 @@ unitTest(
// deno-dom's WASM file is a real-world non-trivial case that gave us
// trouble when implementing this.
await WebAssembly.instantiateStreaming(fetch(
- "http://localhost:4545/cli/tests/deno_dom_0.1.3-alpha2.wasm",
+ "http://localhost:4545/deno_dom_0.1.3-alpha2.wasm",
));
},
);
diff --git a/cli/tests/unit/webgpu_test.ts b/cli/tests/unit/webgpu_test.ts
index 4fbbd5cde..cbefa7c07 100644
--- a/cli/tests/unit/webgpu_test.ts
+++ b/cli/tests/unit/webgpu_test.ts
@@ -22,7 +22,7 @@ unitTest({
assert(device);
const shaderCode = await Deno.readTextFile(
- "cli/tests/webgpu_computepass_shader.wgsl",
+ "cli/tests/testdata/webgpu_computepass_shader.wgsl",
);
const shaderModule = device.createShaderModule({
@@ -111,7 +111,7 @@ unitTest({
assert(device);
const shaderCode = await Deno.readTextFile(
- "cli/tests/webgpu_hellotriangle_shader.wgsl",
+ "cli/tests/testdata/webgpu_hellotriangle_shader.wgsl",
);
const shaderModule = device.createShaderModule({
@@ -194,7 +194,10 @@ unitTest({
await outputBuffer.mapAsync(1);
const data = new Uint8Array(outputBuffer.getMappedRange());
- assertEquals(data, await Deno.readFile("cli/tests/webgpu_hellotriangle.out"));
+ assertEquals(
+ data,
+ await Deno.readFile("cli/tests/testdata/webgpu_hellotriangle.out"),
+ );
outputBuffer.unmap();