summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2021-02-15 14:48:47 +0100
committerGitHub <noreply@github.com>2021-02-15 14:48:47 +0100
commit8c6d147e6ae40a1f92aba1aedc0d95ef437dd4ba (patch)
treefbb59c9a6b294fd242854480067ae50cfb61fba7
parent1afe6b48e0bfee44f37206eb0fc03ea6ae37ad4d (diff)
chore: Reorganise workers tests (#9493)
-rw-r--r--cli/bench/main.rs4
-rw-r--r--cli/tests/integration_tests.rs26
-rw-r--r--cli/tests/unit/worker_types.ts2
-rw-r--r--cli/tests/workers/bench_round_robin.ts (renamed from cli/tests/workers_round_robin_bench.ts)4
-rw-r--r--cli/tests/workers/bench_startup.ts (renamed from cli/tests/workers_startup_bench.ts)2
-rw-r--r--cli/tests/workers/error.ts (renamed from cli/tests/subdir/worker_error.ts)0
-rw-r--r--cli/tests/workers/post_undefined.ts (renamed from cli/tests/worker_post_undefined.ts)0
-rw-r--r--cli/tests/workers/test.ts (renamed from cli/tests/workers_test.ts)57
-rw-r--r--cli/tests/workers/worker_error.ts (renamed from cli/tests/073_worker_error.ts)2
-rw-r--r--cli/tests/workers/worker_error.ts.out (renamed from cli/tests/073_worker_error.ts.out)0
-rw-r--r--cli/tests/workers/worker_location.ts (renamed from cli/tests/subdir/worker_location.ts)0
-rw-r--r--cli/tests/workers/worker_nested_error.ts (renamed from cli/tests/074_worker_nested_error.ts)2
-rw-r--r--cli/tests/workers/worker_nested_error.ts.out (renamed from cli/tests/074_worker_nested_error.ts.out)0
-rw-r--r--cli/tests/workers/worker_types.ts (renamed from cli/tests/subdir/worker_types.ts)0
14 files changed, 49 insertions, 50 deletions
diff --git a/cli/bench/main.rs b/cli/bench/main.rs
index d2823a02b..b69bbc7ac 100644
--- a/cli/bench/main.rs
+++ b/cli/bench/main.rs
@@ -55,7 +55,7 @@ const EXEC_TIME_BENCHMARKS: &[(&str, &[&str], Option<i32>)] = &[
),
(
"workers_startup",
- &["run", "--allow-read", "cli/tests/workers_startup_bench.ts"],
+ &["run", "--allow-read", "cli/tests/workers/bench_startup.ts"],
None,
),
(
@@ -63,7 +63,7 @@ const EXEC_TIME_BENCHMARKS: &[(&str, &[&str], Option<i32>)] = &[
&[
"run",
"--allow-read",
- "cli/tests/workers_round_robin_bench.ts",
+ "cli/tests/workers/bench_round_robin.ts",
],
None,
),
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index 7c0df57b7..15da2359d 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -2369,7 +2369,7 @@ console.log("finish");
.arg("--allow-net")
.arg("--allow-read")
.arg("--unstable")
- .arg("workers_test.ts")
+ .arg("workers/test.ts")
.spawn()
.unwrap()
.wait()
@@ -2377,6 +2377,18 @@ console.log("finish");
assert!(status.success());
}
+ itest!(worker_error {
+ args: "run -A workers/worker_error.ts",
+ output: "workers/worker_error.ts.out",
+ exit_code: 1,
+ });
+
+ itest!(worker_nested_error {
+ args: "run -A workers/worker_nested_error.ts",
+ output: "workers/worker_nested_error.ts.out",
+ exit_code: 1,
+ });
+
#[test]
fn compiler_api() {
let status = util::deno_cmd()
@@ -2626,18 +2638,6 @@ console.log("finish");
http_server: true,
});
- itest!(_073_worker_error {
- args: "run -A 073_worker_error.ts",
- output: "073_worker_error.ts.out",
- exit_code: 1,
- });
-
- itest!(_074_worker_nested_error {
- args: "run -A 074_worker_nested_error.ts",
- output: "074_worker_nested_error.ts.out",
- exit_code: 1,
- });
-
itest!(_075_import_local_query_hash {
args: "run 075_import_local_query_hash.ts",
output: "075_import_local_query_hash.ts.out",
diff --git a/cli/tests/unit/worker_types.ts b/cli/tests/unit/worker_types.ts
index 687060172..d7dd87c54 100644
--- a/cli/tests/unit/worker_types.ts
+++ b/cli/tests/unit/worker_types.ts
@@ -5,7 +5,7 @@ unitTest(
{ perms: { read: true } },
function utimeSyncFileSuccess() {
const w = new Worker(
- new URL("../subdir/worker_types.ts", import.meta.url).href,
+ new URL("../workers/worker_types.ts", import.meta.url).href,
{ type: "module" },
);
assert(w);
diff --git a/cli/tests/workers_round_robin_bench.ts b/cli/tests/workers/bench_round_robin.ts
index 3dee290fe..7974760af 100644
--- a/cli/tests/workers_round_robin_bench.ts
+++ b/cli/tests/workers/bench_round_robin.ts
@@ -5,7 +5,7 @@ const data = "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n";
const workerCount = 4;
const cmdsPerWorker = 400;
-import { Deferred, deferred } from "../../test_util/std/async/deferred.ts";
+import { Deferred, deferred } from "../../../test_util/std/async/deferred.ts";
function handleAsyncMsgFromWorker(
promiseTable: Map<number, Deferred<string>>,
@@ -22,7 +22,7 @@ async function main(): Promise<void> {
const workers: Array<[Map<number, Deferred<string>>, Worker]> = [];
for (let i = 1; i <= workerCount; ++i) {
const worker = new Worker(
- new URL("workers/bench_worker.ts", import.meta.url).href,
+ new URL("bench_worker.ts", import.meta.url).href,
{ type: "module" },
);
const promise = deferred();
diff --git a/cli/tests/workers_startup_bench.ts b/cli/tests/workers/bench_startup.ts
index f85bd13a1..5fbf23b45 100644
--- a/cli/tests/workers_startup_bench.ts
+++ b/cli/tests/workers/bench_startup.ts
@@ -5,7 +5,7 @@ async function bench(): Promise<void> {
const workers: Worker[] = [];
for (let i = 1; i <= workerCount; ++i) {
const worker = new Worker(
- new URL("workers/bench_worker.ts", import.meta.url).href,
+ new URL("bench_worker.ts", import.meta.url).href,
{ type: "module" },
);
const promise = new Promise<void>((resolve): void => {
diff --git a/cli/tests/subdir/worker_error.ts b/cli/tests/workers/error.ts
index 495971090..495971090 100644
--- a/cli/tests/subdir/worker_error.ts
+++ b/cli/tests/workers/error.ts
diff --git a/cli/tests/worker_post_undefined.ts b/cli/tests/workers/post_undefined.ts
index 1b9b8d6ca..1b9b8d6ca 100644
--- a/cli/tests/worker_post_undefined.ts
+++ b/cli/tests/workers/post_undefined.ts
diff --git a/cli/tests/workers_test.ts b/cli/tests/workers/test.ts
index 383cad8a0..0888e01db 100644
--- a/cli/tests/workers_test.ts
+++ b/cli/tests/workers/test.ts
@@ -6,9 +6,8 @@ import {
assert,
assertEquals,
assertThrows,
- fail,
-} from "../../test_util/std/testing/asserts.ts";
-import { deferred } from "../../test_util/std/async/deferred.ts";
+} from "../../../test_util/std/testing/asserts.ts";
+import { deferred } from "../../../test_util/std/async/deferred.ts";
Deno.test({
name: "worker terminate",
@@ -16,11 +15,11 @@ Deno.test({
const promise = deferred();
const jsWorker = new Worker(
- new URL("workers/test_worker.js", import.meta.url).href,
+ new URL("test_worker.js", import.meta.url).href,
{ type: "module" },
);
const tsWorker = new Worker(
- new URL("workers/test_worker.ts", import.meta.url).href,
+ new URL("test_worker.ts", import.meta.url).href,
{ type: "module", name: "tsWorker" },
);
@@ -73,7 +72,7 @@ Deno.test({
const promise = deferred();
const nestedWorker = new Worker(
- new URL("workers/nested_worker.js", import.meta.url).href,
+ new URL("nested_worker.js", import.meta.url).href,
{ type: "module", name: "nested" },
);
@@ -93,7 +92,7 @@ Deno.test({
fn: async function (): Promise<void> {
const promise = deferred();
const throwingWorker = new Worker(
- new URL("workers/throwing_worker.js", import.meta.url).href,
+ new URL("throwing_worker.js", import.meta.url).href,
{ type: "module" },
);
@@ -115,7 +114,7 @@ Deno.test({
const promise = deferred();
const workerOptions: WorkerOptions = { type: "module" };
const w = new Worker(
- new URL("workers/worker_globals.ts", import.meta.url).href,
+ new URL("worker_globals.ts", import.meta.url).href,
workerOptions,
);
w.onmessage = (e): void => {
@@ -134,7 +133,7 @@ Deno.test({
const promise = deferred();
const fetchingWorker = new Worker(
- new URL("workers/fetching_worker.js", import.meta.url).href,
+ new URL("fetching_worker.js", import.meta.url).href,
{ type: "module" },
);
@@ -161,7 +160,7 @@ Deno.test({
const promise = deferred();
const busyWorker = new Worker(
- new URL("workers/busy_worker.js", import.meta.url).href,
+ new URL("busy_worker.js", import.meta.url).href,
{ type: "module" },
);
@@ -194,7 +193,7 @@ Deno.test({
const promise = deferred();
const racyWorker = new Worker(
- new URL("workers/racy_worker.js", import.meta.url).href,
+ new URL("racy_worker.js", import.meta.url).href,
{ type: "module" },
);
@@ -222,7 +221,7 @@ Deno.test({
const promise2 = deferred();
const worker = new Worker(
- new URL("workers/event_worker.js", import.meta.url).href,
+ new URL("event_worker.js", import.meta.url).href,
{ type: "module" },
);
@@ -266,7 +265,7 @@ Deno.test({
const promise1 = deferred();
const worker = new Worker(
- new URL("workers/event_worker_scope.js", import.meta.url).href,
+ new URL("event_worker_scope.js", import.meta.url).href,
{ type: "module" },
);
@@ -295,11 +294,11 @@ Deno.test({
const promise2 = deferred();
const regularWorker = new Worker(
- new URL("workers/non_deno_worker.js", import.meta.url).href,
+ new URL("non_deno_worker.js", import.meta.url).href,
{ type: "module" },
);
const denoWorker = new Worker(
- new URL("workers/deno_worker.ts", import.meta.url).href,
+ new URL("deno_worker.ts", import.meta.url).href,
{
type: "module",
deno: {
@@ -333,7 +332,7 @@ Deno.test({
fn: async function (): Promise<void> {
const promise = deferred();
const w = new Worker(
- new URL("workers/worker_crypto.js", import.meta.url).href,
+ new URL("worker_crypto.js", import.meta.url).href,
{ type: "module" },
);
w.onmessage = (e): void => {
@@ -351,7 +350,7 @@ Deno.test({
fn: async function (): Promise<void> {
const promise = deferred();
const w = new Worker(
- new URL("workers/test_worker.ts", import.meta.url).href,
+ new URL("test_worker.ts", import.meta.url).href,
{ type: "module", name: "tsWorker" },
);
const arr: number[] = [];
@@ -375,7 +374,7 @@ Deno.test({
fn: async function (): Promise<void> {
const promise = deferred();
const w = new Worker(
- new URL("./workers/immediately_close_worker.js", import.meta.url).href,
+ new URL("./immediately_close_worker.js", import.meta.url).href,
{ type: "module" },
);
setTimeout(() => {
@@ -391,7 +390,7 @@ Deno.test({
fn: async function (): Promise<void> {
const promise = deferred();
const worker = new Worker(
- new URL("./worker_post_undefined.ts", import.meta.url).href,
+ new URL("./post_undefined.ts", import.meta.url).href,
{ type: "module" },
);
@@ -414,7 +413,7 @@ Deno.test({
Deno.test("Worker inherits permissions", async function () {
const promise = deferred();
const worker = new Worker(
- new URL("./workers/read_check_worker.js", import.meta.url).href,
+ new URL("./read_check_worker.js", import.meta.url).href,
{
type: "module",
deno: {
@@ -438,7 +437,7 @@ Deno.test("Worker inherits permissions", async function () {
Deno.test("Worker limit children permissions", async function () {
const promise = deferred();
const worker = new Worker(
- new URL("./workers/read_check_worker.js", import.meta.url).href,
+ new URL("./read_check_worker.js", import.meta.url).href,
{
type: "module",
deno: {
@@ -464,14 +463,14 @@ Deno.test("Worker limit children permissions", async function () {
Deno.test("Worker limit children permissions granularly", async function () {
const promise = deferred();
const worker = new Worker(
- new URL("./workers/read_check_granular_worker.js", import.meta.url).href,
+ new URL("./read_check_granular_worker.js", import.meta.url).href,
{
type: "module",
deno: {
namespace: true,
permissions: {
read: [
- new URL("./workers/read_check_worker.js", import.meta.url),
+ new URL("./read_check_worker.js", import.meta.url),
],
},
},
@@ -510,7 +509,7 @@ Deno.test("Nested worker limit children permissions", async function () {
/** This worker has read permissions but doesn't grant them to its children */
const worker = new Worker(
- new URL("./workers/parent_read_check_worker.js", import.meta.url).href,
+ new URL("./parent_read_check_worker.js", import.meta.url).href,
{
type: "module",
deno: {
@@ -537,7 +536,7 @@ Deno.test("Nested worker limit children permissions granularly", async function
/** This worker has read permissions but doesn't grant them to its children */
const worker = new Worker(
- new URL("./workers/parent_read_check_granular_worker.js", import.meta.url)
+ new URL("./parent_read_check_granular_worker.js", import.meta.url)
.href,
{
type: "module",
@@ -545,7 +544,7 @@ Deno.test("Nested worker limit children permissions granularly", async function
namespace: true,
permissions: {
read: [
- new URL("./workers/read_check_granular_worker.js", import.meta.url),
+ new URL("./read_check_granular_worker.js", import.meta.url),
],
},
},
@@ -599,7 +598,7 @@ Deno.test("Worker initialization throws on worker permissions greater than paren
assertThrows(
() => {
const worker = new Worker(
- new URL("./workers/deno_worker.ts", import.meta.url).href,
+ new URL("./deno_worker.ts", import.meta.url).href,
{
type: "module",
deno: {
@@ -621,7 +620,7 @@ Deno.test("Worker with disabled permissions", async function () {
const promise = deferred();
const worker = new Worker(
- new URL("./workers/no_permissions_worker.js", import.meta.url).href,
+ new URL("./no_permissions_worker.js", import.meta.url).href,
{
type: "module",
deno: {
@@ -646,7 +645,7 @@ Deno.test({
fn: async function (): Promise<void> {
const promise = deferred();
const workerModuleHref =
- new URL("subdir/worker_location.ts", import.meta.url).href;
+ new URL("worker_location.ts", import.meta.url).href;
const w = new Worker(workerModuleHref, { type: "module" });
w.onmessage = (e): void => {
assertEquals(e.data, `${workerModuleHref}, true`);
diff --git a/cli/tests/073_worker_error.ts b/cli/tests/workers/worker_error.ts
index 736c4fde6..696680de8 100644
--- a/cli/tests/073_worker_error.ts
+++ b/cli/tests/workers/worker_error.ts
@@ -1,5 +1,5 @@
const worker = new Worker(
- new URL("subdir/worker_error.ts", import.meta.url).href,
+ new URL("error.ts", import.meta.url).href,
{ type: "module", name: "bar" },
);
setTimeout(() => worker.terminate(), 30000);
diff --git a/cli/tests/073_worker_error.ts.out b/cli/tests/workers/worker_error.ts.out
index e46478979..e46478979 100644
--- a/cli/tests/073_worker_error.ts.out
+++ b/cli/tests/workers/worker_error.ts.out
diff --git a/cli/tests/subdir/worker_location.ts b/cli/tests/workers/worker_location.ts
index 89fa83036..89fa83036 100644
--- a/cli/tests/subdir/worker_location.ts
+++ b/cli/tests/workers/worker_location.ts
diff --git a/cli/tests/074_worker_nested_error.ts b/cli/tests/workers/worker_nested_error.ts
index 975d897ca..aba2011be 100644
--- a/cli/tests/074_worker_nested_error.ts
+++ b/cli/tests/workers/worker_nested_error.ts
@@ -1,5 +1,5 @@
const worker = new Worker(
- new URL("073_worker_error.ts", import.meta.url).href,
+ new URL("worker_error.ts", import.meta.url).href,
{ type: "module", name: "baz" },
);
setTimeout(() => worker.terminate(), 30000);
diff --git a/cli/tests/074_worker_nested_error.ts.out b/cli/tests/workers/worker_nested_error.ts.out
index e46478979..e46478979 100644
--- a/cli/tests/074_worker_nested_error.ts.out
+++ b/cli/tests/workers/worker_nested_error.ts.out
diff --git a/cli/tests/subdir/worker_types.ts b/cli/tests/workers/worker_types.ts
index b67a3b782..b67a3b782 100644
--- a/cli/tests/subdir/worker_types.ts
+++ b/cli/tests/workers/worker_types.ts