diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-04-29 10:08:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-29 10:08:27 -0400 |
commit | da52058a945999d486b07700d2834f027a65947c (patch) | |
tree | b6031c274cbc36dcefc6d681473e366cdb208c89 /tests/specs | |
parent | b02ffec37c73be8a73b95b33b32efa693e84e01b (diff) |
chore: migrate bench, publish, and more itests to spec tests (#23584)
Diffstat (limited to 'tests/specs')
331 files changed, 2599 insertions, 27 deletions
diff --git a/tests/specs/README.md b/tests/specs/README.md index 55880fe23..5711b41d5 100644 --- a/tests/specs/README.md +++ b/tests/specs/README.md @@ -78,6 +78,7 @@ a "steps" array. - `output` - Path to use to assert the output. - `cleanDenoDir` (boolean) - Whether to empty the deno_dir before running the step. +- `flaky` - Step should be repeated until success a maximum of 3 times. - `if` (`"windows"`, `"linux"`, `"mac"`, `"unix"`) - Whether to run this step. - `exitCode` (number) - Expected exit code. diff --git a/tests/specs/bench/allow_all/__test__.jsonc b/tests/specs/bench/allow_all/__test__.jsonc new file mode 100644 index 000000000..dcc5cc421 --- /dev/null +++ b/tests/specs/bench/allow_all/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --allow-all allow_all.ts", + "output": "allow_all.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/allow_all/allow_all.out b/tests/specs/bench/allow_all/allow_all.out new file mode 100644 index 000000000..0c6a8a034 --- /dev/null +++ b/tests/specs/bench/allow_all/allow_all.out @@ -0,0 +1,23 @@ +[WILDCARD] +Check [WILDLINE]/allow_all.ts +cpu: [WILDLINE] +runtime: deno [WILDLINE] ([WILDLINE]) + +[WILDLINE]/allow_all.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +------------------------------------------------------------------ ----------------------------- +read false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +read true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +write false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +write true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +net false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +net true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +env false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +env true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +run false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +run true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +ffi false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +ffi true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +hrtime false [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] +hrtime true [WILDLINE] [WILDLINE]/iter[WILDLINE]([WILDLINE] … [WILDLINE]) [WILDLINE] + diff --git a/tests/specs/bench/allow_all/allow_all.ts b/tests/specs/bench/allow_all/allow_all.ts new file mode 100644 index 000000000..9747fb414 --- /dev/null +++ b/tests/specs/bench/allow_all/allow_all.ts @@ -0,0 +1,43 @@ +import { assertEquals } from "jsr:@std/assert"; + +const permissions: Deno.PermissionName[] = [ + "read", + "write", + "net", + "env", + "run", + "ffi", + "hrtime", +]; + +for (const name of permissions) { + Deno.bench({ + name: `${name} false`, + permissions: { + [name]: false, + }, + async fn() { + for await (const n of permissions) { + const status = await Deno.permissions.query({ name: n }); + assertEquals(status.state, "prompt"); + } + }, + }); + + Deno.bench({ + name: `${name} true`, + permissions: { + [name]: true, + }, + async fn() { + for await (const n of permissions) { + const status = await Deno.permissions.query({ name: n }); + if (n === name) { + assertEquals(status.state, "granted"); + } else { + assertEquals(status.state, "prompt"); + } + } + }, + }); +} diff --git a/tests/specs/bench/allow_none/__test__.jsonc b/tests/specs/bench/allow_none/__test__.jsonc new file mode 100644 index 000000000..9ae51f75b --- /dev/null +++ b/tests/specs/bench/allow_none/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench allow_none.ts", + "output": "allow_none.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/allow_none/allow_none.out b/tests/specs/bench/allow_none/allow_none.out new file mode 100644 index 000000000..cfe86adcb --- /dev/null +++ b/tests/specs/bench/allow_none/allow_none.out @@ -0,0 +1,22 @@ +Check [WILDLINE]/allow_none.ts +cpu: [WILDLINE] +runtime: deno [WILDLINE] ([WILDLINE]) + +[WILDLINE]/allow_none.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +read error: PermissionDenied: Can't escalate parent thread permissions +[WILDCARD] +write error: PermissionDenied: Can't escalate parent thread permissions +[WILDCARD] +net error: PermissionDenied: Can't escalate parent thread permissions +[WILDCARD] +env error: PermissionDenied: Can't escalate parent thread permissions +[WILDCARD] +run error: PermissionDenied: Can't escalate parent thread permissions +[WILDCARD] +ffi error: PermissionDenied: Can't escalate parent thread permissions +[WILDCARD] +hrtime error: PermissionDenied: Can't escalate parent thread permissions +[WILDCARD] +error: Bench failed diff --git a/tests/specs/bench/allow_none/allow_none.ts b/tests/specs/bench/allow_none/allow_none.ts new file mode 100644 index 000000000..77f86f256 --- /dev/null +++ b/tests/specs/bench/allow_none/allow_none.ts @@ -0,0 +1,21 @@ +const permissions: Deno.PermissionName[] = [ + "read", + "write", + "net", + "env", + "run", + "ffi", + "hrtime", +]; + +for (const name of permissions) { + Deno.bench({ + name, + permissions: { + [name]: true, + }, + fn() { + throw new Error("unreachable"); + }, + }); +} diff --git a/tests/specs/bench/before_unload_prevent_default/__test__.jsonc b/tests/specs/bench/before_unload_prevent_default/__test__.jsonc new file mode 100644 index 000000000..5253af5df --- /dev/null +++ b/tests/specs/bench/before_unload_prevent_default/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "bench --quiet before_unload_prevent_default.ts", + "output": "before_unload_prevent_default.out" +} diff --git a/tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.out b/tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.out new file mode 100644 index 000000000..dcb6d8194 --- /dev/null +++ b/tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.out @@ -0,0 +1,7 @@ +cpu: [WILDCARD] +runtime: deno [WILDCARD] + +[WILDCARD]/before_unload_prevent_default.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +foo [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.ts b/tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.ts new file mode 100644 index 000000000..2759d4659 --- /dev/null +++ b/tests/specs/bench/before_unload_prevent_default/before_unload_prevent_default.ts @@ -0,0 +1,6 @@ +addEventListener("beforeunload", (e) => { + // The worker should be killed once benchmarks are done regardless of this. + e.preventDefault(); +}); + +Deno.bench("foo", () => {}); diff --git a/tests/specs/bench/bench_explicit_start_end/__test__.jsonc b/tests/specs/bench/bench_explicit_start_end/__test__.jsonc new file mode 100644 index 000000000..e8e5bf8c2 --- /dev/null +++ b/tests/specs/bench/bench_explicit_start_end/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --quiet -A explicit_start_and_end.ts", + "output": "explicit_start_and_end.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.out b/tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.out new file mode 100644 index 000000000..fa118540c --- /dev/null +++ b/tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.out @@ -0,0 +1,25 @@ +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/explicit_start_and_end.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +------------------------------------------------------------------- ----------------------------- +start and end [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +start only [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +end only [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +double start error: TypeError: BenchContext::start() has already been invoked. + t.start(); + ^ + at BenchContext.start ([WILDCARD]) + at [WILDCARD]/explicit_start_and_end.ts:[WILDCARD] +double end error: TypeError: BenchContext::end() has already been invoked. + t.end(); + ^ + at BenchContext.end ([WILDCARD]) + at [WILDCARD]/explicit_start_and_end.ts:[WILDCARD] +captured error: TypeError: The benchmark which this context belongs to is not being executed. + captured!.start(); + ^ + at BenchContext.start ([WILDCARD]) + at [WILDCARD]/explicit_start_and_end.ts:[WILDCARD] +error: Bench failed diff --git a/tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.ts b/tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.ts new file mode 100644 index 000000000..60a3d10d7 --- /dev/null +++ b/tests/specs/bench/bench_explicit_start_end/explicit_start_and_end.ts @@ -0,0 +1,50 @@ +Deno.bench("start and end", (t) => { + const id = setInterval(() => {}, 1000); + t.start(); + Deno.inspect(id); + t.end(); + clearInterval(id); +}); + +Deno.bench("start only", (t) => { + const id = setInterval(() => {}, 1000); + t.start(); + Deno.inspect(id); + clearInterval(id); +}); + +Deno.bench("end only", (t) => { + const id = setInterval(() => {}, 1000); + Deno.inspect(id); + t.end(); + clearInterval(id); +}); + +Deno.bench("double start", (t) => { + const id = setInterval(() => {}, 1000); + t.start(); + t.start(); + Deno.inspect(id); + t.end(); + clearInterval(id); +}); + +let captured: Deno.BenchContext; + +Deno.bench("double end", (t) => { + captured = t; + const id = setInterval(() => {}, 1000); + t.start(); + Deno.inspect(id); + t.end(); + t.end(); + clearInterval(id); +}); + +Deno.bench("captured", () => { + const id = setInterval(() => {}, 1000); + captured!.start(); + Deno.inspect(id); + captured!.end(); + clearInterval(id); +}); diff --git a/tests/specs/bench/bench_formatting/__test__.jsonc b/tests/specs/bench/bench_formatting/__test__.jsonc new file mode 100644 index 000000000..1f1d89394 --- /dev/null +++ b/tests/specs/bench/bench_formatting/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench bench_formatting.ts", + "output": "bench_formatting.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/bench_formatting/bench_formatting.out b/tests/specs/bench/bench_formatting/bench_formatting.out new file mode 100644 index 000000000..79617a32d --- /dev/null +++ b/tests/specs/bench/bench_formatting/bench_formatting.out @@ -0,0 +1,8 @@ +Check [WILDCARD]/bench_formatting.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/bench_formatting.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +[WILDCARD] [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
\ No newline at end of file diff --git a/tests/specs/bench/bench_formatting/bench_formatting.ts b/tests/specs/bench/bench_formatting/bench_formatting.ts new file mode 100644 index 000000000..fdee15abb --- /dev/null +++ b/tests/specs/bench/bench_formatting/bench_formatting.ts @@ -0,0 +1,3 @@ +Deno.bench("Date.now", () => { + Date.now(); +}); diff --git a/tests/specs/bench/check_local_by_default/__test__.jsonc b/tests/specs/bench/check_local_by_default/__test__.jsonc new file mode 100644 index 000000000..76dd80b7b --- /dev/null +++ b/tests/specs/bench/check_local_by_default/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "bench --quiet check_local_by_default.ts", + "output": "check_local_by_default.out" +} diff --git a/tests/specs/bench/check_local_by_default/check_local_by_default.out b/tests/specs/bench/check_local_by_default/check_local_by_default.out new file mode 100644 index 000000000..63a6b5fa5 --- /dev/null +++ b/tests/specs/bench/check_local_by_default/check_local_by_default.out @@ -0,0 +1,6 @@ +[WILDCARD] + +[WILDCARD]/check_local_by_default.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- + diff --git a/tests/specs/bench/check_local_by_default/check_local_by_default.ts b/tests/specs/bench/check_local_by_default/check_local_by_default.ts new file mode 100644 index 000000000..2ae8c2692 --- /dev/null +++ b/tests/specs/bench/check_local_by_default/check_local_by_default.ts @@ -0,0 +1,3 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +console.log(a.a); diff --git a/tests/specs/bench/check_local_by_default2/__test__.jsonc b/tests/specs/bench/check_local_by_default2/__test__.jsonc new file mode 100644 index 000000000..5f2366d1e --- /dev/null +++ b/tests/specs/bench/check_local_by_default2/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --quiet check_local_by_default2.ts", + "output": "check_local_by_default2.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/check_local_by_default2/check_local_by_default2.out b/tests/specs/bench/check_local_by_default2/check_local_by_default2.out new file mode 100644 index 000000000..089b17f4b --- /dev/null +++ b/tests/specs/bench/check_local_by_default2/check_local_by_default2.out @@ -0,0 +1,4 @@ +error: TS2322 [ERROR]: Type '12' is not assignable to type '"b"'. +const b: "b" = 12; + ^ + at [WILDCARD]/check_local_by_default2.ts:3:7 diff --git a/tests/specs/bench/check_local_by_default2/check_local_by_default2.ts b/tests/specs/bench/check_local_by_default2/check_local_by_default2.ts new file mode 100644 index 000000000..5177ff944 --- /dev/null +++ b/tests/specs/bench/check_local_by_default2/check_local_by_default2.ts @@ -0,0 +1,6 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +const b: "b" = 12; + +console.log(a.a); +console.log(b); diff --git a/tests/specs/bench/clear_timeout/__test__.jsonc b/tests/specs/bench/clear_timeout/__test__.jsonc new file mode 100644 index 000000000..4535c931d --- /dev/null +++ b/tests/specs/bench/clear_timeout/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench clear_timeout.ts", + "output": "clear_timeout.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/clear_timeout/clear_timeout.out b/tests/specs/bench/clear_timeout/clear_timeout.out new file mode 100644 index 000000000..48a31378b --- /dev/null +++ b/tests/specs/bench/clear_timeout/clear_timeout.out @@ -0,0 +1,10 @@ +Check [WILDCARD]/clear_timeout.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/clear_timeout.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +bench1 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/tests/specs/bench/clear_timeout/clear_timeout.ts b/tests/specs/bench/clear_timeout/clear_timeout.ts new file mode 100644 index 000000000..4148263ac --- /dev/null +++ b/tests/specs/bench/clear_timeout/clear_timeout.ts @@ -0,0 +1,5 @@ +clearTimeout(setTimeout(() => {}, 1000)); + +Deno.bench("bench1", () => {}); +Deno.bench("bench2", () => {}); +Deno.bench("bench3", () => {}); diff --git a/tests/specs/bench/collect/__test__.jsonc b/tests/specs/bench/collect/__test__.jsonc new file mode 100644 index 000000000..e5aabd82d --- /dev/null +++ b/tests/specs/bench/collect/__test__.jsonc @@ -0,0 +1,19 @@ +{ + "steps": [{ + "args": "bench --ignore=collect/ignore collect", + "output": "collect.out" + }, { + "cleanDenoDir": true, + "args": "bench --config collect/deno.jsonc collect", + "output": "collect.out" + }, { + "cleanDenoDir": true, + "args": "bench --config collect/deno2.jsonc collect", + "output": "collect2.out" + }, { + "cleanDenoDir": true, + "args": "bench --config collect/deno.malformed.jsonc", + "exitCode": 1, + "output": "collect_with_malformed_config.out" + }] +} diff --git a/tests/specs/bench/collect/collect.out b/tests/specs/bench/collect/collect.out new file mode 100644 index 000000000..0d3f7a8ff --- /dev/null +++ b/tests/specs/bench/collect/collect.out @@ -0,0 +1,18 @@ +Check [WILDCARD]/collect/bench.ts +Check [WILDCARD]/collect/include/2_bench.ts +Check [WILDCARD]/collect/include/bench.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/collect/bench.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- + +[WILDCARD]/collect/include/2_bench.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- + +[WILDCARD]/collect/include/bench.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- + diff --git a/tests/specs/bench/collect/collect/bench.ts b/tests/specs/bench/collect/collect/bench.ts new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/specs/bench/collect/collect/bench.ts diff --git a/tests/specs/bench/collect/collect/deno.jsonc b/tests/specs/bench/collect/collect/deno.jsonc new file mode 100644 index 000000000..7f8f190d3 --- /dev/null +++ b/tests/specs/bench/collect/collect/deno.jsonc @@ -0,0 +1,5 @@ +{ + "bench": { + "exclude": ["./ignore"] + } +} diff --git a/tests/specs/bench/collect/collect/deno.malformed.jsonc b/tests/specs/bench/collect/collect/deno.malformed.jsonc new file mode 100644 index 000000000..8e558fbcf --- /dev/null +++ b/tests/specs/bench/collect/collect/deno.malformed.jsonc @@ -0,0 +1,5 @@ +{ + "bench": { + "dont_know_this_field": {} + } +} diff --git a/tests/specs/bench/collect/collect/deno2.jsonc b/tests/specs/bench/collect/collect/deno2.jsonc new file mode 100644 index 000000000..653ab1e31 --- /dev/null +++ b/tests/specs/bench/collect/collect/deno2.jsonc @@ -0,0 +1,6 @@ +{ + "bench": { + "include": ["./include/"], + "exclude": ["./ignore", "./include/2_bench.ts"] + } +} diff --git a/tests/specs/bench/collect/collect/ignore/bench.ts b/tests/specs/bench/collect/collect/ignore/bench.ts new file mode 100644 index 000000000..16fb63ba7 --- /dev/null +++ b/tests/specs/bench/collect/collect/ignore/bench.ts @@ -0,0 +1 @@ +throw new Error("this module should be ignored"); diff --git a/tests/specs/bench/collect/collect/include/2_bench.ts b/tests/specs/bench/collect/collect/include/2_bench.ts new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/specs/bench/collect/collect/include/2_bench.ts diff --git a/tests/specs/bench/collect/collect/include/bench.ts b/tests/specs/bench/collect/collect/include/bench.ts new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/specs/bench/collect/collect/include/bench.ts diff --git a/tests/specs/bench/collect/collect2.out b/tests/specs/bench/collect/collect2.out new file mode 100644 index 000000000..49ceee996 --- /dev/null +++ b/tests/specs/bench/collect/collect2.out @@ -0,0 +1,13 @@ +Check [WILDCARD]/collect/bench.ts +Check [WILDCARD]/collect/include/bench.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/collect/bench.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- + +[WILDCARD]/collect/include/bench.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- + diff --git a/tests/specs/bench/collect/collect_with_malformed_config.out b/tests/specs/bench/collect/collect_with_malformed_config.out new file mode 100644 index 000000000..92e5e29d2 --- /dev/null +++ b/tests/specs/bench/collect/collect_with_malformed_config.out @@ -0,0 +1,4 @@ +error: Failed to parse "bench" configuration + +Caused by: + unknown field `dont_know_this_field`, expected one of `include`, `exclude`, `files` diff --git a/tests/specs/bench/exit_sanitizer/__test__.jsonc b/tests/specs/bench/exit_sanitizer/__test__.jsonc new file mode 100644 index 000000000..a14531651 --- /dev/null +++ b/tests/specs/bench/exit_sanitizer/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench exit_sanitizer.ts", + "output": "exit_sanitizer.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/exit_sanitizer/exit_sanitizer.out b/tests/specs/bench/exit_sanitizer/exit_sanitizer.out new file mode 100644 index 000000000..eefc86e60 --- /dev/null +++ b/tests/specs/bench/exit_sanitizer/exit_sanitizer.out @@ -0,0 +1,14 @@ +Check [WILDCARD]/exit_sanitizer.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/exit_sanitizer.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +exit(0) error: Error: Bench attempted to exit with exit code: 0 +[WILDCARD] +exit(1) error: Error: Bench attempted to exit with exit code: 1 +[WILDCARD] +exit(2) error: Error: Bench attempted to exit with exit code: 2 +[WILDCARD] +error: Bench failed diff --git a/tests/specs/bench/exit_sanitizer/exit_sanitizer.ts b/tests/specs/bench/exit_sanitizer/exit_sanitizer.ts new file mode 100644 index 000000000..8e596b310 --- /dev/null +++ b/tests/specs/bench/exit_sanitizer/exit_sanitizer.ts @@ -0,0 +1,11 @@ +Deno.bench("exit(0)", function () { + Deno.exit(0); +}); + +Deno.bench("exit(1)", function () { + Deno.exit(1); +}); + +Deno.bench("exit(2)", function () { + Deno.exit(2); +}); diff --git a/tests/specs/bench/explicit_start_and_end_low_precision/__test__.jsonc b/tests/specs/bench/explicit_start_and_end_low_precision/__test__.jsonc new file mode 100644 index 000000000..2cd093f3f --- /dev/null +++ b/tests/specs/bench/explicit_start_and_end_low_precision/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --quiet -A main.bench.ts", + "output": "main.bench.out", + "flaky": true +} diff --git a/tests/specs/bench/explicit_start_and_end_low_precision/main.bench.out b/tests/specs/bench/explicit_start_and_end_low_precision/main.bench.out new file mode 100644 index 000000000..516c001b1 --- /dev/null +++ b/tests/specs/bench/explicit_start_and_end_low_precision/main.bench.out @@ -0,0 +1,10 @@ +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/main.bench.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +----------------------------------------------------------------------------- ----------------------------- +noop with start and end [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +Warning: start() and end() calls in "noop with start and end" are ignored because it averages less +than 10µs per iteration. Remove them for better results. + diff --git a/tests/specs/bench/explicit_start_and_end_low_precision/main.bench.ts b/tests/specs/bench/explicit_start_and_end_low_precision/main.bench.ts new file mode 100644 index 000000000..23bdf19fe --- /dev/null +++ b/tests/specs/bench/explicit_start_and_end_low_precision/main.bench.ts @@ -0,0 +1,4 @@ +Deno.bench("noop with start and end", (b) => { + b.start(); + b.end(); +}); diff --git a/tests/specs/bench/fail/__test__.jsonc b/tests/specs/bench/fail/__test__.jsonc new file mode 100644 index 000000000..18748c31e --- /dev/null +++ b/tests/specs/bench/fail/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench fail.ts", + "output": "fail.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/fail/fail.out b/tests/specs/bench/fail/fail.out new file mode 100644 index 000000000..03f04cf4f --- /dev/null +++ b/tests/specs/bench/fail/fail.out @@ -0,0 +1,28 @@ +Check [WILDCARD]/fail.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/fail.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +bench0 error: Error +[WILDCARD] +bench1 error: Error +[WILDCARD] +bench2 error: Error +[WILDCARD] +bench3 error: Error +[WILDCARD] +bench4 error: Error +[WILDCARD] +bench5 error: Error +[WILDCARD] +bench6 error: Error +[WILDCARD] +bench7 error: Error +[WILDCARD] +bench8 error: Error +[WILDCARD] +bench9 error: Error +[WILDCARD] +error: Bench failed diff --git a/tests/specs/bench/fail/fail.ts b/tests/specs/bench/fail/fail.ts new file mode 100644 index 000000000..33d70ce55 --- /dev/null +++ b/tests/specs/bench/fail/fail.ts @@ -0,0 +1,30 @@ +Deno.bench("bench0", () => { + throw new Error(); +}); +Deno.bench("bench1", () => { + throw new Error(); +}); +Deno.bench("bench2", () => { + throw new Error(); +}); +Deno.bench("bench3", () => { + throw new Error(); +}); +Deno.bench("bench4", () => { + throw new Error(); +}); +Deno.bench("bench5", () => { + throw new Error(); +}); +Deno.bench("bench6", () => { + throw new Error(); +}); +Deno.bench("bench7", () => { + throw new Error(); +}); +Deno.bench("bench8", () => { + throw new Error(); +}); +Deno.bench("bench9", () => { + throw new Error(); +}); diff --git a/tests/specs/bench/filter/__test__.jsonc b/tests/specs/bench/filter/__test__.jsonc new file mode 100644 index 000000000..685ee9571 --- /dev/null +++ b/tests/specs/bench/filter/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "bench --filter=foo", + "output": "filter.out" +} diff --git a/tests/specs/bench/filter/a_bench.ts b/tests/specs/bench/filter/a_bench.ts new file mode 100644 index 000000000..fc4ef859c --- /dev/null +++ b/tests/specs/bench/filter/a_bench.ts @@ -0,0 +1,3 @@ +Deno.bench("foo", function () {}); +Deno.bench("bar", function () {}); +Deno.bench("baz", function () {}); diff --git a/tests/specs/bench/filter/b_bench.ts b/tests/specs/bench/filter/b_bench.ts new file mode 100644 index 000000000..fc4ef859c --- /dev/null +++ b/tests/specs/bench/filter/b_bench.ts @@ -0,0 +1,3 @@ +Deno.bench("foo", function () {}); +Deno.bench("bar", function () {}); +Deno.bench("baz", function () {}); diff --git a/tests/specs/bench/filter/c_bench.ts b/tests/specs/bench/filter/c_bench.ts new file mode 100644 index 000000000..fc4ef859c --- /dev/null +++ b/tests/specs/bench/filter/c_bench.ts @@ -0,0 +1,3 @@ +Deno.bench("foo", function () {}); +Deno.bench("bar", function () {}); +Deno.bench("baz", function () {}); diff --git a/tests/specs/bench/filter/filter.out b/tests/specs/bench/filter/filter.out new file mode 100644 index 000000000..970171e0b --- /dev/null +++ b/tests/specs/bench/filter/filter.out @@ -0,0 +1,20 @@ +Check [WILDCARD]/bench/filter/a_bench.ts +Check [WILDCARD]/bench/filter/b_bench.ts +Check [WILDCARD]/bench/filter/c_bench.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/bench/filter/a_bench.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +foo [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] + +[WILDCARD]/bench/filter/b_bench.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +foo [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] + +[WILDCARD]/bench/filter/c_bench.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +foo [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/tests/specs/bench/filter_group_header/main.out b/tests/specs/bench/filter_group_header/main.out index efe157f6c..5791538fe 100644 --- a/tests/specs/bench/filter_group_header/main.out +++ b/tests/specs/bench/filter_group_header/main.out @@ -7,7 +7,7 @@ benchmark time (avg) iter/s (min … max) p75 --------------------------------------------------------------- ----------------------------- group G1 -G1-B [WILDCARD] +G1-B [WILDCARD] group G2 -G2-B [WILDCARD]
\ No newline at end of file +G2-B [WILDCARD]
\ No newline at end of file diff --git a/tests/specs/bench/finally_timeout/__test__.jsonc b/tests/specs/bench/finally_timeout/__test__.jsonc new file mode 100644 index 000000000..621537204 --- /dev/null +++ b/tests/specs/bench/finally_timeout/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench finally_timeout.ts", + "output": "finally_timeout.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/finally_timeout/finally_timeout.out b/tests/specs/bench/finally_timeout/finally_timeout.out new file mode 100644 index 000000000..cefa18760 --- /dev/null +++ b/tests/specs/bench/finally_timeout/finally_timeout.out @@ -0,0 +1,11 @@ +Check [WILDCARD]/finally_timeout.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/finally_timeout.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +error error: Error: fail +[WILDCARD] +success [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +error: Bench failed diff --git a/tests/specs/bench/finally_timeout/finally_timeout.ts b/tests/specs/bench/finally_timeout/finally_timeout.ts new file mode 100644 index 000000000..c49eb8da2 --- /dev/null +++ b/tests/specs/bench/finally_timeout/finally_timeout.ts @@ -0,0 +1,11 @@ +Deno.bench("error", function () { + const timer = setTimeout(() => null, 10000); + try { + throw new Error("fail"); + } finally { + clearTimeout(timer); + } +}); + +Deno.bench("success", function () { +}); diff --git a/tests/specs/bench/group_baseline/__test__.jsonc b/tests/specs/bench/group_baseline/__test__.jsonc new file mode 100644 index 000000000..5874b40c8 --- /dev/null +++ b/tests/specs/bench/group_baseline/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench group_baseline.ts", + "output": "group_baseline.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/group_baseline/group_baseline.out b/tests/specs/bench/group_baseline/group_baseline.out new file mode 100644 index 000000000..54a6cd359 --- /dev/null +++ b/tests/specs/bench/group_baseline/group_baseline.out @@ -0,0 +1,20 @@ +[WILDCARD]/group_baseline.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +-------------------------------------------------------------------- ----------------------------- +noop [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +noop2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] + +summary + noo[WILDCARD] + [WILDCARD]x [WILDCARD] than noo[WILDCARD] + +group url +noop3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +parse url 2x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +parse url 200x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] + +summary + parse url 2x + [WILDCARD]x slower than noop3 + [WILDCARD]x faster than parse url 200x + diff --git a/tests/specs/bench/group_baseline/group_baseline.ts b/tests/specs/bench/group_baseline/group_baseline.ts new file mode 100644 index 000000000..a86f6455c --- /dev/null +++ b/tests/specs/bench/group_baseline/group_baseline.ts @@ -0,0 +1,15 @@ +Deno.bench("noop", () => {}); +Deno.bench("noop2", { baseline: true }, () => {}); + +Deno.bench("noop3", { group: "url" }, () => {}); + +Deno.bench("parse url 2x", { group: "url", baseline: true }, () => { + new URL("https://deno.land/std/http/server.ts"); + new URL("https://deno.land/std/http/server.ts"); +}); + +Deno.bench("parse url 200x", { group: "url" }, () => { + for (let i = 0; i < 200; i++) { + new URL("https://deno.land/std/http/server.ts"); + } +}); diff --git a/tests/specs/bench/ignore/__test__.jsonc b/tests/specs/bench/ignore/__test__.jsonc new file mode 100644 index 000000000..97053bb79 --- /dev/null +++ b/tests/specs/bench/ignore/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench ignore.ts", + "output": "ignore.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/ignore/ignore.out b/tests/specs/bench/ignore/ignore.out new file mode 100644 index 000000000..d74a0c181 --- /dev/null +++ b/tests/specs/bench/ignore/ignore.out @@ -0,0 +1,8 @@ +Check [WILDCARD]/ignore.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/ignore.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- + diff --git a/tests/specs/bench/ignore/ignore.ts b/tests/specs/bench/ignore/ignore.ts new file mode 100644 index 000000000..0226fe76f --- /dev/null +++ b/tests/specs/bench/ignore/ignore.ts @@ -0,0 +1,9 @@ +for (let i = 0; i < 10; i++) { + Deno.bench({ + name: `bench${i}`, + ignore: true, + fn() { + throw new Error("unreachable"); + }, + }); +} diff --git a/tests/specs/bench/ignore_permissions/__test__.jsonc b/tests/specs/bench/ignore_permissions/__test__.jsonc new file mode 100644 index 000000000..592ab0240 --- /dev/null +++ b/tests/specs/bench/ignore_permissions/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench ignore_permissions.ts", + "output": "ignore_permissions.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/ignore_permissions/ignore_permissions.out b/tests/specs/bench/ignore_permissions/ignore_permissions.out new file mode 100644 index 000000000..eb577fecc --- /dev/null +++ b/tests/specs/bench/ignore_permissions/ignore_permissions.out @@ -0,0 +1,8 @@ +Check [WILDCARD]/ignore_permissions.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/ignore_permissions.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- + diff --git a/tests/specs/bench/ignore_permissions/ignore_permissions.ts b/tests/specs/bench/ignore_permissions/ignore_permissions.ts new file mode 100644 index 000000000..0dcd9299f --- /dev/null +++ b/tests/specs/bench/ignore_permissions/ignore_permissions.ts @@ -0,0 +1,16 @@ +Deno.bench({ + name: "ignore", + permissions: { + read: true, + write: true, + net: true, + env: true, + run: true, + ffi: true, + hrtime: true, + }, + ignore: true, + fn() { + throw new Error("unreachable"); + }, +}); diff --git a/tests/specs/bench/interval/__test__.jsonc b/tests/specs/bench/interval/__test__.jsonc new file mode 100644 index 000000000..f4e89c1b5 --- /dev/null +++ b/tests/specs/bench/interval/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench interval.ts", + "output": "interval.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/interval/interval.out b/tests/specs/bench/interval/interval.out new file mode 100644 index 000000000..11e440940 --- /dev/null +++ b/tests/specs/bench/interval/interval.out @@ -0,0 +1,8 @@ +Check [WILDCARD]/interval.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/interval.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- + diff --git a/tests/specs/bench/interval/interval.ts b/tests/specs/bench/interval/interval.ts new file mode 100644 index 000000000..7eb588c59 --- /dev/null +++ b/tests/specs/bench/interval/interval.ts @@ -0,0 +1 @@ +setInterval(function () {}, 0); diff --git a/tests/specs/bench/json_output/__test__.jsonc b/tests/specs/bench/json_output/__test__.jsonc new file mode 100644 index 000000000..fa0dadcd0 --- /dev/null +++ b/tests/specs/bench/json_output/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --json pass.ts", + "output": "pass.json.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/json_output/pass.json.out b/tests/specs/bench/json_output/pass.json.out new file mode 100644 index 000000000..53259e758 --- /dev/null +++ b/tests/specs/bench/json_output/pass.json.out @@ -0,0 +1,28 @@ +Check file:///[WILDCARD]/pass.ts +{ + "runtime": "Deno/[WILDCARD]", + "cpu": "[WILDCARD]", + "benches": [ + { + "origin": "file:///[WILDCARD]/pass.ts", + "group": null, + "name": "bench0", + "baseline": false, + "results": [ + { + "ok": { + "n": [WILDCARD], + "min": [WILDCARD], + "max": [WILDCARD], + "avg": [WILDCARD], + "p75": [WILDCARD], + "p99": [WILDCARD], + "p995": [WILDCARD], + "p999": [WILDCARD] + } + } + ] + }, +[WILDCARD] + ] +} diff --git a/tests/specs/bench/json_output/pass.ts b/tests/specs/bench/json_output/pass.ts new file mode 100644 index 000000000..48348d447 --- /dev/null +++ b/tests/specs/bench/json_output/pass.ts @@ -0,0 +1,10 @@ +Deno.bench("bench0", () => {}); +Deno.bench("bench1", () => {}); +Deno.bench("bench2", () => {}); +Deno.bench("bench3", () => {}); +Deno.bench("bench4", () => {}); +Deno.bench("bench5", () => {}); +Deno.bench("bench6", () => {}); +Deno.bench("bench7", () => {}); +Deno.bench("bench8", () => {}); +Deno.bench("bench9", () => {}); diff --git a/tests/specs/bench/load_unload/__test__.jsonc b/tests/specs/bench/load_unload/__test__.jsonc new file mode 100644 index 000000000..8837d3d80 --- /dev/null +++ b/tests/specs/bench/load_unload/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench load_unload.ts", + "output": "load_unload.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/load_unload/load_unload.out b/tests/specs/bench/load_unload/load_unload.out new file mode 100644 index 000000000..99e4389ac --- /dev/null +++ b/tests/specs/bench/load_unload/load_unload.out @@ -0,0 +1,8 @@ +Check [WILDCARD]/load_unload.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/load_unload.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +bench [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/tests/specs/bench/load_unload/load_unload.ts b/tests/specs/bench/load_unload/load_unload.ts new file mode 100644 index 000000000..3653c135d --- /dev/null +++ b/tests/specs/bench/load_unload/load_unload.ts @@ -0,0 +1,22 @@ +let interval: number | null = null; +addEventListener("load", () => { + if (interval) { + throw new Error("Interval is already set"); + } + + interval = setInterval(() => {}, 0); +}); + +addEventListener("unload", () => { + if (!interval) { + throw new Error("Interval was not set"); + } + + clearInterval(interval); +}); + +Deno.bench("bench", () => { + if (!interval) { + throw new Error("Interval was not set"); + } +}); diff --git a/tests/specs/bench/meta/__test__.jsonc b/tests/specs/bench/meta/__test__.jsonc new file mode 100644 index 000000000..10a4ff3a4 --- /dev/null +++ b/tests/specs/bench/meta/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench meta.ts", + "output": "meta.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/meta/meta.out b/tests/specs/bench/meta/meta.out new file mode 100644 index 000000000..75a75984e --- /dev/null +++ b/tests/specs/bench/meta/meta.out @@ -0,0 +1,10 @@ +Check [WILDCARD]/meta.ts +import.meta.main: false +import.meta.url: [WILDCARD]/meta.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/meta.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- + diff --git a/tests/specs/bench/meta/meta.ts b/tests/specs/bench/meta/meta.ts new file mode 100644 index 000000000..e32fdeea6 --- /dev/null +++ b/tests/specs/bench/meta/meta.ts @@ -0,0 +1,2 @@ +console.log("import.meta.main: %s", import.meta.main); +console.log("import.meta.url: %s", import.meta.url); diff --git a/tests/specs/bench/multifile_summary/__test__.jsonc b/tests/specs/bench/multifile_summary/__test__.jsonc new file mode 100644 index 000000000..757af150b --- /dev/null +++ b/tests/specs/bench/multifile_summary/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench group_baseline.ts pass.ts multiple_group.ts", + "output": "multifile_summary.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/multifile_summary/group_baseline.ts b/tests/specs/bench/multifile_summary/group_baseline.ts new file mode 100644 index 000000000..a86f6455c --- /dev/null +++ b/tests/specs/bench/multifile_summary/group_baseline.ts @@ -0,0 +1,15 @@ +Deno.bench("noop", () => {}); +Deno.bench("noop2", { baseline: true }, () => {}); + +Deno.bench("noop3", { group: "url" }, () => {}); + +Deno.bench("parse url 2x", { group: "url", baseline: true }, () => { + new URL("https://deno.land/std/http/server.ts"); + new URL("https://deno.land/std/http/server.ts"); +}); + +Deno.bench("parse url 200x", { group: "url" }, () => { + for (let i = 0; i < 200; i++) { + new URL("https://deno.land/std/http/server.ts"); + } +}); diff --git a/tests/specs/bench/multifile_summary/multifile_summary.out b/tests/specs/bench/multifile_summary/multifile_summary.out new file mode 100644 index 000000000..c0439ebba --- /dev/null +++ b/tests/specs/bench/multifile_summary/multifile_summary.out @@ -0,0 +1,64 @@ +Check [WILDCARD]/group_baseline.ts +Check [WILDCARD]/pass.ts +Check [WILDCARD]/multiple_group.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/group_baseline.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +-------------------------------------------------------------------- ----------------------------- +noop [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +noop2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] + +summary + noo[WILDCARD] + [WILDCARD]x [WILDCARD] than noo[WILDCARD] + +group url +noop3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +parse url 2x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +parse url 200x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] + +summary + parse url 2x + [WILDLINE]x slower than noop3 + [WILDLINE]x faster than parse url 200x + + +[WILDLINE]/pass.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +bench0 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench1 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench4 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench5 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench6 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench7 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench8 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench9 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] + + +[WILDLINE]/multiple_group.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +-------------------------------------------------------------------- ----------------------------- + +group noop +noop [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +noop2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] + +summary + noo[WILDCARD] + [WILDCARD]x [WILDCARD] than noo[WILDCARD] + +group url +noop3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +parse url 2x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +parse url 200x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] + +summary + parse url 2x + [WILDCARD]x slower than noop3 + [WILDCARD]x faster than parse url 200x + diff --git a/tests/specs/bench/multifile_summary/multiple_group.ts b/tests/specs/bench/multifile_summary/multiple_group.ts new file mode 100644 index 000000000..165b5e201 --- /dev/null +++ b/tests/specs/bench/multifile_summary/multiple_group.ts @@ -0,0 +1,15 @@ +Deno.bench("noop", { group: "noop" }, () => {}); +Deno.bench("noop2", { group: "noop", baseline: true }, () => {}); + +Deno.bench("noop3", { group: "url" }, () => {}); + +Deno.bench("parse url 2x", { group: "url", baseline: true }, () => { + new URL("https://jsr.io/@std/http/0.221.0/file_server.ts"); + new URL("https://jsr.io/@std/http/0.221.0/file_server.ts"); +}); + +Deno.bench("parse url 200x", { group: "url" }, () => { + for (let i = 0; i < 200; i++) { + new URL("https://jsr.io/@std/http/0.221.0/file_server.ts"); + } +}); diff --git a/tests/specs/bench/multifile_summary/pass.ts b/tests/specs/bench/multifile_summary/pass.ts new file mode 100644 index 000000000..48348d447 --- /dev/null +++ b/tests/specs/bench/multifile_summary/pass.ts @@ -0,0 +1,10 @@ +Deno.bench("bench0", () => {}); +Deno.bench("bench1", () => {}); +Deno.bench("bench2", () => {}); +Deno.bench("bench3", () => {}); +Deno.bench("bench4", () => {}); +Deno.bench("bench5", () => {}); +Deno.bench("bench6", () => {}); +Deno.bench("bench7", () => {}); +Deno.bench("bench8", () => {}); +Deno.bench("bench9", () => {}); diff --git a/tests/specs/bench/no_check/__test__.jsonc b/tests/specs/bench/no_check/__test__.jsonc new file mode 100644 index 000000000..d031e52de --- /dev/null +++ b/tests/specs/bench/no_check/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --no-check no_check.ts", + "output": "no_check.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/no_check/no_check.out b/tests/specs/bench/no_check/no_check.out new file mode 100644 index 000000000..c373c812c --- /dev/null +++ b/tests/specs/bench/no_check/no_check.out @@ -0,0 +1,9 @@ +error: (in promise) TypeError: Cannot read properties of undefined (reading 'fn') +Deno.bench(); + ^ + at [WILDCARD] + at [WILDCARD]/no_check.ts:1:6 +This error was not caught from a benchmark and caused the bench runner to fail on the referenced module. +It most likely originated from a dangling promise, event/timeout handler or top-level code. + +error: Bench failed diff --git a/tests/specs/bench/no_check/no_check.ts b/tests/specs/bench/no_check/no_check.ts new file mode 100644 index 000000000..b159cabd6 --- /dev/null +++ b/tests/specs/bench/no_check/no_check.ts @@ -0,0 +1 @@ +Deno.bench(); diff --git a/tests/specs/bench/no_prompt_by_default/__test__.jsonc b/tests/specs/bench/no_prompt_by_default/__test__.jsonc new file mode 100644 index 000000000..e3f4127da --- /dev/null +++ b/tests/specs/bench/no_prompt_by_default/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --quiet no_prompt_by_default.ts", + "output": "no_prompt_by_default.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/no_prompt_by_default/no_prompt_by_default.out b/tests/specs/bench/no_prompt_by_default/no_prompt_by_default.out new file mode 100644 index 000000000..7c5f2b5c2 --- /dev/null +++ b/tests/specs/bench/no_prompt_by_default/no_prompt_by_default.out @@ -0,0 +1,9 @@ +[WILDCARD]cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/no_prompt_by_default.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +no prompt error: PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag +[WILDCARD] +error: Bench failed diff --git a/tests/specs/bench/no_prompt_by_default/no_prompt_by_default.ts b/tests/specs/bench/no_prompt_by_default/no_prompt_by_default.ts new file mode 100644 index 000000000..59359eebd --- /dev/null +++ b/tests/specs/bench/no_prompt_by_default/no_prompt_by_default.ts @@ -0,0 +1,3 @@ +Deno.bench("no prompt", async () => { + await Deno.readTextFile("./some_file.txt"); +}); diff --git a/tests/specs/bench/no_prompt_with_denied_perms/__test__.jsonc b/tests/specs/bench/no_prompt_with_denied_perms/__test__.jsonc new file mode 100644 index 000000000..a06645249 --- /dev/null +++ b/tests/specs/bench/no_prompt_with_denied_perms/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --quiet --allow-read no_prompt_with_denied_perms.ts", + "output": "no_prompt_with_denied_perms.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.out b/tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.out new file mode 100644 index 000000000..bbdd2ac46 --- /dev/null +++ b/tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.out @@ -0,0 +1,9 @@ +[WILDCARD]cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/no_prompt_with_denied_perms.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +no prompt error: PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag +[WILDCARD] +error: Bench failed diff --git a/tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.ts b/tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.ts new file mode 100644 index 000000000..2f0d63bbe --- /dev/null +++ b/tests/specs/bench/no_prompt_with_denied_perms/no_prompt_with_denied_perms.ts @@ -0,0 +1,3 @@ +Deno.bench("no prompt", { permissions: { read: false } }, async () => { + await Deno.readTextFile("./some_file.txt"); +}); diff --git a/tests/specs/bench/no_run/__test__.jsonc b/tests/specs/bench/no_run/__test__.jsonc new file mode 100644 index 000000000..159f6fd5a --- /dev/null +++ b/tests/specs/bench/no_run/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --no-run no_run.ts", + "output": "no_run.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/no_run/no_run.out b/tests/specs/bench/no_run/no_run.out new file mode 100644 index 000000000..77ce18366 --- /dev/null +++ b/tests/specs/bench/no_run/no_run.out @@ -0,0 +1,5 @@ +Check [WILDCARD]/no_run.ts +error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. +const _value: string = 1; + ~~~~~~ + at [WILDCARD]/no_run.ts:1:7 diff --git a/tests/specs/bench/no_run/no_run.ts b/tests/specs/bench/no_run/no_run.ts new file mode 100644 index 000000000..c7a5dc1e8 --- /dev/null +++ b/tests/specs/bench/no_run/no_run.ts @@ -0,0 +1,2 @@ +const _value: string = 1; +console.log("this should not be run"); diff --git a/tests/specs/bench/only/__test__.jsonc b/tests/specs/bench/only/__test__.jsonc new file mode 100644 index 000000000..7d50a6dec --- /dev/null +++ b/tests/specs/bench/only/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench only.ts", + "output": "only.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/only/only.out b/tests/specs/bench/only/only.out new file mode 100644 index 000000000..e3332d174 --- /dev/null +++ b/tests/specs/bench/only/only.out @@ -0,0 +1,9 @@ +Check [WILDCARD]/only.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/only.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +only [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +error: Bench failed because the "only" option was used diff --git a/tests/specs/bench/only/only.ts b/tests/specs/bench/only/only.ts new file mode 100644 index 000000000..0129c024c --- /dev/null +++ b/tests/specs/bench/only/only.ts @@ -0,0 +1,15 @@ +Deno.bench({ + name: "before", + fn() {}, +}); + +Deno.bench({ + only: true, + name: "only", + fn() {}, +}); + +Deno.bench({ + name: "after", + fn() {}, +}); diff --git a/tests/specs/bench/overloads/__test__.jsonc b/tests/specs/bench/overloads/__test__.jsonc new file mode 100644 index 000000000..ae0fe0a07 --- /dev/null +++ b/tests/specs/bench/overloads/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench overloads.ts", + "output": "overloads.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/overloads/overloads.out b/tests/specs/bench/overloads/overloads.out new file mode 100644 index 000000000..21f8759dd --- /dev/null +++ b/tests/specs/bench/overloads/overloads.out @@ -0,0 +1,12 @@ +Check [WILDCARD]/overloads.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/overloads.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +bench0 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench1 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench4 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/tests/specs/bench/overloads/overloads.ts b/tests/specs/bench/overloads/overloads.ts new file mode 100644 index 000000000..4f5887f79 --- /dev/null +++ b/tests/specs/bench/overloads/overloads.ts @@ -0,0 +1,6 @@ +Deno.bench("bench0", () => {}); +Deno.bench(function bench1() {}); +Deno.bench({ name: "bench2", fn: () => {} }); +Deno.bench("bench3", { permissions: "none" }, () => {}); +Deno.bench({ name: "bench4" }, () => {}); +Deno.bench({ ignore: true }, function bench5() {}); diff --git a/tests/specs/bench/package_json/__test__.jsonc b/tests/specs/bench/package_json/__test__.jsonc new file mode 100644 index 000000000..001cc8b54 --- /dev/null +++ b/tests/specs/bench/package_json/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "tempDir": true, + "args": "bench", + "output": "lib.bench.out" +} diff --git a/tests/specs/bench/package_json/lib.bench.out b/tests/specs/bench/package_json/lib.bench.out new file mode 100644 index 000000000..fa9c5efc6 --- /dev/null +++ b/tests/specs/bench/package_json/lib.bench.out @@ -0,0 +1,11 @@ +Download http://localhost:4545/npm/registry/@denotest/esm-basic +Download http://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz +Initialize @denotest/esm-basic@1.0.0 +Check file:///[WILDCARD]/lib.bench.ts +cpu: [WILDCARD] +runtime: [WILDCARD] + +file:///[WILDCARD]/lib.bench.ts +[WILDCARD] +---------------------------------------------------------------- ----------------------------- +should add [WILDCARD] diff --git a/tests/specs/bench/package_json/lib.bench.ts b/tests/specs/bench/package_json/lib.bench.ts new file mode 100644 index 000000000..e6b79d025 --- /dev/null +++ b/tests/specs/bench/package_json/lib.bench.ts @@ -0,0 +1,7 @@ +import { add } from "./lib.ts"; + +Deno.bench("should add", () => { + if (add(1, 2) !== 3) { + throw new Error("Fail"); + } +}); diff --git a/tests/specs/bench/package_json/lib.ts b/tests/specs/bench/package_json/lib.ts new file mode 100644 index 000000000..1deed81f7 --- /dev/null +++ b/tests/specs/bench/package_json/lib.ts @@ -0,0 +1,9 @@ +import * as test from "@denotest/esm-basic"; + +export function add(a: number, b: number) { + return a + b; +} + +export function getValue() { + return test.getValue(); +} diff --git a/tests/specs/bench/package_json/package.json b/tests/specs/bench/package_json/package.json new file mode 100644 index 000000000..54ca824d6 --- /dev/null +++ b/tests/specs/bench/package_json/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@denotest/esm-basic": "*" + } +} diff --git a/tests/specs/bench/pass/__test__.jsonc b/tests/specs/bench/pass/__test__.jsonc new file mode 100644 index 000000000..797684ec6 --- /dev/null +++ b/tests/specs/bench/pass/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench pass.ts", + "output": "pass.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/pass/pass.out b/tests/specs/bench/pass/pass.out new file mode 100644 index 000000000..4be2b8723 --- /dev/null +++ b/tests/specs/bench/pass/pass.out @@ -0,0 +1,17 @@ +Check [WILDCARD]/pass.ts +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/pass.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +--------------------------------------------------------------- ----------------------------- +bench0 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench1 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench4 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench5 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench6 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench7 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench8 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +bench9 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/tests/specs/bench/pass/pass.ts b/tests/specs/bench/pass/pass.ts new file mode 100644 index 000000000..48348d447 --- /dev/null +++ b/tests/specs/bench/pass/pass.ts @@ -0,0 +1,10 @@ +Deno.bench("bench0", () => {}); +Deno.bench("bench1", () => {}); +Deno.bench("bench2", () => {}); +Deno.bench("bench3", () => {}); +Deno.bench("bench4", () => {}); +Deno.bench("bench5", () => {}); +Deno.bench("bench6", () => {}); +Deno.bench("bench7", () => {}); +Deno.bench("bench8", () => {}); +Deno.bench("bench9", () => {}); diff --git a/tests/specs/bench/quiet/__test__.jsonc b/tests/specs/bench/quiet/__test__.jsonc new file mode 100644 index 000000000..a220e9936 --- /dev/null +++ b/tests/specs/bench/quiet/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench --quiet quiet.ts", + "output": "quiet.out", + "exitCode": 0 +} diff --git a/tests/specs/bench/quiet/quiet.out b/tests/specs/bench/quiet/quiet.out new file mode 100644 index 000000000..fa9166d65 --- /dev/null +++ b/tests/specs/bench/quiet/quiet.out @@ -0,0 +1,10 @@ +cpu: [WILDCARD] +runtime: deno [WILDCARD] ([WILDCARD]) + +[WILDCARD]/quiet.ts +benchmark time (avg) iter/s (min … max) p75 p99 p995 +------------------------------------------------------------------- ----------------------------- +console.log [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +console.error [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +console.info [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] +console.warn [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD] diff --git a/tests/specs/bench/quiet/quiet.ts b/tests/specs/bench/quiet/quiet.ts new file mode 100644 index 000000000..efeb366ff --- /dev/null +++ b/tests/specs/bench/quiet/quiet.ts @@ -0,0 +1,15 @@ +Deno.bench("console.log", function () { + console.log("log"); +}); + +Deno.bench("console.error", function () { + console.error("error"); +}); + +Deno.bench("console.info", function () { + console.info("info"); +}); + +Deno.bench("console.warn", function () { + console.info("warn"); +}); diff --git a/tests/specs/bench/unhandled_rejection/__test__.jsonc b/tests/specs/bench/unhandled_rejection/__test__.jsonc new file mode 100644 index 000000000..0576136ef --- /dev/null +++ b/tests/specs/bench/unhandled_rejection/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench unhandled_rejection.ts", + "output": "unhandled_rejection.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/unhandled_rejection/unhandled_rejection.out b/tests/specs/bench/unhandled_rejection/unhandled_rejection.out new file mode 100644 index 000000000..b95b9ab8b --- /dev/null +++ b/tests/specs/bench/unhandled_rejection/unhandled_rejection.out @@ -0,0 +1,11 @@ +Check [WILDCARD]/unhandled_rejection.ts +error: (in promise) Error: rejection + reject(new Error("rejection")); + ^ + at [WILDCARD]/unhandled_rejection.ts:2:10 + at new Promise (<anonymous>) + at [WILDCARD]/unhandled_rejection.ts:1:1 +This error was not caught from a benchmark and caused the bench runner to fail on the referenced module. +It most likely originated from a dangling promise, event/timeout handler or top-level code. + +error: Bench failed diff --git a/tests/specs/bench/unhandled_rejection/unhandled_rejection.ts b/tests/specs/bench/unhandled_rejection/unhandled_rejection.ts new file mode 100644 index 000000000..32f3111ea --- /dev/null +++ b/tests/specs/bench/unhandled_rejection/unhandled_rejection.ts @@ -0,0 +1,3 @@ +new Promise((_resolve, reject) => { + reject(new Error("rejection")); +}); diff --git a/tests/specs/bench/unresolved_promise/__test__.jsonc b/tests/specs/bench/unresolved_promise/__test__.jsonc new file mode 100644 index 000000000..487e46b3d --- /dev/null +++ b/tests/specs/bench/unresolved_promise/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "bench unresolved_promise.ts", + "output": "unresolved_promise.out", + "exitCode": 1 +} diff --git a/tests/specs/bench/unresolved_promise/unresolved_promise.out b/tests/specs/bench/unresolved_promise/unresolved_promise.out new file mode 100644 index 000000000..92d29f399 --- /dev/null +++ b/tests/specs/bench/unresolved_promise/unresolved_promise.out @@ -0,0 +1,9 @@ +Check [WILDCARD]/unresolved_promise.ts +error: Top-level await promise never resolved +await new Promise((_resolve, _reject) => {}); +^ + at <anonymous> ([WILDCARD]/unresolved_promise.ts:1:1) +This error was not caught from a benchmark and caused the bench runner to fail on the referenced module. +It most likely originated from a dangling promise, event/timeout handler or top-level code. + +error: Bench failed diff --git a/tests/specs/bench/unresolved_promise/unresolved_promise.ts b/tests/specs/bench/unresolved_promise/unresolved_promise.ts new file mode 100644 index 000000000..25fe70762 --- /dev/null +++ b/tests/specs/bench/unresolved_promise/unresolved_promise.ts @@ -0,0 +1 @@ +await new Promise((_resolve, _reject) => {}); diff --git a/tests/specs/cache/check_local_by_default/__test__.jsonc b/tests/specs/cache/check_local_by_default/__test__.jsonc new file mode 100644 index 000000000..e6d0829fd --- /dev/null +++ b/tests/specs/cache/check_local_by_default/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "cache --quiet check_local_by_default.ts", + "output": "check_local_by_default.out" +} diff --git a/tests/specs/cache/check_local_by_default/check_local_by_default.out b/tests/specs/cache/check_local_by_default/check_local_by_default.out new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/specs/cache/check_local_by_default/check_local_by_default.out diff --git a/tests/specs/cache/check_local_by_default/check_local_by_default.ts b/tests/specs/cache/check_local_by_default/check_local_by_default.ts new file mode 100644 index 000000000..2ae8c2692 --- /dev/null +++ b/tests/specs/cache/check_local_by_default/check_local_by_default.ts @@ -0,0 +1,3 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +console.log(a.a); diff --git a/tests/specs/cache/check_local_by_default2/__test__.jsonc b/tests/specs/cache/check_local_by_default2/__test__.jsonc new file mode 100644 index 000000000..a9e70dcd9 --- /dev/null +++ b/tests/specs/cache/check_local_by_default2/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "cache --quiet check_local_by_default2.ts", + "output": "check_local_by_default2.out" +} diff --git a/tests/specs/cache/check_local_by_default2/check_local_by_default2.out b/tests/specs/cache/check_local_by_default2/check_local_by_default2.out new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/specs/cache/check_local_by_default2/check_local_by_default2.out diff --git a/tests/specs/cache/check_local_by_default2/check_local_by_default2.ts b/tests/specs/cache/check_local_by_default2/check_local_by_default2.ts new file mode 100644 index 000000000..5177ff944 --- /dev/null +++ b/tests/specs/cache/check_local_by_default2/check_local_by_default2.ts @@ -0,0 +1,6 @@ +import * as a from "http://localhost:4545/subdir/type_error.ts"; + +const b: "b" = 12; + +console.log(a.a); +console.log(b); diff --git a/tests/specs/cache/extensionless/__test__.jsonc b/tests/specs/cache/extensionless/__test__.jsonc new file mode 100644 index 000000000..837f26ecc --- /dev/null +++ b/tests/specs/cache/extensionless/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "cache --reload --check=all http://localhost:4545/subdir/no_js_ext", + "output": "cache_extensionless.out" +} diff --git a/tests/specs/cache/extensionless/cache_extensionless.out b/tests/specs/cache/extensionless/cache_extensionless.out new file mode 100644 index 000000000..3694c67cb --- /dev/null +++ b/tests/specs/cache/extensionless/cache_extensionless.out @@ -0,0 +1,2 @@ +[WILDCARD] +Check http://localhost:4545/subdir/no_js_ext diff --git a/tests/specs/cache/fetch_multiple/__test__.jsonc b/tests/specs/cache/fetch_multiple/__test__.jsonc new file mode 100644 index 000000000..a5cf41113 --- /dev/null +++ b/tests/specs/cache/fetch_multiple/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "cache --reload --check=all test.ts other.ts", + "output": "fetch_multiple.out" +} diff --git a/tests/specs/cache/fetch_multiple/fetch_multiple.out b/tests/specs/cache/fetch_multiple/fetch_multiple.out new file mode 100644 index 000000000..1cd3639ec --- /dev/null +++ b/tests/specs/cache/fetch_multiple/fetch_multiple.out @@ -0,0 +1,5 @@ +Download http://localhost:4545/subdir/mod2.ts +Download http://localhost:4545/subdir/mt_text_typescript.t1.ts +Download http://localhost:4545/subdir/print_hello.ts +Check [WILDCARD]/fetch_multiple/test.ts +Check [WILDCARD]/fetch_multiple/other.ts diff --git a/tests/specs/cache/fetch_multiple/other.ts b/tests/specs/cache/fetch_multiple/other.ts new file mode 100644 index 000000000..91fe376b3 --- /dev/null +++ b/tests/specs/cache/fetch_multiple/other.ts @@ -0,0 +1 @@ +import "http://localhost:4545/subdir/mt_text_typescript.t1.ts"; diff --git a/tests/specs/cache/fetch_multiple/test.ts b/tests/specs/cache/fetch_multiple/test.ts new file mode 100644 index 000000000..baa52775d --- /dev/null +++ b/tests/specs/cache/fetch_multiple/test.ts @@ -0,0 +1 @@ +import "http://localhost:4545/subdir/mod2.ts"; diff --git a/tests/specs/cache/ignore_require/__test__.jsonc b/tests/specs/cache/ignore_require/__test__.jsonc new file mode 100644 index 000000000..e6d0093c7 --- /dev/null +++ b/tests/specs/cache/ignore_require/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "cache --reload --no-check ignore_require.js", + "output": "" +} diff --git a/tests/specs/cache/ignore_require/ignore_require.js b/tests/specs/cache/ignore_require/ignore_require.js new file mode 100644 index 000000000..a8ef15021 --- /dev/null +++ b/tests/specs/cache/ignore_require/ignore_require.js @@ -0,0 +1,2 @@ +// deno-lint-ignore-file +require("invalid module specifier"); diff --git a/tests/specs/cache/json_import/__test__.jsonc b/tests/specs/cache/json_import/__test__.jsonc new file mode 100644 index 000000000..fdc3459c3 --- /dev/null +++ b/tests/specs/cache/json_import/__test__.jsonc @@ -0,0 +1,5 @@ +{ + // should not error + "args": "cache --quiet main.ts", + "output": "[WILDCARD]" +} diff --git a/tests/specs/cache/json_import/main.ts b/tests/specs/cache/json_import/main.ts new file mode 100644 index 000000000..78273558f --- /dev/null +++ b/tests/specs/cache/json_import/main.ts @@ -0,0 +1,2 @@ +import asdf from "./test.json" assert { type: "json" }; +console.log(asdf); diff --git a/tests/specs/cache/json_import/test.json b/tests/specs/cache/json_import/test.json new file mode 100644 index 000000000..258849a68 --- /dev/null +++ b/tests/specs/cache/json_import/test.json @@ -0,0 +1,5 @@ +{ + "foo": { + "bar": 1 + } +} diff --git a/tests/specs/cache/package_json/__test__.jsonc b/tests/specs/cache/package_json/__test__.jsonc new file mode 100644 index 000000000..b25ac147d --- /dev/null +++ b/tests/specs/cache/package_json/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "tempDir": true, + "args": "cache main.ts", + "output": "main.cache.out" +} diff --git a/tests/specs/cache/package_json/lib.ts b/tests/specs/cache/package_json/lib.ts new file mode 100644 index 000000000..1deed81f7 --- /dev/null +++ b/tests/specs/cache/package_json/lib.ts @@ -0,0 +1,9 @@ +import * as test from "@denotest/esm-basic"; + +export function add(a: number, b: number) { + return a + b; +} + +export function getValue() { + return test.getValue(); +} diff --git a/tests/specs/cache/package_json/main.cache.out b/tests/specs/cache/package_json/main.cache.out new file mode 100644 index 000000000..1c729e2a3 --- /dev/null +++ b/tests/specs/cache/package_json/main.cache.out @@ -0,0 +1,3 @@ +Download http://localhost:4545/npm/registry/@denotest/esm-basic +Download http://localhost:4545/npm/registry/@denotest/esm-basic/1.0.0.tgz +Initialize @denotest/esm-basic@1.0.0 diff --git a/tests/specs/cache/package_json/main.ts b/tests/specs/cache/package_json/main.ts new file mode 100644 index 000000000..e241f3002 --- /dev/null +++ b/tests/specs/cache/package_json/main.ts @@ -0,0 +1,3 @@ +import { getValue } from "./lib.ts"; + +console.log(getValue()); diff --git a/tests/specs/cache/package_json/package.json b/tests/specs/cache/package_json/package.json new file mode 100644 index 000000000..54ca824d6 --- /dev/null +++ b/tests/specs/cache/package_json/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@denotest/esm-basic": "*" + } +} diff --git a/tests/specs/cache/performance_stats/__test__.jsonc b/tests/specs/cache/performance_stats/__test__.jsonc new file mode 100644 index 000000000..f4d37b803 --- /dev/null +++ b/tests/specs/cache/performance_stats/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "cache --reload --check=all --log-level debug hello.ts", + "output": "performance_stats.out" +} diff --git a/tests/specs/cache/performance_stats/hello.ts b/tests/specs/cache/performance_stats/hello.ts new file mode 100644 index 000000000..accefceba --- /dev/null +++ b/tests/specs/cache/performance_stats/hello.ts @@ -0,0 +1 @@ +console.log("Hello World"); diff --git a/tests/specs/cache/performance_stats/performance_stats.out b/tests/specs/cache/performance_stats/performance_stats.out new file mode 100644 index 000000000..141829ee6 --- /dev/null +++ b/tests/specs/cache/performance_stats/performance_stats.out @@ -0,0 +1,16 @@ +[WILDCARD] +DEBUG RS - [WILDCARD] - Compilation statistics: + Files: [WILDCARD] + Nodes: [WILDCARD] + Identifiers: [WILDCARD] + Symbols: [WILDCARD] + Types: [WILDCARD] + Instantiations: [WILDCARD] + Parse time: [WILDCARD] + Bind time: [WILDCARD] + Check time: [WILDCARD] + Emit time: [WILDCARD] + Total TS time: [WILDCARD] + Compile time: [WILDCARD] + +[WILDCARD] diff --git a/tests/specs/cache/random_extension/__test__.jsonc b/tests/specs/cache/random_extension/__test__.jsonc new file mode 100644 index 000000000..7b847a77d --- /dev/null +++ b/tests/specs/cache/random_extension/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "cache --reload --check=all http://localhost:4545/subdir/no_js_ext@1.0.0", + "output": "cache_random_extension.out" +} diff --git a/tests/specs/cache/random_extension/cache_random_extension.out b/tests/specs/cache/random_extension/cache_random_extension.out new file mode 100644 index 000000000..745a2e0e3 --- /dev/null +++ b/tests/specs/cache/random_extension/cache_random_extension.out @@ -0,0 +1,2 @@ +[WILDCARD] +Check http://localhost:4545/subdir/no_js_ext@1.0.0 diff --git a/tests/specs/cache/redirect/__test__.jsonc b/tests/specs/cache/redirect/__test__.jsonc new file mode 100644 index 000000000..251bc6174 --- /dev/null +++ b/tests/specs/cache/redirect/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "cache --reload --check=all http://localhost:4548/subdir/redirects/a.ts", + "output": "redirect_cache.out" +} diff --git a/tests/specs/cache/redirect/redirect_cache.out b/tests/specs/cache/redirect/redirect_cache.out new file mode 100644 index 000000000..8905c4529 --- /dev/null +++ b/tests/specs/cache/redirect/redirect_cache.out @@ -0,0 +1,5 @@ +Download http://localhost:4548/subdir/redirects/a.ts +Download http://localhost:4546/subdir/redirects/a.ts +Download http://localhost:4545/subdir/redirects/a.ts +Download http://localhost:4545/subdir/redirects/b.ts +Check http://localhost:4548/subdir/redirects/a.ts diff --git a/tests/specs/cache/with_bare_import/095_cache_with_bare_import.ts b/tests/specs/cache/with_bare_import/095_cache_with_bare_import.ts new file mode 100644 index 000000000..c0748305d --- /dev/null +++ b/tests/specs/cache/with_bare_import/095_cache_with_bare_import.ts @@ -0,0 +1 @@ +import "foo"; diff --git a/tests/specs/cache/with_bare_import/095_cache_with_bare_import.ts.out b/tests/specs/cache/with_bare_import/095_cache_with_bare_import.ts.out new file mode 100644 index 000000000..2668a6e08 --- /dev/null +++ b/tests/specs/cache/with_bare_import/095_cache_with_bare_import.ts.out @@ -0,0 +1,2 @@ +[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../ + at file:///[WILDCARD]/095_cache_with_bare_import.ts:[WILDCARD] diff --git a/tests/specs/cache/with_bare_import/__test__.jsonc b/tests/specs/cache/with_bare_import/__test__.jsonc new file mode 100644 index 000000000..0ff2d09cb --- /dev/null +++ b/tests/specs/cache/with_bare_import/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "cache 095_cache_with_bare_import.ts", + "output": "095_cache_with_bare_import.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/check/check_types_dts/__test__.jsonc b/tests/specs/check/check_types_dts/__test__.jsonc new file mode 100644 index 000000000..7f620daa2 --- /dev/null +++ b/tests/specs/check/check_types_dts/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "check main.ts", + "output": "main.out", + "exitCode": 0 +} diff --git a/tests/specs/check/check_types_dts/deno.json b/tests/specs/check/check_types_dts/deno.json new file mode 100644 index 000000000..85f1549e0 --- /dev/null +++ b/tests/specs/check/check_types_dts/deno.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "types": [ + "./types.d.ts" + ] + } +} diff --git a/tests/specs/check/check_types_dts/main.out b/tests/specs/check/check_types_dts/main.out new file mode 100644 index 000000000..b8fb00c4f --- /dev/null +++ b/tests/specs/check/check_types_dts/main.out @@ -0,0 +1 @@ +Check file:///[WILDCARD]/main.ts diff --git a/tests/specs/check/check_types_dts/main.ts b/tests/specs/check/check_types_dts/main.ts new file mode 100644 index 000000000..ca375a094 --- /dev/null +++ b/tests/specs/check/check_types_dts/main.ts @@ -0,0 +1,3 @@ +console.log("Hello world!"); + +test.test(); diff --git a/tests/specs/check/check_types_dts/types.d.ts b/tests/specs/check/check_types_dts/types.d.ts new file mode 100644 index 000000000..141c2a3d3 --- /dev/null +++ b/tests/specs/check/check_types_dts/types.d.ts @@ -0,0 +1,3 @@ +declare class test { + static test(): void; +} diff --git a/tests/specs/check/check_with_excluded_file_specified/__test__.jsonc b/tests/specs/check/check_with_excluded_file_specified/__test__.jsonc new file mode 100644 index 000000000..212ab8fb3 --- /dev/null +++ b/tests/specs/check/check_with_excluded_file_specified/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "check lib/types.d.ts", + "output": "check.out" +} diff --git a/tests/specs/check/check_with_excluded_file_specified/check.out b/tests/specs/check/check_with_excluded_file_specified/check.out new file mode 100644 index 000000000..2bc26aaaf --- /dev/null +++ b/tests/specs/check/check_with_excluded_file_specified/check.out @@ -0,0 +1 @@ +Warning No matching files found. diff --git a/tests/specs/check/check_with_excluded_file_specified/deno.json b/tests/specs/check/check_with_excluded_file_specified/deno.json new file mode 100644 index 000000000..039be18df --- /dev/null +++ b/tests/specs/check/check_with_excluded_file_specified/deno.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "types": ["./lib/types.d.ts"] + }, + "exclude": ["lib"] +} diff --git a/tests/specs/check/check_with_excluded_file_specified/lib/types.d.ts b/tests/specs/check/check_with_excluded_file_specified/lib/types.d.ts new file mode 100644 index 000000000..a02ad0cbe --- /dev/null +++ b/tests/specs/check/check_with_excluded_file_specified/lib/types.d.ts @@ -0,0 +1,2 @@ +// deno-lint-ignore-file +declare var test: number; diff --git a/tests/specs/check/extensionless/__test__.jsonc b/tests/specs/check/extensionless/__test__.jsonc new file mode 100644 index 000000000..670680b7d --- /dev/null +++ b/tests/specs/check/extensionless/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "check --reload --all http://localhost:4545/subdir/no_js_ext", + "output": "check.out" +} diff --git a/tests/specs/check/extensionless/check.out b/tests/specs/check/extensionless/check.out new file mode 100644 index 000000000..3694c67cb --- /dev/null +++ b/tests/specs/check/extensionless/check.out @@ -0,0 +1,2 @@ +[WILDCARD] +Check http://localhost:4545/subdir/no_js_ext diff --git a/tests/specs/check/random_extension/__test__.jsonc b/tests/specs/check/random_extension/__test__.jsonc new file mode 100644 index 000000000..f504c1d2b --- /dev/null +++ b/tests/specs/check/random_extension/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "check --reload --all http://localhost:4545/subdir/no_js_ext@1.0.0", + "output": "output.out" +} diff --git a/tests/specs/check/random_extension/output.out b/tests/specs/check/random_extension/output.out new file mode 100644 index 000000000..745a2e0e3 --- /dev/null +++ b/tests/specs/check/random_extension/output.out @@ -0,0 +1,2 @@ +[WILDCARD] +Check http://localhost:4545/subdir/no_js_ext@1.0.0 diff --git a/tests/specs/check/with_bare_import/095_cache_with_bare_import.ts b/tests/specs/check/with_bare_import/095_cache_with_bare_import.ts new file mode 100644 index 000000000..c0748305d --- /dev/null +++ b/tests/specs/check/with_bare_import/095_cache_with_bare_import.ts @@ -0,0 +1 @@ +import "foo"; diff --git a/tests/specs/check/with_bare_import/095_cache_with_bare_import.ts.out b/tests/specs/check/with_bare_import/095_cache_with_bare_import.ts.out new file mode 100644 index 000000000..2668a6e08 --- /dev/null +++ b/tests/specs/check/with_bare_import/095_cache_with_bare_import.ts.out @@ -0,0 +1,2 @@ +[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../ + at file:///[WILDCARD]/095_cache_with_bare_import.ts:[WILDCARD] diff --git a/tests/specs/check/with_bare_import/__test__.jsonc b/tests/specs/check/with_bare_import/__test__.jsonc new file mode 100644 index 000000000..c32a66ad2 --- /dev/null +++ b/tests/specs/check/with_bare_import/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "check 095_cache_with_bare_import.ts", + "output": "095_cache_with_bare_import.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/no_slow_types/__test__.jsonc b/tests/specs/lint/no_slow_types/__test__.jsonc new file mode 100644 index 000000000..2a5a34032 --- /dev/null +++ b/tests/specs/lint/no_slow_types/__test__.jsonc @@ -0,0 +1,17 @@ +{ + "steps": [{ + "args": "lint", + "output": "no_slow_types.out", + "exitCode": 1 + }, { + "args": "lint --rules-exclude=no-slow-types", + "output": "Checked 4 files\n" + }, { + "args": "lint --config=deno.non-package.json", + "output": "Checked 4 files\n" + }, { + // non-entrypoint + "args": "lint d.ts", + "output": "Checked 1 file\n" + }] +} diff --git a/tests/specs/lint/no_slow_types/a.ts b/tests/specs/lint/no_slow_types/a.ts new file mode 100644 index 000000000..3b399665d --- /dev/null +++ b/tests/specs/lint/no_slow_types/a.ts @@ -0,0 +1,3 @@ +export function add(a: number, b: number) { + return a + b; +} diff --git a/tests/specs/lint/no_slow_types/b.ts b/tests/specs/lint/no_slow_types/b.ts new file mode 100644 index 000000000..b96a79489 --- /dev/null +++ b/tests/specs/lint/no_slow_types/b.ts @@ -0,0 +1,5 @@ +export function addB(a: number, b: number) { + return a + b; +} + +export * from "./d.ts"; diff --git a/tests/specs/lint/no_slow_types/c.ts b/tests/specs/lint/no_slow_types/c.ts new file mode 100644 index 000000000..517aa3d21 --- /dev/null +++ b/tests/specs/lint/no_slow_types/c.ts @@ -0,0 +1,4 @@ +// this one won't error because it's not an export +export function addC(a: number, b: number) { + return a + b; +} diff --git a/tests/specs/lint/no_slow_types/d.ts b/tests/specs/lint/no_slow_types/d.ts new file mode 100644 index 000000000..babe9d81b --- /dev/null +++ b/tests/specs/lint/no_slow_types/d.ts @@ -0,0 +1,4 @@ +// this one is re-exported via b.ts +export function addD(a: number, b: number) { + return a + b; +} diff --git a/tests/specs/lint/no_slow_types/deno.json b/tests/specs/lint/no_slow_types/deno.json new file mode 100644 index 000000000..2fd0af5f0 --- /dev/null +++ b/tests/specs/lint/no_slow_types/deno.json @@ -0,0 +1,8 @@ +{ + "name": "@pkg/pkg", + "version": "1.0.0", + "exports": { + "./a": "./a.ts", + "./b": "./b.ts" + } +} diff --git a/tests/specs/lint/no_slow_types/deno.non-package.json b/tests/specs/lint/no_slow_types/deno.non-package.json new file mode 100644 index 000000000..2c63c0851 --- /dev/null +++ b/tests/specs/lint/no_slow_types/deno.non-package.json @@ -0,0 +1,2 @@ +{ +} diff --git a/tests/specs/lint/no_slow_types/no_slow_types.out b/tests/specs/lint/no_slow_types/no_slow_types.out new file mode 100644 index 000000000..5828906e7 --- /dev/null +++ b/tests/specs/lint/no_slow_types/no_slow_types.out @@ -0,0 +1,35 @@ +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]a.ts:1:17 + | +1 | export function add(a: number, b: number) { + | ^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]b.ts:1:17 + | +1 | export function addB(a: number, b: number) { + | ^^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]d.ts:2:17 + | +2 | export function addD(a: number, b: number) { + | ^^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +Found 3 problems +Checked 4 files diff --git a/tests/specs/lint/no_slow_types/no_slow_types_entrypoint.out b/tests/specs/lint/no_slow_types/no_slow_types_entrypoint.out new file mode 100644 index 000000000..b8c1013bf --- /dev/null +++ b/tests/specs/lint/no_slow_types/no_slow_types_entrypoint.out @@ -0,0 +1,35 @@ +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]a.ts:1:17 + | +1 | export function add(a: number, b: number) { + | ^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]b.ts:1:17 + | +1 | export function addB(a: number, b: number) { + | ^^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]d.ts:2:17 + | +2 | export function addD(a: number, b: number) { + | ^^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +Found 3 problems +Checked 1 file diff --git a/tests/specs/lint/no_slow_types_entrypoint/__test__.jsonc b/tests/specs/lint/no_slow_types_entrypoint/__test__.jsonc new file mode 100644 index 000000000..2ba74c03f --- /dev/null +++ b/tests/specs/lint/no_slow_types_entrypoint/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint a.ts", + "output": "no_slow_types_entrypoint.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/no_slow_types_entrypoint/a.ts b/tests/specs/lint/no_slow_types_entrypoint/a.ts new file mode 100644 index 000000000..3b399665d --- /dev/null +++ b/tests/specs/lint/no_slow_types_entrypoint/a.ts @@ -0,0 +1,3 @@ +export function add(a: number, b: number) { + return a + b; +} diff --git a/tests/specs/lint/no_slow_types_entrypoint/b.ts b/tests/specs/lint/no_slow_types_entrypoint/b.ts new file mode 100644 index 000000000..b96a79489 --- /dev/null +++ b/tests/specs/lint/no_slow_types_entrypoint/b.ts @@ -0,0 +1,5 @@ +export function addB(a: number, b: number) { + return a + b; +} + +export * from "./d.ts"; diff --git a/tests/specs/lint/no_slow_types_entrypoint/c.ts b/tests/specs/lint/no_slow_types_entrypoint/c.ts new file mode 100644 index 000000000..517aa3d21 --- /dev/null +++ b/tests/specs/lint/no_slow_types_entrypoint/c.ts @@ -0,0 +1,4 @@ +// this one won't error because it's not an export +export function addC(a: number, b: number) { + return a + b; +} diff --git a/tests/specs/lint/no_slow_types_entrypoint/d.ts b/tests/specs/lint/no_slow_types_entrypoint/d.ts new file mode 100644 index 000000000..babe9d81b --- /dev/null +++ b/tests/specs/lint/no_slow_types_entrypoint/d.ts @@ -0,0 +1,4 @@ +// this one is re-exported via b.ts +export function addD(a: number, b: number) { + return a + b; +} diff --git a/tests/specs/lint/no_slow_types_entrypoint/deno.json b/tests/specs/lint/no_slow_types_entrypoint/deno.json new file mode 100644 index 000000000..2fd0af5f0 --- /dev/null +++ b/tests/specs/lint/no_slow_types_entrypoint/deno.json @@ -0,0 +1,8 @@ +{ + "name": "@pkg/pkg", + "version": "1.0.0", + "exports": { + "./a": "./a.ts", + "./b": "./b.ts" + } +} diff --git a/tests/specs/lint/no_slow_types_entrypoint/deno.non-package.json b/tests/specs/lint/no_slow_types_entrypoint/deno.non-package.json new file mode 100644 index 000000000..2c63c0851 --- /dev/null +++ b/tests/specs/lint/no_slow_types_entrypoint/deno.non-package.json @@ -0,0 +1,2 @@ +{ +} diff --git a/tests/specs/lint/no_slow_types_entrypoint/no_slow_types.out b/tests/specs/lint/no_slow_types_entrypoint/no_slow_types.out new file mode 100644 index 000000000..5828906e7 --- /dev/null +++ b/tests/specs/lint/no_slow_types_entrypoint/no_slow_types.out @@ -0,0 +1,35 @@ +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]a.ts:1:17 + | +1 | export function add(a: number, b: number) { + | ^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]b.ts:1:17 + | +1 | export function addB(a: number, b: number) { + | ^^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]d.ts:2:17 + | +2 | export function addD(a: number, b: number) { + | ^^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +Found 3 problems +Checked 4 files diff --git a/tests/specs/lint/no_slow_types_entrypoint/no_slow_types_entrypoint.out b/tests/specs/lint/no_slow_types_entrypoint/no_slow_types_entrypoint.out new file mode 100644 index 000000000..b8c1013bf --- /dev/null +++ b/tests/specs/lint/no_slow_types_entrypoint/no_slow_types_entrypoint.out @@ -0,0 +1,35 @@ +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]a.ts:1:17 + | +1 | export function add(a: number, b: number) { + | ^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]b.ts:1:17 + | +1 | export function addB(a: number, b: number) { + | ^^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]d.ts:2:17 + | +2 | export function addD(a: number, b: number) { + | ^^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +Found 3 problems +Checked 1 file diff --git a/tests/specs/lint/no_slow_types_workspace/__test__.jsonc b/tests/specs/lint/no_slow_types_workspace/__test__.jsonc new file mode 100644 index 000000000..7128e116c --- /dev/null +++ b/tests/specs/lint/no_slow_types_workspace/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "lint", + "output": "output.out", + "exitCode": 1 +} diff --git a/tests/specs/lint/no_slow_types_workspace/a/b.ts b/tests/specs/lint/no_slow_types_workspace/a/b.ts new file mode 100644 index 000000000..b96a79489 --- /dev/null +++ b/tests/specs/lint/no_slow_types_workspace/a/b.ts @@ -0,0 +1,5 @@ +export function addB(a: number, b: number) { + return a + b; +} + +export * from "./d.ts"; diff --git a/tests/specs/lint/no_slow_types_workspace/a/d.ts b/tests/specs/lint/no_slow_types_workspace/a/d.ts new file mode 100644 index 000000000..babe9d81b --- /dev/null +++ b/tests/specs/lint/no_slow_types_workspace/a/d.ts @@ -0,0 +1,4 @@ +// this one is re-exported via b.ts +export function addD(a: number, b: number) { + return a + b; +} diff --git a/tests/specs/lint/no_slow_types_workspace/a/deno.json b/tests/specs/lint/no_slow_types_workspace/a/deno.json new file mode 100644 index 000000000..5a971cd85 --- /dev/null +++ b/tests/specs/lint/no_slow_types_workspace/a/deno.json @@ -0,0 +1,8 @@ +{ + "name": "@pkg/a", + "version": "1.0.0", + "exports": { + "./a": "./mod.ts", + "./b": "./b.ts" + } +} diff --git a/tests/specs/lint/no_slow_types_workspace/a/mod.ts b/tests/specs/lint/no_slow_types_workspace/a/mod.ts new file mode 100644 index 000000000..3b399665d --- /dev/null +++ b/tests/specs/lint/no_slow_types_workspace/a/mod.ts @@ -0,0 +1,3 @@ +export function add(a: number, b: number) { + return a + b; +} diff --git a/tests/specs/lint/no_slow_types_workspace/b/deno.json b/tests/specs/lint/no_slow_types_workspace/b/deno.json new file mode 100644 index 000000000..c95aeb029 --- /dev/null +++ b/tests/specs/lint/no_slow_types_workspace/b/deno.json @@ -0,0 +1,5 @@ +{ + "name": "@pkg/b", + "version": "1.0.0", + "exports": "./mod.ts" +} diff --git a/tests/specs/lint/no_slow_types_workspace/b/mod.ts b/tests/specs/lint/no_slow_types_workspace/b/mod.ts new file mode 100644 index 000000000..fa1c068de --- /dev/null +++ b/tests/specs/lint/no_slow_types_workspace/b/mod.ts @@ -0,0 +1,4 @@ +// ok +export function addB(a: number, b: number): number { + return a + b; +} diff --git a/tests/specs/lint/no_slow_types_workspace/c/deno.json b/tests/specs/lint/no_slow_types_workspace/c/deno.json new file mode 100644 index 000000000..36d6e2e67 --- /dev/null +++ b/tests/specs/lint/no_slow_types_workspace/c/deno.json @@ -0,0 +1,5 @@ +{ + "name": "@pkg/c", + "version": "1.0.0", + "exports": "./mod_c.ts" +} diff --git a/tests/specs/lint/no_slow_types_workspace/c/mod_c.ts b/tests/specs/lint/no_slow_types_workspace/c/mod_c.ts new file mode 100644 index 000000000..632a90b65 --- /dev/null +++ b/tests/specs/lint/no_slow_types_workspace/c/mod_c.ts @@ -0,0 +1,4 @@ +// not ok +export function addC(a: number, b: number) { + return a + b; +} diff --git a/tests/specs/lint/no_slow_types_workspace/deno.json b/tests/specs/lint/no_slow_types_workspace/deno.json new file mode 100644 index 000000000..e3dd981e5 --- /dev/null +++ b/tests/specs/lint/no_slow_types_workspace/deno.json @@ -0,0 +1,7 @@ +{ + "workspaces": [ + "./a", + "./b", + "./c" + ] +} diff --git a/tests/specs/lint/no_slow_types_workspace/output.out b/tests/specs/lint/no_slow_types_workspace/output.out new file mode 100644 index 000000000..05f54099b --- /dev/null +++ b/tests/specs/lint/no_slow_types_workspace/output.out @@ -0,0 +1,46 @@ +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]b.ts:1:17 + | +1 | export function addB(a: number, b: number) { + | ^^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]d.ts:2:17 + | +2 | export function addD(a: number, b: number) { + | ^^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]mod.ts:1:17 + | +1 | export function add(a: number, b: number) { + | ^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +error[no-slow-types]: missing explicit return type in the public API + --> [WILDCARD]mod_c.ts:2:17 + | +2 | export function addC(a: number, b: number) { + | ^^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + + +Found 4 problems +Checked 5 files diff --git a/tests/specs/lockfile/no_lock/__test__.jsonc b/tests/specs/lockfile/no_lock/__test__.jsonc new file mode 100644 index 000000000..60bbd17e0 --- /dev/null +++ b/tests/specs/lockfile/no_lock/__test__.jsonc @@ -0,0 +1,31 @@ +{ + "steps": [{ + "args": "info main.ts", + "output": "fail_initial.out", + "exitCode": 10 + }, { + "args": "info --no-lock main.ts", + "output": "info.nolock.out" + }, { + "args": "bench", + "output": "fail.out", + "exitCode": 10 + }, { + "args": "bench --no-lock", + "output": "bench.nolock.out" + }, { + "args": "doc main.ts", + "exitCode": 10, + "output": "fail.out" + }, { + "args": "doc --no-lock main.ts", + "output": "doc.nolock.out" + }, { + "args": "test", + "exitCode": 10, + "output": "fail.out" + }, { + "args": "test --no-lock", + "output": "test.nolock.out" + }] +} diff --git a/tests/specs/lockfile/no_lock/bench.nolock.out b/tests/specs/lockfile/no_lock/bench.nolock.out new file mode 100644 index 000000000..351efc970 --- /dev/null +++ b/tests/specs/lockfile/no_lock/bench.nolock.out @@ -0,0 +1,5 @@ +Check file:///[WILDCARD]/main.bench.ts +cpu: [WILDCARD] +runtime: [WILDCARD] + +[WILDCARD] diff --git a/tests/specs/lockfile/no_lock/deno.json b/tests/specs/lockfile/no_lock/deno.json new file mode 100644 index 000000000..d6541b78e --- /dev/null +++ b/tests/specs/lockfile/no_lock/deno.json @@ -0,0 +1,5 @@ +{ + "imports": { + "mod": "http://localhost:4545/lockfile/basic/mod.ts" + } +} diff --git a/tests/specs/lockfile/no_lock/deno.lock b/tests/specs/lockfile/no_lock/deno.lock new file mode 100644 index 000000000..42ab94f9b --- /dev/null +++ b/tests/specs/lockfile/no_lock/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/lockfile/basic/mod.ts": "invalid" + } +} diff --git a/tests/specs/lockfile/no_lock/doc.nolock.out b/tests/specs/lockfile/no_lock/doc.nolock.out new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/specs/lockfile/no_lock/doc.nolock.out diff --git a/tests/specs/lockfile/no_lock/fail.out b/tests/specs/lockfile/no_lock/fail.out new file mode 100644 index 000000000..4c2b04423 --- /dev/null +++ b/tests/specs/lockfile/no_lock/fail.out @@ -0,0 +1,3 @@ +error: The source code is invalid, as it does not match the expected hash in the lock file. + Specifier: [WILDCARD]mod.ts + Lock file: [WILDCARD]deno.lock diff --git a/tests/specs/lockfile/no_lock/fail_initial.out b/tests/specs/lockfile/no_lock/fail_initial.out new file mode 100644 index 000000000..6a808c0a5 --- /dev/null +++ b/tests/specs/lockfile/no_lock/fail_initial.out @@ -0,0 +1,4 @@ +Download http://localhost:4545/lockfile/basic/mod.ts +error: The source code is invalid, as it does not match the expected hash in the lock file. + Specifier: [WILDCARD]mod.ts + Lock file: [WILDCARD]deno.lock diff --git a/tests/specs/lockfile/no_lock/info.nolock.out b/tests/specs/lockfile/no_lock/info.nolock.out new file mode 100644 index 000000000..b03661193 --- /dev/null +++ b/tests/specs/lockfile/no_lock/info.nolock.out @@ -0,0 +1,7 @@ +local: [WILDLINE]main.ts +type: TypeScript +dependencies: 1 unique +size: [WILDCARD] + +file:///[WILDCARD]/main.ts ([WILDLINE]) +└── http://localhost:4545/lockfile/basic/mod.ts ([WILDLINE]) diff --git a/tests/specs/lockfile/no_lock/main.bench.ts b/tests/specs/lockfile/no_lock/main.bench.ts new file mode 100644 index 000000000..918adde2f --- /dev/null +++ b/tests/specs/lockfile/no_lock/main.bench.ts @@ -0,0 +1,8 @@ +import { getValue } from "mod"; + +Deno.bench("bench", () => { + const testing = 1 + getValue(); + if (testing !== 6) { + throw "FAIL"; + } +}); diff --git a/tests/specs/lockfile/no_lock/main.test.ts b/tests/specs/lockfile/no_lock/main.test.ts new file mode 100644 index 000000000..fe45c799d --- /dev/null +++ b/tests/specs/lockfile/no_lock/main.test.ts @@ -0,0 +1,8 @@ +import { getValue } from "mod"; + +Deno.test("test", () => { + const testing = 1 + getValue(); + if (testing !== 6) { + throw "FAIL"; + } +}); diff --git a/tests/specs/lockfile/no_lock/main.ts b/tests/specs/lockfile/no_lock/main.ts new file mode 100644 index 000000000..8d07c8153 --- /dev/null +++ b/tests/specs/lockfile/no_lock/main.ts @@ -0,0 +1,3 @@ +import { getValue } from "mod"; + +console.log(getValue()); diff --git a/tests/specs/lockfile/no_lock/test.nolock.out b/tests/specs/lockfile/no_lock/test.nolock.out new file mode 100644 index 000000000..b5039c2d6 --- /dev/null +++ b/tests/specs/lockfile/no_lock/test.nolock.out @@ -0,0 +1,3 @@ +Check file:///[WILDCARD]/main.test.ts +running 1 test from [WILDCARD]/main.test.ts +[WILDCARD] diff --git a/tests/specs/mod.rs b/tests/specs/mod.rs index 16a9e6f05..fc61fefac 100644 --- a/tests/specs/mod.rs +++ b/tests/specs/mod.rs @@ -71,6 +71,9 @@ struct StepMetaData { /// Whether to clean the deno_dir before running the step. #[serde(default)] pub clean_deno_dir: bool, + /// If the test should be retried multiple times on failure. + #[serde(default)] + pub flaky: bool, pub args: VecOrString, pub cwd: Option<String>, #[serde(rename = "if")] @@ -173,33 +176,12 @@ fn run_test(test: &CollectedTest, diagnostic_logger: Rc<RefCell<Vec<u8>>>) { } for step in metadata.steps.iter().filter(|s| should_run_step(s)) { - if step.clean_deno_dir { - context.deno_dir().path().remove_dir_all(); - } - - let command = context - .new_command() - .envs(metadata.envs.iter().chain(step.envs.iter())); - let command = match &step.args { - VecOrString::Vec(args) => command.args_vec(args), - VecOrString::String(text) => command.args(text), - }; - let command = match &step.cwd { - Some(cwd) => command.current_dir(cwd), - None => command, - }; - let command = match &step.command_name { - Some(command_name) => command.name(command_name), - None => command, - }; - let output = command.run(); - if step.output.ends_with(".out") { - let test_output_path = cwd.join(&step.output); - output.assert_matches_file(test_output_path); + let run_func = || run_step(step, &metadata, &cwd, &context); + if step.flaky { + run_flaky(run_func); } else { - output.assert_matches_text(&step.output); + run_func(); } - output.assert_exit_code(step.exit_code); } } @@ -217,6 +199,53 @@ fn should_run_step(step: &StepMetaData) -> bool { } } +fn run_flaky(action: impl Fn()) { + for _ in 0..2 { + let result = std::panic::catch_unwind(AssertUnwindSafe(&action)); + if result.is_ok() { + return; + } + } + + // surface error on third try + action(); +} + +fn run_step( + step: &StepMetaData, + metadata: &MultiTestMetaData, + cwd: &PathRef, + context: &test_util::TestContext, +) { + if step.clean_deno_dir { + context.deno_dir().path().remove_dir_all(); + } + + let command = context + .new_command() + .envs(metadata.envs.iter().chain(step.envs.iter())); + let command = match &step.args { + VecOrString::Vec(args) => command.args_vec(args), + VecOrString::String(text) => command.args(text), + }; + let command = match &step.cwd { + Some(cwd) => command.current_dir(cwd), + None => command, + }; + let command = match &step.command_name { + Some(command_name) => command.name(command_name), + None => command, + }; + let output = command.run(); + if step.output.ends_with(".out") { + let test_output_path = cwd.join(&step.output); + output.assert_matches_file(test_output_path); + } else { + output.assert_matches_text(&step.output); + } + output.assert_exit_code(step.exit_code); +} + fn resolve_test_and_assertion_files( dir: &PathRef, metadata: &MultiTestMetaData, diff --git a/tests/specs/publish/allow_slow_types/__test__.jsonc b/tests/specs/publish/allow_slow_types/__test__.jsonc new file mode 100644 index 000000000..e9f1cd011 --- /dev/null +++ b/tests/specs/publish/allow_slow_types/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --allow-slow-types --token 'sadfasdf'", + "output": "allow_slow_types.out", + "exitCode": 0 +} diff --git a/tests/specs/publish/allow_slow_types/allow_slow_types.out b/tests/specs/publish/allow_slow_types/allow_slow_types.out new file mode 100644 index 000000000..cd22c0ce7 --- /dev/null +++ b/tests/specs/publish/allow_slow_types/allow_slow_types.out @@ -0,0 +1,5 @@ +Check file:///[WILDCARD]mod.ts +Warning Publishing a library with slow types is not recommended. This may lead to poor type checking performance for users of your package, may affect the quality of automatic documentation generation, and your package will not be shipped with a .d.ts file for Node.js users. +Publishing @foo/bar@1.1.0 ... +Successfully published @foo/bar@1.1.0 +Visit http://127.0.0.1:4250/@foo/bar@1.1.0 for details diff --git a/tests/specs/publish/allow_slow_types/deno.json b/tests/specs/publish/allow_slow_types/deno.json new file mode 100644 index 000000000..5826e5529 --- /dev/null +++ b/tests/specs/publish/allow_slow_types/deno.json @@ -0,0 +1,7 @@ +{ + "name": "@foo/bar", + "version": "1.1.0", + "exports": { + ".": "./mod.ts" + } +} diff --git a/tests/specs/publish/allow_slow_types/mod.ts b/tests/specs/publish/allow_slow_types/mod.ts new file mode 100644 index 000000000..025311049 --- /dev/null +++ b/tests/specs/publish/allow_slow_types/mod.ts @@ -0,0 +1,4 @@ +// requires an explicit type annotation of `number` +export function getRandom() { + return Math.random(); +} diff --git a/tests/specs/publish/bare_node_builtins/__test__.jsonc b/tests/specs/publish/bare_node_builtins/__test__.jsonc new file mode 100644 index 000000000..f9e38fbe5 --- /dev/null +++ b/tests/specs/publish/bare_node_builtins/__test__.jsonc @@ -0,0 +1,17 @@ +{ + "tempDir": true, + "envs": { + "DISABLE_JSR_PROVENANCE": "true", + "DENO_TESTING_DISABLE_GIT_CHECK": "1" + }, + "steps": [{ + "args": "publish --token 'sadfasdf' --dry-run --unstable-bare-node-builtins", + "output": "bare_node_builtins.out" + }, { + "envs": { + "DENO_DISABLE_PEDANTIC_NODE_WARNINGS": "1" + }, + "args": "publish --token 'sadfasdf' --dry-run --unstable-bare-node-builtins", + "output": "no_warnings.out" + }] +} diff --git a/tests/specs/publish/bare_node_builtins/bare_node_builtins.out b/tests/specs/publish/bare_node_builtins/bare_node_builtins.out new file mode 100644 index 000000000..09acc639f --- /dev/null +++ b/tests/specs/publish/bare_node_builtins/bare_node_builtins.out @@ -0,0 +1,11 @@ +Warning: Resolving "url" as "node:url" at file:///[WILDLINE]/mod.ts:1:22. If you want to use a built-in Node module, add a "node:" prefix. +Warning: Resolving "url" as "node:url" at file:///[WILDLINE]/mod.ts:1:22. If you want to use a built-in Node module, add a "node:" prefix. +Download http://localhost:4545/npm/registry/@types/node +Download http://localhost:4545/npm/registry/@types/node/node-18.16.19.tgz +Check file:///[WILDLINE]/mod.ts +Checking for slow types in the public API... +Check file:///[WILDLINE]/mod.ts +Simulating publish of @foo/bar@1.0.0 with files: + file:///[WILDLINE]/deno.json (87B) + file:///[WILDLINE]/mod.ts (121B) +Warning Aborting due to --dry-run diff --git a/tests/specs/publish/bare_node_builtins/deno.json b/tests/specs/publish/bare_node_builtins/deno.json new file mode 100644 index 000000000..213a7cec6 --- /dev/null +++ b/tests/specs/publish/bare_node_builtins/deno.json @@ -0,0 +1,7 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + } +} diff --git a/tests/specs/publish/bare_node_builtins/mod.ts b/tests/specs/publish/bare_node_builtins/mod.ts new file mode 100644 index 000000000..04374d8b7 --- /dev/null +++ b/tests/specs/publish/bare_node_builtins/mod.ts @@ -0,0 +1,5 @@ +import * as url from "url"; + +export function foobar(): { href: string } { + return url.pathToFileURL("/foo/bar"); +} diff --git a/tests/specs/publish/bare_node_builtins/no_warnings.out b/tests/specs/publish/bare_node_builtins/no_warnings.out new file mode 100644 index 000000000..f9a11f37c --- /dev/null +++ b/tests/specs/publish/bare_node_builtins/no_warnings.out @@ -0,0 +1,5 @@ +Checking for slow types in the public API... +Simulating publish of @foo/bar@1.0.0 with files: + file:///[WILDLINE]/deno.json (87B) + file:///[WILDLINE]/mod.ts (121B) +Warning Aborting due to --dry-run diff --git a/tests/specs/publish/config_file_jsonc/__test__.jsonc b/tests/specs/publish/config_file_jsonc/__test__.jsonc new file mode 100644 index 000000000..bef8ce4ca --- /dev/null +++ b/tests/specs/publish/config_file_jsonc/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "deno_jsonc.out" +} diff --git a/tests/specs/publish/config_file_jsonc/deno.jsonc b/tests/specs/publish/config_file_jsonc/deno.jsonc new file mode 100644 index 000000000..4c9dfb08c --- /dev/null +++ b/tests/specs/publish/config_file_jsonc/deno.jsonc @@ -0,0 +1,11 @@ +{ + // It's .jsonc file so it can have comments + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + }, + "imports": { + "@std/http": "./std_http.ts" + } +} diff --git a/tests/specs/publish/config_file_jsonc/deno_jsonc.out b/tests/specs/publish/config_file_jsonc/deno_jsonc.out new file mode 100644 index 000000000..af45ed598 --- /dev/null +++ b/tests/specs/publish/config_file_jsonc/deno_jsonc.out @@ -0,0 +1,6 @@ +Check file:///[WILDCARD]/mod.ts +Checking for slow types in the public API... +Check file:///[WILDCARD]/mod.ts +Publishing @foo/bar@1.0.0 ... +Successfully published @foo/bar@1.0.0 +Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/specs/publish/config_file_jsonc/mod.ts b/tests/specs/publish/config_file_jsonc/mod.ts new file mode 100644 index 000000000..6e8a61bae --- /dev/null +++ b/tests/specs/publish/config_file_jsonc/mod.ts @@ -0,0 +1,7 @@ +import http from "@std/http"; + +export function foobar(): { fileServer(): void } { + return { + fileServer: http.fileServer, + }; +} diff --git a/tests/specs/publish/config_file_jsonc/std_http.ts b/tests/specs/publish/config_file_jsonc/std_http.ts new file mode 100644 index 000000000..9d57b36f3 --- /dev/null +++ b/tests/specs/publish/config_file_jsonc/std_http.ts @@ -0,0 +1,6 @@ +// temp until we get jsr:@std/http in the test server +export default { + fileServer() { + console.log("Hi"); + }, +}; diff --git a/tests/specs/publish/config_flag/__test__.jsonc b/tests/specs/publish/config_flag/__test__.jsonc new file mode 100644 index 000000000..289f9abc9 --- /dev/null +++ b/tests/specs/publish/config_flag/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf' --config=successful/deno.json", + "output": "successful.out" +} diff --git a/tests/specs/publish/config_flag/successful.out b/tests/specs/publish/config_flag/successful.out new file mode 100644 index 000000000..78265361a --- /dev/null +++ b/tests/specs/publish/config_flag/successful.out @@ -0,0 +1,6 @@ +Check file:///[WILDCARD]/successful/mod.ts +Checking for slow types in the public API... +Check file:///[WILDCARD]/successful/mod.ts +Publishing @foo/bar@1.0.0 ... +Successfully published @foo/bar@1.0.0 +Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/specs/publish/config_flag/successful/deno.json b/tests/specs/publish/config_flag/successful/deno.json new file mode 100644 index 000000000..fefab899b --- /dev/null +++ b/tests/specs/publish/config_flag/successful/deno.json @@ -0,0 +1,10 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + }, + "imports": { + "@std/http": "./std_http.ts" + } +} diff --git a/tests/specs/publish/config_flag/successful/mod.ts b/tests/specs/publish/config_flag/successful/mod.ts new file mode 100644 index 000000000..6e8a61bae --- /dev/null +++ b/tests/specs/publish/config_flag/successful/mod.ts @@ -0,0 +1,7 @@ +import http from "@std/http"; + +export function foobar(): { fileServer(): void } { + return { + fileServer: http.fileServer, + }; +} diff --git a/tests/specs/publish/config_flag/successful/std_http.ts b/tests/specs/publish/config_flag/successful/std_http.ts new file mode 100644 index 000000000..9d57b36f3 --- /dev/null +++ b/tests/specs/publish/config_flag/successful/std_http.ts @@ -0,0 +1,6 @@ +// temp until we get jsr:@std/http in the test server +export default { + fileServer() { + console.log("Hi"); + }, +}; diff --git a/tests/specs/publish/dry_run/__test__.jsonc b/tests/specs/publish/dry_run/__test__.jsonc new file mode 100644 index 000000000..3ca6ff4d3 --- /dev/null +++ b/tests/specs/publish/dry_run/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf' --dry-run", + "output": "dry_run.out" +} diff --git a/tests/specs/publish/dry_run/deno.json b/tests/specs/publish/dry_run/deno.json new file mode 100644 index 000000000..fefab899b --- /dev/null +++ b/tests/specs/publish/dry_run/deno.json @@ -0,0 +1,10 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + }, + "imports": { + "@std/http": "./std_http.ts" + } +} diff --git a/tests/specs/publish/dry_run/dry_run.out b/tests/specs/publish/dry_run/dry_run.out new file mode 100644 index 000000000..afc2ba66a --- /dev/null +++ b/tests/specs/publish/dry_run/dry_run.out @@ -0,0 +1,8 @@ +Check file:///[WILDCARD]/mod.ts +Checking for slow types in the public API... +Check file:///[WILDCARD]/mod.ts +Simulating publish of @foo/bar@1.0.0 with files: + [WILDCARD]deno.json (140B) + [WILDCARD]mod.ts (137B) + [WILDCARD]std_http.ts (119B) +Warning Aborting due to --dry-run diff --git a/tests/specs/publish/dry_run/mod.ts b/tests/specs/publish/dry_run/mod.ts new file mode 100644 index 000000000..6e8a61bae --- /dev/null +++ b/tests/specs/publish/dry_run/mod.ts @@ -0,0 +1,7 @@ +import http from "@std/http"; + +export function foobar(): { fileServer(): void } { + return { + fileServer: http.fileServer, + }; +} diff --git a/tests/specs/publish/dry_run/std_http.ts b/tests/specs/publish/dry_run/std_http.ts new file mode 100644 index 000000000..9d57b36f3 --- /dev/null +++ b/tests/specs/publish/dry_run/std_http.ts @@ -0,0 +1,6 @@ +// temp until we get jsr:@std/http in the test server +export default { + fileServer() { + console.log("Hi"); + }, +}; diff --git a/tests/specs/publish/has_slow_types/__test__.jsonc b/tests/specs/publish/has_slow_types/__test__.jsonc new file mode 100644 index 000000000..470bae81b --- /dev/null +++ b/tests/specs/publish/has_slow_types/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "has_slow_types.out", + "exitCode": 1 +} diff --git a/tests/specs/publish/has_slow_types/deno.json b/tests/specs/publish/has_slow_types/deno.json new file mode 100644 index 000000000..5826e5529 --- /dev/null +++ b/tests/specs/publish/has_slow_types/deno.json @@ -0,0 +1,7 @@ +{ + "name": "@foo/bar", + "version": "1.1.0", + "exports": { + ".": "./mod.ts" + } +} diff --git a/tests/specs/publish/has_slow_types/has_slow_types.out b/tests/specs/publish/has_slow_types/has_slow_types.out new file mode 100644 index 000000000..43ac86658 --- /dev/null +++ b/tests/specs/publish/has_slow_types/has_slow_types.out @@ -0,0 +1,22 @@ +Check file:///[WILDCARD]/mod.ts +Checking for slow types in the public API... +error[missing-explicit-return-type]: missing explicit return type in the public API + --> [WILDCARD]mod.ts:2:17 + | +2 | export function getRandom() { + | ^^^^^^^^^ this function is missing an explicit return type + = hint: add an explicit return type to the function + + info: all functions in the public API must have an explicit return type + docs: https://jsr.io/go/slow-type-missing-explicit-return-type + +This package contains errors for slow types. Fixing these errors will: + + 1. Significantly improve your package users' type checking performance. + 2. Improve the automatic documentation generation. + 3. Enable automatic .d.ts generation for Node.js. + +Don't want to bother? You can choose to skip this step by +providing the --allow-slow-types flag. + +error: Found 1 problem diff --git a/tests/specs/publish/has_slow_types/mod.ts b/tests/specs/publish/has_slow_types/mod.ts new file mode 100644 index 000000000..025311049 --- /dev/null +++ b/tests/specs/publish/has_slow_types/mod.ts @@ -0,0 +1,4 @@ +// requires an explicit type annotation of `number` +export function getRandom() { + return Math.random(); +} diff --git a/tests/specs/publish/invalid_import/__test__.jsonc b/tests/specs/publish/invalid_import/__test__.jsonc new file mode 100644 index 000000000..5436a04f8 --- /dev/null +++ b/tests/specs/publish/invalid_import/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --token 'sadfasdf' --dry-run", + "output": "invalid_import.out", + "exitCode": 1 +} diff --git a/tests/specs/publish/invalid_import/deno.json b/tests/specs/publish/invalid_import/deno.json new file mode 100644 index 000000000..49b666d22 --- /dev/null +++ b/tests/specs/publish/invalid_import/deno.json @@ -0,0 +1,10 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "imports": { + "$echo": "http://localhost:4545/echo.ts" + }, + "exports": { + ".": "./mod.ts" + } +} diff --git a/tests/specs/publish/invalid_import/invalid_import.out b/tests/specs/publish/invalid_import/invalid_import.out new file mode 100644 index 000000000..f6742de95 --- /dev/null +++ b/tests/specs/publish/invalid_import/invalid_import.out @@ -0,0 +1,32 @@ +Download http://localhost:4545/welcome.ts +Download http://localhost:4545/echo.ts +Download http://localhost:4545/npm/registry/chalk +Download http://localhost:4545/npm/registry/chalk/chalk-5.0.1.tgz +Check file:///[WILDCARD]/mod.ts +Checking for slow types in the public API... +Check file://[WILDCARD]mod.ts +error[invalid-external-import]: invalid import to a non-JSR 'http' specifier + --> [WILDCARD]mod.ts:1:8 + | +1 | import "http://localhost:4545/welcome.ts"; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the specifier + = hint: replace this import with one from jsr or npm, or vendor the dependency into your package + + info: the import was resolved to 'http://localhost:4545/welcome.ts' + info: this specifier is not allowed to be imported on jsr + info: jsr only supports importing `jsr:`, `npm:`, and `data:` specifiers + docs: https://jsr.io/go/invalid-external-import + +error[invalid-external-import]: invalid import to a non-JSR 'http' specifier + --> [WILDCARD]mod.ts:2:8 + | +2 | import "$echo"; + | ^^^^^^^ the specifier + = hint: replace this import with one from jsr or npm, or vendor the dependency into your package + + info: the import was resolved to 'http://localhost:4545/echo.ts' + info: this specifier is not allowed to be imported on jsr + info: jsr only supports importing `jsr:`, `npm:`, and `data:` specifiers + docs: https://jsr.io/go/invalid-external-import + +error: Found 2 problems diff --git a/tests/specs/publish/invalid_import/mod.ts b/tests/specs/publish/invalid_import/mod.ts new file mode 100644 index 000000000..bdaf010e2 --- /dev/null +++ b/tests/specs/publish/invalid_import/mod.ts @@ -0,0 +1,9 @@ +import "http://localhost:4545/welcome.ts"; +import "$echo"; + +import "data:application/javascript,console.log(1)"; +import "npm:chalk@5"; + +export function foobar(): string { + return "string"; +} diff --git a/tests/specs/publish/invalid_import_esm_sh_suggestion/__test__.jsonc b/tests/specs/publish/invalid_import_esm_sh_suggestion/__test__.jsonc new file mode 100644 index 000000000..6a6c3bdec --- /dev/null +++ b/tests/specs/publish/invalid_import_esm_sh_suggestion/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --token 'sadfasdf' --dry-run", + "output": "invalid_import_esm_sh_suggestion.out", + "exitCode": 1 +} diff --git a/tests/specs/publish/invalid_import_esm_sh_suggestion/deno.json b/tests/specs/publish/invalid_import_esm_sh_suggestion/deno.json new file mode 100644 index 000000000..49b666d22 --- /dev/null +++ b/tests/specs/publish/invalid_import_esm_sh_suggestion/deno.json @@ -0,0 +1,10 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "imports": { + "$echo": "http://localhost:4545/echo.ts" + }, + "exports": { + ".": "./mod.ts" + } +} diff --git a/tests/specs/publish/invalid_import_esm_sh_suggestion/invalid_import_esm_sh_suggestion.out b/tests/specs/publish/invalid_import_esm_sh_suggestion/invalid_import_esm_sh_suggestion.out new file mode 100644 index 000000000..a014f3de6 --- /dev/null +++ b/tests/specs/publish/invalid_import_esm_sh_suggestion/invalid_import_esm_sh_suggestion.out @@ -0,0 +1,20 @@ +[WILDCARD] +Check file:///[WILDCARD]/mod.ts +Checking for slow types in the public API... +Check file:///[WILDCARD]mod.ts +error[invalid-external-import]: invalid import to a non-JSR 'http' specifier + --> [WILDCARD]mod.ts:1:8 + | +1 | import "http://esm.sh/react-dom@18.2.0/server"; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the specifier + = hint: replace this import with one from jsr or npm, or vendor the dependency into your package + | +1 | "npm:react-dom@18.2.0" + | ---------------------- try this specifier + + info: the import was resolved to 'http://esm.sh/react-dom@18.2.0/server' + info: this specifier is not allowed to be imported on jsr + info: jsr only supports importing `jsr:`, `npm:`, and `data:` specifiers + docs: https://jsr.io/go/invalid-external-import + +error: Found 1 problem diff --git a/tests/specs/publish/invalid_import_esm_sh_suggestion/mod.ts b/tests/specs/publish/invalid_import_esm_sh_suggestion/mod.ts new file mode 100644 index 000000000..e597218ed --- /dev/null +++ b/tests/specs/publish/invalid_import_esm_sh_suggestion/mod.ts @@ -0,0 +1,5 @@ +import "http://esm.sh/react-dom@18.2.0/server"; + +export function foobar(): string { + return "string"; +} diff --git a/tests/specs/publish/invalid_path/__test__.jsonc b/tests/specs/publish/invalid_path/__test__.jsonc new file mode 100644 index 000000000..24f9c0dfa --- /dev/null +++ b/tests/specs/publish/invalid_path/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "invalid_path.out", + "exitCode": 1 +} diff --git a/tests/specs/publish/invalid_path/deno.json b/tests/specs/publish/invalid_path/deno.json new file mode 100644 index 000000000..213a7cec6 --- /dev/null +++ b/tests/specs/publish/invalid_path/deno.json @@ -0,0 +1,7 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + } +} diff --git a/tests/specs/publish/invalid_path/invalid_path.out b/tests/specs/publish/invalid_path/invalid_path.out new file mode 100644 index 000000000..d47cb01de --- /dev/null +++ b/tests/specs/publish/invalid_path/invalid_path.out @@ -0,0 +1,11 @@ +Check file://[WILDCARD]mod.ts +Checking for slow types in the public API... +Check file://[WILDCARD]mod.ts +error[invalid-path]: package path must not contain whitespace (found ' ') + --> [WILDCARD]path with spaces.txt + = hint: rename or remove the file, or add it to 'publish.exclude' in the config file + + info: to portably support all platforms, including windows, the allowed characters in package paths are limited + docs: https://jsr.io/go/invalid-path + +error: Found 1 problem diff --git a/tests/specs/publish/invalid_path/mod.ts b/tests/specs/publish/invalid_path/mod.ts new file mode 100644 index 000000000..9e217d9b0 --- /dev/null +++ b/tests/specs/publish/invalid_path/mod.ts @@ -0,0 +1,3 @@ +export function foobar(): string { + return "string"; +} diff --git a/tests/specs/publish/invalid_path/path with spaces.txt b/tests/specs/publish/invalid_path/path with spaces.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/specs/publish/invalid_path/path with spaces.txt diff --git a/tests/specs/publish/javascript_decl_file/__test__.jsonc b/tests/specs/publish/javascript_decl_file/__test__.jsonc new file mode 100644 index 000000000..0b6b0888e --- /dev/null +++ b/tests/specs/publish/javascript_decl_file/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "javascript_decl_file.out", + "exitCode": 0 +} diff --git a/tests/specs/publish/javascript_decl_file/deno.json b/tests/specs/publish/javascript_decl_file/deno.json new file mode 100644 index 000000000..e5dbfa8d3 --- /dev/null +++ b/tests/specs/publish/javascript_decl_file/deno.json @@ -0,0 +1,7 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.js" + } +} diff --git a/tests/specs/publish/javascript_decl_file/javascript_decl_file.out b/tests/specs/publish/javascript_decl_file/javascript_decl_file.out new file mode 100644 index 000000000..48128e82f --- /dev/null +++ b/tests/specs/publish/javascript_decl_file/javascript_decl_file.out @@ -0,0 +1,5 @@ +Check file:///[WILDCARD]/javascript_decl_file/mod.js +Checking for slow types in the public API... +Publishing @foo/bar@1.0.0 ... +Successfully published @foo/bar@1.0.0 +Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/specs/publish/javascript_decl_file/mod.d.ts b/tests/specs/publish/javascript_decl_file/mod.d.ts new file mode 100644 index 000000000..b2f6c69a8 --- /dev/null +++ b/tests/specs/publish/javascript_decl_file/mod.d.ts @@ -0,0 +1 @@ +export function getRandom(): number; diff --git a/tests/specs/publish/javascript_decl_file/mod.js b/tests/specs/publish/javascript_decl_file/mod.js new file mode 100644 index 000000000..2395e622b --- /dev/null +++ b/tests/specs/publish/javascript_decl_file/mod.js @@ -0,0 +1,5 @@ +/// <reference types="./mod.d.ts" /> + +export function getRandom() { + return Math.random(); +} diff --git a/tests/specs/publish/javascript_missing_decl_file/__test__.jsonc b/tests/specs/publish/javascript_missing_decl_file/__test__.jsonc new file mode 100644 index 000000000..1e760cf22 --- /dev/null +++ b/tests/specs/publish/javascript_missing_decl_file/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "javascript_missing_decl_file.out", + "exitCode": 0 +} diff --git a/tests/specs/publish/javascript_missing_decl_file/deno.json b/tests/specs/publish/javascript_missing_decl_file/deno.json new file mode 100644 index 000000000..e12927c26 --- /dev/null +++ b/tests/specs/publish/javascript_missing_decl_file/deno.json @@ -0,0 +1,8 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.js", + "./other": "./other.js" + } +} diff --git a/tests/specs/publish/javascript_missing_decl_file/javascript_missing_decl_file.out b/tests/specs/publish/javascript_missing_decl_file/javascript_missing_decl_file.out new file mode 100644 index 000000000..08e92e320 --- /dev/null +++ b/tests/specs/publish/javascript_missing_decl_file/javascript_missing_decl_file.out @@ -0,0 +1,20 @@ +Checking for slow types in the public API... +warning[unsupported-javascript-entrypoint]: used a JavaScript module without type declarations as an entrypoint + --> [WILDCARD]mod.js + = hint: add a type declaration (d.ts) for the JavaScript module, or rewrite it to TypeScript + + info: JavaScript files with no corresponding declaration require type inference to be type checked + info: fast check avoids type inference, so JavaScript entrypoints should be avoided + docs: https://jsr.io/go/slow-type-unsupported-javascript-entrypoint + +warning[unsupported-javascript-entrypoint]: used a JavaScript module without type declarations as an entrypoint + --> [WILDCARD]other.js + = hint: add a type declaration (d.ts) for the JavaScript module, or rewrite it to TypeScript + + info: JavaScript files with no corresponding declaration require type inference to be type checked + info: fast check avoids type inference, so JavaScript entrypoints should be avoided + docs: https://jsr.io/go/slow-type-unsupported-javascript-entrypoint + +Publishing @foo/bar@1.0.0 ... +Successfully published @foo/bar@1.0.0 +Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/specs/publish/javascript_missing_decl_file/mod.js b/tests/specs/publish/javascript_missing_decl_file/mod.js new file mode 100644 index 000000000..4a62fa5b4 --- /dev/null +++ b/tests/specs/publish/javascript_missing_decl_file/mod.js @@ -0,0 +1,3 @@ +export function getRandom() { + return Math.random(); +} diff --git a/tests/specs/publish/javascript_missing_decl_file/other.js b/tests/specs/publish/javascript_missing_decl_file/other.js new file mode 100644 index 000000000..89ffb80ba --- /dev/null +++ b/tests/specs/publish/javascript_missing_decl_file/other.js @@ -0,0 +1,3 @@ +export function other() { + return Math.random(); +} diff --git a/tests/specs/publish/jsr_jsonc/__test__.jsonc b/tests/specs/publish/jsr_jsonc/__test__.jsonc new file mode 100644 index 000000000..774d5a534 --- /dev/null +++ b/tests/specs/publish/jsr_jsonc/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "mod.out" +} diff --git a/tests/specs/publish/jsr_jsonc/jsr.jsonc b/tests/specs/publish/jsr_jsonc/jsr.jsonc new file mode 100644 index 000000000..4c9dfb08c --- /dev/null +++ b/tests/specs/publish/jsr_jsonc/jsr.jsonc @@ -0,0 +1,11 @@ +{ + // It's .jsonc file so it can have comments + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + }, + "imports": { + "@std/http": "./std_http.ts" + } +} diff --git a/tests/specs/publish/jsr_jsonc/mod.out b/tests/specs/publish/jsr_jsonc/mod.out new file mode 100644 index 000000000..38b61d568 --- /dev/null +++ b/tests/specs/publish/jsr_jsonc/mod.out @@ -0,0 +1,6 @@ +Check file:///[WILDCARD]/publish/jsr_jsonc/mod.ts +Checking for slow types in the public API... +Check file:///[WILDCARD]/publish/jsr_jsonc/mod.ts +Publishing @foo/bar@1.0.0 ... +Successfully published @foo/bar@1.0.0 +Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/specs/publish/jsr_jsonc/mod.ts b/tests/specs/publish/jsr_jsonc/mod.ts new file mode 100644 index 000000000..6e8a61bae --- /dev/null +++ b/tests/specs/publish/jsr_jsonc/mod.ts @@ -0,0 +1,7 @@ +import http from "@std/http"; + +export function foobar(): { fileServer(): void } { + return { + fileServer: http.fileServer, + }; +} diff --git a/tests/specs/publish/jsr_jsonc/std_http.ts b/tests/specs/publish/jsr_jsonc/std_http.ts new file mode 100644 index 000000000..9d57b36f3 --- /dev/null +++ b/tests/specs/publish/jsr_jsonc/std_http.ts @@ -0,0 +1,6 @@ +// temp until we get jsr:@std/http in the test server +export default { + fileServer() { + console.log("Hi"); + }, +}; diff --git a/tests/specs/publish/missing_deno_json/__test__.jsonc b/tests/specs/publish/missing_deno_json/__test__.jsonc new file mode 100644 index 000000000..614caecd6 --- /dev/null +++ b/tests/specs/publish/missing_deno_json/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "missing_deno_json.out", + "exitCode": 1 +} diff --git a/tests/specs/publish/missing_deno_json/main.ts b/tests/specs/publish/missing_deno_json/main.ts new file mode 100644 index 000000000..8d9b8a22a --- /dev/null +++ b/tests/specs/publish/missing_deno_json/main.ts @@ -0,0 +1,3 @@ +export function add(a: number, b: number): number { + return a + b; +} diff --git a/tests/specs/publish/missing_deno_json/missing_deno_json.out b/tests/specs/publish/missing_deno_json/missing_deno_json.out new file mode 100644 index 000000000..2c074bf83 --- /dev/null +++ b/tests/specs/publish/missing_deno_json/missing_deno_json.out @@ -0,0 +1 @@ +error: Couldn't find a deno.json, deno.jsonc, jsr.json or jsr.jsonc configuration file in [WILDCARD]
\ No newline at end of file diff --git a/tests/specs/publish/no_check/__test__.jsonc b/tests/specs/publish/no_check/__test__.jsonc new file mode 100644 index 000000000..e89cd7a57 --- /dev/null +++ b/tests/specs/publish/no_check/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf' --no-check", + "output": "successful_no_check.out" +} diff --git a/tests/specs/publish/no_check/deno.json b/tests/specs/publish/no_check/deno.json new file mode 100644 index 000000000..fefab899b --- /dev/null +++ b/tests/specs/publish/no_check/deno.json @@ -0,0 +1,10 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + }, + "imports": { + "@std/http": "./std_http.ts" + } +} diff --git a/tests/specs/publish/no_check/mod.ts b/tests/specs/publish/no_check/mod.ts new file mode 100644 index 000000000..6e8a61bae --- /dev/null +++ b/tests/specs/publish/no_check/mod.ts @@ -0,0 +1,7 @@ +import http from "@std/http"; + +export function foobar(): { fileServer(): void } { + return { + fileServer: http.fileServer, + }; +} diff --git a/tests/specs/publish/no_check/std_http.ts b/tests/specs/publish/no_check/std_http.ts new file mode 100644 index 000000000..9d57b36f3 --- /dev/null +++ b/tests/specs/publish/no_check/std_http.ts @@ -0,0 +1,6 @@ +// temp until we get jsr:@std/http in the test server +export default { + fileServer() { + console.log("Hi"); + }, +}; diff --git a/tests/specs/publish/no_check/successful_no_check.out b/tests/specs/publish/no_check/successful_no_check.out new file mode 100644 index 000000000..01c53a9ba --- /dev/null +++ b/tests/specs/publish/no_check/successful_no_check.out @@ -0,0 +1,4 @@ +Checking for slow types in the public API... +Publishing @foo/bar@1.0.0 ... +Successfully published @foo/bar@1.0.0 +Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/specs/publish/no_token/__test__.jsonc b/tests/specs/publish/no_token/__test__.jsonc new file mode 100644 index 000000000..f8a7fa942 --- /dev/null +++ b/tests/specs/publish/no_token/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish", + "output": "no_token.out", + "exitCode": 1 +} diff --git a/tests/specs/publish/no_token/main.ts b/tests/specs/publish/no_token/main.ts new file mode 100644 index 000000000..8d9b8a22a --- /dev/null +++ b/tests/specs/publish/no_token/main.ts @@ -0,0 +1,3 @@ +export function add(a: number, b: number): number { + return a + b; +} diff --git a/tests/specs/publish/no_token/no_token.out b/tests/specs/publish/no_token/no_token.out new file mode 100644 index 000000000..41415094c --- /dev/null +++ b/tests/specs/publish/no_token/no_token.out @@ -0,0 +1 @@ +error: No means to authenticate. Pass a token to `--token`[WILDCARD] diff --git a/tests/specs/publish/node_specifier/__test__.jsonc b/tests/specs/publish/node_specifier/__test__.jsonc new file mode 100644 index 000000000..f845f2479 --- /dev/null +++ b/tests/specs/publish/node_specifier/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "node_specifier.out" +} diff --git a/tests/specs/publish/node_specifier/deno.json b/tests/specs/publish/node_specifier/deno.json new file mode 100644 index 000000000..213a7cec6 --- /dev/null +++ b/tests/specs/publish/node_specifier/deno.json @@ -0,0 +1,7 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + } +} diff --git a/tests/specs/publish/node_specifier/mod.ts b/tests/specs/publish/node_specifier/mod.ts new file mode 100644 index 000000000..9d8263709 --- /dev/null +++ b/tests/specs/publish/node_specifier/mod.ts @@ -0,0 +1,5 @@ +import "node:http"; + +export function foobar(): string { + return "string"; +} diff --git a/tests/specs/publish/node_specifier/node_specifier.out b/tests/specs/publish/node_specifier/node_specifier.out new file mode 100644 index 000000000..d3e4a367b --- /dev/null +++ b/tests/specs/publish/node_specifier/node_specifier.out @@ -0,0 +1,8 @@ +Download http://localhost:4545/npm/registry/@types/node +Download http://localhost:4545/npm/registry/@types/node/node-[WILDCARD].tgz +Check file:///[WILDCARD]/mod.ts +Checking for slow types in the public API... +Check file:///[WILDCARD]/publish/node_specifier/mod.ts +Publishing @foo/bar@1.0.0 ... +Successfully published @foo/bar@1.0.0 +Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/specs/publish/package_json/__test__.jsonc b/tests/specs/publish/package_json/__test__.jsonc new file mode 100644 index 000000000..c4e954a6e --- /dev/null +++ b/tests/specs/publish/package_json/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "package_json.out" +} diff --git a/tests/specs/publish/package_json/deno.json b/tests/specs/publish/package_json/deno.json new file mode 100644 index 000000000..6e2826ef5 --- /dev/null +++ b/tests/specs/publish/package_json/deno.json @@ -0,0 +1,8 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + }, + "nodeModulesDir": false +} diff --git a/tests/specs/publish/package_json/mod.ts b/tests/specs/publish/package_json/mod.ts new file mode 100644 index 000000000..ae98962fa --- /dev/null +++ b/tests/specs/publish/package_json/mod.ts @@ -0,0 +1,9 @@ +import pc from "picocolors"; + +export function add(a: number, b: number): number { + return a + b; +} + +export function getValue(): string { + return pc.green("hey"); +} diff --git a/tests/specs/publish/package_json/package.json b/tests/specs/publish/package_json/package.json new file mode 100644 index 000000000..c1b171f4c --- /dev/null +++ b/tests/specs/publish/package_json/package.json @@ -0,0 +1,7 @@ +{ + "name": "@deno/foo", + "version": "0.0.1", + "dependencies": { + "picocolors": "*" + } +} diff --git a/tests/specs/publish/package_json/package_json.out b/tests/specs/publish/package_json/package_json.out new file mode 100644 index 000000000..7b54ce8da --- /dev/null +++ b/tests/specs/publish/package_json/package_json.out @@ -0,0 +1,8 @@ +Download http://localhost:4545/npm/registry/picocolors +Download http://localhost:4545/npm/registry/picocolors/picocolors-1.0.0.tgz +Check file:///[WILDCARD]/publish/package_json/mod.ts +Checking for slow types in the public API... +Check file:///[WILDCARD]/publish/package_json/mod.ts +Publishing @foo/bar@1.0.0 ... +Successfully published @foo/bar@1.0.0 +Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/specs/publish/sloppy_imports/__test__.jsonc b/tests/specs/publish/sloppy_imports/__test__.jsonc new file mode 100644 index 000000000..bfb3d38dd --- /dev/null +++ b/tests/specs/publish/sloppy_imports/__test__.jsonc @@ -0,0 +1,21 @@ +{ + "envs": { + "DISABLE_JSR_PROVENANCE": "true", + "DENO_TESTING_DISABLE_GIT_CHECK": "1" + }, + "tempDir": true, + "steps": [{ + "args": "publish --token 'sadfasdf' --dry-run --unstable-sloppy-imports", + "output": "sloppy_imports.out" + }, { + "args": "publish --token 'sadfasdf' --dry-run", + "output": "sloppy_imports_not_enabled.out", + "exitCode": 1 + }, { + "args": "publish --token 'sadfasdf' --dry-run --unstable-sloppy-imports", + "output": "sloppy_imports_no_warnings.out", + "envs": { + "DENO_DISABLE_PEDANTIC_NODE_WARNINGS": "1" + } + }] +} diff --git a/tests/specs/publish/sloppy_imports/b/index.ts b/tests/specs/publish/sloppy_imports/b/index.ts new file mode 100644 index 000000000..1392bf6ba --- /dev/null +++ b/tests/specs/publish/sloppy_imports/b/index.ts @@ -0,0 +1 @@ +export const PI = Math.PI; diff --git a/tests/specs/publish/sloppy_imports/deno.json b/tests/specs/publish/sloppy_imports/deno.json new file mode 100644 index 000000000..213a7cec6 --- /dev/null +++ b/tests/specs/publish/sloppy_imports/deno.json @@ -0,0 +1,7 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + } +} diff --git a/tests/specs/publish/sloppy_imports/mod.ts b/tests/specs/publish/sloppy_imports/mod.ts new file mode 100644 index 000000000..f5084bb3b --- /dev/null +++ b/tests/specs/publish/sloppy_imports/mod.ts @@ -0,0 +1 @@ +export { PI } from "./b"; diff --git a/tests/specs/publish/sloppy_imports/sloppy_imports.out b/tests/specs/publish/sloppy_imports/sloppy_imports.out new file mode 100644 index 000000000..bfa258b93 --- /dev/null +++ b/tests/specs/publish/sloppy_imports/sloppy_imports.out @@ -0,0 +1,10 @@ +Warning Sloppy module resolution (hint: specify path to index.ts file in directory instead) + at file:///[WILDCARD]/mod.ts:1:20 +Check file:///[WILDCARD]/mod.ts +Checking for slow types in the public API... +Check file:///[WILDCARD]/mod.ts +Simulating publish of @foo/bar@1.0.0 with files: + file:///[WILDCARD]/b/index.ts (27B) + file:///[WILDCARD]/deno.json (87B) + file:///[WILDCARD]/mod.ts (35B) +Warning Aborting due to --dry-run diff --git a/tests/specs/publish/sloppy_imports/sloppy_imports_no_warnings.out b/tests/specs/publish/sloppy_imports/sloppy_imports_no_warnings.out new file mode 100644 index 000000000..72ff281a3 --- /dev/null +++ b/tests/specs/publish/sloppy_imports/sloppy_imports_no_warnings.out @@ -0,0 +1,6 @@ +Checking for slow types in the public API... +Simulating publish of @foo/bar@1.0.0 with files: + file:///[WILDCARD]/b/index.ts (27B) + file:///[WILDCARD]/deno.json (87B) + file:///[WILDCARD]/mod.ts (35B) +Warning Aborting due to --dry-run diff --git a/tests/specs/publish/sloppy_imports/sloppy_imports_not_enabled.out b/tests/specs/publish/sloppy_imports/sloppy_imports_not_enabled.out new file mode 100644 index 000000000..4eacbea65 --- /dev/null +++ b/tests/specs/publish/sloppy_imports/sloppy_imports_not_enabled.out @@ -0,0 +1,2 @@ +error: [WILDCARD] Maybe specify path to 'index.ts' file in directory instead or run with --unstable-sloppy-imports + at file:///[WILDCARD]/mod.ts:1:20 diff --git a/tests/specs/publish/successful/__test__.jsonc b/tests/specs/publish/successful/__test__.jsonc new file mode 100644 index 000000000..fe5287e71 --- /dev/null +++ b/tests/specs/publish/successful/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "successful.out" +} diff --git a/tests/specs/publish/successful/deno.json b/tests/specs/publish/successful/deno.json new file mode 100644 index 000000000..fefab899b --- /dev/null +++ b/tests/specs/publish/successful/deno.json @@ -0,0 +1,10 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + }, + "imports": { + "@std/http": "./std_http.ts" + } +} diff --git a/tests/specs/publish/successful/mod.ts b/tests/specs/publish/successful/mod.ts new file mode 100644 index 000000000..6e8a61bae --- /dev/null +++ b/tests/specs/publish/successful/mod.ts @@ -0,0 +1,7 @@ +import http from "@std/http"; + +export function foobar(): { fileServer(): void } { + return { + fileServer: http.fileServer, + }; +} diff --git a/tests/specs/publish/successful/std_http.ts b/tests/specs/publish/successful/std_http.ts new file mode 100644 index 000000000..9d57b36f3 --- /dev/null +++ b/tests/specs/publish/successful/std_http.ts @@ -0,0 +1,6 @@ +// temp until we get jsr:@std/http in the test server +export default { + fileServer() { + console.log("Hi"); + }, +}; diff --git a/tests/specs/publish/successful/successful.out b/tests/specs/publish/successful/successful.out new file mode 100644 index 000000000..a3da4290d --- /dev/null +++ b/tests/specs/publish/successful/successful.out @@ -0,0 +1,6 @@ +Check file:///[WILDCARD]/publish/successful/mod.ts +Checking for slow types in the public API... +Check file:///[WILDCARD]/publish/successful/mod.ts +Publishing @foo/bar@1.0.0 ... +Successfully published @foo/bar@1.0.0 +Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/specs/publish/symlink/__test__.jsonc b/tests/specs/publish/symlink/__test__.jsonc new file mode 100644 index 000000000..32da3baff --- /dev/null +++ b/tests/specs/publish/symlink/__test__.jsonc @@ -0,0 +1,15 @@ +{ + "tempDir": true, + "envs": { + "DISABLE_JSR_PROVENANCE": "true", + "DENO_TESTING_DISABLE_GIT_CHECK": "1" + }, + "steps": [{ + "args": ["eval", "Deno.symlinkSync('./mod.ts', './symlink');"], + "output": "[WILDCARD]" + }, { + "args": "publish --token 'sadfasdf' --dry-run", + "output": "symlink.out", + "exitCode": 0 + }] +} diff --git a/tests/specs/publish/symlink/deno.json b/tests/specs/publish/symlink/deno.json new file mode 100644 index 000000000..213a7cec6 --- /dev/null +++ b/tests/specs/publish/symlink/deno.json @@ -0,0 +1,7 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + } +} diff --git a/tests/specs/publish/symlink/mod.ts b/tests/specs/publish/symlink/mod.ts new file mode 100644 index 000000000..9e217d9b0 --- /dev/null +++ b/tests/specs/publish/symlink/mod.ts @@ -0,0 +1,3 @@ +export function foobar(): string { + return "string"; +} diff --git a/tests/specs/publish/symlink/symlink.out b/tests/specs/publish/symlink/symlink.out new file mode 100644 index 000000000..9f89f5b7c --- /dev/null +++ b/tests/specs/publish/symlink/symlink.out @@ -0,0 +1,15 @@ +Check [WILDCARD]mod.ts +Checking for slow types in the public API... +Check [WILDCARD]mod.ts +warning[unsupported-file-type]: unsupported file type 'symlink' + --> [WILDCARD]symlink + = hint: remove the file, or add it to 'publish.exclude' in the config file + + info: only files and directories are supported + info: the file was ignored and will not be published + docs: https://jsr.io/go/unsupported-file-type + +Simulating publish of @foo/bar@1.0.0 with files: + [WILDCARD]deno.json (87B) + [WILDCARD]mod.ts (56B) +Warning Aborting due to --dry-run diff --git a/tests/specs/publish/unanalyzable_dynamic_import/__test__.jsonc b/tests/specs/publish/unanalyzable_dynamic_import/__test__.jsonc new file mode 100644 index 000000000..45073b099 --- /dev/null +++ b/tests/specs/publish/unanalyzable_dynamic_import/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "unanalyzable_dynamic_import.out", + "exitCode": 0 +} diff --git a/tests/specs/publish/unanalyzable_dynamic_import/deno.json b/tests/specs/publish/unanalyzable_dynamic_import/deno.json new file mode 100644 index 000000000..213a7cec6 --- /dev/null +++ b/tests/specs/publish/unanalyzable_dynamic_import/deno.json @@ -0,0 +1,7 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + } +} diff --git a/tests/specs/publish/unanalyzable_dynamic_import/mod.ts b/tests/specs/publish/unanalyzable_dynamic_import/mod.ts new file mode 100644 index 000000000..291311385 --- /dev/null +++ b/tests/specs/publish/unanalyzable_dynamic_import/mod.ts @@ -0,0 +1,2 @@ +const asd = "asd"; +await import("asd " + asd); diff --git a/tests/specs/publish/unanalyzable_dynamic_import/unanalyzable_dynamic_import.out b/tests/specs/publish/unanalyzable_dynamic_import/unanalyzable_dynamic_import.out new file mode 100644 index 000000000..7f3ca5555 --- /dev/null +++ b/tests/specs/publish/unanalyzable_dynamic_import/unanalyzable_dynamic_import.out @@ -0,0 +1,16 @@ +Check file://[WILDCARD]/mod.ts +Checking for slow types in the public API... +Check file://[WILDCARD]/mod.ts +warning[unanalyzable-dynamic-import]: unable to analyze dynamic import + --> [WILDCARD]mod.ts:2:14 + | +2 | await import("asd " + asd); + | ^^^^^^^^^^^^ the unanalyzable dynamic import + + info: after publishing this package, imports from the local import map / package.json do not work + info: dynamic imports that can not be analyzed at publish time will not be rewritten automatically + info: make sure the dynamic import is resolvable at runtime without an import map / package.json + +Publishing @foo/bar@1.0.0 ... +Successfully published @foo/bar@1.0.0 +Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/specs/publish/unsupported_jsx_tsx/__test__.jsonc b/tests/specs/publish/unsupported_jsx_tsx/__test__.jsonc new file mode 100644 index 000000000..774d5a534 --- /dev/null +++ b/tests/specs/publish/unsupported_jsx_tsx/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --token 'sadfasdf'", + "output": "mod.out" +} diff --git a/tests/specs/publish/unsupported_jsx_tsx/foo.jsx b/tests/specs/publish/unsupported_jsx_tsx/foo.jsx new file mode 100644 index 000000000..021c2d49e --- /dev/null +++ b/tests/specs/publish/unsupported_jsx_tsx/foo.jsx @@ -0,0 +1,5 @@ +import { renderToString } from "npm:preact-render-to-string"; + +export default function render() { + return renderToString(<div>foo.tsx</div>); +} diff --git a/tests/specs/publish/unsupported_jsx_tsx/foo.tsx b/tests/specs/publish/unsupported_jsx_tsx/foo.tsx new file mode 100644 index 000000000..021c2d49e --- /dev/null +++ b/tests/specs/publish/unsupported_jsx_tsx/foo.tsx @@ -0,0 +1,5 @@ +import { renderToString } from "npm:preact-render-to-string"; + +export default function render() { + return renderToString(<div>foo.tsx</div>); +} diff --git a/tests/specs/publish/unsupported_jsx_tsx/jsr.jsonc b/tests/specs/publish/unsupported_jsx_tsx/jsr.jsonc new file mode 100644 index 000000000..7aea08842 --- /dev/null +++ b/tests/specs/publish/unsupported_jsx_tsx/jsr.jsonc @@ -0,0 +1,11 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + }, + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "npm:preact" + } +} diff --git a/tests/specs/publish/unsupported_jsx_tsx/mod.out b/tests/specs/publish/unsupported_jsx_tsx/mod.out new file mode 100644 index 000000000..5f085fb33 --- /dev/null +++ b/tests/specs/publish/unsupported_jsx_tsx/mod.out @@ -0,0 +1,17 @@ +[WILDCARD] +Check file:///[WILDCARD]/publish/unsupported_jsx_tsx/mod.ts +Checking for slow types in the public API... +Check file:///[WILDCARD]/publish/unsupported_jsx_tsx/mod.ts +warning[unsupported-jsx-tsx]: JSX and TSX files are currently not supported + --> [WILDCARD]foo.jsx + + info: follow https://github.com/jsr-io/jsr/issues/24 for updates + +warning[unsupported-jsx-tsx]: JSX and TSX files are currently not supported + --> [WILDCARD]foo.tsx + + info: follow https://github.com/jsr-io/jsr/issues/24 for updates + +Publishing @foo/bar@1.0.0 ... +Successfully published @foo/bar@1.0.0 +Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/specs/publish/unsupported_jsx_tsx/mod.ts b/tests/specs/publish/unsupported_jsx_tsx/mod.ts new file mode 100644 index 000000000..4631a829d --- /dev/null +++ b/tests/specs/publish/unsupported_jsx_tsx/mod.ts @@ -0,0 +1,7 @@ +import fooTsx from "./foo.tsx"; +import fooJsx from "./foo.jsx"; + +export function renderTsxJsx() { + console.log(fooTsx()); + console.log(fooJsx()); +} diff --git a/tests/specs/publish/workspace/__test__.jsonc b/tests/specs/publish/workspace/__test__.jsonc new file mode 100644 index 000000000..7b1c04d56 --- /dev/null +++ b/tests/specs/publish/workspace/__test__.jsonc @@ -0,0 +1,10 @@ +{ + "steps": [{ + "args": "publish --token 'sadfasdf'", + "output": "workspace.out" + }, { + "cwd": "./bar", + "args": "publish --token 'sadfasdf'", + "output": "workspace_individual.out" + }] +} diff --git a/tests/specs/publish/workspace/bar/deno.json b/tests/specs/publish/workspace/bar/deno.json new file mode 100644 index 000000000..213a7cec6 --- /dev/null +++ b/tests/specs/publish/workspace/bar/deno.json @@ -0,0 +1,7 @@ +{ + "name": "@foo/bar", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + } +} diff --git a/tests/specs/publish/workspace/bar/mod.ts b/tests/specs/publish/workspace/bar/mod.ts new file mode 100644 index 000000000..8d9b8a22a --- /dev/null +++ b/tests/specs/publish/workspace/bar/mod.ts @@ -0,0 +1,3 @@ +export function add(a: number, b: number): number { + return a + b; +} diff --git a/tests/specs/publish/workspace/deno.json b/tests/specs/publish/workspace/deno.json new file mode 100644 index 000000000..57602aab5 --- /dev/null +++ b/tests/specs/publish/workspace/deno.json @@ -0,0 +1,6 @@ +{ + "workspaces": [ + "foo", + "bar" + ] +} diff --git a/tests/specs/publish/workspace/foo/deno.json b/tests/specs/publish/workspace/foo/deno.json new file mode 100644 index 000000000..79563d36c --- /dev/null +++ b/tests/specs/publish/workspace/foo/deno.json @@ -0,0 +1,10 @@ +{ + "name": "@foo/foo", + "version": "1.0.0", + "exports": { + ".": "./mod.ts" + }, + "imports": { + "bar": "jsr:@foo/bar@1" + } +} diff --git a/tests/specs/publish/workspace/foo/mod.ts b/tests/specs/publish/workspace/foo/mod.ts new file mode 100644 index 000000000..adf584463 --- /dev/null +++ b/tests/specs/publish/workspace/foo/mod.ts @@ -0,0 +1,5 @@ +import * as bar from "bar"; + +export function add(a: number, b: number): number { + return bar.add(a, b); +} diff --git a/tests/specs/publish/workspace/workspace.out b/tests/specs/publish/workspace/workspace.out new file mode 100644 index 000000000..8c57bc2dd --- /dev/null +++ b/tests/specs/publish/workspace/workspace.out @@ -0,0 +1,12 @@ +Publishing a workspace... +Check file:///[WILDCARD]/foo/mod.ts +Check file:///[WILDCARD]/bar/mod.ts +Checking for slow types in the public API... +Check file:///[WILDCARD]/foo/mod.ts +Check file:///[WILDCARD]/bar/mod.ts +Publishing @foo/bar@1.0.0 ... +Successfully published @foo/bar@1.0.0 +Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details +Publishing @foo/foo@1.0.0 ... +Successfully published @foo/foo@1.0.0 +Visit http://127.0.0.1:4250/@foo/foo@1.0.0 for details diff --git a/tests/specs/publish/workspace/workspace_individual.out b/tests/specs/publish/workspace/workspace_individual.out new file mode 100644 index 000000000..edb6b53aa --- /dev/null +++ b/tests/specs/publish/workspace/workspace_individual.out @@ -0,0 +1,6 @@ +Check file:///[WILDCARD]/bar/mod.ts +Checking for slow types in the public API... +Check file:///[WILDCARD]/bar/mod.ts +Publishing @foo/bar@1.0.0 ... +Successfully published @foo/bar@1.0.0 +Visit http://127.0.0.1:4250/@foo/bar@1.0.0 for details diff --git a/tests/specs/run/no_deno_json/__test__.jsonc b/tests/specs/run/no_deno_json/__test__.jsonc new file mode 100644 index 000000000..67867f023 --- /dev/null +++ b/tests/specs/run/no_deno_json/__test__.jsonc @@ -0,0 +1,36 @@ +{ + "tempDir": true, + "steps": [{ + // --no-config + "args": "run -L debug -A --no-config noconfig.ts", + "output": "noconfig.out", + "cwd": "code" + }, { + // --no-npm + "args": "run -L debug -A --no-npm noconfig.ts", + "output": "noconfig.out", + "cwd": "code" + }, { + // not auto-discovered with env var + "args": "run -L debug -A noconfig.ts", + "output": "noconfig.out", + "cwd": "code", + "envs": { + "DENO_NO_PACKAGE_JSON": "1" + } + }, { + // this should not use --quiet because we should ensure no package.json install occurs + "args": "run -A no_package_json_imports.ts", + "output": "no_package_json_imports.out", + "cwd": "code" + }, { + // auto-discovered node_modules relative package.json + "args": "run -A main.js", + "output": "code/sub_dir/main.out", + "cwd": "code/sub_dir" + }, { + // auto-discovered for local script arg + "args": "run -L debug -A code/main.ts", // notice this is not in the sub dir + "output": "main.out" + }] +} diff --git a/tests/specs/run/no_deno_json/code/main.ts b/tests/specs/run/no_deno_json/code/main.ts new file mode 100644 index 000000000..1e6e50040 --- /dev/null +++ b/tests/specs/run/no_deno_json/code/main.ts @@ -0,0 +1,4 @@ +import chalk from "chalk"; + +console.log("ok"); +console.log(chalk); diff --git a/tests/specs/run/no_deno_json/code/no_package_json_imports.ts b/tests/specs/run/no_deno_json/code/no_package_json_imports.ts new file mode 100644 index 000000000..0f3785f91 --- /dev/null +++ b/tests/specs/run/no_deno_json/code/no_package_json_imports.ts @@ -0,0 +1 @@ +console.log(5); diff --git a/tests/specs/run/no_deno_json/code/noconfig.ts b/tests/specs/run/no_deno_json/code/noconfig.ts new file mode 100644 index 000000000..e6f77f92b --- /dev/null +++ b/tests/specs/run/no_deno_json/code/noconfig.ts @@ -0,0 +1,8 @@ +// ensure the cwd is this directory +const cwd = Deno.cwd(); +if (!cwd.endsWith("code")) { + console.log(cwd); + throw "FAIL"; +} else { + console.log("success"); +} diff --git a/tests/specs/run/no_deno_json/code/package.json b/tests/specs/run/no_deno_json/code/package.json new file mode 100644 index 000000000..a85b890a8 --- /dev/null +++ b/tests/specs/run/no_deno_json/code/package.json @@ -0,0 +1,9 @@ +{ + "dependencies": { + "@denotest/check-error": "1.0.0", + "chalk": "4" + }, + "devDependencies": { + "@denotest/cjs-default-export": "1.0.0" + } +} diff --git a/tests/specs/run/no_deno_json/code/sub_dir/main.js b/tests/specs/run/no_deno_json/code/sub_dir/main.js new file mode 100644 index 000000000..492a8fa40 --- /dev/null +++ b/tests/specs/run/no_deno_json/code/sub_dir/main.js @@ -0,0 +1,3 @@ +import "chalk"; +console.log(Deno.cwd()); +console.log(Deno.statSync("../node_modules")); diff --git a/tests/specs/run/no_deno_json/code/sub_dir/main.out b/tests/specs/run/no_deno_json/code/sub_dir/main.out new file mode 100644 index 000000000..0ec791960 --- /dev/null +++ b/tests/specs/run/no_deno_json/code/sub_dir/main.out @@ -0,0 +1,7 @@ +Download http://[WILDCARD] +[WILDCARD]sub_dir +{ + [WILDCARD] + isDirectory: true, + [WILDCARD] +} diff --git a/tests/specs/run/no_deno_json/main.out b/tests/specs/run/no_deno_json/main.out new file mode 100644 index 000000000..92f5de748 --- /dev/null +++ b/tests/specs/run/no_deno_json/main.out @@ -0,0 +1,4 @@ +[WILDCARD]package.json file found at '[WILDCARD]code[WILDCHAR]package.json' +[WILDCARD] +ok +[Function (anonymous)] Chalk [WILDCARD] diff --git a/tests/specs/run/no_deno_json/no_package_json_imports.out b/tests/specs/run/no_deno_json/no_package_json_imports.out new file mode 100644 index 000000000..7ed6ff82d --- /dev/null +++ b/tests/specs/run/no_deno_json/no_package_json_imports.out @@ -0,0 +1 @@ +5 diff --git a/tests/specs/run/no_deno_json/noconfig.out b/tests/specs/run/no_deno_json/noconfig.out new file mode 100644 index 000000000..b9f9a6dea --- /dev/null +++ b/tests/specs/run/no_deno_json/noconfig.out @@ -0,0 +1,4 @@ +[WILDCARD]package.json auto-discovery is disabled +[WILDCARD] +success +[WILDCARD] diff --git a/tests/specs/schema.json b/tests/specs/schema.json index b3a30f936..94e069400 100644 --- a/tests/specs/schema.json +++ b/tests/specs/schema.json @@ -36,6 +36,9 @@ "type": "string" } }, + "flaky": { + "type": "boolean" + }, "if": { "type": "string", "examples": [ diff --git a/tests/specs/test/include_relative_pattern_dot_slash/__test__.jsonc b/tests/specs/test/include_relative_pattern_dot_slash/__test__.jsonc new file mode 100644 index 000000000..335c9ccd6 --- /dev/null +++ b/tests/specs/test/include_relative_pattern_dot_slash/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "test", + "output": "output.out" +} diff --git a/tests/specs/test/include_relative_pattern_dot_slash/deno.json b/tests/specs/test/include_relative_pattern_dot_slash/deno.json new file mode 100644 index 000000000..7c2c4a5d3 --- /dev/null +++ b/tests/specs/test/include_relative_pattern_dot_slash/deno.json @@ -0,0 +1,7 @@ +{ + "test": { + "include": [ + "./test/**/*.test.mjs" + ] + } +} diff --git a/tests/specs/test/include_relative_pattern_dot_slash/output.out b/tests/specs/test/include_relative_pattern_dot_slash/output.out new file mode 100644 index 000000000..be2961cff --- /dev/null +++ b/tests/specs/test/include_relative_pattern_dot_slash/output.out @@ -0,0 +1,5 @@ +running 1 test from ./test/add.test.mjs +should add ... ok ([WILDCARD]) + +ok | 1 passed | 0 failed ([WILDCARD]) + diff --git a/tests/specs/test/include_relative_pattern_dot_slash/test/add.mjs b/tests/specs/test/include_relative_pattern_dot_slash/test/add.mjs new file mode 100644 index 000000000..7d658310b --- /dev/null +++ b/tests/specs/test/include_relative_pattern_dot_slash/test/add.mjs @@ -0,0 +1,3 @@ +export function add(a, b) { + return a + b; +} diff --git a/tests/specs/test/include_relative_pattern_dot_slash/test/add.test.mjs b/tests/specs/test/include_relative_pattern_dot_slash/test/add.test.mjs new file mode 100644 index 000000000..7b21d2fbc --- /dev/null +++ b/tests/specs/test/include_relative_pattern_dot_slash/test/add.test.mjs @@ -0,0 +1,7 @@ +import { add } from "./add.mjs"; + +Deno.test("should add", () => { + if (add(1, 2) !== 3) { + throw new Error("FAIL"); + } +}); |