diff --git a/cli/bench/main.rs b/cli/bench/main.rs index d2823a02bd..b69bbc7ac6 100644 --- a/cli/bench/main.rs +++ b/cli/bench/main.rs @@ -55,7 +55,7 @@ const EXEC_TIME_BENCHMARKS: &[(&str, &[&str], Option)] = &[ ), ( "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)] = &[ &[ "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 7c0df57b7b..15da2359df 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 687060172c..d7dd87c540 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 similarity index 93% rename from cli/tests/workers_round_robin_bench.ts rename to cli/tests/workers/bench_round_robin.ts index 3dee290fec..7974760af5 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>, @@ -22,7 +22,7 @@ async function main(): Promise { const workers: Array<[Map>, 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 similarity index 93% rename from cli/tests/workers_startup_bench.ts rename to cli/tests/workers/bench_startup.ts index f85bd13a17..5fbf23b453 100644 --- a/cli/tests/workers_startup_bench.ts +++ b/cli/tests/workers/bench_startup.ts @@ -5,7 +5,7 @@ async function bench(): Promise { 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((resolve): void => { diff --git a/cli/tests/subdir/worker_error.ts b/cli/tests/workers/error.ts similarity index 100% rename from cli/tests/subdir/worker_error.ts rename to cli/tests/workers/error.ts diff --git a/cli/tests/worker_post_undefined.ts b/cli/tests/workers/post_undefined.ts similarity index 100% rename from cli/tests/worker_post_undefined.ts rename to cli/tests/workers/post_undefined.ts diff --git a/cli/tests/workers_test.ts b/cli/tests/workers/test.ts similarity index 88% rename from cli/tests/workers_test.ts rename to cli/tests/workers/test.ts index 383cad8a0a..0888e01db2 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 { 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 { 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 { 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 { 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 { 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 { 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 similarity index 65% rename from cli/tests/073_worker_error.ts rename to cli/tests/workers/worker_error.ts index 736c4fde69..696680de8f 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 similarity index 100% rename from cli/tests/073_worker_error.ts.out rename to cli/tests/workers/worker_error.ts.out diff --git a/cli/tests/subdir/worker_location.ts b/cli/tests/workers/worker_location.ts similarity index 100% rename from cli/tests/subdir/worker_location.ts rename to cli/tests/workers/worker_location.ts diff --git a/cli/tests/074_worker_nested_error.ts b/cli/tests/workers/worker_nested_error.ts similarity index 66% rename from cli/tests/074_worker_nested_error.ts rename to cli/tests/workers/worker_nested_error.ts index 975d897caa..aba2011be5 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 similarity index 100% rename from cli/tests/074_worker_nested_error.ts.out rename to cli/tests/workers/worker_nested_error.ts.out diff --git a/cli/tests/subdir/worker_types.ts b/cli/tests/workers/worker_types.ts similarity index 100% rename from cli/tests/subdir/worker_types.ts rename to cli/tests/workers/worker_types.ts