summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/041_info_flag.out1
-rw-r--r--cli/tests/041_info_flag_location.out6
-rw-r--r--cli/tests/info_json.out3
-rw-r--r--cli/tests/info_json_location.out8
-rw-r--r--cli/tests/integration_tests.rs10
-rw-r--r--cli/tests/unit/broadcast_channel_test.ts27
-rw-r--r--cli/tests/unit/utime_test.ts39
-rw-r--r--cli/tests/unit/version_test.ts3
-rw-r--r--cli/tests/workers/broadcast_channel.ts5
9 files changed, 100 insertions, 2 deletions
diff --git a/cli/tests/041_info_flag.out b/cli/tests/041_info_flag.out
index 4376c8156..ded795339 100644
--- a/cli/tests/041_info_flag.out
+++ b/cli/tests/041_info_flag.out
@@ -2,3 +2,4 @@ DENO_DIR location: "[WILDCARD]"
Remote modules cache: "[WILDCARD]deps"
Emitted modules cache: "[WILDCARD]gen"
Language server registries cache: "[WILDCARD]registries"
+Origin storage: "[WILDCARD]location_data"
diff --git a/cli/tests/041_info_flag_location.out b/cli/tests/041_info_flag_location.out
new file mode 100644
index 000000000..207065012
--- /dev/null
+++ b/cli/tests/041_info_flag_location.out
@@ -0,0 +1,6 @@
+DENO_DIR location: "[WILDCARD]"
+Remote modules cache: "[WILDCARD]deps"
+Emitted modules cache: "[WILDCARD]gen"
+Language server registries cache: "[WILDCARD]registries"
+Origin storage: "[WILDCARD]location_data[WILDCARD]"
+Local Storage: "[WILDCARD]location_data[WILDCARD]local_storage"
diff --git a/cli/tests/info_json.out b/cli/tests/info_json.out
index d7be26375..a0d316307 100644
--- a/cli/tests/info_json.out
+++ b/cli/tests/info_json.out
@@ -2,5 +2,6 @@
"denoDir": "[WILDCARD]",
"modulesCache": "[WILDCARD]deps",
"typescriptCache": "[WILDCARD]gen",
- "registryCache": "[WILDCARD]registries"
+ "registryCache": "[WILDCARD]registries",
+ "originStorage": "[WILDCARD]location_data"
} \ No newline at end of file
diff --git a/cli/tests/info_json_location.out b/cli/tests/info_json_location.out
new file mode 100644
index 000000000..dd9377d3b
--- /dev/null
+++ b/cli/tests/info_json_location.out
@@ -0,0 +1,8 @@
+{
+ "denoDir": "[WILDCARD]",
+ "modulesCache": "[WILDCARD]deps",
+ "typescriptCache": "[WILDCARD]gen",
+ "registryCache": "[WILDCARD]registries",
+ "originStorage": "[WILDCARD]location_data[WILDCARD]",
+ "localStorage": "[WILDCARD]location_data[WILDCARD]local_storage"
+} \ No newline at end of file
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index de009a064..5af533dab 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -2846,11 +2846,21 @@ console.log("finish");
output: "041_info_flag.out",
});
+ itest!(_042_info_flag_location {
+ args: "info --location https://deno.land",
+ output: "041_info_flag_location.out",
+ });
+
itest!(info_json {
args: "info --json --unstable",
output: "info_json.out",
});
+ itest!(info_json_location {
+ args: "info --json --unstable --location https://deno.land",
+ output: "info_json_location.out",
+ });
+
itest!(_042_dyn_import_evalcontext {
args: "run --quiet --allow-read --reload 042_dyn_import_evalcontext.ts",
output: "042_dyn_import_evalcontext.ts.out",
diff --git a/cli/tests/unit/broadcast_channel_test.ts b/cli/tests/unit/broadcast_channel_test.ts
new file mode 100644
index 000000000..cfa62c856
--- /dev/null
+++ b/cli/tests/unit/broadcast_channel_test.ts
@@ -0,0 +1,27 @@
+// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
+import { assertEquals } from "../../../test_util/std/testing/asserts.ts";
+import { deferred } from "../../../test_util/std/async/deferred.ts";
+
+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 worker = new Worker(url.href, { type: "module", name: "worker" });
+ worker.onmessage = () => intercom.postMessage(++count);
+
+ const promise = deferred();
+
+ intercom.onmessage = function (e) {
+ assertEquals(count, e.data);
+ if (count < 42) {
+ intercom.postMessage(++count);
+ } else {
+ worker.terminate();
+ intercom.close();
+ promise.resolve();
+ }
+ };
+
+ await promise;
+});
diff --git a/cli/tests/unit/utime_test.ts b/cli/tests/unit/utime_test.ts
index 4e56ff193..32b631406 100644
--- a/cli/tests/unit/utime_test.ts
+++ b/cli/tests/unit/utime_test.ts
@@ -3,6 +3,7 @@ import {
assertEquals,
assertThrows,
assertThrowsAsync,
+ pathToAbsoluteFileUrl,
unitTest,
} from "./test_util.ts";
@@ -71,6 +72,25 @@ unitTest(
unitTest(
{ perms: { read: true, write: true } },
+ function utimeSyncUrlSuccess(): void {
+ const testDir = Deno.makeTempDirSync();
+ const filename = testDir + "/file.txt";
+ Deno.writeFileSync(filename, new TextEncoder().encode("hello"), {
+ mode: 0o666,
+ });
+
+ const atime = 1000;
+ const mtime = 50000;
+ Deno.utimeSync(pathToAbsoluteFileUrl(filename), atime, mtime);
+
+ const fileInfo = Deno.statSync(filename);
+ assertEquals(fileInfo.atime, new Date(atime * 1000));
+ assertEquals(fileInfo.mtime, new Date(mtime * 1000));
+ },
+);
+
+unitTest(
+ { perms: { read: true, write: true } },
function utimeSyncDirectorySuccess(): void {
const testDir = Deno.makeTempDirSync();
@@ -179,6 +199,25 @@ unitTest(
unitTest(
{ perms: { read: true, write: true } },
+ async function utimeUrlSuccess(): Promise<void> {
+ const testDir = Deno.makeTempDirSync();
+ const filename = testDir + "/file.txt";
+ Deno.writeFileSync(filename, new TextEncoder().encode("hello"), {
+ mode: 0o666,
+ });
+
+ const atime = 1000;
+ const mtime = 50000;
+ await Deno.utime(pathToAbsoluteFileUrl(filename), atime, mtime);
+
+ const fileInfo = Deno.statSync(filename);
+ assertEquals(fileInfo.atime, new Date(atime * 1000));
+ assertEquals(fileInfo.mtime, new Date(mtime * 1000));
+ },
+);
+
+unitTest(
+ { perms: { read: true, write: true } },
async function utimeDirectorySuccess(): Promise<void> {
const testDir = Deno.makeTempDirSync();
diff --git a/cli/tests/unit/version_test.ts b/cli/tests/unit/version_test.ts
index 91bbb260f..d3a5270c9 100644
--- a/cli/tests/unit/version_test.ts
+++ b/cli/tests/unit/version_test.ts
@@ -7,6 +7,7 @@ unitTest(function version(): void {
// Unreleased version of TypeScript now set the version to 0-dev
assert(
pattern.test(Deno.version.typescript) ||
- Deno.version.typescript === "0-dev",
+ Deno.version.typescript === "0-dev" ||
+ Deno.version.typescript === "0-beta",
);
});
diff --git a/cli/tests/workers/broadcast_channel.ts b/cli/tests/workers/broadcast_channel.ts
new file mode 100644
index 000000000..5076e9eb7
--- /dev/null
+++ b/cli/tests/workers/broadcast_channel.ts
@@ -0,0 +1,5 @@
+new BroadcastChannel("intercom").onmessage = function (e) {
+ this.postMessage(e.data);
+};
+
+self.postMessage("go");