From c8d229dbf03177e81f4fd2f43c7daf74a7f2e283 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 30 Oct 2024 00:35:42 +0100 Subject: [PATCH 01/40] fix(install): percent encodings in interactive progress bar (#26600) Fixes percent encodings showing up when installing scoped packages via `deno add` or `deno install`. The issue is caused by us trying to map back the package name from the resolved http url. This doesn't and has never worked with private registries. The proper solution would be to pass the original specifier into here, but that's a bit of a bigger refactor. So for now the quickest workaround is to replace `%2f` back to `/`. Fixes https://github.com/denoland/deno/issues/26576 --- cli/util/progress_bar/renderer.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cli/util/progress_bar/renderer.rs b/cli/util/progress_bar/renderer.rs index a83ceb3334..6b08dada12 100644 --- a/cli/util/progress_bar/renderer.rs +++ b/cli/util/progress_bar/renderer.rs @@ -193,10 +193,16 @@ impl ProgressBarRenderer for TextOnlyProgressBarRenderer { } }; + // TODO(@marvinhagemeister): We're trying to reconstruct the original + // specifier from the resolved one, but we lack the information about + // private registries URLs and other things here. let message = display_entry .message .replace("https://registry.npmjs.org/", "npm:") - .replace("https://jsr.io/", "jsr:"); + .replace("https://jsr.io/", "jsr:") + .replace("%2f", "/") + .replace("%2F", "/"); + display_str.push_str( &colors::gray(format!(" - {}{}\n", message, bytes_text)).to_string(), ); From a1473d82c5612676c50af00ded0467dbb29bc0a8 Mon Sep 17 00:00:00 2001 From: denobot <33910674+denobot@users.noreply.github.com> Date: Wed, 30 Oct 2024 08:46:31 -0400 Subject: [PATCH 02/40] chore: forward v2.0.4 release commit to main (#26636) This is the release commit being forwarded back to main for 2.0.4 Co-authored-by: bartlomieju --- .github/workflows/ci.generate.ts | 2 +- .github/workflows/ci.yml | 8 ++--- Cargo.lock | 58 ++++++++++++++++---------------- Cargo.toml | 56 +++++++++++++++--------------- Releases.md | 32 ++++++++++++++++++ bench_util/Cargo.toml | 2 +- cli/Cargo.toml | 2 +- ext/broadcast_channel/Cargo.toml | 2 +- ext/cache/Cargo.toml | 2 +- ext/canvas/Cargo.toml | 2 +- ext/console/Cargo.toml | 2 +- ext/cron/Cargo.toml | 2 +- ext/crypto/Cargo.toml | 2 +- ext/fetch/Cargo.toml | 2 +- ext/ffi/Cargo.toml | 2 +- ext/fs/Cargo.toml | 2 +- ext/http/Cargo.toml | 2 +- ext/io/Cargo.toml | 2 +- ext/kv/Cargo.toml | 2 +- ext/napi/Cargo.toml | 2 +- ext/napi/sym/Cargo.toml | 2 +- ext/net/Cargo.toml | 2 +- ext/node/Cargo.toml | 2 +- ext/tls/Cargo.toml | 2 +- ext/url/Cargo.toml | 2 +- ext/web/Cargo.toml | 2 +- ext/webgpu/Cargo.toml | 2 +- ext/webidl/Cargo.toml | 2 +- ext/websocket/Cargo.toml | 2 +- ext/webstorage/Cargo.toml | 2 +- resolvers/deno/Cargo.toml | 2 +- resolvers/node/Cargo.toml | 2 +- runtime/Cargo.toml | 2 +- runtime/permissions/Cargo.toml | 2 +- 34 files changed, 123 insertions(+), 91 deletions(-) diff --git a/.github/workflows/ci.generate.ts b/.github/workflows/ci.generate.ts index 3e2b079643..d5ee67b654 100755 --- a/.github/workflows/ci.generate.ts +++ b/.github/workflows/ci.generate.ts @@ -5,7 +5,7 @@ import { stringify } from "jsr:@std/yaml@^0.221/stringify"; // Bump this number when you want to purge the cache. // Note: the tools/release/01_bump_crate_versions.ts script will update this version // automatically via regex, so ensure that this line maintains this format. -const cacheVersion = 22; +const cacheVersion = 23; const ubuntuX86Runner = "ubuntu-22.04"; const ubuntuX86XlRunner = "ubuntu-22.04-xl"; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5739537bb0..a6421d9244 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -361,8 +361,8 @@ jobs: path: |- ~/.cargo/registry/index ~/.cargo/registry/cache - key: '22-cargo-home-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles(''Cargo.lock'') }}' - restore-keys: '22-cargo-home-${{ matrix.os }}-${{ matrix.arch }}' + key: '23-cargo-home-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles(''Cargo.lock'') }}' + restore-keys: '23-cargo-home-${{ matrix.os }}-${{ matrix.arch }}' if: '!(matrix.skip)' - name: Restore cache build output (PR) uses: actions/cache/restore@v4 @@ -375,7 +375,7 @@ jobs: !./target/*/*.zip !./target/*/*.tar.gz key: never_saved - restore-keys: '22-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-' + restore-keys: '23-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-' - name: Apply and update mtime cache if: '!(matrix.skip) && (!startsWith(github.ref, ''refs/tags/''))' uses: ./.github/mtime_cache @@ -685,7 +685,7 @@ jobs: !./target/*/*.zip !./target/*/*.sha256sum !./target/*/*.tar.gz - key: '22-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-${{ github.sha }}' + key: '23-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-${{ github.sha }}' publish-canary: name: publish canary runs-on: ubuntu-22.04 diff --git a/Cargo.lock b/Cargo.lock index 2c8028a1e2..36ba70d9d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1154,7 +1154,7 @@ dependencies = [ [[package]] name = "deno" -version = "2.0.3" +version = "2.0.4" dependencies = [ "anstream", "async-trait", @@ -1323,7 +1323,7 @@ dependencies = [ [[package]] name = "deno_bench_util" -version = "0.168.0" +version = "0.169.0" dependencies = [ "bencher", "deno_core", @@ -1332,7 +1332,7 @@ dependencies = [ [[package]] name = "deno_broadcast_channel" -version = "0.168.0" +version = "0.169.0" dependencies = [ "async-trait", "deno_core", @@ -1343,7 +1343,7 @@ dependencies = [ [[package]] name = "deno_cache" -version = "0.106.0" +version = "0.107.0" dependencies = [ "async-trait", "deno_core", @@ -1376,7 +1376,7 @@ dependencies = [ [[package]] name = "deno_canvas" -version = "0.43.0" +version = "0.44.0" dependencies = [ "deno_core", "deno_webgpu", @@ -1411,7 +1411,7 @@ dependencies = [ [[package]] name = "deno_console" -version = "0.174.0" +version = "0.175.0" dependencies = [ "deno_core", ] @@ -1456,7 +1456,7 @@ checksum = "a13951ea98c0a4c372f162d669193b4c9d991512de9f2381dd161027f34b26b1" [[package]] name = "deno_cron" -version = "0.54.0" +version = "0.55.0" dependencies = [ "anyhow", "async-trait", @@ -1469,7 +1469,7 @@ dependencies = [ [[package]] name = "deno_crypto" -version = "0.188.0" +version = "0.189.0" dependencies = [ "aes", "aes-gcm", @@ -1531,7 +1531,7 @@ dependencies = [ [[package]] name = "deno_fetch" -version = "0.198.0" +version = "0.199.0" dependencies = [ "base64 0.21.7", "bytes", @@ -1564,7 +1564,7 @@ dependencies = [ [[package]] name = "deno_ffi" -version = "0.161.0" +version = "0.162.0" dependencies = [ "deno_core", "deno_permissions", @@ -1584,7 +1584,7 @@ dependencies = [ [[package]] name = "deno_fs" -version = "0.84.0" +version = "0.85.0" dependencies = [ "async-trait", "base32", @@ -1635,7 +1635,7 @@ dependencies = [ [[package]] name = "deno_http" -version = "0.172.0" +version = "0.173.0" dependencies = [ "async-compression", "async-trait", @@ -1674,7 +1674,7 @@ dependencies = [ [[package]] name = "deno_io" -version = "0.84.0" +version = "0.85.0" dependencies = [ "async-trait", "deno_core", @@ -1695,7 +1695,7 @@ dependencies = [ [[package]] name = "deno_kv" -version = "0.82.0" +version = "0.83.0" dependencies = [ "anyhow", "async-trait", @@ -1767,7 +1767,7 @@ dependencies = [ [[package]] name = "deno_napi" -version = "0.105.0" +version = "0.106.0" dependencies = [ "deno_core", "deno_permissions", @@ -1795,7 +1795,7 @@ dependencies = [ [[package]] name = "deno_net" -version = "0.166.0" +version = "0.167.0" dependencies = [ "deno_core", "deno_permissions", @@ -1812,7 +1812,7 @@ dependencies = [ [[package]] name = "deno_node" -version = "0.111.0" +version = "0.112.0" dependencies = [ "aead-gcm-stream", "aes", @@ -1961,7 +1961,7 @@ dependencies = [ [[package]] name = "deno_permissions" -version = "0.34.0" +version = "0.35.0" dependencies = [ "deno_core", "deno_path_util", @@ -1978,7 +1978,7 @@ dependencies = [ [[package]] name = "deno_resolver" -version = "0.6.0" +version = "0.7.0" dependencies = [ "anyhow", "base32", @@ -1994,7 +1994,7 @@ dependencies = [ [[package]] name = "deno_runtime" -version = "0.183.0" +version = "0.184.0" dependencies = [ "color-print", "deno_ast", @@ -2112,7 +2112,7 @@ dependencies = [ [[package]] name = "deno_tls" -version = "0.161.0" +version = "0.162.0" dependencies = [ "deno_core", "deno_native_certs", @@ -2161,7 +2161,7 @@ dependencies = [ [[package]] name = "deno_url" -version = "0.174.0" +version = "0.175.0" dependencies = [ "deno_bench_util", "deno_console", @@ -2173,7 +2173,7 @@ dependencies = [ [[package]] name = "deno_web" -version = "0.205.0" +version = "0.206.0" dependencies = [ "async-trait", "base64-simd 0.8.0", @@ -2195,7 +2195,7 @@ dependencies = [ [[package]] name = "deno_webgpu" -version = "0.141.0" +version = "0.142.0" dependencies = [ "deno_core", "raw-window-handle", @@ -2208,7 +2208,7 @@ dependencies = [ [[package]] name = "deno_webidl" -version = "0.174.0" +version = "0.175.0" dependencies = [ "deno_bench_util", "deno_core", @@ -2216,7 +2216,7 @@ dependencies = [ [[package]] name = "deno_websocket" -version = "0.179.0" +version = "0.180.0" dependencies = [ "bytes", "deno_core", @@ -2238,7 +2238,7 @@ dependencies = [ [[package]] name = "deno_webstorage" -version = "0.169.0" +version = "0.170.0" dependencies = [ "deno_core", "deno_web", @@ -4483,7 +4483,7 @@ dependencies = [ [[package]] name = "napi_sym" -version = "0.104.0" +version = "0.105.0" dependencies = [ "quote", "serde", @@ -4538,7 +4538,7 @@ dependencies = [ [[package]] name = "node_resolver" -version = "0.13.0" +version = "0.14.0" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index b622cbe443..aab9e149b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,16 +48,16 @@ repository = "https://github.com/denoland/deno" deno_ast = { version = "=0.42.2", features = ["transpiling"] } deno_core = { version = "0.314.2" } -deno_bench_util = { version = "0.168.0", path = "./bench_util" } +deno_bench_util = { version = "0.169.0", path = "./bench_util" } deno_lockfile = "=0.23.1" deno_media_type = { version = "0.1.4", features = ["module_specifier"] } deno_npm = "=0.25.4" deno_path_util = "=0.2.1" -deno_permissions = { version = "0.34.0", path = "./runtime/permissions" } -deno_runtime = { version = "0.183.0", path = "./runtime" } +deno_permissions = { version = "0.35.0", path = "./runtime/permissions" } +deno_runtime = { version = "0.184.0", path = "./runtime" } deno_semver = "=0.5.16" deno_terminal = "0.2.0" -napi_sym = { version = "0.104.0", path = "./ext/napi/sym" } +napi_sym = { version = "0.105.0", path = "./ext/napi/sym" } test_util = { package = "test_server", path = "./tests/util/server" } denokv_proto = "0.8.1" @@ -66,32 +66,32 @@ denokv_remote = "0.8.1" denokv_sqlite = { default-features = false, version = "0.8.2" } # exts -deno_broadcast_channel = { version = "0.168.0", path = "./ext/broadcast_channel" } -deno_cache = { version = "0.106.0", path = "./ext/cache" } -deno_canvas = { version = "0.43.0", path = "./ext/canvas" } -deno_console = { version = "0.174.0", path = "./ext/console" } -deno_cron = { version = "0.54.0", path = "./ext/cron" } -deno_crypto = { version = "0.188.0", path = "./ext/crypto" } -deno_fetch = { version = "0.198.0", path = "./ext/fetch" } -deno_ffi = { version = "0.161.0", path = "./ext/ffi" } -deno_fs = { version = "0.84.0", path = "./ext/fs" } -deno_http = { version = "0.172.0", path = "./ext/http" } -deno_io = { version = "0.84.0", path = "./ext/io" } -deno_kv = { version = "0.82.0", path = "./ext/kv" } -deno_napi = { version = "0.105.0", path = "./ext/napi" } -deno_net = { version = "0.166.0", path = "./ext/net" } -deno_node = { version = "0.111.0", path = "./ext/node" } -deno_tls = { version = "0.161.0", path = "./ext/tls" } -deno_url = { version = "0.174.0", path = "./ext/url" } -deno_web = { version = "0.205.0", path = "./ext/web" } -deno_webgpu = { version = "0.141.0", path = "./ext/webgpu" } -deno_webidl = { version = "0.174.0", path = "./ext/webidl" } -deno_websocket = { version = "0.179.0", path = "./ext/websocket" } -deno_webstorage = { version = "0.169.0", path = "./ext/webstorage" } +deno_broadcast_channel = { version = "0.169.0", path = "./ext/broadcast_channel" } +deno_cache = { version = "0.107.0", path = "./ext/cache" } +deno_canvas = { version = "0.44.0", path = "./ext/canvas" } +deno_console = { version = "0.175.0", path = "./ext/console" } +deno_cron = { version = "0.55.0", path = "./ext/cron" } +deno_crypto = { version = "0.189.0", path = "./ext/crypto" } +deno_fetch = { version = "0.199.0", path = "./ext/fetch" } +deno_ffi = { version = "0.162.0", path = "./ext/ffi" } +deno_fs = { version = "0.85.0", path = "./ext/fs" } +deno_http = { version = "0.173.0", path = "./ext/http" } +deno_io = { version = "0.85.0", path = "./ext/io" } +deno_kv = { version = "0.83.0", path = "./ext/kv" } +deno_napi = { version = "0.106.0", path = "./ext/napi" } +deno_net = { version = "0.167.0", path = "./ext/net" } +deno_node = { version = "0.112.0", path = "./ext/node" } +deno_tls = { version = "0.162.0", path = "./ext/tls" } +deno_url = { version = "0.175.0", path = "./ext/url" } +deno_web = { version = "0.206.0", path = "./ext/web" } +deno_webgpu = { version = "0.142.0", path = "./ext/webgpu" } +deno_webidl = { version = "0.175.0", path = "./ext/webidl" } +deno_websocket = { version = "0.180.0", path = "./ext/websocket" } +deno_webstorage = { version = "0.170.0", path = "./ext/webstorage" } # resolvers -deno_resolver = { version = "0.6.0", path = "./resolvers/deno" } -node_resolver = { version = "0.13.0", path = "./resolvers/node" } +deno_resolver = { version = "0.7.0", path = "./resolvers/deno" } +node_resolver = { version = "0.14.0", path = "./resolvers/node" } aes = "=0.8.3" anyhow = "1.0.57" diff --git a/Releases.md b/Releases.md index 5576d4bd8c..a183e01ecd 100644 --- a/Releases.md +++ b/Releases.md @@ -6,6 +6,38 @@ https://github.com/denoland/deno/releases We also have one-line install commands at: https://github.com/denoland/deno_install +### 2.0.4 / 2024.10.29 + +- Revert "fix(ext/node): fix dns.lookup result ordering (#26264)" (#26621) +- Revert "fix(ext/node): use primordials in `ext/node/polyfills/https.ts` + (#26323)" (#26613) +- feat(lsp): "typescript.preferences.preferTypeOnlyAutoImports" setting (#26546) +- fix(check): expose more globals from @types/node (#26603) +- fix(check): ignore resolving `jsxImportSource` when jsx is not used in graph + (#26548) +- fix(cli): Make --watcher CLEAR_SCREEN clear scrollback buffer as well as + visible screen (#25997) +- fix(compile): regression handling redirects (#26586) +- fix(ext/napi): export dynamic symbols list for {Free,Open}BSD (#26605) +- fix(ext/node): add path to `fs.stat` and `fs.statSync` error (#26037) +- fix(ext/node): compatibility with {Free,Open}BSD (#26604) +- fix(ext/node): use primordials in + ext\node\polyfills\internal\crypto\_randomInt.ts (#26534) +- fix(install): cache json exports of JSR packages (#26552) +- fix(install): regression - do not panic when config file contains \r\n + newlines (#26547) +- fix(lsp): make missing import action fix infallible (#26539) +- fix(npm): match npm bearer token generation (#26544) +- fix(upgrade): stop running `deno lsp` processes on windows before attempting + to replace executable (#26542) +- fix(watch): don't panic on invalid file specifiers (#26577) +- fix: do not panic when failing to write to http cache (#26591) +- fix: provide hints in terminal errors for Node.js globals (#26610) +- fix: report exceptions from nextTick (#26579) +- fix: support watch flag to enable watching other files than the main module on + serve subcommand (#26622) +- perf: pass transpiled module to deno_core as known string (#26555) + ### 2.0.3 / 2024.10.25 - feat(lsp): interactive inlay hints (#26382) diff --git a/bench_util/Cargo.toml b/bench_util/Cargo.toml index eea9c69a3c..31c27b9a9d 100644 --- a/bench_util/Cargo.toml +++ b/bench_util/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_bench_util" -version = "0.168.0" +version = "0.169.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 0065a2cbd0..ef92947d21 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno" -version = "2.0.3" +version = "2.0.4" authors.workspace = true default-run = "deno" edition.workspace = true diff --git a/ext/broadcast_channel/Cargo.toml b/ext/broadcast_channel/Cargo.toml index 845544f0c8..e6eeeed5ec 100644 --- a/ext/broadcast_channel/Cargo.toml +++ b/ext/broadcast_channel/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_broadcast_channel" -version = "0.168.0" +version = "0.169.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/cache/Cargo.toml b/ext/cache/Cargo.toml index a07a8f7207..7cae8d88a2 100644 --- a/ext/cache/Cargo.toml +++ b/ext/cache/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_cache" -version = "0.106.0" +version = "0.107.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/canvas/Cargo.toml b/ext/canvas/Cargo.toml index 4c125ea9b5..5d2c371999 100644 --- a/ext/canvas/Cargo.toml +++ b/ext/canvas/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_canvas" -version = "0.43.0" +version = "0.44.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/console/Cargo.toml b/ext/console/Cargo.toml index b89f67fece..b3543ed85f 100644 --- a/ext/console/Cargo.toml +++ b/ext/console/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_console" -version = "0.174.0" +version = "0.175.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/cron/Cargo.toml b/ext/cron/Cargo.toml index 6c5547c35f..0d52cb6a97 100644 --- a/ext/cron/Cargo.toml +++ b/ext/cron/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_cron" -version = "0.54.0" +version = "0.55.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/crypto/Cargo.toml b/ext/crypto/Cargo.toml index e9761f48f1..95981bba3b 100644 --- a/ext/crypto/Cargo.toml +++ b/ext/crypto/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_crypto" -version = "0.188.0" +version = "0.189.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/fetch/Cargo.toml b/ext/fetch/Cargo.toml index 316a6eea81..93fc88ae64 100644 --- a/ext/fetch/Cargo.toml +++ b/ext/fetch/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_fetch" -version = "0.198.0" +version = "0.199.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/ffi/Cargo.toml b/ext/ffi/Cargo.toml index 405030df29..58144790bf 100644 --- a/ext/ffi/Cargo.toml +++ b/ext/ffi/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_ffi" -version = "0.161.0" +version = "0.162.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/fs/Cargo.toml b/ext/fs/Cargo.toml index 2a1c5bf2c6..0ccde7f7e2 100644 --- a/ext/fs/Cargo.toml +++ b/ext/fs/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_fs" -version = "0.84.0" +version = "0.85.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/http/Cargo.toml b/ext/http/Cargo.toml index 0bae99ef76..a1a4cb20be 100644 --- a/ext/http/Cargo.toml +++ b/ext/http/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_http" -version = "0.172.0" +version = "0.173.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/io/Cargo.toml b/ext/io/Cargo.toml index f7ffe46bc3..7e858d298c 100644 --- a/ext/io/Cargo.toml +++ b/ext/io/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_io" -version = "0.84.0" +version = "0.85.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/kv/Cargo.toml b/ext/kv/Cargo.toml index a4e35193d5..bbd2349011 100644 --- a/ext/kv/Cargo.toml +++ b/ext/kv/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_kv" -version = "0.82.0" +version = "0.83.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/napi/Cargo.toml b/ext/napi/Cargo.toml index 622429f7c8..c31367118e 100644 --- a/ext/napi/Cargo.toml +++ b/ext/napi/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_napi" -version = "0.105.0" +version = "0.106.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/napi/sym/Cargo.toml b/ext/napi/sym/Cargo.toml index 9fe2d839ad..c23054eb40 100644 --- a/ext/napi/sym/Cargo.toml +++ b/ext/napi/sym/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "napi_sym" -version = "0.104.0" +version = "0.105.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/net/Cargo.toml b/ext/net/Cargo.toml index a458dbe9e3..5ffd1b4504 100644 --- a/ext/net/Cargo.toml +++ b/ext/net/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_net" -version = "0.166.0" +version = "0.167.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/node/Cargo.toml b/ext/node/Cargo.toml index 3743e6a85e..ed31dbf17e 100644 --- a/ext/node/Cargo.toml +++ b/ext/node/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_node" -version = "0.111.0" +version = "0.112.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/tls/Cargo.toml b/ext/tls/Cargo.toml index d163fd7eb4..6871faa5b8 100644 --- a/ext/tls/Cargo.toml +++ b/ext/tls/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_tls" -version = "0.161.0" +version = "0.162.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/url/Cargo.toml b/ext/url/Cargo.toml index ef7890e2ae..24d81abf83 100644 --- a/ext/url/Cargo.toml +++ b/ext/url/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_url" -version = "0.174.0" +version = "0.175.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/web/Cargo.toml b/ext/web/Cargo.toml index 0cb08e19c1..a02cff98fc 100644 --- a/ext/web/Cargo.toml +++ b/ext/web/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_web" -version = "0.205.0" +version = "0.206.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/webgpu/Cargo.toml b/ext/webgpu/Cargo.toml index 84ee4a012f..3bb814c25c 100644 --- a/ext/webgpu/Cargo.toml +++ b/ext/webgpu/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_webgpu" -version = "0.141.0" +version = "0.142.0" authors = ["the Deno authors"] edition.workspace = true license = "MIT" diff --git a/ext/webidl/Cargo.toml b/ext/webidl/Cargo.toml index a403db2fea..1685bb1fd0 100644 --- a/ext/webidl/Cargo.toml +++ b/ext/webidl/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_webidl" -version = "0.174.0" +version = "0.175.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/websocket/Cargo.toml b/ext/websocket/Cargo.toml index b48b39c99f..6a575cb416 100644 --- a/ext/websocket/Cargo.toml +++ b/ext/websocket/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_websocket" -version = "0.179.0" +version = "0.180.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/webstorage/Cargo.toml b/ext/webstorage/Cargo.toml index 911e252414..079ab2e4ee 100644 --- a/ext/webstorage/Cargo.toml +++ b/ext/webstorage/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_webstorage" -version = "0.169.0" +version = "0.170.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/resolvers/deno/Cargo.toml b/resolvers/deno/Cargo.toml index 418e1cb522..d8569d7219 100644 --- a/resolvers/deno/Cargo.toml +++ b/resolvers/deno/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_resolver" -version = "0.6.0" +version = "0.7.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/resolvers/node/Cargo.toml b/resolvers/node/Cargo.toml index 9638899209..95f7eabad8 100644 --- a/resolvers/node/Cargo.toml +++ b/resolvers/node/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "node_resolver" -version = "0.13.0" +version = "0.14.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 703bd5a432..c4c0c8ff9b 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_runtime" -version = "0.183.0" +version = "0.184.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/runtime/permissions/Cargo.toml b/runtime/permissions/Cargo.toml index 45266791ae..bfa37b4898 100644 --- a/runtime/permissions/Cargo.toml +++ b/runtime/permissions/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_permissions" -version = "0.34.0" +version = "0.35.0" authors.workspace = true edition.workspace = true license.workspace = true From 1431ffa9f8142e4f76f565c51301f4fb174e449a Mon Sep 17 00:00:00 2001 From: McSneaky Date: Wed, 30 Oct 2024 17:32:04 +0200 Subject: [PATCH 03/40] docs(console): Update docstrings for install and uninstall (#26623) When running `deno -h` then `install` and `uninstall` scripts had description since deno 1 times :) --- cli/args/flags.rs | 4 ++-- tests/integration/flags_tests.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/args/flags.rs b/cli/args/flags.rs index 235dd53a42..1a1213aac2 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -1179,8 +1179,8 @@ static DENO_HELP: &str = cstr!( Dependency management: add Add dependencies deno add jsr:@std/assert | deno add npm:express - install Install script as an executable - uninstall Uninstall a script previously installed with deno install + install Installs dependencies either in the local project or globally to a bin directory + uninstall Uninstalls a dependency or an executable script in the installation root's bin directory remove Remove dependencies from the configuration file Tooling: diff --git a/tests/integration/flags_tests.rs b/tests/integration/flags_tests.rs index 455507b9fa..663da363da 100644 --- a/tests/integration/flags_tests.rs +++ b/tests/integration/flags_tests.rs @@ -18,8 +18,8 @@ fn help_output() { "Start an interactive Read-Eval-Print Loop (REPL) for Deno", "Evaluate a script from the command line", "Add dependencies", - "Install script as an executable", - "Uninstall a script previously installed with deno install", + "Installs dependencies either in the local project or globally to a bin directory", + "Uninstalls a dependency or an executable script in the installation root's bin directory", "Run benchmarks", "Type-check the dependencies", "Compile the script into a self contained executable", From 5f5ac4063142c6c411486581f2f26cf51a32d7e3 Mon Sep 17 00:00:00 2001 From: HasanAlrimawi <141642411+HasanAlrimawi@users.noreply.github.com> Date: Wed, 30 Oct 2024 19:32:18 +0200 Subject: [PATCH 04/40] fix(serve): support serve hmr (#26078) This PR addresses issue #25600 Changes: Updated `fn has_hmr` to check `serve` subcommand and return its hmr value if found, in order to run the worker in serve mode with hmr_runner. Thus the hmr event can be dispatched upon changes on the file served. --- cli/args/mod.rs | 6 ++++++ cli/tools/serve.rs | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cli/args/mod.rs b/cli/args/mod.rs index f5ecc04496..754cd38fa9 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -1452,6 +1452,12 @@ impl CliOptions { watch: Some(WatchFlagsWithPaths { hmr, .. }), .. }) = &self.flags.subcommand + { + *hmr + } else if let DenoSubcommand::Serve(ServeFlags { + watch: Some(WatchFlagsWithPaths { hmr, .. }), + .. + }) = &self.flags.subcommand { *hmr } else { diff --git a/cli/tools/serve.rs b/cli/tools/serve.rs index 4ce1cad6f2..e3f9e94f8e 100644 --- a/cli/tools/serve.rs +++ b/cli/tools/serve.rs @@ -44,12 +44,15 @@ pub async fn serve( maybe_npm_install(&factory).await?; let worker_factory = factory.create_cli_main_worker_factory().await?; - + let hmr = serve_flags + .watch + .map(|watch_flags| watch_flags.hmr) + .unwrap_or(false); do_serve( worker_factory, main_module.clone(), serve_flags.worker_count, - false, + hmr, ) .await } @@ -109,8 +112,6 @@ async fn do_serve( } } Ok(exit_code) - - // main.await? } async fn run_worker( @@ -119,7 +120,7 @@ async fn run_worker( main_module: ModuleSpecifier, hmr: bool, ) -> Result { - let mut worker = worker_factory + let mut worker: crate::worker::CliMainWorker = worker_factory .create_main_worker( deno_runtime::WorkerExecutionMode::Serve { is_main: false, From a346071dd2bd822a7c2abcb187406efe7d1d1471 Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:13:32 -0700 Subject: [PATCH 05/40] fix(ext/node): return `this` from `http.Server.ref/unref()` (#26647) Fixes https://github.com/denoland/deno/issues/26642 --- ext/node/polyfills/http.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index e8a189f70f..9a920adeee 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -1802,6 +1802,8 @@ export class ServerImpl extends EventEmitter { this.#server.ref(); } this.#unref = false; + + return this; } unref() { @@ -1809,6 +1811,8 @@ export class ServerImpl extends EventEmitter { this.#server.unref(); } this.#unref = true; + + return this; } close(cb?: (err?: Error) => void): this { From a8846eb70f96445753fe5f8f56e6155cb2d0fac6 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 30 Oct 2024 16:43:22 -0400 Subject: [PATCH 06/40] fix: remove permission check in op_require_node_module_paths (#26645) --- ext/node/ops/require.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ext/node/ops/require.rs b/ext/node/ops/require.rs index f4607f4e8a..43867053b0 100644 --- a/ext/node/ops/require.rs +++ b/ext/node/ops/require.rs @@ -131,9 +131,6 @@ where normalize_path(current_dir.join(from)) }; - let from = ensure_read_permission::

(state, &from) - .map_err(RequireError::Permission)?; - if cfg!(windows) { // return root node_modules when path is 'D:\\'. let from_str = from.to_str().unwrap(); @@ -154,7 +151,7 @@ where } let mut paths = Vec::with_capacity(from.components().count()); - let mut current_path = from.as_ref(); + let mut current_path = from.as_path(); let mut maybe_parent = Some(current_path); while let Some(parent) = maybe_parent { if !parent.ends_with("node_modules") { From 8bfd134da6d730cc1d182ab430b1713901d7a5b5 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Thu, 31 Oct 2024 10:10:07 +0530 Subject: [PATCH 07/40] fix: clamp smi in fast calls by default (#26506) Fixes https://github.com/denoland/deno/issues/26480 Ref https://github.com/denoland/deno_core/commit/d2945fb65bca56ebfa7bb80556a4c8f4330d2315 --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- ext/node/ops/crypto/mod.rs | 8 ++++---- runtime/inspector_server.rs | 7 +++++++ runtime/worker.rs | 8 +++++++- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 36ba70d9d2..3fa6203842 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1418,9 +1418,9 @@ dependencies = [ [[package]] name = "deno_core" -version = "0.314.2" +version = "0.316.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83138917579676069b423c3eb9be3c1e579f60dc022d85f6ded4c792456255ff" +checksum = "94f68061c88ced959c6b0417f0f0d0b3dbeaeb18013b55f86c505e9fba705cf8" dependencies = [ "anyhow", "bincode", @@ -1921,9 +1921,9 @@ dependencies = [ [[package]] name = "deno_ops" -version = "0.190.1" +version = "0.192.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26f46d4e4f52f26c882b74a9b58810ea75252b807cf0966166ec333077cdfd85" +checksum = "bdb7096887508456349d7e7e09e326d157d4dba46ef1f5849bc544592ea3042a" dependencies = [ "proc-macro-rules", "proc-macro2", @@ -6169,9 +6169,9 @@ dependencies = [ [[package]] name = "serde_v8" -version = "0.223.1" +version = "0.225.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf3d859dda87ee96423c01244f10af864fa6d6a9fcdc2b77e0595078ea0ea11" +checksum = "ce4b71200ef49a9e629edaea3d13fc98c25ede07e1496558df7f09354e37976f" dependencies = [ "num-bigint", "serde", diff --git a/Cargo.toml b/Cargo.toml index aab9e149b0..285c077809 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ repository = "https://github.com/denoland/deno" [workspace.dependencies] deno_ast = { version = "=0.42.2", features = ["transpiling"] } -deno_core = { version = "0.314.2" } +deno_core = { version = "0.316.0" } deno_bench_util = { version = "0.169.0", path = "./bench_util" } deno_lockfile = "=0.23.1" diff --git a/ext/node/ops/crypto/mod.rs b/ext/node/ops/crypto/mod.rs index 600d315587..0cf34511b4 100644 --- a/ext/node/ops/crypto/mod.rs +++ b/ext/node/ops/crypto/mod.rs @@ -519,11 +519,11 @@ pub fn op_node_dh_compute_secret( } #[op2(fast)] -#[smi] +#[number] pub fn op_node_random_int( - #[smi] min: i32, - #[smi] max: i32, -) -> Result { + #[number] min: i64, + #[number] max: i64, +) -> Result { let mut rng = rand::thread_rng(); // Uniform distribution is required to avoid Modulo Bias // https://en.wikipedia.org/wiki/Fisher–Yates_shuffle#Modulo_bias diff --git a/runtime/inspector_server.rs b/runtime/inspector_server.rs index 1f8cd5e714..a789dd3dca 100644 --- a/runtime/inspector_server.rs +++ b/runtime/inspector_server.rs @@ -19,6 +19,8 @@ use deno_core::serde_json::Value; use deno_core::unsync::spawn; use deno_core::url::Url; use deno_core::InspectorMsg; +use deno_core::InspectorSessionKind; +use deno_core::InspectorSessionOptions; use deno_core::InspectorSessionProxy; use deno_core::JsRuntime; use fastwebsockets::Frame; @@ -192,6 +194,11 @@ fn handle_ws_request( let inspector_session_proxy = InspectorSessionProxy { tx: outbound_tx, rx: inbound_rx, + options: InspectorSessionOptions { + kind: InspectorSessionKind::NonBlocking { + wait_for_disconnect: true, + }, + }, }; log::info!("Debugger session started."); diff --git a/runtime/worker.rs b/runtime/worker.rs index 477d3b880c..b780aefc1b 100644 --- a/runtime/worker.rs +++ b/runtime/worker.rs @@ -20,6 +20,8 @@ use deno_core::CompiledWasmModuleStore; use deno_core::Extension; use deno_core::FeatureChecker; use deno_core::GetErrorClassFn; +use deno_core::InspectorSessionKind; +use deno_core::InspectorSessionOptions; use deno_core::JsRuntime; use deno_core::LocalInspectorSession; use deno_core::ModuleCodeString; @@ -792,7 +794,11 @@ impl MainWorker { /// was not configured to create inspector. pub fn create_inspector_session(&mut self) -> LocalInspectorSession { self.js_runtime.maybe_init_inspector(); - self.js_runtime.inspector().borrow().create_local_session() + self.js_runtime.inspector().borrow().create_local_session( + InspectorSessionOptions { + kind: InspectorSessionKind::Blocking, + }, + ) } pub async fn run_event_loop( From 2f0c25d33fc0c8bb8e6e92826b2549f429d68d42 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Thu, 31 Oct 2024 10:52:43 +0000 Subject: [PATCH 08/40] fix(lsp): include unstable features from editor settings (#26655) --- cli/lsp/config.rs | 12 +++++++++++- cli/lsp/language_server.rs | 10 +++------- cli/lsp/resolver.rs | 4 ++-- tests/integration/lsp_tests.rs | 30 ++++++++++++++---------------- 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs index 3ffc9e657a..cac0637a05 100644 --- a/cli/lsp/config.rs +++ b/cli/lsp/config.rs @@ -41,6 +41,7 @@ use deno_runtime::deno_node::PackageJson; use indexmap::IndexSet; use lsp_types::ClientCapabilities; use std::collections::BTreeMap; +use std::collections::BTreeSet; use std::collections::HashMap; use std::ops::Deref; use std::ops::DerefMut; @@ -1190,6 +1191,7 @@ pub struct ConfigData { pub resolver: Arc, pub sloppy_imports_resolver: Option>, pub import_map_from_settings: Option, + pub unstable: BTreeSet, watched_files: HashMap, } @@ -1587,9 +1589,16 @@ impl ConfigData { .join("\n") ); } + let unstable = member_dir + .workspace + .unstable_features() + .iter() + .chain(settings.unstable.as_deref()) + .cloned() + .collect::>(); let unstable_sloppy_imports = std::env::var("DENO_UNSTABLE_SLOPPY_IMPORTS") .is_ok() - || member_dir.workspace.has_unstable("sloppy-imports"); + || unstable.contains("sloppy-imports"); let sloppy_imports_resolver = unstable_sloppy_imports.then(|| { Arc::new(CliSloppyImportsResolver::new( SloppyImportsCachedFs::new_without_stat_cache(Arc::new( @@ -1630,6 +1639,7 @@ impl ConfigData { lockfile, npmrc, import_map_from_settings, + unstable, watched_files, } } diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 33ae539f85..a592245ce7 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -1384,14 +1384,10 @@ impl Inner { .clone(); fmt_options.use_tabs = Some(!params.options.insert_spaces); fmt_options.indent_width = Some(params.options.tab_size as u8); - let maybe_workspace = self - .config - .tree - .data_for_specifier(&specifier) - .map(|d| &d.member_dir.workspace); + let config_data = self.config.tree.data_for_specifier(&specifier); let unstable_options = UnstableFmtOptions { - component: maybe_workspace - .map(|w| w.has_unstable("fmt-component")) + component: config_data + .map(|d| d.unstable.contains("fmt-component")) .unwrap_or(false), }; let document = document.clone(); diff --git a/cli/lsp/resolver.rs b/cli/lsp/resolver.rs index c89273147a..00587f8f50 100644 --- a/cli/lsp/resolver.rs +++ b/cli/lsp/resolver.rs @@ -555,8 +555,8 @@ fn create_graph_resolver( workspace.to_maybe_jsx_import_source_config().ok().flatten() }), maybe_vendor_dir: config_data.and_then(|d| d.vendor_dir.as_ref()), - bare_node_builtins_enabled: workspace - .is_some_and(|workspace| workspace.has_unstable("bare-node-builtins")), + bare_node_builtins_enabled: config_data + .is_some_and(|d| d.unstable.contains("bare-node-builtins")), sloppy_imports_resolver: config_data .and_then(|d| d.sloppy_imports_resolver.clone()), })) diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index 79e6dc5c48..2376aebd90 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -15484,25 +15484,23 @@ fn lsp_sloppy_imports() { fn lsp_sloppy_imports_prefers_dts() { let context = TestContextBuilder::new().use_temp_cwd().build(); let temp_dir = context.temp_dir(); - let temp_dir = temp_dir.path(); - - temp_dir - .join("deno.json") - .write(r#"{ "unstable": ["sloppy-imports"] }"#); - - let mut client: LspClient = context - .new_lsp_command() - .set_root_dir(temp_dir.clone()) - .build(); - client.initialize_default(); - - temp_dir.join("a.js").write("export const foo: number;"); - - let a_dts = source_file(temp_dir.join("a.d.ts"), "export const foo = 3;"); + temp_dir.write("deno.json", json!({}).to_string()); + temp_dir.write("a.js", "export const foo: number;"); + let a_dts = + source_file(temp_dir.path().join("a.d.ts"), "export const foo = 3;"); let file = source_file( - temp_dir.join("file.ts"), + temp_dir.path().join("file.ts"), "import { foo } from './a.js';\nconsole.log(foo);", ); + let mut client: LspClient = context.new_lsp_command().build(); + client.initialize_default(); + client.change_configuration(json!({ + "deno": { + "enable": true, + "unstable": ["sloppy-imports"], + }, + })); + let diagnostics = client.did_open_file(&file); // no other warnings because "a.js" exists assert_eq!( From 56f25af2c7b8b158ae21271c129ea0f0bf3c258f Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Thu, 31 Oct 2024 21:50:58 +0800 Subject: [PATCH 09/40] fix(fmt): fix several HTML and components issues (#26654) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #26245 Close #26324 Fix #26508 Fix #26540 Fix #26562 --------- Co-authored-by: Bartek Iwańczuk --- .dprint.json | 2 +- Cargo.lock | 4 ++-- cli/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.dprint.json b/.dprint.json index 7877f17647..ea99f2aeda 100644 --- a/.dprint.json +++ b/.dprint.json @@ -68,7 +68,7 @@ "third_party" ], "plugins": [ - "https://plugins.dprint.dev/typescript-0.93.0.wasm", + "https://plugins.dprint.dev/typescript-0.93.1.wasm", "https://plugins.dprint.dev/json-0.19.4.wasm", "https://plugins.dprint.dev/markdown-0.17.8.wasm", "https://plugins.dprint.dev/toml-0.6.3.wasm", diff --git a/Cargo.lock b/Cargo.lock index 3fa6203842..e0780b2268 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4311,9 +4311,9 @@ dependencies = [ [[package]] name = "markup_fmt" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f15d7b24ae4ea9b87279bc0696462a4fb6c2168847f2cc162a2da05fe1a0f61" +checksum = "ebae65c91eab3d42231232bf48107f351e5a8d511454927218c53aeb68bbdb6f" dependencies = [ "aho-corasick", "css_dataset", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index ef92947d21..782adfd903 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -129,7 +129,7 @@ libz-sys.workspace = true log = { workspace = true, features = ["serde"] } lsp-types.workspace = true malva = "=0.11.0" -markup_fmt = "=0.14.0" +markup_fmt = "=0.15.0" memmem.workspace = true monch.workspace = true notify.workspace = true From 50ea707b58dff85b479905ebbeef866c95bc3cad Mon Sep 17 00:00:00 2001 From: Taku Amano Date: Thu, 31 Oct 2024 23:20:26 +0900 Subject: [PATCH 10/40] fix(coverage): exclude comment lines from coverage reports (#25939) --- cli/tools/coverage/mod.rs | 19 ++++- tests/testdata/coverage/complex.ts | 13 +++ tests/testdata/coverage/complex_expected.lcov | 82 ++++++++----------- tests/testdata/coverage/complex_expected.out | 31 +++---- 4 files changed, 80 insertions(+), 65 deletions(-) diff --git a/cli/tools/coverage/mod.rs b/cli/tools/coverage/mod.rs index 3b08f2c77a..48922f1449 100644 --- a/cli/tools/coverage/mod.rs +++ b/cli/tools/coverage/mod.rs @@ -327,6 +327,7 @@ fn generate_coverage_report( coverage_report.found_lines = if let Some(source_map) = maybe_source_map.as_ref() { + let script_source_lines = script_source.lines().collect::>(); let mut found_lines = line_counts .iter() .enumerate() @@ -334,7 +335,23 @@ fn generate_coverage_report( // get all the mappings from this destination line to a different src line let mut results = source_map .tokens() - .filter(move |token| token.get_dst_line() as usize == index) + .filter(|token| { + let dst_line = token.get_dst_line() as usize; + dst_line == index && { + let dst_col = token.get_dst_col() as usize; + let content = script_source_lines + .get(dst_line) + .and_then(|line| { + line.get(dst_col..std::cmp::min(dst_col + 2, line.len())) + }) + .unwrap_or(""); + + !content.is_empty() + && content != "/*" + && content != "*/" + && content != "//" + } + }) .map(move |token| (token.get_src_line() as usize, *count)) .collect::>(); // only keep the results that point at different src lines diff --git a/tests/testdata/coverage/complex.ts b/tests/testdata/coverage/complex.ts index d128b54373..316986cd22 100644 --- a/tests/testdata/coverage/complex.ts +++ b/tests/testdata/coverage/complex.ts @@ -1,3 +1,8 @@ +/** + * @module + * Complex module + */ + // This entire interface should be completely ignored by the coverage tool. export interface Complex { // These comments should be ignored. @@ -19,6 +24,7 @@ function dependency( bar: string, baz: string, ): Complex { + // inline comment in tested function return { foo, bar, @@ -34,6 +40,9 @@ export function complex( bar: string, baz: string, ): Complex { + /* + * block comment in tested function + */ return dependency( foo, bar, @@ -48,6 +57,7 @@ export function unused( bar: string, baz: string, ): Complex { + // inline comment in untested function return complex( foo, bar, @@ -62,6 +72,9 @@ export const π = Math.PI; // And same applies for this one, this one is unused and will show up in // lacking coverage. export function ƒ(): number { + /* + * block comment in untested function + */ return ( 0 ); diff --git a/tests/testdata/coverage/complex_expected.lcov b/tests/testdata/coverage/complex_expected.lcov index 94b86465ae..7e5c0f40f6 100644 --- a/tests/testdata/coverage/complex_expected.lcov +++ b/tests/testdata/coverage/complex_expected.lcov @@ -1,8 +1,8 @@ SF:[WILDCARD]complex.ts -FN:17,dependency -FN:32,complex -FN:46,unused -FN:64,ƒ +FN:22,dependency +FN:38,complex +FN:55,unused +FN:74,ƒ FNDA:1,dependency FNDA:1,complex FNDA:0,unused @@ -11,57 +11,41 @@ FNF:4 FNH:2 BRF:0 BRH:0 -DA:1,1 -DA:13,1 -DA:14,1 -DA:15,1 -DA:16,1 -DA:17,2 -DA:18,2 -DA:19,2 -DA:20,2 DA:22,2 DA:23,2 DA:24,2 DA:25,2 -DA:26,2 -DA:27,2 -DA:29,1 -DA:30,1 -DA:31,1 -DA:32,1 -DA:33,1 -DA:34,1 -DA:35,1 -DA:37,2 -DA:38,2 -DA:39,2 -DA:40,2 -DA:42,2 -DA:44,1 -DA:45,1 -DA:46,0 -DA:47,0 -DA:48,0 -DA:49,0 -DA:51,0 -DA:52,0 -DA:53,0 -DA:54,0 +DA:28,2 +DA:29,2 +DA:30,2 +DA:31,2 +DA:32,2 +DA:33,2 +DA:38,1 +DA:39,1 +DA:40,1 +DA:41,1 +DA:46,2 +DA:47,2 +DA:48,2 +DA:49,2 +DA:51,2 +DA:55,0 DA:56,0 -DA:58,1 -DA:59,1 -DA:60,1 -DA:62,1 -DA:63,1 +DA:57,0 +DA:58,0 +DA:61,0 +DA:62,0 +DA:63,0 DA:64,0 -DA:65,0 DA:66,0 -DA:68,0 DA:70,1 -DA:71,0 -DA:73,1 -DA:74,1 -LH:37 -LF:51 +DA:74,0 +DA:78,0 +DA:79,0 +DA:81,0 +DA:84,0 +DA:87,1 +LH:21 +LF:35 end_of_record diff --git a/tests/testdata/coverage/complex_expected.out b/tests/testdata/coverage/complex_expected.out index 3d5f6a0ab6..f626024b96 100644 --- a/tests/testdata/coverage/complex_expected.out +++ b/tests/testdata/coverage/complex_expected.out @@ -1,20 +1,21 @@ -cover [WILDCARD]/coverage/complex.ts ... 72.549% (37/51) - 46 | export function unused( - 47 | foo: string, - 48 | bar: string, - 49 | baz: string, +cover [WILDCARD]/coverage/complex.ts ... 60.000% (21/35) + 55 | export function unused( + 56 | foo: string, + 57 | bar: string, + 58 | baz: string, -----|----- - 51 | return complex( - 52 | foo, - 53 | bar, - 54 | baz, + 61 | return complex( + 62 | foo, + 63 | bar, + 64 | baz, -----|----- - 56 | } + 66 | } -----|----- - 64 | export function ƒ(): number { - 65 | return ( - 66 | 0 + 74 | export function ƒ(): number { -----|----- - 68 | } + 78 | return ( + 79 | 0 -----|----- - 71 | console.log("%s", () => 1); + 81 | } +-----|----- + 84 | console.log("%s", () => 1); From 90edca21a26fd2decd0603fea37af10d1e11e454 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 31 Oct 2024 11:35:17 -0400 Subject: [PATCH 11/40] fix: surface package.json location on dep parse failure (#26665) Related: https://github.com/denoland/deno/issues/26653 --- cli/args/mod.rs | 1 + cli/args/package_json.rs | 25 ++++++++++++++++--- cli/npm/managed/mod.rs | 20 +++++++++------ .../install/invalid_scheme/__test__.jsonc | 5 ++++ .../specs/install/invalid_scheme/install.out | 5 ++++ .../specs/install/invalid_scheme/package.json | 6 +++++ .../run/package_json/invalid_value/add.out | 3 ++- .../package_json/invalid_value/install.out | 3 ++- 8 files changed, 56 insertions(+), 12 deletions(-) create mode 100644 tests/specs/install/invalid_scheme/__test__.jsonc create mode 100644 tests/specs/install/invalid_scheme/install.out create mode 100644 tests/specs/install/invalid_scheme/package.json diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 754cd38fa9..d725264623 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -46,6 +46,7 @@ pub use flags::*; pub use lockfile::CliLockfile; pub use lockfile::CliLockfileReadFromPathOptions; pub use package_json::NpmInstallDepsProvider; +pub use package_json::PackageJsonDepValueParseWithLocationError; use deno_ast::ModuleSpecifier; use deno_core::anyhow::bail; diff --git a/cli/args/package_json.rs b/cli/args/package_json.rs index 2ef39a30d2..7dc75550c3 100644 --- a/cli/args/package_json.rs +++ b/cli/args/package_json.rs @@ -5,10 +5,12 @@ use std::sync::Arc; use deno_config::workspace::Workspace; use deno_core::serde_json; +use deno_core::url::Url; use deno_package_json::PackageJsonDepValue; use deno_package_json::PackageJsonDepValueParseError; use deno_semver::npm::NpmPackageReqReference; use deno_semver::package::PackageReq; +use thiserror::Error; #[derive(Debug)] pub struct InstallNpmRemotePkg { @@ -23,11 +25,20 @@ pub struct InstallNpmWorkspacePkg { pub target_dir: PathBuf, } +#[derive(Debug, Error, Clone)] +#[error("Failed to install '{}'\n at {}", alias, location)] +pub struct PackageJsonDepValueParseWithLocationError { + pub location: Url, + pub alias: String, + #[source] + pub source: PackageJsonDepValueParseError, +} + #[derive(Debug, Default)] pub struct NpmInstallDepsProvider { remote_pkgs: Vec, workspace_pkgs: Vec, - pkg_json_dep_errors: Vec, + pkg_json_dep_errors: Vec, } impl NpmInstallDepsProvider { @@ -89,7 +100,13 @@ impl NpmInstallDepsProvider { let dep = match dep { Ok(dep) => dep, Err(err) => { - pkg_json_dep_errors.push(err); + pkg_json_dep_errors.push( + PackageJsonDepValueParseWithLocationError { + location: pkg_json.specifier(), + alias, + source: err, + }, + ); continue; } }; @@ -150,7 +167,9 @@ impl NpmInstallDepsProvider { &self.workspace_pkgs } - pub fn pkg_json_dep_errors(&self) -> &[PackageJsonDepValueParseError] { + pub fn pkg_json_dep_errors( + &self, + ) -> &[PackageJsonDepValueParseWithLocationError] { &self.pkg_json_dep_errors } } diff --git a/cli/npm/managed/mod.rs b/cli/npm/managed/mod.rs index d0880557fe..a0754812bb 100644 --- a/cli/npm/managed/mod.rs +++ b/cli/npm/managed/mod.rs @@ -38,6 +38,7 @@ use crate::args::LifecycleScriptsConfig; use crate::args::NpmInstallDepsProvider; use crate::args::NpmProcessState; use crate::args::NpmProcessStateKind; +use crate::args::PackageJsonDepValueParseWithLocationError; use crate::cache::DenoCacheEnvFsAdapter; use crate::cache::FastInsecureHasher; use crate::http_util::HttpClientProvider; @@ -480,19 +481,24 @@ impl ManagedCliNpmResolver { self.resolution.resolve_pkg_id_from_pkg_req(req) } - pub fn ensure_no_pkg_json_dep_errors(&self) -> Result<(), AnyError> { + pub fn ensure_no_pkg_json_dep_errors( + &self, + ) -> Result<(), Box> { for err in self.npm_install_deps_provider.pkg_json_dep_errors() { - match err { + match &err.source { deno_package_json::PackageJsonDepValueParseError::VersionReq(_) => { - return Err( - AnyError::from(err.clone()) - .context("Failed to install from package.json"), - ); + return Err(Box::new(err.clone())); } deno_package_json::PackageJsonDepValueParseError::Unsupported { .. } => { - log::warn!("{} {} in package.json", colors::yellow("Warning"), err) + // only warn for this one + log::warn!( + "{} {}\n at {}", + colors::yellow("Warning"), + err.source, + err.location, + ) } } } diff --git a/tests/specs/install/invalid_scheme/__test__.jsonc b/tests/specs/install/invalid_scheme/__test__.jsonc new file mode 100644 index 0000000000..c4d3ebbf06 --- /dev/null +++ b/tests/specs/install/invalid_scheme/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "tempDir": true, + "args": "install", + "output": "install.out" +} diff --git a/tests/specs/install/invalid_scheme/install.out b/tests/specs/install/invalid_scheme/install.out new file mode 100644 index 0000000000..cf100216bd --- /dev/null +++ b/tests/specs/install/invalid_scheme/install.out @@ -0,0 +1,5 @@ +Warning Not implemented scheme 'git' + at file:///[WILDLINE]/package.json +Download http://localhost:4260/@denotest%2fadd +Download http://localhost:4260/@denotest/add/1.0.0.tgz +Initialize @denotest/add@1.0.0 diff --git a/tests/specs/install/invalid_scheme/package.json b/tests/specs/install/invalid_scheme/package.json new file mode 100644 index 0000000000..5e50ae591d --- /dev/null +++ b/tests/specs/install/invalid_scheme/package.json @@ -0,0 +1,6 @@ +{ + "dependencies": { + "@denotest/add": "*", + "deno": "git:denoland/deno" + } +} diff --git a/tests/specs/run/package_json/invalid_value/add.out b/tests/specs/run/package_json/invalid_value/add.out index 9b7493c1a2..32d9acaed6 100644 --- a/tests/specs/run/package_json/invalid_value/add.out +++ b/tests/specs/run/package_json/invalid_value/add.out @@ -1,5 +1,6 @@ Add npm:cowsay@1.5.0 -error: Failed to install from package.json +error: Failed to install '@denotest/cjs-default-export' + at file:///[WILDLINE]/package.json Caused by: 0: Invalid version requirement diff --git a/tests/specs/run/package_json/invalid_value/install.out b/tests/specs/run/package_json/invalid_value/install.out index cc82b345b0..ca3492ab22 100644 --- a/tests/specs/run/package_json/invalid_value/install.out +++ b/tests/specs/run/package_json/invalid_value/install.out @@ -1,4 +1,5 @@ -error: Failed to install from package.json +error: Failed to install '@denotest/cjs-default-export' + at file:///[WILDLINE]/package.json Caused by: 0: Invalid version requirement From 951103fc8de952f32386121d3f0e4803fe267ea4 Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Thu, 31 Oct 2024 10:02:17 -0700 Subject: [PATCH 12/40] fix(ext/node): convert errors from `fs.readFile/fs.readFileSync` to node format (#26632) Fixes the original issue reported in #26404. storybook runs into other errors after this PR (the new errors will be fixed in other PRs). Some code used by a dependency of storybook does a [string comparison on the error message](https://github.com/chromaui/chromatic-cli/blob/ce30b2be343cb96a0826390b95ea42befb2be547/node-src/lib/getConfiguration.ts#L88-L92) thrown here to check for a file not found error. --- ext/node/polyfills/_fs/_fs_readFile.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ext/node/polyfills/_fs/_fs_readFile.ts b/ext/node/polyfills/_fs/_fs_readFile.ts index 0f05ee1678..cf7e0305d8 100644 --- a/ext/node/polyfills/_fs/_fs_readFile.ts +++ b/ext/node/polyfills/_fs/_fs_readFile.ts @@ -19,6 +19,7 @@ import { TextEncodings, } from "ext:deno_node/_utils.ts"; import { FsFile } from "ext:deno_fs/30_fs.js"; +import { denoErrorToNodeError } from "ext:deno_node/internal/errors.ts"; function maybeDecode(data: Uint8Array, encoding: TextEncodings): string; function maybeDecode( @@ -87,7 +88,7 @@ export function readFile( } const buffer = maybeDecode(data, encoding); (cb as BinaryCallback)(null, buffer); - }, (err) => cb && cb(err)); + }, (err) => cb && cb(denoErrorToNodeError(err))); } } @@ -117,7 +118,12 @@ export function readFileSync( opt?: FileOptionsArgument, ): string | Buffer { path = path instanceof URL ? pathFromURL(path) : path; - const data = Deno.readFileSync(path); + let data; + try { + data = Deno.readFileSync(path); + } catch (err) { + throw denoErrorToNodeError(err); + } const encoding = getEncoding(opt); if (encoding && encoding !== "binary") { const text = maybeDecode(data, encoding); From 6d44952d4daaaab8ed9ec82212d2256c058eb05d Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Thu, 31 Oct 2024 10:02:31 -0700 Subject: [PATCH 13/40] fix(ext/node): resolve exports even if parent module filename isn't present (#26553) Fixes https://github.com/denoland/deno/issues/26505 I'm not exactly sure how this case comes about (I tried to write tests for it but couldn't manage to reproduce it), but what happens is the parent filename ends up null, and we bail out of resolving the specifier in package exports. I've checked, and in node the parent filename is also null (so that's not a bug on our part), but node continues to resolve even in that case. So this PR should match node's behavior more closely than we currently do. --- ext/node/ops/require.rs | 8 ++++++-- ext/node/polyfills/01_require.js | 6 +----- .../cjs-multiple-exports/1.0.0/package.json | 8 ++++++++ .../cjs-multiple-exports/1.0.0/src/add.js | 3 +++ .../cjs-multiple-exports/1.0.0/src/index.js | 3 +++ .../__test__.jsonc | 13 +++++++++++++ .../main.cjs | 16 ++++++++++++++++ .../package.json | 5 +++++ 8 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/package.json create mode 100644 tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/src/add.js create mode 100644 tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/src/index.js create mode 100644 tests/specs/node/require_export_from_parent_with_no_filename/__test__.jsonc create mode 100644 tests/specs/node/require_export_from_parent_with_no_filename/main.cjs create mode 100644 tests/specs/node/require_export_from_parent_with_no_filename/package.json diff --git a/ext/node/ops/require.rs b/ext/node/ops/require.rs index 43867053b0..7524fb43c7 100644 --- a/ext/node/ops/require.rs +++ b/ext/node/ops/require.rs @@ -529,12 +529,16 @@ where return Ok(None); }; - let referrer = Url::from_file_path(parent_path).unwrap(); + let referrer = if parent_path.is_empty() { + None + } else { + Some(Url::from_file_path(parent_path).unwrap()) + }; let r = node_resolver.package_exports_resolve( &pkg.path, &format!(".{expansion}"), exports, - Some(&referrer), + referrer.as_ref(), NodeModuleKind::Cjs, REQUIRE_CONDITIONS, NodeResolutionMode::Execution, diff --git a/ext/node/polyfills/01_require.js b/ext/node/polyfills/01_require.js index 5b0980c310..7935903a8d 100644 --- a/ext/node/polyfills/01_require.js +++ b/ext/node/polyfills/01_require.js @@ -523,17 +523,13 @@ function resolveExports( return; } - if (!parentPath) { - return false; - } - return op_require_resolve_exports( usesLocalNodeModulesDir, modulesPath, request, name, expansion, - parentPath, + parentPath ?? "", ) ?? false; } diff --git a/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/package.json b/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/package.json new file mode 100644 index 0000000000..43f07a2351 --- /dev/null +++ b/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/package.json @@ -0,0 +1,8 @@ +{ + "name": "@denotest/cjs-multiple-exports", + "version": "1.0.0", + "exports": { + ".": "./src/index.js", + "./add": "./src/add.js" + } +} \ No newline at end of file diff --git a/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/src/add.js b/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/src/add.js new file mode 100644 index 0000000000..42c8a7c604 --- /dev/null +++ b/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/src/add.js @@ -0,0 +1,3 @@ +module.exports = function add(a, b) { + return a + b; +}; \ No newline at end of file diff --git a/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/src/index.js b/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/src/index.js new file mode 100644 index 0000000000..432ed652ed --- /dev/null +++ b/tests/registry/npm/@denotest/cjs-multiple-exports/1.0.0/src/index.js @@ -0,0 +1,3 @@ +module.exports = { + hello: "world" +}; \ No newline at end of file diff --git a/tests/specs/node/require_export_from_parent_with_no_filename/__test__.jsonc b/tests/specs/node/require_export_from_parent_with_no_filename/__test__.jsonc new file mode 100644 index 0000000000..a3de08e460 --- /dev/null +++ b/tests/specs/node/require_export_from_parent_with_no_filename/__test__.jsonc @@ -0,0 +1,13 @@ +{ + "tempDir": true, + "steps": [ + { + "args": "install", + "output": "[WILDCARD]" + }, + { + "args": "run -A main.cjs", + "output": "3\n" + } + ] +} diff --git a/tests/specs/node/require_export_from_parent_with_no_filename/main.cjs b/tests/specs/node/require_export_from_parent_with_no_filename/main.cjs new file mode 100644 index 0000000000..3335ae1bf9 --- /dev/null +++ b/tests/specs/node/require_export_from_parent_with_no_filename/main.cjs @@ -0,0 +1,16 @@ +const path = require("node:path"); +const Module = require("node:module"); +function requireFromString(code, filename) { + const paths = Module._nodeModulePaths((0, path.dirname)(filename)); + const m = new Module(filename, module.parent); + m.paths = paths; + m._compile(code, filename); + return m.exports; +} + +const code = ` +const add = require("@denotest/cjs-multiple-exports/add"); + +console.log(add(1, 2)); +`; +requireFromString(code, "fake.js"); diff --git a/tests/specs/node/require_export_from_parent_with_no_filename/package.json b/tests/specs/node/require_export_from_parent_with_no_filename/package.json new file mode 100644 index 0000000000..9cd6438953 --- /dev/null +++ b/tests/specs/node/require_export_from_parent_with_no_filename/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@denotest/cjs-multiple-exports": "1.0.0" + } +} From 6c6bbeb97495e8c3e8eac7bea27bf836f02b575f Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Thu, 31 Oct 2024 22:18:33 -0700 Subject: [PATCH 14/40] fix(node): Implement `os.userInfo` properly, add missing `toPrimitive` (#24702) Fixes the implementation of `os.userInfo`, and adds a missing `toPrimitive` for `tmpdir`. This allows us to enable the corresponding node_compat test. --- ext/node/lib.rs | 2 +- ext/node/ops/os/mod.rs | 156 ++++++++++- ext/node/polyfills/internal/errors.ts | 13 - ext/node/polyfills/os.ts | 53 ++-- runtime/errors.rs | 1 + runtime/permissions/lib.rs | 8 +- tests/node_compat/config.jsonc | 3 +- tests/node_compat/runner/TODO.md | 1 - tests/node_compat/test/parallel/test-os.js | 286 +++++++++++++++++++++ 9 files changed, 469 insertions(+), 54 deletions(-) create mode 100644 tests/node_compat/test/parallel/test-os.js diff --git a/ext/node/lib.rs b/ext/node/lib.rs index 32624f38b7..b34bea815b 100644 --- a/ext/node/lib.rs +++ b/ext/node/lib.rs @@ -348,7 +348,7 @@ deno_core::extension!(deno_node, ops::http2::op_http2_send_response, ops::os::op_node_os_get_priority

, ops::os::op_node_os_set_priority

, - ops::os::op_node_os_username

, + ops::os::op_node_os_user_info

, ops::os::op_geteuid

, ops::os::op_getegid

, ops::os::op_cpus

, diff --git a/ext/node/ops/os/mod.rs b/ext/node/ops/os/mod.rs index b4c9eaa8ca..ea7e6b99fd 100644 --- a/ext/node/ops/os/mod.rs +++ b/ext/node/ops/os/mod.rs @@ -1,5 +1,7 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +use std::mem::MaybeUninit; + use crate::NodePermissions; use deno_core::op2; use deno_core::OpState; @@ -15,6 +17,8 @@ pub enum OsError { Permission(deno_core::error::AnyError), #[error("Failed to get cpu info")] FailedToGetCpuInfo, + #[error("Failed to get user info")] + FailedToGetUserInfo(#[source] std::io::Error), } #[op2(fast)] @@ -54,20 +58,162 @@ where priority::set_priority(pid, priority).map_err(OsError::Priority) } +#[derive(serde::Serialize)] +pub struct UserInfo { + username: String, + homedir: String, + shell: Option, +} + +#[cfg(unix)] +fn get_user_info(uid: u32) -> Result { + use std::ffi::CStr; + let mut pw: MaybeUninit = MaybeUninit::uninit(); + let mut result: *mut libc::passwd = std::ptr::null_mut(); + // SAFETY: libc call, no invariants + let max_buf_size = unsafe { libc::sysconf(libc::_SC_GETPW_R_SIZE_MAX) }; + let buf_size = if max_buf_size < 0 { + // from the man page + 16_384 + } else { + max_buf_size as usize + }; + let mut buf = { + let mut b = Vec::>::with_capacity(buf_size); + // SAFETY: MaybeUninit has no initialization invariants, and len == cap + unsafe { + b.set_len(buf_size); + } + b + }; + // SAFETY: libc call, args are correct + let s = unsafe { + libc::getpwuid_r( + uid, + pw.as_mut_ptr(), + buf.as_mut_ptr().cast(), + buf_size, + std::ptr::addr_of_mut!(result), + ) + }; + if result.is_null() { + if s != 0 { + return Err( + OsError::FailedToGetUserInfo(std::io::Error::last_os_error()), + ); + } else { + return Err(OsError::FailedToGetUserInfo(std::io::Error::from( + std::io::ErrorKind::NotFound, + ))); + } + } + // SAFETY: pw was initialized by the call to `getpwuid_r` above + let pw = unsafe { pw.assume_init() }; + // SAFETY: initialized above, pw alive until end of function, nul terminated + let username = unsafe { CStr::from_ptr(pw.pw_name) }; + // SAFETY: initialized above, pw alive until end of function, nul terminated + let homedir = unsafe { CStr::from_ptr(pw.pw_dir) }; + // SAFETY: initialized above, pw alive until end of function, nul terminated + let shell = unsafe { CStr::from_ptr(pw.pw_shell) }; + Ok(UserInfo { + username: username.to_string_lossy().into_owned(), + homedir: homedir.to_string_lossy().into_owned(), + shell: Some(shell.to_string_lossy().into_owned()), + }) +} + +#[cfg(windows)] +fn get_user_info(_uid: u32) -> Result { + use std::ffi::OsString; + use std::os::windows::ffi::OsStringExt; + + use windows_sys::Win32::Foundation::CloseHandle; + use windows_sys::Win32::Foundation::GetLastError; + use windows_sys::Win32::Foundation::ERROR_INSUFFICIENT_BUFFER; + use windows_sys::Win32::Foundation::HANDLE; + use windows_sys::Win32::System::Threading::GetCurrentProcess; + use windows_sys::Win32::System::Threading::OpenProcessToken; + use windows_sys::Win32::UI::Shell::GetUserProfileDirectoryW; + struct Handle(HANDLE); + impl Drop for Handle { + fn drop(&mut self) { + // SAFETY: win32 call + unsafe { + CloseHandle(self.0); + } + } + } + let mut token: MaybeUninit = MaybeUninit::uninit(); + + // Get a handle to the current process + // SAFETY: win32 call + unsafe { + if OpenProcessToken( + GetCurrentProcess(), + windows_sys::Win32::Security::TOKEN_READ, + token.as_mut_ptr(), + ) == 0 + { + return Err( + OsError::FailedToGetUserInfo(std::io::Error::last_os_error()), + ); + } + } + + // SAFETY: initialized by call above + let token = Handle(unsafe { token.assume_init() }); + + let mut bufsize = 0; + // get the size for the homedir buf (it'll end up in `bufsize`) + // SAFETY: win32 call + unsafe { + GetUserProfileDirectoryW(token.0, std::ptr::null_mut(), &mut bufsize); + let err = GetLastError(); + if err != ERROR_INSUFFICIENT_BUFFER { + return Err(OsError::FailedToGetUserInfo( + std::io::Error::from_raw_os_error(err as i32), + )); + } + } + let mut path = vec![0; bufsize as usize]; + // Actually get the homedir + // SAFETY: path is `bufsize` elements + unsafe { + if GetUserProfileDirectoryW(token.0, path.as_mut_ptr(), &mut bufsize) == 0 { + return Err( + OsError::FailedToGetUserInfo(std::io::Error::last_os_error()), + ); + } + } + // remove trailing nul + path.pop(); + let homedir_wide = OsString::from_wide(&path); + let homedir = homedir_wide.to_string_lossy().into_owned(); + + Ok(UserInfo { + username: deno_whoami::username(), + homedir, + shell: None, + }) +} + #[op2] -#[string] -pub fn op_node_os_username

( +#[serde] +pub fn op_node_os_user_info

( state: &mut OpState, -) -> Result + #[smi] uid: u32, +) -> Result where P: NodePermissions + 'static, { { let permissions = state.borrow_mut::

(); - permissions.check_sys("username", "node:os.userInfo()")?; + permissions + .check_sys("userInfo", "node:os.userInfo()") + .map_err(OsError::Permission)?; } - Ok(deno_whoami::username()) + get_user_info(uid) } #[op2(fast)] diff --git a/ext/node/polyfills/internal/errors.ts b/ext/node/polyfills/internal/errors.ts index 51bd7a0250..5a3d4437a1 100644 --- a/ext/node/polyfills/internal/errors.ts +++ b/ext/node/polyfills/internal/errors.ts @@ -2558,19 +2558,6 @@ export class ERR_FS_RMDIR_ENOTDIR extends NodeSystemError { } } -export class ERR_OS_NO_HOMEDIR extends NodeSystemError { - constructor() { - const code = isWindows ? "ENOENT" : "ENOTDIR"; - const ctx: NodeSystemErrorCtx = { - message: "not a directory", - syscall: "home", - code, - errno: isWindows ? osConstants.errno.ENOENT : osConstants.errno.ENOTDIR, - }; - super(code, ctx, "Path is not a directory"); - } -} - export class ERR_HTTP_SOCKET_ASSIGNED extends NodeError { constructor() { super( diff --git a/ext/node/polyfills/os.ts b/ext/node/polyfills/os.ts index e47e8679ec..edc89ed2c3 100644 --- a/ext/node/polyfills/os.ts +++ b/ext/node/polyfills/os.ts @@ -28,16 +28,17 @@ import { op_homedir, op_node_os_get_priority, op_node_os_set_priority, - op_node_os_username, + op_node_os_user_info, } from "ext:core/ops"; import { validateIntegerRange } from "ext:deno_node/_utils.ts"; import process from "node:process"; import { isWindows } from "ext:deno_node/_util/os.ts"; -import { ERR_OS_NO_HOMEDIR } from "ext:deno_node/internal/errors.ts"; import { os } from "ext:deno_node/internal_binding/constants.ts"; import { osUptime } from "ext:runtime/30_os.js"; import { Buffer } from "ext:deno_node/internal/buffer.mjs"; +import { primordials } from "ext:core/mod.js"; +const { StringPrototypeEndsWith, StringPrototypeSlice } = primordials; export const constants = os; @@ -136,6 +137,8 @@ export function arch(): string { (uptime as any)[Symbol.toPrimitive] = (): number => uptime(); // deno-lint-ignore no-explicit-any (machine as any)[Symbol.toPrimitive] = (): string => machine(); +// deno-lint-ignore no-explicit-any +(tmpdir as any)[Symbol.toPrimitive] = (): string | null => tmpdir(); export function cpus(): CPUCoreInfo[] { return op_cpus(); @@ -268,26 +271,27 @@ export function setPriority(pid: number, priority?: number) { export function tmpdir(): string | null { /* This follows the node js implementation, but has a few differences: - * On windows, if none of the environment variables are defined, - we return null. - * On unix we use a plain Deno.env.get, instead of safeGetenv, + * We use a plain Deno.env.get, instead of safeGetenv, which special cases setuid binaries. - * Node removes a single trailing / or \, we remove all. */ if (isWindows) { - const temp = Deno.env.get("TEMP") || Deno.env.get("TMP"); - if (temp) { - return temp.replace(/(? 1 && StringPrototypeEndsWith(temp, "\\") && + !StringPrototypeEndsWith(temp, ":\\") + ) { + temp = StringPrototypeSlice(temp, 0, -1); } - const base = Deno.env.get("SYSTEMROOT") || Deno.env.get("WINDIR"); - if (base) { - return base + "\\temp"; - } - return null; + + return temp; } else { // !isWindows - const temp = Deno.env.get("TMPDIR") || Deno.env.get("TMP") || + let temp = Deno.env.get("TMPDIR") || Deno.env.get("TMP") || Deno.env.get("TEMP") || "/tmp"; - return temp.replace(/(? 1 && StringPrototypeEndsWith(temp, "/")) { + temp = StringPrototypeSlice(temp, 0, -1); + } + return temp; } } @@ -320,7 +324,6 @@ export function uptime(): number { return osUptime(); } -/** Not yet implemented */ export function userInfo( options: UserInfoOptions = { encoding: "utf-8" }, ): UserInfo { @@ -331,20 +334,10 @@ export function userInfo( uid = -1; gid = -1; } - - // TODO(@crowlKats): figure out how to do this correctly: - // The value of homedir returned by os.userInfo() is provided by the operating system. - // This differs from the result of os.homedir(), which queries environment - // variables for the home directory before falling back to the operating system response. - let _homedir = homedir(); - if (!_homedir) { - throw new ERR_OS_NO_HOMEDIR(); - } - let shell = isWindows ? null : (Deno.env.get("SHELL") || null); - let username = op_node_os_username(); + let { username, homedir, shell } = op_node_os_user_info(uid); if (options?.encoding === "buffer") { - _homedir = _homedir ? Buffer.from(_homedir) : _homedir; + homedir = homedir ? Buffer.from(homedir) : homedir; shell = shell ? Buffer.from(shell) : shell; username = Buffer.from(username); } @@ -352,7 +345,7 @@ export function userInfo( return { uid, gid, - homedir: _homedir, + homedir, shell, username, }; diff --git a/runtime/errors.rs b/runtime/errors.rs index 07bf694dc1..a5c436e751 100644 --- a/runtime/errors.rs +++ b/runtime/errors.rs @@ -1086,6 +1086,7 @@ mod node { }, OsError::Permission(e) => get_error_class_name(e).unwrap_or("Error"), OsError::FailedToGetCpuInfo => "TypeError", + OsError::FailedToGetUserInfo(e) => get_io_error_class(e), } } diff --git a/runtime/permissions/lib.rs b/runtime/permissions/lib.rs index 1e1321bb2f..84503f025b 100644 --- a/runtime/permissions/lib.rs +++ b/runtime/permissions/lib.rs @@ -1368,8 +1368,12 @@ impl SysDescriptor { match kind.as_str() { "hostname" | "osRelease" | "osUptime" | "loadavg" | "networkInterfaces" | "systemMemoryInfo" | "uid" | "gid" | "cpus" - | "homedir" | "getegid" | "username" | "statfs" | "getPriority" - | "setPriority" => Ok(Self(kind)), + | "homedir" | "getegid" | "statfs" | "getPriority" | "setPriority" + | "userInfo" => Ok(Self(kind)), + + // the underlying permission check changed to `userInfo` to better match the API, + // alias this to avoid breaking existing projects with `--allow-sys=username` + "username" => Ok(Self("userInfo".into())), _ => Err(type_error(format!("unknown system info kind \"{kind}\""))), } } diff --git a/tests/node_compat/config.jsonc b/tests/node_compat/config.jsonc index a99a427900..16951d9ede 100644 --- a/tests/node_compat/config.jsonc +++ b/tests/node_compat/config.jsonc @@ -87,8 +87,6 @@ "test-net-server-try-ports.js", "test-net-socket-timeout.js", "test-net-write-arguments.js", - // TODO(nathanwhit): Disable os.userInfo is slightly incorrect - // "test-os.js", "test-path-resolve.js", "test-querystring.js", "test-readline-interface.js", @@ -448,6 +446,7 @@ "test-next-tick-when-exiting.js", "test-next-tick.js", "test-nodeeventtarget.js", + "test-os.js", "test-outgoing-message-destroy.js", "test-outgoing-message-pipe.js", "test-parse-args.mjs", diff --git a/tests/node_compat/runner/TODO.md b/tests/node_compat/runner/TODO.md index 35a67e72d2..231a4f62c9 100644 --- a/tests/node_compat/runner/TODO.md +++ b/tests/node_compat/runner/TODO.md @@ -1878,7 +1878,6 @@ NOTE: This file should not be manually edited. Please edit `tests/node_compat/co - [parallel/test-os-homedir-no-envvar.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-os-homedir-no-envvar.js) - [parallel/test-os-process-priority.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-os-process-priority.js) - [parallel/test-os-userinfo-handles-getter-errors.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-os-userinfo-handles-getter-errors.js) -- [parallel/test-os.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-os.js) - [parallel/test-path-posix-relative-on-windows.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-path-posix-relative-on-windows.js) - [parallel/test-pending-deprecation.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-pending-deprecation.js) - [parallel/test-perf-gc-crash.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-perf-gc-crash.js) diff --git a/tests/node_compat/test/parallel/test-os.js b/tests/node_compat/test/parallel/test-os.js new file mode 100644 index 0000000000..f7c24342ad --- /dev/null +++ b/tests/node_compat/test/parallel/test-os.js @@ -0,0 +1,286 @@ +// deno-fmt-ignore-file +// deno-lint-ignore-file + +// Copyright Joyent and Node contributors. All rights reserved. MIT license. +// Taken from Node 18.12.1 +// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually. + +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const os = require('os'); +const path = require('path'); +const { inspect } = require('util'); + +const is = { + number: (value, key) => { + assert(!Number.isNaN(value), `${key} should not be NaN`); + assert.strictEqual(typeof value, 'number'); + }, + string: (value) => { assert.strictEqual(typeof value, 'string'); }, + array: (value) => { assert.ok(Array.isArray(value)); }, + object: (value) => { + assert.strictEqual(typeof value, 'object'); + assert.notStrictEqual(value, null); + } +}; + +process.env.TMPDIR = '/tmpdir'; +process.env.TMP = '/tmp'; +process.env.TEMP = '/temp'; +if (common.isWindows) { + assert.strictEqual(os.tmpdir(), '/temp'); + process.env.TEMP = ''; + assert.strictEqual(os.tmpdir(), '/tmp'); + process.env.TMP = ''; + const expected = `${process.env.SystemRoot || process.env.windir}\\temp`; + assert.strictEqual(os.tmpdir(), expected); + process.env.TEMP = '\\temp\\'; + assert.strictEqual(os.tmpdir(), '\\temp'); + process.env.TEMP = '\\tmpdir/'; + assert.strictEqual(os.tmpdir(), '\\tmpdir/'); + process.env.TEMP = '\\'; + assert.strictEqual(os.tmpdir(), '\\'); + process.env.TEMP = 'C:\\'; + assert.strictEqual(os.tmpdir(), 'C:\\'); +} else { + assert.strictEqual(os.tmpdir(), '/tmpdir'); + process.env.TMPDIR = ''; + assert.strictEqual(os.tmpdir(), '/tmp'); + process.env.TMP = ''; + assert.strictEqual(os.tmpdir(), '/temp'); + process.env.TEMP = ''; + assert.strictEqual(os.tmpdir(), '/tmp'); + process.env.TMPDIR = '/tmpdir/'; + assert.strictEqual(os.tmpdir(), '/tmpdir'); + process.env.TMPDIR = '/tmpdir\\'; + assert.strictEqual(os.tmpdir(), '/tmpdir\\'); + process.env.TMPDIR = '/'; + assert.strictEqual(os.tmpdir(), '/'); +} + +const endianness = os.endianness(); +is.string(endianness); +assert.match(endianness, /[BL]E/); + +const hostname = os.hostname(); +is.string(hostname); +assert.ok(hostname.length > 0); + +// IBMi process priority is different. +if (!common.isIBMi) { + const DUMMY_PRIORITY = 10; + os.setPriority(DUMMY_PRIORITY); + const priority = os.getPriority(); + is.number(priority); + assert.strictEqual(priority, DUMMY_PRIORITY); +} + +// On IBMi, os.uptime() returns 'undefined' +if (!common.isIBMi) { + const uptime = os.uptime(); + is.number(uptime); + assert.ok(uptime > 0); +} + +const cpus = os.cpus(); +is.array(cpus); +assert.ok(cpus.length > 0); +for (const cpu of cpus) { + assert.strictEqual(typeof cpu.model, 'string'); + assert.strictEqual(typeof cpu.speed, 'number'); + assert.strictEqual(typeof cpu.times.user, 'number'); + assert.strictEqual(typeof cpu.times.nice, 'number'); + assert.strictEqual(typeof cpu.times.sys, 'number'); + assert.strictEqual(typeof cpu.times.idle, 'number'); + assert.strictEqual(typeof cpu.times.irq, 'number'); +} + +const type = os.type(); +is.string(type); +assert.ok(type.length > 0); + +const release = os.release(); +is.string(release); +assert.ok(release.length > 0); +// TODO: Check format on more than just AIX +if (common.isAIX) + assert.match(release, /^\d+\.\d+$/); + +const platform = os.platform(); +is.string(platform); +assert.ok(platform.length > 0); + +const arch = os.arch(); +is.string(arch); +assert.ok(arch.length > 0); + +if (!common.isSunOS) { + // not implemented yet + assert.ok(os.loadavg().length > 0); + assert.ok(os.freemem() > 0); + assert.ok(os.totalmem() > 0); +} + +const interfaces = os.networkInterfaces(); +switch (platform) { + case 'linux': { + const filter = (e) => + e.address === '127.0.0.1' && + e.netmask === '255.0.0.0'; + + const actual = interfaces.lo.filter(filter); + const expected = [{ + address: '127.0.0.1', + netmask: '255.0.0.0', + family: 'IPv4', + mac: '00:00:00:00:00:00', + internal: true, + cidr: '127.0.0.1/8' + }]; + assert.deepStrictEqual(actual, expected); + break; + } + case 'win32': { + const filter = (e) => + e.address === '127.0.0.1'; + + const actual = interfaces['Loopback Pseudo-Interface 1'].filter(filter); + const expected = [{ + address: '127.0.0.1', + netmask: '255.0.0.0', + family: 'IPv4', + mac: '00:00:00:00:00:00', + internal: true, + cidr: '127.0.0.1/8' + }]; + assert.deepStrictEqual(actual, expected); + break; + } +} +const netmaskToCIDRSuffixMap = new Map(Object.entries({ + '255.0.0.0': 8, + '255.255.255.0': 24, + 'ffff:ffff:ffff:ffff::': 64, + 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff': 128 +})); + +Object.values(interfaces) + .flat(Infinity) + .map((v) => ({ v, mask: netmaskToCIDRSuffixMap.get(v.netmask) })) + .forEach(({ v, mask }) => { + assert.ok('cidr' in v, `"cidr" prop not found in ${inspect(v)}`); + if (mask) { + assert.strictEqual(v.cidr, `${v.address}/${mask}`); + } + }); + +const EOL = os.EOL; +if (common.isWindows) { + assert.strictEqual(EOL, '\r\n'); +} else { + assert.strictEqual(EOL, '\n'); +} + +const home = os.homedir(); +is.string(home); +assert.ok(home.includes(path.sep)); + +const version = os.version(); +assert.strictEqual(typeof version, 'string'); +assert(version); + +if (common.isWindows && process.env.USERPROFILE) { + assert.strictEqual(home, process.env.USERPROFILE); + delete process.env.USERPROFILE; + assert.ok(os.homedir().includes(path.sep)); + process.env.USERPROFILE = home; +} else if (!common.isWindows && process.env.HOME) { + assert.strictEqual(home, process.env.HOME); + delete process.env.HOME; + assert.ok(os.homedir().includes(path.sep)); + process.env.HOME = home; +} + +const pwd = os.userInfo(); +is.object(pwd); +const pwdBuf = os.userInfo({ encoding: 'buffer' }); + +if (common.isWindows) { + assert.strictEqual(pwd.uid, -1); + assert.strictEqual(pwd.gid, -1); + assert.strictEqual(pwd.shell, null); + assert.strictEqual(pwdBuf.uid, -1); + assert.strictEqual(pwdBuf.gid, -1); + assert.strictEqual(pwdBuf.shell, null); +} else { + is.number(pwd.uid); + is.number(pwd.gid); + assert.strictEqual(typeof pwd.shell, 'string'); + // It's possible for /etc/passwd to leave the user's shell blank. + if (pwd.shell.length > 0) { + assert(pwd.shell.includes(path.sep)); + } + assert.strictEqual(pwd.uid, pwdBuf.uid); + assert.strictEqual(pwd.gid, pwdBuf.gid); + assert.strictEqual(pwd.shell, pwdBuf.shell.toString('utf8')); +} + +is.string(pwd.username); +assert.ok(pwd.homedir.includes(path.sep)); +assert.strictEqual(pwd.username, pwdBuf.username.toString('utf8')); +assert.strictEqual(pwd.homedir, pwdBuf.homedir.toString('utf8')); + +assert.strictEqual(`${os.hostname}`, os.hostname()); +assert.strictEqual(`${os.homedir}`, os.homedir()); +assert.strictEqual(`${os.release}`, os.release()); +assert.strictEqual(`${os.type}`, os.type()); +assert.strictEqual(`${os.endianness}`, os.endianness()); +assert.strictEqual(`${os.tmpdir}`, os.tmpdir()); +assert.strictEqual(`${os.arch}`, os.arch()); +assert.strictEqual(`${os.platform}`, os.platform()); +assert.strictEqual(`${os.version}`, os.version()); +assert.strictEqual(`${os.machine}`, os.machine()); +assert.strictEqual(+os.totalmem, os.totalmem()); + +// Assert that the following values are coercible to numbers. +// On IBMi, os.uptime() returns 'undefined' +if (!common.isIBMi) { + is.number(+os.uptime, 'uptime'); + is.number(os.uptime(), 'uptime'); +} + +is.number(+os.availableParallelism, 'availableParallelism'); +is.number(os.availableParallelism(), 'availableParallelism'); +is.number(+os.freemem, 'freemem'); +is.number(os.freemem(), 'freemem'); + +const devNull = os.devNull; +if (common.isWindows) { + assert.strictEqual(devNull, '\\\\.\\nul'); +} else { + assert.strictEqual(devNull, '/dev/null'); +} + +assert.ok(os.availableParallelism() > 0); From 04ae1a551726dd6e0047a942b459d18e1dcb1935 Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Thu, 31 Oct 2024 22:19:19 -0700 Subject: [PATCH 15/40] fix(cli): set `npm_config_user_agent` when running npm packages or tasks (#26639) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #25342. Still not sure on the exact user agent to set (should it include `node`?). After this PR, here's the state of running some `create-*` packages (just ones I could think of off the top of my head): | package | prints/runs/suggests deno install | notes | | ---------------- | ------------- | ------ | | `create-next-app` | ❌ | falls back to npm, needs a PR ([code](https://github.com/vercel/next.js/blob/c32e2802097c03fd9f95b1dae228d6e0257569c0/packages/create-next-app/helpers/get-pkg-manager.ts#L3)) | `sv create` | ❌ | uses `package-manager-detector`, needs a PR ([code](https://github.com/antfu-collective/package-manager-detector/tree/main)) | `create-qwik` | ✅ | runs `deno install` but suggests `deno start` which doesn't work (should be `deno task start` or `deno run start`) | `create-astro` | ✅ | runs `deno install` but suggests `npm run dev` later in output, probably needs a PR | `nuxi init` | ❌ | deno not an option in dialog, needs a PR ([code](https://github.com/nuxt/cli/blob/f04e2e894446f597da9d971b7eb03191d5a0da7e/src/commands/init.ts#L96-L102)) | `create-react-app` | ❌ | uses npm | `ng new` (`@angular/cli`) | ❌ | uses npm | `create-vite` | ✅ | suggests working deno commands 🎉 | `create-solid` | ❌ | suggests npm commands, needs PR It's possible that fixing `package-manager-detector` or other packages might make some of these just work, but haven't looked too carefully at each --- cli/npm/mod.rs | 12 +++++ cli/task_runner.rs | 10 +++- cli/tools/run/mod.rs | 18 ++++++++ .../print-npm-user-agent/1.0.0/index.js | 2 + .../print-npm-user-agent/1.0.0/package.json | 10 ++++ .../npm/user_agent_env_var/__test__.jsonc | 46 +++++++++++++++++++ .../npm/user_agent_env_var/bin_command.out | 2 + tests/specs/npm/user_agent_env_var/deno.jsonc | 3 ++ tests/specs/npm/user_agent_env_var/main.ts | 1 + .../specs/npm/user_agent_env_var/package.json | 8 ++++ .../npm/user_agent_env_var/postinstall.out | 10 ++++ tests/specs/npm/user_agent_env_var/run.out | 1 + tests/specs/npm/user_agent_env_var/test.mjs | 1 + 13 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 tests/registry/npm/@denotest/print-npm-user-agent/1.0.0/index.js create mode 100644 tests/registry/npm/@denotest/print-npm-user-agent/1.0.0/package.json create mode 100644 tests/specs/npm/user_agent_env_var/__test__.jsonc create mode 100644 tests/specs/npm/user_agent_env_var/bin_command.out create mode 100644 tests/specs/npm/user_agent_env_var/deno.jsonc create mode 100644 tests/specs/npm/user_agent_env_var/main.ts create mode 100644 tests/specs/npm/user_agent_env_var/package.json create mode 100644 tests/specs/npm/user_agent_env_var/postinstall.out create mode 100644 tests/specs/npm/user_agent_env_var/run.out create mode 100644 tests/specs/npm/user_agent_env_var/test.mjs diff --git a/cli/npm/mod.rs b/cli/npm/mod.rs index f48f7a7405..3971b1a0b3 100644 --- a/cli/npm/mod.rs +++ b/cli/npm/mod.rs @@ -189,3 +189,15 @@ impl NpmFetchResolver { info } } + +pub const NPM_CONFIG_USER_AGENT_ENV_VAR: &str = "npm_config_user_agent"; + +pub fn get_npm_config_user_agent() -> String { + format!( + "deno/{} npm/? deno/{} {} {}", + env!("CARGO_PKG_VERSION"), + env!("CARGO_PKG_VERSION"), + std::env::consts::OS, + std::env::consts::ARCH + ) +} diff --git a/cli/task_runner.rs b/cli/task_runner.rs index 418043b23f..43840e868d 100644 --- a/cli/task_runner.rs +++ b/cli/task_runner.rs @@ -155,6 +155,12 @@ fn prepare_env_vars( initial_cwd.to_string_lossy().to_string(), ); } + if !env_vars.contains_key(crate::npm::NPM_CONFIG_USER_AGENT_ENV_VAR) { + env_vars.insert( + crate::npm::NPM_CONFIG_USER_AGENT_ENV_VAR.into(), + crate::npm::get_npm_config_user_agent(), + ); + } if let Some(node_modules_dir) = node_modules_dir { prepend_to_path( &mut env_vars, @@ -204,7 +210,7 @@ impl ShellCommand for NpmCommand { mut context: ShellCommandContext, ) -> LocalBoxFuture<'static, ExecuteResult> { if context.args.first().map(|s| s.as_str()) == Some("run") - && context.args.len() > 2 + && context.args.len() >= 2 // for now, don't run any npm scripts that have a flag because // we don't handle stuff like `--workspaces` properly && !context.args.iter().any(|s| s.starts_with('-')) @@ -267,10 +273,12 @@ impl ShellCommand for NodeCommand { ) .execute(context); } + args.extend(["run", "-A"].into_iter().map(|s| s.to_string())); args.extend(context.args.iter().cloned()); let mut state = context.state; + state.apply_env_var(USE_PKG_JSON_HIDDEN_ENV_VAR_NAME, "1"); ExecutableCommand::new("deno".to_string(), std::env::current_exe().unwrap()) .execute(ShellCommandContext { diff --git a/cli/tools/run/mod.rs b/cli/tools/run/mod.rs index 152e2650bd..bebb3f5881 100644 --- a/cli/tools/run/mod.rs +++ b/cli/tools/run/mod.rs @@ -30,6 +30,16 @@ To grant permissions, set them before the script argument. For example: } } +fn set_npm_user_agent() { + static ONCE: std::sync::Once = std::sync::Once::new(); + ONCE.call_once(|| { + std::env::set_var( + crate::npm::NPM_CONFIG_USER_AGENT_ENV_VAR, + crate::npm::get_npm_config_user_agent(), + ); + }); +} + pub async fn run_script( mode: WorkerExecutionMode, flags: Arc, @@ -58,6 +68,10 @@ pub async fn run_script( let main_module = cli_options.resolve_main_module()?; + if main_module.scheme() == "npm" { + set_npm_user_agent(); + } + maybe_npm_install(&factory).await?; let worker_factory = factory.create_cli_main_worker_factory().await?; @@ -119,6 +133,10 @@ async fn run_with_watch( let cli_options = factory.cli_options()?; let main_module = cli_options.resolve_main_module()?; + if main_module.scheme() == "npm" { + set_npm_user_agent(); + } + maybe_npm_install(&factory).await?; let _ = watcher_communicator.watch_paths(cli_options.watch_paths()); diff --git a/tests/registry/npm/@denotest/print-npm-user-agent/1.0.0/index.js b/tests/registry/npm/@denotest/print-npm-user-agent/1.0.0/index.js new file mode 100644 index 0000000000..b835b8e25e --- /dev/null +++ b/tests/registry/npm/@denotest/print-npm-user-agent/1.0.0/index.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +console.log(`npm_config_user_agent: ${process.env["npm_config_user_agent"]}`); \ No newline at end of file diff --git a/tests/registry/npm/@denotest/print-npm-user-agent/1.0.0/package.json b/tests/registry/npm/@denotest/print-npm-user-agent/1.0.0/package.json new file mode 100644 index 0000000000..9071173467 --- /dev/null +++ b/tests/registry/npm/@denotest/print-npm-user-agent/1.0.0/package.json @@ -0,0 +1,10 @@ +{ + "name": "@denotest/print-npm-user-agent", + "version": "1.0.0", + "bin": { + "print-npm-user-agent": "index.js" + }, + "scripts": { + "postinstall": "echo postinstall && node index.js && exit 1" + } +} \ No newline at end of file diff --git a/tests/specs/npm/user_agent_env_var/__test__.jsonc b/tests/specs/npm/user_agent_env_var/__test__.jsonc new file mode 100644 index 0000000000..a2af970a0e --- /dev/null +++ b/tests/specs/npm/user_agent_env_var/__test__.jsonc @@ -0,0 +1,46 @@ +{ + "tempDir": true, + "tests": { + "set_for_npm_package": { + "steps": [ + { + "args": "install", + "output": "[WILDCARD]" + }, + { + "args": "run -A npm:@denotest/print-npm-user-agent", + "output": "run.out" + } + ] + }, + "unset_for_local_file": { + "steps": [ + { + "args": "run -A main.ts", + "output": "Download [WILDCARD]\nnpm_config_user_agent: undefined\n" + } + ] + }, + "set_for_tasks": { + "steps": [ + { + "args": "install", + "output": "[WILDCARD]" + }, + { + "args": "task run-via-bin", + "output": "bin_command.out" + } + ] + }, + "set_for_lifecycle_scripts": { + "steps": [ + { + "args": "install --allow-scripts", + "output": "postinstall.out", + "exitCode": 1 + } + ] + } + } +} diff --git a/tests/specs/npm/user_agent_env_var/bin_command.out b/tests/specs/npm/user_agent_env_var/bin_command.out new file mode 100644 index 0000000000..c8e9413038 --- /dev/null +++ b/tests/specs/npm/user_agent_env_var/bin_command.out @@ -0,0 +1,2 @@ +Task run-via-bin print-npm-user-agent +npm_config_user_agent: deno/[WILDCARD] npm/? deno/[WILDCARD] [WILDCARD] [WILDCARD] diff --git a/tests/specs/npm/user_agent_env_var/deno.jsonc b/tests/specs/npm/user_agent_env_var/deno.jsonc new file mode 100644 index 0000000000..fbd70ec480 --- /dev/null +++ b/tests/specs/npm/user_agent_env_var/deno.jsonc @@ -0,0 +1,3 @@ +{ + "nodeModulesDir": "auto" +} diff --git a/tests/specs/npm/user_agent_env_var/main.ts b/tests/specs/npm/user_agent_env_var/main.ts new file mode 100644 index 0000000000..2c51107e3c --- /dev/null +++ b/tests/specs/npm/user_agent_env_var/main.ts @@ -0,0 +1 @@ +console.log(`npm_config_user_agent: ${Deno.env.get("npm_config_user_agent")}`); diff --git a/tests/specs/npm/user_agent_env_var/package.json b/tests/specs/npm/user_agent_env_var/package.json new file mode 100644 index 0000000000..12cc0cc6fb --- /dev/null +++ b/tests/specs/npm/user_agent_env_var/package.json @@ -0,0 +1,8 @@ +{ + "scripts": { + "run-via-bin": "print-npm-user-agent" + }, + "dependencies": { + "@denotest/print-npm-user-agent": "1.0.0" + } +} diff --git a/tests/specs/npm/user_agent_env_var/postinstall.out b/tests/specs/npm/user_agent_env_var/postinstall.out new file mode 100644 index 0000000000..19a08598fb --- /dev/null +++ b/tests/specs/npm/user_agent_env_var/postinstall.out @@ -0,0 +1,10 @@ +Download http://localhost:4260/@denotest%2fprint-npm-user-agent +Download http://localhost:4260/@denotest/print-npm-user-agent/1.0.0.tgz +Initialize @denotest/print-npm-user-agent@1.0.0 +Initialize @denotest/print-npm-user-agent@1.0.0: running 'postinstall' script +error: script 'postinstall' in '@denotest/print-npm-user-agent@1.0.0' failed with exit code 1 +stdout: +postinstall +npm_config_user_agent: deno/[WILDCARD] npm/? deno/[WILDCARD] [WILDCARD] [WILDCARD] + +error: failed to run scripts for packages: @denotest/print-npm-user-agent@1.0.0 diff --git a/tests/specs/npm/user_agent_env_var/run.out b/tests/specs/npm/user_agent_env_var/run.out new file mode 100644 index 0000000000..a630ac412f --- /dev/null +++ b/tests/specs/npm/user_agent_env_var/run.out @@ -0,0 +1 @@ +npm_config_user_agent: deno/[WILDCARD] npm/? deno/[WILDCARD] [WILDCARD] [WILDCARD] diff --git a/tests/specs/npm/user_agent_env_var/test.mjs b/tests/specs/npm/user_agent_env_var/test.mjs new file mode 100644 index 0000000000..ae035d40ef --- /dev/null +++ b/tests/specs/npm/user_agent_env_var/test.mjs @@ -0,0 +1 @@ +console.log(process.env.npm_config_user_agent); From 4774eab64d5176e997b6431f03f075782321b3d9 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Fri, 1 Nov 2024 16:13:02 +0530 Subject: [PATCH 16/40] chore: upgrade to rust 1.82 and LLVM 19 (#26615) Upgrade to rust 1.82 and LLVM 19 . Removes one webusb test because `requestAdapter` not working on new ubuntu 24 runners --- .github/workflows/ci.generate.ts | 10 +++--- .github/workflows/ci.yml | 36 +++++++++++----------- cli/tools/info.rs | 4 +-- ext/node/ops/crypto/sign.rs | 30 ++++++++---------- runtime/permissions/prompter.rs | 2 +- rust-toolchain.toml | 2 +- tests/napi/src/async.rs | 2 +- tests/specs/future/unstable_flags/main.js | 1 - tests/specs/future/unstable_flags/main.out | 1 - 9 files changed, 40 insertions(+), 48 deletions(-) diff --git a/.github/workflows/ci.generate.ts b/.github/workflows/ci.generate.ts index d5ee67b654..49d11107d5 100755 --- a/.github/workflows/ci.generate.ts +++ b/.github/workflows/ci.generate.ts @@ -7,8 +7,8 @@ import { stringify } from "jsr:@std/yaml@^0.221/stringify"; // automatically via regex, so ensure that this line maintains this format. const cacheVersion = 23; -const ubuntuX86Runner = "ubuntu-22.04"; -const ubuntuX86XlRunner = "ubuntu-22.04-xl"; +const ubuntuX86Runner = "ubuntu-24.04"; +const ubuntuX86XlRunner = "ubuntu-24.04-xl"; const ubuntuARMRunner = "ubicloud-standard-16-arm"; const windowsX86Runner = "windows-2022"; const windowsX86XlRunner = "windows-2022-xl"; @@ -59,7 +59,7 @@ const prCacheKeyPrefix = `${cacheVersion}-cargo-target-\${{ matrix.os }}-\${{ matrix.arch }}-\${{ matrix.profile }}-\${{ matrix.job }}-`; // Note that you may need to add more version to the `apt-get remove` line below if you change this -const llvmVersion = 18; +const llvmVersion = 19; const installPkgsCommand = `sudo apt-get install --no-install-recommends clang-${llvmVersion} lld-${llvmVersion} clang-tools-${llvmVersion} clang-format-${llvmVersion} clang-tidy-${llvmVersion}`; const sysRootStep = { @@ -71,7 +71,7 @@ export DEBIAN_FRONTEND=noninteractive sudo apt-get -qq remove --purge -y man-db > /dev/null 2> /dev/null # Remove older clang before we install sudo apt-get -qq remove \ - 'clang-12*' 'clang-13*' 'clang-14*' 'clang-15*' 'clang-16*' 'llvm-12*' 'llvm-13*' 'llvm-14*' 'llvm-15*' 'llvm-16*' 'lld-12*' 'lld-13*' 'lld-14*' 'lld-15*' 'lld-16*' > /dev/null 2> /dev/null + 'clang-12*' 'clang-13*' 'clang-14*' 'clang-15*' 'clang-16*' 'clang-17*' 'clang-18*' 'llvm-12*' 'llvm-13*' 'llvm-14*' 'llvm-15*' 'llvm-16*' 'lld-12*' 'lld-13*' 'lld-14*' 'lld-15*' 'lld-16*' 'lld-17*' 'lld-18*' > /dev/null 2> /dev/null # Install clang-XXX, lld-XXX, and debootstrap. echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-${llvmVersion} main" | @@ -86,7 +86,7 @@ ${installPkgsCommand} || echo 'Failed. Trying again.' && sudo apt-get clean && s (yes '' | sudo update-alternatives --force --all) > /dev/null 2> /dev/null || true echo "Decompressing sysroot..." -wget -q https://github.com/denoland/deno_sysroot_build/releases/download/sysroot-20240528/sysroot-\`uname -m\`.tar.xz -O /tmp/sysroot.tar.xz +wget -q https://github.com/denoland/deno_sysroot_build/releases/download/sysroot-20241030/sysroot-\`uname -m\`.tar.xz -O /tmp/sysroot.tar.xz cd / xzcat /tmp/sysroot.tar.xz | sudo tar -x sudo mount --rbind /dev /sysroot/dev diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6421d9244..a9c06de17a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: profile: debug - os: macos arch: x86_64 - runner: '${{ (!contains(github.event.pull_request.labels.*.name, ''ci-full'') && (github.event_name == ''pull_request'')) && ''ubuntu-22.04'' || ''macos-13'' }}' + runner: '${{ (!contains(github.event.pull_request.labels.*.name, ''ci-full'') && (github.event_name == ''pull_request'')) && ''ubuntu-24.04'' || ''macos-13'' }}' job: test profile: release skip: '${{ !contains(github.event.pull_request.labels.*.name, ''ci-full'') && (github.event_name == ''pull_request'') }}' @@ -73,7 +73,7 @@ jobs: profile: debug - os: macos arch: aarch64 - runner: '${{ (!contains(github.event.pull_request.labels.*.name, ''ci-full'') && (github.event_name == ''pull_request'')) && ''ubuntu-22.04'' || ''macos-14'' }}' + runner: '${{ (!contains(github.event.pull_request.labels.*.name, ''ci-full'') && (github.event_name == ''pull_request'')) && ''ubuntu-24.04'' || ''macos-14'' }}' job: test profile: release skip: '${{ !contains(github.event.pull_request.labels.*.name, ''ci-full'') && (github.event_name == ''pull_request'') }}' @@ -84,33 +84,33 @@ jobs: profile: debug - os: windows arch: x86_64 - runner: '${{ (!contains(github.event.pull_request.labels.*.name, ''ci-full'') && (github.event_name == ''pull_request'')) && ''ubuntu-22.04'' || github.repository == ''denoland/deno'' && ''windows-2022-xl'' || ''windows-2022'' }}' + runner: '${{ (!contains(github.event.pull_request.labels.*.name, ''ci-full'') && (github.event_name == ''pull_request'')) && ''ubuntu-24.04'' || github.repository == ''denoland/deno'' && ''windows-2022-xl'' || ''windows-2022'' }}' job: test profile: release skip: '${{ !contains(github.event.pull_request.labels.*.name, ''ci-full'') && (github.event_name == ''pull_request'') }}' - os: linux arch: x86_64 - runner: '${{ github.repository == ''denoland/deno'' && ''ubuntu-22.04-xl'' || ''ubuntu-22.04'' }}' + runner: '${{ github.repository == ''denoland/deno'' && ''ubuntu-24.04-xl'' || ''ubuntu-24.04'' }}' job: test profile: release use_sysroot: true wpt: '${{ !startsWith(github.ref, ''refs/tags/'') }}' - os: linux arch: x86_64 - runner: '${{ (!contains(github.event.pull_request.labels.*.name, ''ci-full'') && (github.event_name == ''pull_request'' && !contains(github.event.pull_request.labels.*.name, ''ci-bench''))) && ''ubuntu-22.04'' || github.repository == ''denoland/deno'' && ''ubuntu-22.04-xl'' || ''ubuntu-22.04'' }}' + runner: '${{ (!contains(github.event.pull_request.labels.*.name, ''ci-full'') && (github.event_name == ''pull_request'' && !contains(github.event.pull_request.labels.*.name, ''ci-bench''))) && ''ubuntu-24.04'' || github.repository == ''denoland/deno'' && ''ubuntu-24.04-xl'' || ''ubuntu-24.04'' }}' job: bench profile: release use_sysroot: true skip: '${{ !contains(github.event.pull_request.labels.*.name, ''ci-full'') && (github.event_name == ''pull_request'' && !contains(github.event.pull_request.labels.*.name, ''ci-bench'')) }}' - os: linux arch: x86_64 - runner: ubuntu-22.04 + runner: ubuntu-24.04 job: test profile: debug use_sysroot: true - os: linux arch: x86_64 - runner: ubuntu-22.04 + runner: ubuntu-24.04 job: lint profile: debug - os: linux @@ -252,22 +252,22 @@ jobs: # to complete. sudo apt-get -qq remove --purge -y man-db > /dev/null 2> /dev/null # Remove older clang before we install - sudo apt-get -qq remove 'clang-12*' 'clang-13*' 'clang-14*' 'clang-15*' 'clang-16*' 'llvm-12*' 'llvm-13*' 'llvm-14*' 'llvm-15*' 'llvm-16*' 'lld-12*' 'lld-13*' 'lld-14*' 'lld-15*' 'lld-16*' > /dev/null 2> /dev/null + sudo apt-get -qq remove 'clang-12*' 'clang-13*' 'clang-14*' 'clang-15*' 'clang-16*' 'clang-17*' 'clang-18*' 'llvm-12*' 'llvm-13*' 'llvm-14*' 'llvm-15*' 'llvm-16*' 'lld-12*' 'lld-13*' 'lld-14*' 'lld-15*' 'lld-16*' 'lld-17*' 'lld-18*' > /dev/null 2> /dev/null # Install clang-XXX, lld-XXX, and debootstrap. - echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" | - sudo dd of=/etc/apt/sources.list.d/llvm-toolchain-jammy-18.list + echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main" | + sudo dd of=/etc/apt/sources.list.d/llvm-toolchain-jammy-19.list curl https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor | sudo dd of=/etc/apt/trusted.gpg.d/llvm-snapshot.gpg sudo apt-get update # this was unreliable sometimes, so try again if it fails - sudo apt-get install --no-install-recommends clang-18 lld-18 clang-tools-18 clang-format-18 clang-tidy-18 || echo 'Failed. Trying again.' && sudo apt-get clean && sudo apt-get update && sudo apt-get install --no-install-recommends clang-18 lld-18 clang-tools-18 clang-format-18 clang-tidy-18 + sudo apt-get install --no-install-recommends clang-19 lld-19 clang-tools-19 clang-format-19 clang-tidy-19 || echo 'Failed. Trying again.' && sudo apt-get clean && sudo apt-get update && sudo apt-get install --no-install-recommends clang-19 lld-19 clang-tools-19 clang-format-19 clang-tidy-19 # Fix alternatives (yes '' | sudo update-alternatives --force --all) > /dev/null 2> /dev/null || true echo "Decompressing sysroot..." - wget -q https://github.com/denoland/deno_sysroot_build/releases/download/sysroot-20240528/sysroot-`uname -m`.tar.xz -O /tmp/sysroot.tar.xz + wget -q https://github.com/denoland/deno_sysroot_build/releases/download/sysroot-20241030/sysroot-`uname -m`.tar.xz -O /tmp/sysroot.tar.xz cd / xzcat /tmp/sysroot.tar.xz | sudo tar -x sudo mount --rbind /dev /sysroot/dev @@ -299,8 +299,8 @@ jobs: CARGO_PROFILE_RELEASE_LTO=false RUSTFLAGS<<__1 -C linker-plugin-lto=true - -C linker=clang-18 - -C link-arg=-fuse-ld=lld-18 + -C linker=clang-19 + -C link-arg=-fuse-ld=lld-19 -C link-arg=-ldl -C link-arg=-Wl,--allow-shlib-undefined -C link-arg=-Wl,--thinlto-cache-dir=$(pwd)/target/release/lto-cache @@ -310,8 +310,8 @@ jobs: __1 RUSTDOCFLAGS<<__1 -C linker-plugin-lto=true - -C linker=clang-18 - -C link-arg=-fuse-ld=lld-18 + -C linker=clang-19 + -C link-arg=-fuse-ld=lld-19 -C link-arg=-ldl -C link-arg=-Wl,--allow-shlib-undefined -C link-arg=-Wl,--thinlto-cache-dir=$(pwd)/target/release/lto-cache @@ -319,7 +319,7 @@ jobs: --cfg tokio_unstable $RUSTFLAGS __1 - CC=/usr/bin/clang-18 + CC=/usr/bin/clang-19 CFLAGS=-flto=thin $CFLAGS " > $GITHUB_ENV - name: Remove macOS cURL --ipv4 flag @@ -688,7 +688,7 @@ jobs: key: '23-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-${{ github.sha }}' publish-canary: name: publish canary - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 needs: - build if: github.repository == 'denoland/deno' && github.ref == 'refs/heads/main' diff --git a/cli/tools/info.rs b/cli/tools/info.rs index 3febaff579..b53485bd6b 100644 --- a/cli/tools/info.rs +++ b/cli/tools/info.rs @@ -530,7 +530,7 @@ impl<'a> GraphDisplayContext<'a> { fn build_module_info(&mut self, module: &Module, type_dep: bool) -> TreeNode { enum PackageOrSpecifier { - Package(NpmResolutionPackage), + Package(Box), Specifier(ModuleSpecifier), } @@ -538,7 +538,7 @@ impl<'a> GraphDisplayContext<'a> { let package_or_specifier = match module.npm() { Some(npm) => match self.npm_info.resolve_package(npm.nv_reference.nv()) { - Some(package) => Package(package.clone()), + Some(package) => Package(Box::new(package.clone())), None => Specifier(module.specifier().clone()), // should never happen }, None => Specifier(module.specifier().clone()), diff --git a/ext/node/ops/crypto/sign.rs b/ext/node/ops/crypto/sign.rs index b7779a5d80..31744f86ba 100644 --- a/ext/node/ops/crypto/sign.rs +++ b/ext/node/ops/crypto/sign.rs @@ -79,18 +79,15 @@ impl KeyObjectHandle { AsymmetricPrivateKey::RsaPss(key) => { let mut hash_algorithm = None; let mut salt_length = None; - match &key.details { - Some(details) => { - if details.hash_algorithm != details.mf1_hash_algorithm { - return Err(type_error( + if let Some(details) = &key.details { + if details.hash_algorithm != details.mf1_hash_algorithm { + return Err(type_error( "rsa-pss with different mf1 hash algorithm and hash algorithm is not supported", )); - } - hash_algorithm = Some(details.hash_algorithm); - salt_length = Some(details.salt_length as usize); } - None => {} - }; + hash_algorithm = Some(details.hash_algorithm); + salt_length = Some(details.salt_length as usize); + } if let Some(s) = pss_salt_length { salt_length = Some(s as usize); } @@ -215,18 +212,15 @@ impl KeyObjectHandle { AsymmetricPublicKey::RsaPss(key) => { let mut hash_algorithm = None; let mut salt_length = None; - match &key.details { - Some(details) => { - if details.hash_algorithm != details.mf1_hash_algorithm { - return Err(type_error( + if let Some(details) = &key.details { + if details.hash_algorithm != details.mf1_hash_algorithm { + return Err(type_error( "rsa-pss with different mf1 hash algorithm and hash algorithm is not supported", )); - } - hash_algorithm = Some(details.hash_algorithm); - salt_length = Some(details.salt_length as usize); } - None => {} - }; + hash_algorithm = Some(details.hash_algorithm); + salt_length = Some(details.salt_length as usize); + } if let Some(s) = pss_salt_length { salt_length = Some(s as usize); } diff --git a/runtime/permissions/prompter.rs b/runtime/permissions/prompter.rs index 316911edc1..b582b4f53e 100644 --- a/runtime/permissions/prompter.rs +++ b/runtime/permissions/prompter.rs @@ -269,7 +269,7 @@ fn get_stdin_metadata() -> std::io::Result { unsafe { let stdin = std::fs::File::from_raw_fd(0); let metadata = stdin.metadata().unwrap(); - stdin.into_raw_fd(); + let _ = stdin.into_raw_fd(); Ok(metadata) } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index f19c7df470..3d572e0d69 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.81.0" +channel = "1.82.0" components = ["rustfmt", "clippy"] diff --git a/tests/napi/src/async.rs b/tests/napi/src/async.rs index 3d3827b51c..367d2e9ef0 100644 --- a/tests/napi/src/async.rs +++ b/tests/napi/src/async.rs @@ -95,7 +95,7 @@ extern "C" fn test_async_work( )); let mut baton = unsafe { Box::from_raw(baton_ptr as *mut Baton) }; baton.task = async_work; - Box::into_raw(baton); + let _ = Box::into_raw(baton); assert_napi_ok!(napi_queue_async_work(env, async_work)); ptr::null_mut() diff --git a/tests/specs/future/unstable_flags/main.js b/tests/specs/future/unstable_flags/main.js index 51af892f6b..8cc8960d97 100644 --- a/tests/specs/future/unstable_flags/main.js +++ b/tests/specs/future/unstable_flags/main.js @@ -1,4 +1,3 @@ -console.log(typeof await navigator.gpu.requestAdapter() === "object"); // Throws without `--unstable-gpu` console.log(typeof Deno.dlopen === "function"); // Undefined without `--unstable-ffi` console.log( // Undefined without `--unstable-fs` diff --git a/tests/specs/future/unstable_flags/main.out b/tests/specs/future/unstable_flags/main.out index b979d62f4f..bb101b641b 100644 --- a/tests/specs/future/unstable_flags/main.out +++ b/tests/specs/future/unstable_flags/main.out @@ -1,3 +1,2 @@ true true -true From 826e42a5b5880c974ae019a7a21aade6a718062c Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 1 Nov 2024 12:27:00 -0400 Subject: [PATCH 17/40] fix: improved support for cjs and cts modules (#26558) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * cts support * better cjs/cts type checking * deno compile cjs/cts support * More efficient detect cjs (going towards stabilization) * Determination of whether .js, .ts, .jsx, or .tsx is cjs or esm is only done after loading * Support `import x = require(...);` Co-authored-by: Bartek Iwańczuk --- Cargo.lock | 28 +- Cargo.toml | 6 +- cli/Cargo.toml | 8 +- cli/args/mod.rs | 11 + cli/cache/cache_db.rs | 6 +- cli/cache/emit.rs | 2 + cli/cache/mod.rs | 101 ++--- cli/cache/module_info.rs | 140 +++++-- cli/cache/parsed_source.rs | 60 +-- cli/emit.rs | 77 ++-- cli/factory.rs | 274 ++++++++----- cli/graph_util.rs | 80 ++-- cli/lsp/analysis.rs | 21 +- cli/lsp/code_lens.rs | 4 +- cli/lsp/config.rs | 2 +- cli/lsp/documents.rs | 20 +- cli/lsp/language_server.rs | 2 +- cli/lsp/resolver.rs | 230 ++++++++--- cli/lsp/testing/collectors.rs | 2 +- cli/lsp/tsc.rs | 27 +- cli/main.rs | 2 +- cli/module_loader.rs | 310 ++++++++++++--- cli/node.rs | 134 +++---- cli/npm/byonm.rs | 43 +- cli/npm/managed/cache/mod.rs | 12 +- cli/npm/managed/mod.rs | 91 +++-- cli/npm/managed/resolvers/common.rs | 4 - cli/npm/managed/resolvers/global.rs | 7 +- cli/npm/managed/resolvers/local.rs | 4 - cli/npm/mod.rs | 34 +- cli/resolver.rs | 354 +++++++++++------ cli/standalone/binary.rs | 38 +- cli/standalone/mod.rs | 370 ++++++++++++------ cli/standalone/serialization.rs | 49 ++- cli/tools/bench/mod.rs | 2 +- cli/tools/check.rs | 11 +- cli/tools/compile.rs | 10 - cli/tools/coverage/mod.rs | 23 +- cli/tools/doc.rs | 6 +- cli/tools/registry/tar.rs | 2 +- cli/tools/repl/session.rs | 6 +- cli/tools/run/hmr.rs | 25 +- cli/tools/test/mod.rs | 2 +- cli/tsc/99_main_compiler.js | 2 + cli/tsc/diagnostics.rs | 2 +- cli/tsc/mod.rs | 153 ++++++-- cli/util/extract.rs | 8 +- cli/util/logger.rs | 2 + cli/util/path.rs | 27 -- cli/util/text_encoding.rs | 1 + cli/worker.rs | 171 +++----- ext/node/lib.rs | 47 +-- ext/node/ops/require.rs | 62 +-- ext/node/ops/worker_threads.rs | 40 +- ext/node/polyfills/01_require.js | 31 +- resolvers/deno/fs.rs | 10 - resolvers/deno/npm/byonm.rs | 41 +- resolvers/deno/npm/mod.rs | 1 + resolvers/deno/sloppy_imports.rs | 2 +- resolvers/node/analyze.rs | 50 ++- resolvers/node/errors.rs | 58 --- resolvers/node/lib.rs | 5 +- resolvers/node/npm.rs | 6 + resolvers/node/package_json.rs | 106 ++++- resolvers/node/resolution.rs | 196 ++-------- runtime/errors.rs | 14 +- runtime/shared.rs | 9 +- tests/integration/run_tests.rs | 3 +- .../@denotest/type-commonjs/1.0.0/index.js | 6 +- .../css_import/exists_run_with_check.out | 2 +- tests/specs/compile/cjs/__test__.jsonc | 24 ++ tests/specs/compile/cjs/add.cjs | 1 + tests/specs/compile/cjs/divide.cts | 1 + tests/specs/compile/cjs/main.js | 5 + tests/specs/compile/cjs/multiply.cts | 4 + tests/specs/compile/cjs/output.out | 2 + tests/specs/compile/cjs/reexport.cjs | 1 + tests/specs/compile/detect_cjs/__test__.jsonc | 11 +- tests/specs/compile/detect_cjs/add.js | 2 +- tests/specs/compile/detect_cjs/compile.out | 1 - tests/specs/compile/detect_cjs/output.out | 3 +- tests/specs/compile/detect_cjs/package.json | 5 +- tests/specs/compile/detect_cjs/subtract.ts | 2 + .../npm/require_type_commonjs/__test__.jsonc | 3 +- .../specs/npm/require_type_commonjs/main.out | 5 +- tests/specs/npm/require_type_commonjs/main.ts | 3 +- .../typescript_file_in_package/__test__.jsonc | 4 +- .../npm/typescript_file_in_package/main.out | 3 + .../{typescript_file_in_package => }/main.ts | 0 .../typescript_file_in_package/main.out | 6 - .../specs/run/cjs/main_module/__test__.jsonc | 4 + tests/specs/run/cjs/main_module/main.cjs | 1 + tests/specs/run/cjs/main_module/main.out | 5 + .../reexport_non_analyzable}/__test__.jsonc | 0 .../reexport_non_analyzable}/deno.json | 0 .../reexport_non_analyzable}/main.ts | 0 .../node_modules/foo.cjs | 0 tests/specs/run/cjs/unprepared/__test__.jsonc | 4 + tests/specs/run/cjs/unprepared/file.cjs | 7 + tests/specs/run/cjs/unprepared/main.out | 1 + tests/specs/run/cjs/unprepared/main.ts | 7 + tests/specs/run/cjs/unprepared/output.cjs | 3 + .../run/cts/cjs_import_cts/__test__.jsonc | 13 + .../add.js => cts/cjs_import_cts/add.cts} | 0 tests/specs/run/cts/cjs_import_cts/check.out | 17 + tests/specs/run/cts/cjs_import_cts/main.js | 3 + tests/specs/run/cts/cjs_import_cts/main.out | 1 + .../specs/run/cts/cjs_import_cts/subtract.cjs | 3 + .../cts/import_export_equals/__test__.jsonc | 17 + .../run/cts/import_export_equals/add.cts | 3 + .../run/cts/import_export_equals/main.cts | 3 + .../run/cts/import_export_equals/main.out | 2 + .../run/cts/import_export_equals/mod.mts | 3 + .../import_export_equals/mod.mts.check.out | 5 + .../run/cts/import_export_equals/mod.mts.out | 1 + tests/specs/run/cts/main/__test__.jsonc | 4 + tests/specs/run/cts/main/import_main.cjs | 1 + tests/specs/run/cts/main/main.cts | 5 + tests/specs/run/cts/main/main.out | 1 + .../commonjs/{ => basic}/__test__.jsonc | 0 .../package_json_type/commonjs/basic/add.js | 3 + .../commonjs/{ => basic}/deno.jsonc | 0 .../{ => basic}/import_import_meta.js | 0 .../commonjs/{ => basic}/import_meta.js | 0 .../commonjs/{ => basic}/main_cjs.js | 0 .../commonjs/{ => basic}/main_esm.js | 0 .../{ => basic}/main_esm_import_meta.js | 0 .../{ => basic}/main_esm_import_meta.out | 0 .../commonjs/{ => basic}/main_mix.js | 0 .../commonjs/{ => basic}/main_mix.out | 0 .../commonjs/{ => basic}/not_import_meta.js | 0 .../commonjs/{ => basic}/package.json | 0 .../commonjs/{ => basic}/tla.js | 0 .../commonjs/jsx/__test__.jsonc | 5 + .../run/package_json_type/commonjs/jsx/add.js | 3 + .../package_json_type/commonjs/jsx/deno.jsonc | 10 + .../package_json_type/commonjs/jsx/main.jsx | 7 + .../package_json_type/commonjs/jsx/main.out | 4 + .../commonjs/jsx/package.json | 7 + .../package_json_type/commonjs/jsx/tsx.tsx | 5 + tests/specs/run/remote_cjs_main/output.out | 2 +- tests/specs/run/require_esm/main.out | 2 +- .../npm/deno_run_cowsay_no_permissions.out | 2 +- 143 files changed, 2418 insertions(+), 1527 deletions(-) create mode 100644 tests/specs/compile/cjs/__test__.jsonc create mode 100644 tests/specs/compile/cjs/add.cjs create mode 100644 tests/specs/compile/cjs/divide.cts create mode 100644 tests/specs/compile/cjs/main.js create mode 100644 tests/specs/compile/cjs/multiply.cts create mode 100644 tests/specs/compile/cjs/output.out create mode 100644 tests/specs/compile/cjs/reexport.cjs create mode 100644 tests/specs/compile/detect_cjs/subtract.ts create mode 100644 tests/specs/npm/typescript_file_in_package/main.out rename tests/specs/npm/typescript_file_in_package/{typescript_file_in_package => }/main.ts (100%) delete mode 100644 tests/specs/npm/typescript_file_in_package/typescript_file_in_package/main.out create mode 100644 tests/specs/run/cjs/main_module/__test__.jsonc create mode 100644 tests/specs/run/cjs/main_module/main.cjs create mode 100644 tests/specs/run/cjs/main_module/main.out rename tests/specs/run/{cjs_reexport_non_analyzable => cjs/reexport_non_analyzable}/__test__.jsonc (100%) rename tests/specs/run/{cjs_reexport_non_analyzable => cjs/reexport_non_analyzable}/deno.json (100%) rename tests/specs/run/{cjs_reexport_non_analyzable => cjs/reexport_non_analyzable}/main.ts (100%) rename tests/specs/run/{cjs_reexport_non_analyzable => cjs/reexport_non_analyzable}/node_modules/foo.cjs (100%) create mode 100644 tests/specs/run/cjs/unprepared/__test__.jsonc create mode 100644 tests/specs/run/cjs/unprepared/file.cjs create mode 100644 tests/specs/run/cjs/unprepared/main.out create mode 100644 tests/specs/run/cjs/unprepared/main.ts create mode 100644 tests/specs/run/cjs/unprepared/output.cjs create mode 100644 tests/specs/run/cts/cjs_import_cts/__test__.jsonc rename tests/specs/run/{package_json_type/commonjs/add.js => cts/cjs_import_cts/add.cts} (100%) create mode 100644 tests/specs/run/cts/cjs_import_cts/check.out create mode 100644 tests/specs/run/cts/cjs_import_cts/main.js create mode 100644 tests/specs/run/cts/cjs_import_cts/main.out create mode 100644 tests/specs/run/cts/cjs_import_cts/subtract.cjs create mode 100644 tests/specs/run/cts/import_export_equals/__test__.jsonc create mode 100644 tests/specs/run/cts/import_export_equals/add.cts create mode 100644 tests/specs/run/cts/import_export_equals/main.cts create mode 100644 tests/specs/run/cts/import_export_equals/main.out create mode 100644 tests/specs/run/cts/import_export_equals/mod.mts create mode 100644 tests/specs/run/cts/import_export_equals/mod.mts.check.out create mode 100644 tests/specs/run/cts/import_export_equals/mod.mts.out create mode 100644 tests/specs/run/cts/main/__test__.jsonc create mode 100644 tests/specs/run/cts/main/import_main.cjs create mode 100644 tests/specs/run/cts/main/main.cts create mode 100644 tests/specs/run/cts/main/main.out rename tests/specs/run/package_json_type/commonjs/{ => basic}/__test__.jsonc (100%) create mode 100644 tests/specs/run/package_json_type/commonjs/basic/add.js rename tests/specs/run/package_json_type/commonjs/{ => basic}/deno.jsonc (100%) rename tests/specs/run/package_json_type/commonjs/{ => basic}/import_import_meta.js (100%) rename tests/specs/run/package_json_type/commonjs/{ => basic}/import_meta.js (100%) rename tests/specs/run/package_json_type/commonjs/{ => basic}/main_cjs.js (100%) rename tests/specs/run/package_json_type/commonjs/{ => basic}/main_esm.js (100%) rename tests/specs/run/package_json_type/commonjs/{ => basic}/main_esm_import_meta.js (100%) rename tests/specs/run/package_json_type/commonjs/{ => basic}/main_esm_import_meta.out (100%) rename tests/specs/run/package_json_type/commonjs/{ => basic}/main_mix.js (100%) rename tests/specs/run/package_json_type/commonjs/{ => basic}/main_mix.out (100%) rename tests/specs/run/package_json_type/commonjs/{ => basic}/not_import_meta.js (100%) rename tests/specs/run/package_json_type/commonjs/{ => basic}/package.json (100%) rename tests/specs/run/package_json_type/commonjs/{ => basic}/tla.js (100%) create mode 100644 tests/specs/run/package_json_type/commonjs/jsx/__test__.jsonc create mode 100644 tests/specs/run/package_json_type/commonjs/jsx/add.js create mode 100644 tests/specs/run/package_json_type/commonjs/jsx/deno.jsonc create mode 100644 tests/specs/run/package_json_type/commonjs/jsx/main.jsx create mode 100644 tests/specs/run/package_json_type/commonjs/jsx/main.out create mode 100644 tests/specs/run/package_json_type/commonjs/jsx/package.json create mode 100644 tests/specs/run/package_json_type/commonjs/jsx/tsx.tsx diff --git a/Cargo.lock b/Cargo.lock index e0780b2268..8c7b35ca9f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1279,9 +1279,9 @@ dependencies = [ [[package]] name = "deno_ast" -version = "0.42.2" +version = "0.43.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b9d03b1bbeeecdac54367f075d572131736d06c5be3bc49037855bc5ab1bbb" +checksum = "48d00b724e06d2081a141ec1155756a0b465d413d8e2a7515221f61d482eb2ee" dependencies = [ "base64 0.21.7", "deno_media_type", @@ -1356,9 +1356,9 @@ dependencies = [ [[package]] name = "deno_cache_dir" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693ca429aebf945de5fef30df232044f9f80be4cc5a5e7c8d767226c43880f5a" +checksum = "08c1f52170cd7715f8006da54cde1444863a0d6fbd9c11d037a737db2dec8e22" dependencies = [ "base32", "deno_media_type", @@ -1506,9 +1506,9 @@ dependencies = [ [[package]] name = "deno_doc" -version = "0.154.0" +version = "0.156.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17e204e45b0d79750880114e37b34abe19ad0710d8435a8da8f23a528fe98de4" +checksum = "2585b98d6ad76dae30bf2d7b6d71b8363cae041158b8780d14a2f4fe17590a61" dependencies = [ "anyhow", "cfg-if", @@ -1606,9 +1606,9 @@ dependencies = [ [[package]] name = "deno_graph" -version = "0.83.4" +version = "0.84.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd20bc0780071989c622cbfd5d4fb2e4fd05a247ccd7f791f13c8d2c3792228" +checksum = "cd4f4a14aa069087be41c2998077b0453f0191747898f96e6343f700abfc2c18" dependencies = [ "anyhow", "async-trait", @@ -1726,9 +1726,9 @@ dependencies = [ [[package]] name = "deno_lint" -version = "0.67.0" +version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "871b60e32bfb6c110cbb9b0688dbf048f81e5d347fe4ce5a42239263de9dd938" +checksum = "bb994e6d1b18223df0a756c7948143b35682941d615edffef60d5b38822f38ac" dependencies = [ "anyhow", "deno_ast", @@ -1756,9 +1756,9 @@ dependencies = [ [[package]] name = "deno_media_type" -version = "0.1.4" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8978229b82552bf8457a0125aa20863f023619cfc21ebb007b1e571d68fd85b" +checksum = "7fcf552fbdedbe81c89705349d7d2485c7051382b000dfddbdbf7fc25931cf83" dependencies = [ "data-url", "serde", @@ -2608,9 +2608,9 @@ dependencies = [ [[package]] name = "dprint-plugin-typescript" -version = "0.93.0" +version = "0.93.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9308d98b923b7c0335c2ee1560199e3f2321b1be82803107b4ba4ed5dac46cc" +checksum = "5abfd78fe3cde4f5a6699d65f760c8d44da130cf446b6f80a7a9bc6580e156ab" dependencies = [ "anyhow", "deno_ast", diff --git a/Cargo.toml b/Cargo.toml index 285c077809..f57563e0b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,12 +45,12 @@ license = "MIT" repository = "https://github.com/denoland/deno" [workspace.dependencies] -deno_ast = { version = "=0.42.2", features = ["transpiling"] } +deno_ast = { version = "=0.43.3", features = ["transpiling"] } deno_core = { version = "0.316.0" } deno_bench_util = { version = "0.169.0", path = "./bench_util" } deno_lockfile = "=0.23.1" -deno_media_type = { version = "0.1.4", features = ["module_specifier"] } +deno_media_type = { version = "0.2.0", features = ["module_specifier"] } deno_npm = "=0.25.4" deno_path_util = "=0.2.1" deno_permissions = { version = "0.35.0", path = "./runtime/permissions" } @@ -111,7 +111,7 @@ console_static_text = "=0.8.1" dashmap = "5.5.3" data-encoding = "2.3.3" data-url = "=0.3.0" -deno_cache_dir = "=0.13.1" +deno_cache_dir = "=0.13.2" deno_package_json = { version = "0.1.2", default-features = false } dlopen2 = "0.6.1" ecb = "=0.1.2" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 782adfd903..a3e2b71f00 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -72,9 +72,9 @@ deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposa deno_cache_dir = { workspace = true } deno_config = { version = "=0.37.2", features = ["workspace", "sync"] } deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] } -deno_doc = { version = "0.154.0", default-features = false, features = ["rust", "html", "syntect"] } -deno_graph = { version = "=0.83.4" } -deno_lint = { version = "=0.67.0", features = ["docs"] } +deno_doc = { version = "0.156.0", default-features = false, features = ["rust", "html", "syntect"] } +deno_graph = { version = "=0.84.1" } +deno_lint = { version = "=0.68.0", features = ["docs"] } deno_lockfile.workspace = true deno_npm.workspace = true deno_package_json.workspace = true @@ -107,7 +107,7 @@ dotenvy = "0.15.7" dprint-plugin-json = "=0.19.4" dprint-plugin-jupyter = "=0.1.5" dprint-plugin-markdown = "=0.17.8" -dprint-plugin-typescript = "=0.93.0" +dprint-plugin-typescript = "=0.93.1" env_logger = "=0.10.0" fancy-regex = "=0.10.0" faster-hex.workspace = true diff --git a/cli/args/mod.rs b/cli/args/mod.rs index d725264623..e19025f8b1 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -201,6 +201,8 @@ pub fn ts_config_to_transpile_and_emit_options( precompile_jsx_dynamic_props: None, transform_jsx, var_decl_imports: false, + // todo(dsherret): support verbatim_module_syntax here properly + verbatim_module_syntax: false, }, deno_ast::EmitOptions { inline_sources: options.inline_sources, @@ -1602,6 +1604,15 @@ impl CliOptions { } pub fn use_byonm(&self) -> bool { + if matches!( + self.sub_command(), + DenoSubcommand::Install(_) + | DenoSubcommand::Add(_) + | DenoSubcommand::Remove(_) + ) { + // For `deno install/add/remove` we want to force the managed resolver so it can set up `node_modules/` directory. + return false; + } if self.node_modules_dir().ok().flatten().is_none() && self.maybe_node_modules_folder.is_some() && self diff --git a/cli/cache/cache_db.rs b/cli/cache/cache_db.rs index b24078f29b..329ed2d970 100644 --- a/cli/cache/cache_db.rs +++ b/cli/cache/cache_db.rs @@ -57,7 +57,7 @@ impl rusqlite::types::FromSql for CacheDBHash { } /// What should the cache should do on failure? -#[derive(Default)] +#[derive(Debug, Default)] pub enum CacheFailure { /// Return errors if failure mode otherwise unspecified. #[default] @@ -69,6 +69,7 @@ pub enum CacheFailure { } /// Configuration SQL and other parameters for a [`CacheDB`]. +#[derive(Debug)] pub struct CacheDBConfiguration { /// SQL to run for a new database. pub table_initializer: &'static str, @@ -98,6 +99,7 @@ impl CacheDBConfiguration { } } +#[derive(Debug)] enum ConnectionState { Connected(Connection), Blackhole, @@ -106,7 +108,7 @@ enum ConnectionState { /// A cache database that eagerly initializes itself off-thread, preventing initialization operations /// from blocking the main thread. -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct CacheDB { // TODO(mmastrac): We can probably simplify our thread-safe implementation here conn: Arc>>, diff --git a/cli/cache/emit.rs b/cli/cache/emit.rs index 74e1c1101b..3c9eecfcbd 100644 --- a/cli/cache/emit.rs +++ b/cli/cache/emit.rs @@ -10,6 +10,7 @@ use deno_core::unsync::sync::AtomicFlag; use super::DiskCache; /// The cache that stores previously emitted files. +#[derive(Debug)] pub struct EmitCache { disk_cache: DiskCache, emit_failed_flag: AtomicFlag, @@ -91,6 +92,7 @@ impl EmitCache { const LAST_LINE_PREFIX: &str = "\n// denoCacheMetadata="; +#[derive(Debug)] struct EmitFileSerializer { cli_version: &'static str, } diff --git a/cli/cache/mod.rs b/cli/cache/mod.rs index bf8f1b1f0b..50fc135ddf 100644 --- a/cli/cache/mod.rs +++ b/cli/cache/mod.rs @@ -8,14 +8,9 @@ use crate::file_fetcher::FetchOptions; use crate::file_fetcher::FetchPermissionsOptionRef; use crate::file_fetcher::FileFetcher; use crate::file_fetcher::FileOrRedirect; -use crate::npm::CliNpmResolver; -use crate::resolver::CliNodeResolver; use crate::util::fs::atomic_write_file_with_retries; use crate::util::fs::atomic_write_file_with_retries_and_fs; use crate::util::fs::AtomicWriteFileFsAdapter; -use crate::util::path::specifier_has_extension; -use crate::util::text_encoding::arc_str_to_bytes; -use crate::util::text_encoding::from_utf8_lossy_owned; use deno_ast::MediaType; use deno_core::futures; @@ -25,7 +20,9 @@ use deno_graph::source::CacheInfo; use deno_graph::source::LoadFuture; use deno_graph::source::LoadResponse; use deno_graph::source::Loader; +use deno_runtime::deno_fs; use deno_runtime::deno_permissions::PermissionsContainer; +use node_resolver::InNpmPackageChecker; use std::collections::HashMap; use std::path::Path; use std::path::PathBuf; @@ -60,7 +57,6 @@ pub use fast_check::FastCheckCache; pub use incremental::IncrementalCache; pub use module_info::ModuleInfoCache; pub use node::NodeAnalysisCache; -pub use parsed_source::EsmOrCjsChecker; pub use parsed_source::LazyGraphSourceParser; pub use parsed_source::ParsedSourceCache; @@ -181,46 +177,40 @@ pub struct FetchCacherOptions { pub permissions: PermissionsContainer, /// If we're publishing for `deno publish`. pub is_deno_publish: bool, - pub unstable_detect_cjs: bool, } /// A "wrapper" for the FileFetcher and DiskCache for the Deno CLI that provides /// a concise interface to the DENO_DIR when building module graphs. pub struct FetchCacher { pub file_header_overrides: HashMap>, - esm_or_cjs_checker: Arc, file_fetcher: Arc, + fs: Arc, global_http_cache: Arc, - node_resolver: Arc, - npm_resolver: Arc, + in_npm_pkg_checker: Arc, module_info_cache: Arc, permissions: PermissionsContainer, is_deno_publish: bool, - unstable_detect_cjs: bool, cache_info_enabled: bool, } impl FetchCacher { pub fn new( - esm_or_cjs_checker: Arc, file_fetcher: Arc, + fs: Arc, global_http_cache: Arc, - node_resolver: Arc, - npm_resolver: Arc, + in_npm_pkg_checker: Arc, module_info_cache: Arc, options: FetchCacherOptions, ) -> Self { Self { file_fetcher, - esm_or_cjs_checker, + fs, global_http_cache, - node_resolver, - npm_resolver, + in_npm_pkg_checker, module_info_cache, file_header_overrides: options.file_header_overrides, permissions: options.permissions, is_deno_publish: options.is_deno_publish, - unstable_detect_cjs: options.unstable_detect_cjs, cache_info_enabled: false, } } @@ -271,70 +261,23 @@ impl Loader for FetchCacher { ) -> LoadFuture { use deno_graph::source::CacheSetting as LoaderCacheSetting; - if specifier.scheme() == "file" { - if specifier.path().contains("/node_modules/") { - // The specifier might be in a completely different symlinked tree than - // what the node_modules url is in (ex. `/my-project-1/node_modules` - // symlinked to `/my-project-2/node_modules`), so first we checked if the path - // is in a node_modules dir to avoid needlessly canonicalizing, then now compare - // against the canonicalized specifier. - let specifier = - crate::node::resolve_specifier_into_node_modules(specifier); - if self.npm_resolver.in_npm_package(&specifier) { - return Box::pin(futures::future::ready(Ok(Some( - LoadResponse::External { specifier }, - )))); - } - } - - // make local CJS modules external to the graph - if specifier_has_extension(specifier, "cjs") { + if specifier.scheme() == "file" + && specifier.path().contains("/node_modules/") + { + // The specifier might be in a completely different symlinked tree than + // what the node_modules url is in (ex. `/my-project-1/node_modules` + // symlinked to `/my-project-2/node_modules`), so first we checked if the path + // is in a node_modules dir to avoid needlessly canonicalizing, then now compare + // against the canonicalized specifier. + let specifier = crate::node::resolve_specifier_into_node_modules( + specifier, + self.fs.as_ref(), + ); + if self.in_npm_pkg_checker.in_npm_package(&specifier) { return Box::pin(futures::future::ready(Ok(Some( - LoadResponse::External { - specifier: specifier.clone(), - }, + LoadResponse::External { specifier }, )))); } - - if self.unstable_detect_cjs && specifier_has_extension(specifier, "js") { - if let Ok(Some(pkg_json)) = - self.node_resolver.get_closest_package_json(specifier) - { - if pkg_json.typ == "commonjs" { - if let Ok(path) = specifier.to_file_path() { - if let Ok(bytes) = std::fs::read(&path) { - let text: Arc = from_utf8_lossy_owned(bytes).into(); - let is_es_module = match self.esm_or_cjs_checker.is_esm( - specifier, - text.clone(), - MediaType::JavaScript, - ) { - Ok(value) => value, - Err(err) => { - return Box::pin(futures::future::ready(Err(err.into()))); - } - }; - if !is_es_module { - self.node_resolver.mark_cjs_resolution(specifier.clone()); - return Box::pin(futures::future::ready(Ok(Some( - LoadResponse::External { - specifier: specifier.clone(), - }, - )))); - } else { - return Box::pin(futures::future::ready(Ok(Some( - LoadResponse::Module { - specifier: specifier.clone(), - content: arc_str_to_bytes(text), - maybe_headers: None, - }, - )))); - } - } - } - } - } - } } if self.is_deno_publish diff --git a/cli/cache/module_info.rs b/cli/cache/module_info.rs index 4dbb01c37b..060a6f4f0c 100644 --- a/cli/cache/module_info.rs +++ b/cli/cache/module_info.rs @@ -44,18 +44,32 @@ pub static MODULE_INFO_CACHE_DB: CacheDBConfiguration = CacheDBConfiguration { /// A cache of `deno_graph::ModuleInfo` objects. Using this leads to a considerable /// performance improvement because when it exists we can skip parsing a module for /// deno_graph. +#[derive(Debug)] pub struct ModuleInfoCache { conn: CacheDB, + parsed_source_cache: Arc, } impl ModuleInfoCache { #[cfg(test)] - pub fn new_in_memory(version: &'static str) -> Self { - Self::new(CacheDB::in_memory(&MODULE_INFO_CACHE_DB, version)) + pub fn new_in_memory( + version: &'static str, + parsed_source_cache: Arc, + ) -> Self { + Self::new( + CacheDB::in_memory(&MODULE_INFO_CACHE_DB, version), + parsed_source_cache, + ) } - pub fn new(conn: CacheDB) -> Self { - Self { conn } + pub fn new( + conn: CacheDB, + parsed_source_cache: Arc, + ) -> Self { + Self { + conn, + parsed_source_cache, + } } /// Useful for testing: re-create this cache DB with a different current version. @@ -63,6 +77,7 @@ impl ModuleInfoCache { pub(crate) fn recreate_with_version(self, version: &'static str) -> Self { Self { conn: self.conn.recreate_with_version(version), + parsed_source_cache: self.parsed_source_cache, } } @@ -113,13 +128,10 @@ impl ModuleInfoCache { Ok(()) } - pub fn as_module_analyzer<'a>( - &'a self, - parsed_source_cache: &'a Arc, - ) -> ModuleInfoCacheModuleAnalyzer<'a> { + pub fn as_module_analyzer(&self) -> ModuleInfoCacheModuleAnalyzer { ModuleInfoCacheModuleAnalyzer { module_info_cache: self, - parsed_source_cache, + parsed_source_cache: &self.parsed_source_cache, } } } @@ -129,6 +141,84 @@ pub struct ModuleInfoCacheModuleAnalyzer<'a> { parsed_source_cache: &'a Arc, } +impl<'a> ModuleInfoCacheModuleAnalyzer<'a> { + fn load_cached_module_info( + &self, + specifier: &ModuleSpecifier, + media_type: MediaType, + source_hash: CacheDBHash, + ) -> Option { + match self.module_info_cache.get_module_info( + specifier, + media_type, + source_hash, + ) { + Ok(Some(info)) => Some(info), + Ok(None) => None, + Err(err) => { + log::debug!( + "Error loading module cache info for {}. {:#}", + specifier, + err + ); + None + } + } + } + + fn save_module_info_to_cache( + &self, + specifier: &ModuleSpecifier, + media_type: MediaType, + source_hash: CacheDBHash, + module_info: &ModuleInfo, + ) { + if let Err(err) = self.module_info_cache.set_module_info( + specifier, + media_type, + source_hash, + module_info, + ) { + log::debug!( + "Error saving module cache info for {}. {:#}", + specifier, + err + ); + } + } + + pub fn analyze_sync( + &self, + specifier: &ModuleSpecifier, + media_type: MediaType, + source: &Arc, + ) -> Result { + // attempt to load from the cache + let source_hash = CacheDBHash::from_source(source); + if let Some(info) = + self.load_cached_module_info(specifier, media_type, source_hash) + { + return Ok(info); + } + + // otherwise, get the module info from the parsed source cache + let parser = self.parsed_source_cache.as_capturing_parser(); + let analyzer = ParserModuleAnalyzer::new(&parser); + let module_info = + analyzer.analyze_sync(specifier, source.clone(), media_type)?; + + // then attempt to cache it + self.save_module_info_to_cache( + specifier, + media_type, + source_hash, + &module_info, + ); + + Ok(module_info) + } +} + #[async_trait::async_trait(?Send)] impl<'a> deno_graph::ModuleAnalyzer for ModuleInfoCacheModuleAnalyzer<'a> { async fn analyze( @@ -139,20 +229,10 @@ impl<'a> deno_graph::ModuleAnalyzer for ModuleInfoCacheModuleAnalyzer<'a> { ) -> Result { // attempt to load from the cache let source_hash = CacheDBHash::from_source(&source); - match self.module_info_cache.get_module_info( - specifier, - media_type, - source_hash, - ) { - Ok(Some(info)) => return Ok(info), - Ok(None) => {} - Err(err) => { - log::debug!( - "Error loading module cache info for {}. {:#}", - specifier, - err - ); - } + if let Some(info) = + self.load_cached_module_info(specifier, media_type, source_hash) + { + return Ok(info); } // otherwise, get the module info from the parsed source cache @@ -169,18 +249,12 @@ impl<'a> deno_graph::ModuleAnalyzer for ModuleInfoCacheModuleAnalyzer<'a> { .unwrap()?; // then attempt to cache it - if let Err(err) = self.module_info_cache.set_module_info( + self.save_module_info_to_cache( specifier, media_type, source_hash, &module_info, - ) { - log::debug!( - "Error saving module cache info for {}. {:#}", - specifier, - err - ); - } + ); Ok(module_info) } @@ -202,7 +276,7 @@ fn serialize_media_type(media_type: MediaType) -> i64 { Tsx => 11, Json => 12, Wasm => 13, - TsBuildInfo => 14, + Css => 14, SourceMap => 15, Unknown => 16, } @@ -217,7 +291,7 @@ mod test { #[test] pub fn module_info_cache_general_use() { - let cache = ModuleInfoCache::new_in_memory("1.0.0"); + let cache = ModuleInfoCache::new_in_memory("1.0.0", Default::default()); let specifier1 = ModuleSpecifier::parse("https://localhost/mod.ts").unwrap(); let specifier2 = diff --git a/cli/cache/parsed_source.rs b/cli/cache/parsed_source.rs index df6e45c35e..7e819ae998 100644 --- a/cli/cache/parsed_source.rs +++ b/cli/cache/parsed_source.rs @@ -5,12 +5,11 @@ use std::sync::Arc; use deno_ast::MediaType; use deno_ast::ModuleSpecifier; -use deno_ast::ParseDiagnostic; use deno_ast::ParsedSource; use deno_core::parking_lot::Mutex; -use deno_graph::CapturingModuleParser; -use deno_graph::DefaultModuleParser; -use deno_graph::ModuleParser; +use deno_graph::CapturingEsParser; +use deno_graph::DefaultEsParser; +use deno_graph::EsParser; use deno_graph::ParseOptions; use deno_graph::ParsedSourceStore; @@ -47,7 +46,7 @@ impl<'a> LazyGraphSourceParser<'a> { } } -#[derive(Default)] +#[derive(Debug, Default)] pub struct ParsedSourceCache { sources: Mutex>, } @@ -58,12 +57,11 @@ impl ParsedSourceCache { module: &deno_graph::JsModule, ) -> Result { let parser = self.as_capturing_parser(); - // this will conditionally parse because it's using a CapturingModuleParser - parser.parse_module(ParseOptions { + // this will conditionally parse because it's using a CapturingEsParser + parser.parse_program(ParseOptions { specifier: &module.specifier, source: module.source.clone(), media_type: module.media_type, - // don't bother enabling because this method is currently only used for vendoring scope_analysis: false, }) } @@ -87,10 +85,9 @@ impl ParsedSourceCache { specifier, source, media_type, - // don't bother enabling because this method is currently only used for emitting scope_analysis: false, }; - DefaultModuleParser.parse_module(options) + DefaultEsParser.parse_program(options) } /// Frees the parsed source from memory. @@ -100,8 +97,8 @@ impl ParsedSourceCache { /// Creates a parser that will reuse a ParsedSource from the store /// if it exists, or else parse. - pub fn as_capturing_parser(&self) -> CapturingModuleParser { - CapturingModuleParser::new(None, self) + pub fn as_capturing_parser(&self) -> CapturingEsParser { + CapturingEsParser::new(None, self) } } @@ -150,42 +147,3 @@ impl deno_graph::ParsedSourceStore for ParsedSourceCache { } } } - -pub struct EsmOrCjsChecker { - parsed_source_cache: Arc, -} - -impl EsmOrCjsChecker { - pub fn new(parsed_source_cache: Arc) -> Self { - Self { - parsed_source_cache, - } - } - - pub fn is_esm( - &self, - specifier: &ModuleSpecifier, - source: Arc, - media_type: MediaType, - ) -> Result { - // todo(dsherret): add a file cache here to avoid parsing with swc on each run - let source = match self.parsed_source_cache.get_parsed_source(specifier) { - Some(source) => source.clone(), - None => { - let source = deno_ast::parse_program(deno_ast::ParseParams { - specifier: specifier.clone(), - text: source, - media_type, - capture_tokens: true, // capture because it's used for cjs export analysis - scope_analysis: false, - maybe_syntax: None, - })?; - self - .parsed_source_cache - .set_parsed_source(specifier.clone(), source.clone()); - source - } - }; - Ok(source.is_module()) - } -} diff --git a/cli/emit.rs b/cli/emit.rs index 8e93092e67..8c4f2091cf 100644 --- a/cli/emit.rs +++ b/cli/emit.rs @@ -3,11 +3,14 @@ use crate::cache::EmitCache; use crate::cache::FastInsecureHasher; use crate::cache::ParsedSourceCache; +use crate::resolver::CjsTracker; +use deno_ast::ModuleKind; use deno_ast::SourceMapOption; use deno_ast::SourceRange; use deno_ast::SourceRanged; use deno_ast::SourceRangedForSpanned; +use deno_ast::TranspileModuleOptions; use deno_ast::TranspileResult; use deno_core::error::AnyError; use deno_core::futures::stream::FuturesUnordered; @@ -19,7 +22,9 @@ use deno_graph::Module; use deno_graph::ModuleGraph; use std::sync::Arc; +#[derive(Debug)] pub struct Emitter { + cjs_tracker: Arc, emit_cache: Arc, parsed_source_cache: Arc, transpile_and_emit_options: @@ -30,6 +35,7 @@ pub struct Emitter { impl Emitter { pub fn new( + cjs_tracker: Arc, emit_cache: Arc, parsed_source_cache: Arc, transpile_options: deno_ast::TranspileOptions, @@ -42,6 +48,7 @@ impl Emitter { hasher.finish() }; Self { + cjs_tracker, emit_cache, parsed_source_cache, transpile_and_emit_options: Arc::new((transpile_options, emit_options)), @@ -59,21 +66,19 @@ impl Emitter { continue; }; - // todo(https://github.com/denoland/deno_media_type/pull/12): use is_emittable() - let is_emittable = matches!( - module.media_type, - MediaType::TypeScript - | MediaType::Mts - | MediaType::Cts - | MediaType::Jsx - | MediaType::Tsx - ); - if is_emittable { + if module.media_type.is_emittable() { futures.push( self .emit_parsed_source( &module.specifier, module.media_type, + ModuleKind::from_is_cjs( + self.cjs_tracker.is_cjs_with_known_is_script( + &module.specifier, + module.media_type, + module.is_script, + )?, + ), &module.source, ) .boxed_local(), @@ -92,9 +97,10 @@ impl Emitter { pub fn maybe_cached_emit( &self, specifier: &ModuleSpecifier, + module_kind: deno_ast::ModuleKind, source: &str, ) -> Option { - let source_hash = self.get_source_hash(source); + let source_hash = self.get_source_hash(module_kind, source); self.emit_cache.get_emit_code(specifier, source_hash) } @@ -102,11 +108,12 @@ impl Emitter { &self, specifier: &ModuleSpecifier, media_type: MediaType, + module_kind: deno_ast::ModuleKind, source: &Arc, ) -> Result { // Note: keep this in sync with the sync version below let helper = EmitParsedSourceHelper(self); - match helper.pre_emit_parsed_source(specifier, source) { + match helper.pre_emit_parsed_source(specifier, module_kind, source) { PreEmitResult::Cached(emitted_text) => Ok(emitted_text), PreEmitResult::NotCached { source_hash } => { let parsed_source_cache = self.parsed_source_cache.clone(); @@ -119,8 +126,9 @@ impl Emitter { EmitParsedSourceHelper::transpile( &parsed_source_cache, &specifier, - source.clone(), media_type, + module_kind, + source.clone(), &transpile_and_emit_options.0, &transpile_and_emit_options.1, ) @@ -142,18 +150,20 @@ impl Emitter { &self, specifier: &ModuleSpecifier, media_type: MediaType, + module_kind: deno_ast::ModuleKind, source: &Arc, ) -> Result { // Note: keep this in sync with the async version above let helper = EmitParsedSourceHelper(self); - match helper.pre_emit_parsed_source(specifier, source) { + match helper.pre_emit_parsed_source(specifier, module_kind, source) { PreEmitResult::Cached(emitted_text) => Ok(emitted_text), PreEmitResult::NotCached { source_hash } => { let transpiled_source = EmitParsedSourceHelper::transpile( &self.parsed_source_cache, specifier, - source.clone(), media_type, + module_kind, + source.clone(), &self.transpile_and_emit_options.0, &self.transpile_and_emit_options.1, )?; @@ -171,6 +181,7 @@ impl Emitter { pub async fn load_and_emit_for_hmr( &self, specifier: &ModuleSpecifier, + module_kind: deno_ast::ModuleKind, ) -> Result { let media_type = MediaType::from_specifier(specifier); let source_code = tokio::fs::read_to_string( @@ -193,9 +204,14 @@ impl Emitter { let mut options = self.transpile_and_emit_options.1.clone(); options.source_map = SourceMapOption::None; let transpiled_source = parsed_source - .transpile(&self.transpile_and_emit_options.0, &options)? - .into_source() - .into_string()?; + .transpile( + &self.transpile_and_emit_options.0, + &deno_ast::TranspileModuleOptions { + module_kind: Some(module_kind), + }, + &options, + )? + .into_source(); Ok(transpiled_source.text) } MediaType::JavaScript @@ -206,7 +222,7 @@ impl Emitter { | MediaType::Dcts | MediaType::Json | MediaType::Wasm - | MediaType::TsBuildInfo + | MediaType::Css | MediaType::SourceMap | MediaType::Unknown => { // clear this specifier from the parsed source cache as it's now out of date @@ -219,10 +235,11 @@ impl Emitter { /// A hashing function that takes the source code and uses the global emit /// options then generates a string hash which can be stored to /// determine if the cached emit is valid or not. - fn get_source_hash(&self, source_text: &str) -> u64 { + fn get_source_hash(&self, module_kind: ModuleKind, source_text: &str) -> u64 { FastInsecureHasher::new_without_deno_version() // stored in the transpile_and_emit_options_hash .write_str(source_text) .write_u64(self.transpile_and_emit_options_hash) + .write_hashable(module_kind) .finish() } } @@ -239,9 +256,10 @@ impl<'a> EmitParsedSourceHelper<'a> { pub fn pre_emit_parsed_source( &self, specifier: &ModuleSpecifier, + module_kind: deno_ast::ModuleKind, source: &Arc, ) -> PreEmitResult { - let source_hash = self.0.get_source_hash(source); + let source_hash = self.0.get_source_hash(module_kind, source); if let Some(emit_code) = self.0.emit_cache.get_emit_code(specifier, source_hash) @@ -255,8 +273,9 @@ impl<'a> EmitParsedSourceHelper<'a> { pub fn transpile( parsed_source_cache: &ParsedSourceCache, specifier: &ModuleSpecifier, - source: Arc, media_type: MediaType, + module_kind: deno_ast::ModuleKind, + source: Arc, transpile_options: &deno_ast::TranspileOptions, emit_options: &deno_ast::EmitOptions, ) -> Result { @@ -265,8 +284,13 @@ impl<'a> EmitParsedSourceHelper<'a> { let parsed_source = parsed_source_cache .remove_or_parse_module(specifier, source, media_type)?; ensure_no_import_assertion(&parsed_source)?; - let transpile_result = - parsed_source.transpile(transpile_options, emit_options)?; + let transpile_result = parsed_source.transpile( + transpile_options, + &TranspileModuleOptions { + module_kind: Some(module_kind), + }, + emit_options, + )?; let transpiled_source = match transpile_result { TranspileResult::Owned(source) => source, TranspileResult::Cloned(source) => { @@ -275,8 +299,7 @@ impl<'a> EmitParsedSourceHelper<'a> { } }; debug_assert!(transpiled_source.source_map.is_none()); - let text = String::from_utf8(transpiled_source.source)?; - Ok(text) + Ok(transpiled_source.text) } pub fn post_emit_parsed_source( @@ -321,7 +344,7 @@ fn ensure_no_import_assertion( deno_core::anyhow::anyhow!("{}", msg) } - let Some(module) = parsed_source.program_ref().as_module() else { + let deno_ast::ProgramRef::Module(module) = parsed_source.program_ref() else { return Ok(()); }; diff --git a/cli/factory.rs b/cli/factory.rs index d5ef4fd8b3..4a36c75ba2 100644 --- a/cli/factory.rs +++ b/cli/factory.rs @@ -11,10 +11,10 @@ use crate::args::StorageKeyResolver; use crate::args::TsConfigType; use crate::cache::Caches; use crate::cache::CodeCache; +use crate::cache::DenoCacheEnvFsAdapter; use crate::cache::DenoDir; use crate::cache::DenoDirProvider; use crate::cache::EmitCache; -use crate::cache::EsmOrCjsChecker; use crate::cache::GlobalHttpCache; use crate::cache::HttpCache; use crate::cache::LocalHttpCache; @@ -33,12 +33,16 @@ use crate::module_loader::ModuleLoadPreparer; use crate::node::CliCjsCodeAnalyzer; use crate::node::CliNodeCodeTranslator; use crate::npm::create_cli_npm_resolver; +use crate::npm::create_in_npm_pkg_checker; use crate::npm::CliByonmNpmResolverCreateOptions; +use crate::npm::CliManagedInNpmPkgCheckerCreateOptions; +use crate::npm::CliManagedNpmResolverCreateOptions; use crate::npm::CliNpmResolver; use crate::npm::CliNpmResolverCreateOptions; -use crate::npm::CliNpmResolverManagedCreateOptions; use crate::npm::CliNpmResolverManagedSnapshotOption; -use crate::resolver::CjsResolutionStore; +use crate::npm::CreateInNpmPkgCheckerOptions; +use crate::resolver::CjsTracker; +use crate::resolver::CjsTrackerOptions; use crate::resolver::CliDenoResolverFs; use crate::resolver::CliGraphResolver; use crate::resolver::CliGraphResolverOptions; @@ -51,6 +55,7 @@ use crate::tools::check::TypeChecker; use crate::tools::coverage::CoverageCollector; use crate::tools::lint::LintRuleProvider; use crate::tools::run::hmr::HmrRunner; +use crate::tsc::TypeCheckingCjsTracker; use crate::util::file_watcher::WatcherCommunicator; use crate::util::fs::canonicalize_path_maybe_not_exists; use crate::util::progress_bar::ProgressBar; @@ -59,6 +64,7 @@ use crate::worker::CliMainWorkerFactory; use crate::worker::CliMainWorkerOptions; use std::path::PathBuf; +use deno_cache_dir::npm::NpmCacheDir; use deno_config::workspace::PackageJsonDepResolution; use deno_config::workspace::WorkspaceResolver; use deno_core::error::AnyError; @@ -68,6 +74,7 @@ use deno_core::FeatureChecker; use deno_runtime::deno_fs; use deno_runtime::deno_node::DenoFsNodeResolverEnv; use deno_runtime::deno_node::NodeResolver; +use deno_runtime::deno_node::PackageJsonResolver; use deno_runtime::deno_permissions::Permissions; use deno_runtime::deno_permissions::PermissionsContainer; use deno_runtime::deno_tls::rustls::RootCertStore; @@ -77,6 +84,7 @@ use deno_runtime::inspector_server::InspectorServer; use deno_runtime::permissions::RuntimePermissionDescriptorParser; use log::warn; use node_resolver::analyze::NodeCodeTranslator; +use node_resolver::InNpmPackageChecker; use once_cell::sync::OnceCell; use std::future::Future; use std::sync::Arc; @@ -164,39 +172,41 @@ impl Deferred { #[derive(Default)] struct CliFactoryServices { - cli_options: Deferred>, + blob_store: Deferred>, caches: Deferred>, + cjs_tracker: Deferred>, + cli_node_resolver: Deferred>, + cli_options: Deferred>, + code_cache: Deferred>, + emit_cache: Deferred>, + emitter: Deferred>, + feature_checker: Deferred>, file_fetcher: Deferred>, + fs: Deferred>, global_http_cache: Deferred>, http_cache: Deferred>, http_client_provider: Deferred>, - emit_cache: Deferred>, - emitter: Deferred>, - esm_or_cjs_checker: Deferred>, - fs: Deferred>, + in_npm_pkg_checker: Deferred>, main_graph_container: Deferred>, - maybe_inspector_server: Deferred>>, - root_cert_store_provider: Deferred>, - blob_store: Deferred>, - module_info_cache: Deferred>, - parsed_source_cache: Deferred>, - resolver: Deferred>, maybe_file_watcher_reporter: Deferred>, + maybe_inspector_server: Deferred>>, module_graph_builder: Deferred>, module_graph_creator: Deferred>, + module_info_cache: Deferred>, module_load_preparer: Deferred>, node_code_translator: Deferred>, node_resolver: Deferred>, + npm_cache_dir: Deferred>, npm_resolver: Deferred>, + parsed_source_cache: Deferred>, permission_desc_parser: Deferred>, + pkg_json_resolver: Deferred>, + resolver: Deferred>, + root_cert_store_provider: Deferred>, root_permissions_container: Deferred, sloppy_imports_resolver: Deferred>>, text_only_progress_bar: Deferred, type_checker: Deferred>, - cjs_resolutions: Deferred>, - cli_node_resolver: Deferred>, - feature_checker: Deferred>, - code_cache: Deferred>, workspace_resolver: Deferred>, } @@ -300,12 +310,6 @@ impl CliFactory { .get_or_init(|| ProgressBar::new(ProgressBarStyle::TextOnly)) } - pub fn esm_or_cjs_checker(&self) -> &Arc { - self.services.esm_or_cjs_checker.get_or_init(|| { - Arc::new(EsmOrCjsChecker::new(self.parsed_source_cache().clone())) - }) - } - pub fn global_http_cache(&self) -> Result<&Arc, AnyError> { self.services.global_http_cache.get_or_try_init(|| { Ok(Arc::new(GlobalHttpCache::new( @@ -359,56 +363,112 @@ impl CliFactory { self.services.fs.get_or_init(|| Arc::new(deno_fs::RealFs)) } + pub fn in_npm_pkg_checker( + &self, + ) -> Result<&Arc, AnyError> { + self.services.in_npm_pkg_checker.get_or_try_init(|| { + let cli_options = self.cli_options()?; + let options = if cli_options.use_byonm() { + CreateInNpmPkgCheckerOptions::Byonm + } else { + CreateInNpmPkgCheckerOptions::Managed( + CliManagedInNpmPkgCheckerCreateOptions { + root_cache_dir_url: self.npm_cache_dir()?.root_dir_url(), + maybe_node_modules_path: cli_options + .node_modules_dir_path() + .map(|p| p.as_path()), + }, + ) + }; + Ok(create_in_npm_pkg_checker(options)) + }) + } + + pub fn npm_cache_dir(&self) -> Result<&Arc, AnyError> { + self.services.npm_cache_dir.get_or_try_init(|| { + let fs = self.fs(); + let global_path = self.deno_dir()?.npm_folder_path(); + let cli_options = self.cli_options()?; + Ok(Arc::new(NpmCacheDir::new( + &DenoCacheEnvFsAdapter(fs.as_ref()), + global_path, + cli_options.npmrc().get_all_known_registries_urls(), + ))) + }) + } + pub async fn npm_resolver( &self, ) -> Result<&Arc, AnyError> { self .services .npm_resolver - .get_or_try_init_async(async { - let fs = self.fs(); - let cli_options = self.cli_options()?; - // For `deno install` we want to force the managed resolver so it can set up `node_modules/` directory. - create_cli_npm_resolver(if cli_options.use_byonm() && !matches!(cli_options.sub_command(), DenoSubcommand::Install(_) | DenoSubcommand::Add(_) | DenoSubcommand::Remove(_)) { - CliNpmResolverCreateOptions::Byonm(CliByonmNpmResolverCreateOptions { - fs: CliDenoResolverFs(fs.clone()), - root_node_modules_dir: Some(match cli_options.node_modules_dir_path() { - Some(node_modules_path) => node_modules_path.to_path_buf(), - // path needs to be canonicalized for node resolution - // (node_modules_dir_path above is already canonicalized) - None => canonicalize_path_maybe_not_exists(cli_options.initial_cwd())? - .join("node_modules"), - }), - }) - } else { - CliNpmResolverCreateOptions::Managed(CliNpmResolverManagedCreateOptions { - snapshot: match cli_options.resolve_npm_resolution_snapshot()? { - Some(snapshot) => { - CliNpmResolverManagedSnapshotOption::Specified(Some(snapshot)) - } - None => match cli_options.maybe_lockfile() { - Some(lockfile) => { - CliNpmResolverManagedSnapshotOption::ResolveFromLockfile( - lockfile.clone(), - ) - } - None => CliNpmResolverManagedSnapshotOption::Specified(None), + .get_or_try_init_async( + async { + let fs = self.fs(); + let cli_options = self.cli_options()?; + create_cli_npm_resolver(if cli_options.use_byonm() { + CliNpmResolverCreateOptions::Byonm( + CliByonmNpmResolverCreateOptions { + fs: CliDenoResolverFs(fs.clone()), + pkg_json_resolver: self.pkg_json_resolver().clone(), + root_node_modules_dir: Some( + match cli_options.node_modules_dir_path() { + Some(node_modules_path) => node_modules_path.to_path_buf(), + // path needs to be canonicalized for node resolution + // (node_modules_dir_path above is already canonicalized) + None => canonicalize_path_maybe_not_exists( + cli_options.initial_cwd(), + )? + .join("node_modules"), + }, + ), }, - }, - maybe_lockfile: cli_options.maybe_lockfile().cloned(), - fs: fs.clone(), - http_client_provider: self.http_client_provider().clone(), - npm_global_cache_dir: self.deno_dir()?.npm_folder_path(), - cache_setting: cli_options.cache_setting(), - text_only_progress_bar: self.text_only_progress_bar().clone(), - maybe_node_modules_path: cli_options.node_modules_dir_path().cloned(), - npm_install_deps_provider: Arc::new(NpmInstallDepsProvider::from_workspace(cli_options.workspace())), - npm_system_info: cli_options.npm_system_info(), - npmrc: cli_options.npmrc().clone(), - lifecycle_scripts: cli_options.lifecycle_scripts_config(), + ) + } else { + CliNpmResolverCreateOptions::Managed( + CliManagedNpmResolverCreateOptions { + snapshot: match cli_options.resolve_npm_resolution_snapshot()? { + Some(snapshot) => { + CliNpmResolverManagedSnapshotOption::Specified(Some( + snapshot, + )) + } + None => match cli_options.maybe_lockfile() { + Some(lockfile) => { + CliNpmResolverManagedSnapshotOption::ResolveFromLockfile( + lockfile.clone(), + ) + } + None => { + CliNpmResolverManagedSnapshotOption::Specified(None) + } + }, + }, + maybe_lockfile: cli_options.maybe_lockfile().cloned(), + fs: fs.clone(), + http_client_provider: self.http_client_provider().clone(), + npm_cache_dir: self.npm_cache_dir()?.clone(), + cache_setting: cli_options.cache_setting(), + text_only_progress_bar: self.text_only_progress_bar().clone(), + maybe_node_modules_path: cli_options + .node_modules_dir_path() + .cloned(), + npm_install_deps_provider: Arc::new( + NpmInstallDepsProvider::from_workspace( + cli_options.workspace(), + ), + ), + npm_system_info: cli_options.npm_system_info(), + npmrc: cli_options.npmrc().clone(), + lifecycle_scripts: cli_options.lifecycle_scripts_config(), + }, + ) }) - }).await - }.boxed_local()) + .await + } + .boxed_local(), + ) .await } @@ -513,6 +573,7 @@ impl CliFactory { self.services.module_info_cache.get_or_try_init(|| { Ok(Arc::new(ModuleInfoCache::new( self.caches()?.dep_analysis_db(), + self.parsed_source_cache().clone(), ))) }) } @@ -541,6 +602,7 @@ impl CliFactory { ts_config_result.ts_config, )?; Ok(Arc::new(Emitter::new( + self.cjs_tracker()?.clone(), self.emit_cache()?.clone(), self.parsed_source_cache().clone(), transpile_options, @@ -564,7 +626,9 @@ impl CliFactory { async { Ok(Arc::new(NodeResolver::new( DenoFsNodeResolverEnv::new(self.fs().clone()), + self.in_npm_pkg_checker()?.clone(), self.npm_resolver().await?.clone().into_npm_resolver(), + self.pkg_json_resolver().clone(), ))) } .boxed_local(), @@ -582,24 +646,35 @@ impl CliFactory { let caches = self.caches()?; let node_analysis_cache = NodeAnalysisCache::new(caches.node_analysis_db()); - let node_resolver = self.cli_node_resolver().await?.clone(); + let node_resolver = self.node_resolver().await?.clone(); let cjs_esm_analyzer = CliCjsCodeAnalyzer::new( node_analysis_cache, + self.cjs_tracker()?.clone(), self.fs().clone(), - node_resolver, Some(self.parsed_source_cache().clone()), + self.cli_options()?.is_npm_main(), ); Ok(Arc::new(NodeCodeTranslator::new( cjs_esm_analyzer, DenoFsNodeResolverEnv::new(self.fs().clone()), - self.node_resolver().await?.clone(), + self.in_npm_pkg_checker()?.clone(), + node_resolver, self.npm_resolver().await?.clone().into_npm_resolver(), + self.pkg_json_resolver().clone(), ))) }) .await } + pub fn pkg_json_resolver(&self) -> &Arc { + self.services.pkg_json_resolver.get_or_init(|| { + Arc::new(PackageJsonResolver::new(DenoFsNodeResolverEnv::new( + self.fs().clone(), + ))) + }) + } + pub async fn type_checker(&self) -> Result<&Arc, AnyError> { self .services @@ -608,6 +683,10 @@ impl CliFactory { let cli_options = self.cli_options()?; Ok(Arc::new(TypeChecker::new( self.caches()?.clone(), + Arc::new(TypeCheckingCjsTracker::new( + self.cjs_tracker()?.clone(), + self.module_info_cache()?.clone(), + )), cli_options.clone(), self.module_graph_builder().await?.clone(), self.node_resolver().await?.clone(), @@ -626,19 +705,18 @@ impl CliFactory { .get_or_try_init_async(async { let cli_options = self.cli_options()?; Ok(Arc::new(ModuleGraphBuilder::new( - cli_options.clone(), self.caches()?.clone(), - self.esm_or_cjs_checker().clone(), + cli_options.clone(), + self.file_fetcher()?.clone(), self.fs().clone(), - self.resolver().await?.clone(), - self.cli_node_resolver().await?.clone(), - self.npm_resolver().await?.clone(), - self.module_info_cache()?.clone(), - self.parsed_source_cache().clone(), + self.global_http_cache()?.clone(), + self.in_npm_pkg_checker()?.clone(), cli_options.maybe_lockfile().cloned(), self.maybe_file_watcher_reporter().clone(), - self.file_fetcher()?.clone(), - self.global_http_cache()?.clone(), + self.module_info_cache()?.clone(), + self.npm_resolver().await?.clone(), + self.parsed_source_cache().clone(), + self.resolver().await?.clone(), self.root_permissions_container()?.clone(), ))) }) @@ -710,8 +788,17 @@ impl CliFactory { .await } - pub fn cjs_resolutions(&self) -> &Arc { - self.services.cjs_resolutions.get_or_init(Default::default) + pub fn cjs_tracker(&self) -> Result<&Arc, AnyError> { + self.services.cjs_tracker.get_or_try_init(|| { + let options = self.cli_options()?; + Ok(Arc::new(CjsTracker::new( + self.in_npm_pkg_checker()?.clone(), + self.pkg_json_resolver().clone(), + CjsTrackerOptions { + unstable_detect_cjs: options.unstable_detect_cjs(), + }, + ))) + }) } pub async fn cli_node_resolver( @@ -722,8 +809,9 @@ impl CliFactory { .cli_node_resolver .get_or_try_init_async(async { Ok(Arc::new(CliNodeResolver::new( - self.cjs_resolutions().clone(), + self.cjs_tracker()?.clone(), self.fs().clone(), + self.in_npm_pkg_checker()?.clone(), self.node_resolver().await?.clone(), self.npm_resolver().await?.clone(), ))) @@ -761,6 +849,7 @@ impl CliFactory { ) -> Result { let cli_options = self.cli_options()?; Ok(DenoCompileBinaryWriter::new( + self.cjs_tracker()?, self.deno_dir()?, self.emitter()?, self.file_fetcher()?, @@ -791,53 +880,60 @@ impl CliFactory { &self, ) -> Result { let cli_options = self.cli_options()?; + let fs = self.fs(); let node_resolver = self.node_resolver().await?; let npm_resolver = self.npm_resolver().await?; - let fs = self.fs(); let cli_node_resolver = self.cli_node_resolver().await?; let cli_npm_resolver = self.npm_resolver().await?.clone(); + let in_npm_pkg_checker = self.in_npm_pkg_checker()?; let maybe_file_watcher_communicator = if cli_options.has_hmr() { Some(self.watcher_communicator.clone().unwrap()) } else { None }; + let node_code_translator = self.node_code_translator().await?; + let cjs_tracker = self.cjs_tracker()?.clone(); + let pkg_json_resolver = self.pkg_json_resolver().clone(); Ok(CliMainWorkerFactory::new( self.blob_store().clone(), - self.cjs_resolutions().clone(), if cli_options.code_cache_enabled() { Some(self.code_cache()?.clone()) } else { None }, self.feature_checker()?.clone(), - self.fs().clone(), + fs.clone(), maybe_file_watcher_communicator, self.maybe_inspector_server()?.clone(), cli_options.maybe_lockfile().cloned(), Box::new(CliModuleLoaderFactory::new( cli_options, + cjs_tracker, if cli_options.code_cache_enabled() { Some(self.code_cache()?.clone()) } else { None }, self.emitter()?.clone(), + fs.clone(), + in_npm_pkg_checker.clone(), self.main_module_graph_container().await?.clone(), self.module_load_preparer().await?.clone(), + node_code_translator.clone(), cli_node_resolver.clone(), cli_npm_resolver.clone(), NpmModuleLoader::new( - self.cjs_resolutions().clone(), - self.node_code_translator().await?.clone(), + self.cjs_tracker()?.clone(), fs.clone(), - cli_node_resolver.clone(), + node_code_translator.clone(), ), self.parsed_source_cache().clone(), self.resolver().await?.clone(), )), node_resolver.clone(), npm_resolver.clone(), + pkg_json_resolver, self.root_cert_store_provider().clone(), self.root_permissions_container()?.clone(), StorageKeyResolver::from_options(cli_options), @@ -853,8 +949,10 @@ impl CliFactory { let create_hmr_runner = if cli_options.has_hmr() { let watcher_communicator = self.watcher_communicator.clone().unwrap(); let emitter = self.emitter()?.clone(); + let cjs_tracker = self.cjs_tracker()?.clone(); let fn_: crate::worker::CreateHmrRunnerCb = Box::new(move |session| { Box::new(HmrRunner::new( + cjs_tracker.clone(), emitter.clone(), session, watcher_communicator.clone(), @@ -891,7 +989,6 @@ impl CliFactory { inspect_wait: cli_options.inspect_wait().is_some(), strace_ops: cli_options.strace_ops().clone(), is_inspecting: cli_options.is_inspecting(), - is_npm_main: cli_options.is_npm_main(), location: cli_options.location_flag().clone(), // if the user ran a binary command, we'll need to set process.argv[0] // to be the name of the binary command instead of deno @@ -909,7 +1006,6 @@ impl CliFactory { node_ipc: cli_options.node_ipc_fd(), serve_port: cli_options.serve_port(), serve_host: cli_options.serve_host(), - unstable_detect_cjs: cli_options.unstable_detect_cjs(), }) } } diff --git a/cli/graph_util.rs b/cli/graph_util.rs index 2eaee228af..46257cf785 100644 --- a/cli/graph_util.rs +++ b/cli/graph_util.rs @@ -6,7 +6,6 @@ use crate::args::CliLockfile; use crate::args::CliOptions; use crate::args::DENO_DISABLE_PEDANTIC_NODE_WARNINGS; use crate::cache; -use crate::cache::EsmOrCjsChecker; use crate::cache::GlobalHttpCache; use crate::cache::ModuleInfoCache; use crate::cache::ParsedSourceCache; @@ -15,7 +14,6 @@ use crate::errors::get_error_class_name; use crate::file_fetcher::FileFetcher; use crate::npm::CliNpmResolver; use crate::resolver::CliGraphResolver; -use crate::resolver::CliNodeResolver; use crate::resolver::CliSloppyImportsResolver; use crate::resolver::SloppyImportsCachedFs; use crate::tools::check; @@ -50,6 +48,7 @@ use deno_runtime::deno_permissions::PermissionsContainer; use deno_semver::jsr::JsrDepPackageReq; use deno_semver::package::PackageNv; use import_map::ImportMapError; +use node_resolver::InNpmPackageChecker; use std::collections::HashSet; use std::error::Error; use std::ops::Deref; @@ -379,54 +378,51 @@ pub struct BuildFastCheckGraphOptions<'a> { } pub struct ModuleGraphBuilder { - options: Arc, caches: Arc, - esm_or_cjs_checker: Arc, + cli_options: Arc, + file_fetcher: Arc, fs: Arc, - resolver: Arc, - node_resolver: Arc, - npm_resolver: Arc, - module_info_cache: Arc, - parsed_source_cache: Arc, + global_http_cache: Arc, + in_npm_pkg_checker: Arc, lockfile: Option>, maybe_file_watcher_reporter: Option, - file_fetcher: Arc, - global_http_cache: Arc, + module_info_cache: Arc, + npm_resolver: Arc, + parsed_source_cache: Arc, + resolver: Arc, root_permissions_container: PermissionsContainer, } impl ModuleGraphBuilder { #[allow(clippy::too_many_arguments)] pub fn new( - options: Arc, caches: Arc, - esm_or_cjs_checker: Arc, + cli_options: Arc, + file_fetcher: Arc, fs: Arc, - resolver: Arc, - node_resolver: Arc, - npm_resolver: Arc, - module_info_cache: Arc, - parsed_source_cache: Arc, + global_http_cache: Arc, + in_npm_pkg_checker: Arc, lockfile: Option>, maybe_file_watcher_reporter: Option, - file_fetcher: Arc, - global_http_cache: Arc, + module_info_cache: Arc, + npm_resolver: Arc, + parsed_source_cache: Arc, + resolver: Arc, root_permissions_container: PermissionsContainer, ) -> Self { Self { - options, caches, - esm_or_cjs_checker, + cli_options, + file_fetcher, fs, - resolver, - node_resolver, - npm_resolver, - module_info_cache, - parsed_source_cache, + global_http_cache, + in_npm_pkg_checker, lockfile, maybe_file_watcher_reporter, - file_fetcher, - global_http_cache, + module_info_cache, + npm_resolver, + parsed_source_cache, + resolver, root_permissions_container, } } @@ -512,13 +508,11 @@ impl ModuleGraphBuilder { } let maybe_imports = if options.graph_kind.include_types() { - self.options.to_compiler_option_types()? + self.cli_options.to_compiler_option_types()? } else { Vec::new() }; - let analyzer = self - .module_info_cache - .as_module_analyzer(&self.parsed_source_cache); + let analyzer = self.module_info_cache.as_module_analyzer(); let mut loader = match options.loader { Some(loader) => MutLoaderRef::Borrowed(loader), None => MutLoaderRef::Owned(self.create_graph_loader()), @@ -566,7 +560,7 @@ impl ModuleGraphBuilder { // ensure an "npm install" is done if the user has explicitly // opted into using a node_modules directory if self - .options + .cli_options .node_modules_dir()? .map(|m| m.uses_node_modules_dir()) .unwrap_or(false) @@ -677,10 +671,10 @@ impl ModuleGraphBuilder { graph.build_fast_check_type_graph( deno_graph::BuildFastCheckTypeGraphOptions { - jsr_url_provider: &CliJsrUrlProvider, + es_parser: Some(&parser), fast_check_cache: fast_check_cache.as_ref().map(|c| c as _), fast_check_dts: false, - module_parser: Some(&parser), + jsr_url_provider: &CliJsrUrlProvider, resolver: Some(graph_resolver), npm_resolver: Some(&graph_npm_resolver), workspace_fast_check: options.workspace_fast_check, @@ -699,20 +693,18 @@ impl ModuleGraphBuilder { permissions: PermissionsContainer, ) -> cache::FetchCacher { cache::FetchCacher::new( - self.esm_or_cjs_checker.clone(), self.file_fetcher.clone(), + self.fs.clone(), self.global_http_cache.clone(), - self.node_resolver.clone(), - self.npm_resolver.clone(), + self.in_npm_pkg_checker.clone(), self.module_info_cache.clone(), cache::FetchCacherOptions { - file_header_overrides: self.options.resolve_file_header_overrides(), + file_header_overrides: self.cli_options.resolve_file_header_overrides(), permissions, is_deno_publish: matches!( - self.options.sub_command(), + self.cli_options.sub_command(), crate::args::DenoSubcommand::Publish { .. } ), - unstable_detect_cjs: self.options.unstable_detect_cjs(), }, ) } @@ -737,12 +729,12 @@ impl ModuleGraphBuilder { &self.fs, roots, GraphValidOptions { - kind: if self.options.type_check_mode().is_true() { + kind: if self.cli_options.type_check_mode().is_true() { GraphKind::All } else { GraphKind::CodeOnly }, - check_js: self.options.check_js(), + check_js: self.cli_options.check_js(), exit_integrity_errors: true, }, ) diff --git a/cli/lsp/analysis.rs b/cli/lsp/analysis.rs index 39f1ae6482..0769c90477 100644 --- a/cli/lsp/analysis.rs +++ b/cli/lsp/analysis.rs @@ -36,7 +36,6 @@ use deno_semver::package::PackageReq; use deno_semver::package::PackageReqReference; use deno_semver::Version; use import_map::ImportMap; -use node_resolver::NpmResolver; use once_cell::sync::Lazy; use regex::Regex; use std::borrow::Cow; @@ -336,7 +335,12 @@ impl<'a> TsResponseImportMapper<'a> { .resolver .maybe_managed_npm_resolver(Some(&self.file_referrer)) { - if npm_resolver.in_npm_package(specifier) { + let in_npm_pkg = self + .resolver + .maybe_node_resolver(Some(&self.file_referrer)) + .map(|n| n.in_npm_package(specifier)) + .unwrap_or(false); + if in_npm_pkg { if let Ok(Some(pkg_id)) = npm_resolver.resolve_pkg_id_from_specifier(specifier) { @@ -1199,14 +1203,11 @@ impl CodeActionCollection { }), ); - match parsed_source.program_ref() { - deno_ast::swc::ast::Program::Module(module) => module - .body - .iter() - .find(|i| i.range().contains(&specifier_range)) - .map(|i| text_info.line_and_column_index(i.range().start)), - deno_ast::swc::ast::Program::Script(_) => None, - } + parsed_source + .program_ref() + .body() + .find(|i| i.range().contains(&specifier_range)) + .map(|i| text_info.line_and_column_index(i.range().start)) } async fn deno_types_for_npm_action( diff --git a/cli/lsp/code_lens.rs b/cli/lsp/code_lens.rs index e117888fba..a57ca3ac9f 100644 --- a/cli/lsp/code_lens.rs +++ b/cli/lsp/code_lens.rs @@ -421,7 +421,7 @@ pub fn collect_test( ) -> Result, AnyError> { let mut collector = DenoTestCollector::new(specifier.clone(), parsed_source.clone()); - parsed_source.module().visit_with(&mut collector); + parsed_source.program().visit_with(&mut collector); Ok(collector.take()) } @@ -581,7 +581,7 @@ mod tests { .unwrap(); let mut collector = DenoTestCollector::new(specifier, parsed_module.clone()); - parsed_module.module().visit_with(&mut collector); + parsed_module.program().visit_with(&mut collector); assert_eq!( collector.take(), vec![ diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs index cac0637a05..34bf64446d 100644 --- a/cli/lsp/config.rs +++ b/cli/lsp/config.rs @@ -985,7 +985,7 @@ impl Config { | MediaType::Tsx => Some(&workspace_settings.typescript), MediaType::Json | MediaType::Wasm - | MediaType::TsBuildInfo + | MediaType::Css | MediaType::SourceMap | MediaType::Unknown => None, } diff --git a/cli/lsp/documents.rs b/cli/lsp/documents.rs index 7d1ca6810d..8609aed05e 100644 --- a/cli/lsp/documents.rs +++ b/cli/lsp/documents.rs @@ -272,7 +272,7 @@ fn get_maybe_test_module_fut( parsed_source.specifier().clone(), parsed_source.text_info_lazy().clone(), ); - parsed_source.module().visit_with(&mut collector); + parsed_source.program().visit_with(&mut collector); Arc::new(collector.take()) }) .map(Result::ok) @@ -332,12 +332,8 @@ impl Document { .filter(|s| cache.is_valid_file_referrer(s)) .cloned() .or(file_referrer); - let media_type = resolve_media_type( - &specifier, - maybe_headers.as_ref(), - maybe_language_id, - &resolver, - ); + let media_type = + resolve_media_type(&specifier, maybe_headers.as_ref(), maybe_language_id); let (maybe_parsed_source, maybe_module) = if media_type_is_diagnosable(media_type) { parse_and_analyze_module( @@ -399,7 +395,6 @@ impl Document { &self.specifier, self.maybe_headers.as_ref(), self.maybe_language_id, - &resolver, ); let dependencies; let maybe_types_dependency; @@ -764,14 +759,7 @@ fn resolve_media_type( specifier: &ModuleSpecifier, maybe_headers: Option<&HashMap>, maybe_language_id: Option, - resolver: &LspResolver, ) -> MediaType { - if resolver.in_node_modules(specifier) { - if let Some(media_type) = resolver.node_media_type(specifier) { - return media_type; - } - } - if let Some(language_id) = maybe_language_id { return MediaType::from_specifier_and_content_type( specifier, @@ -1561,7 +1549,7 @@ fn parse_source( text: Arc, media_type: MediaType, ) -> ParsedSourceResult { - deno_ast::parse_module(deno_ast::ParseParams { + deno_ast::parse_program(deno_ast::ParseParams { specifier, text, media_type, diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index a592245ce7..4fa0e3afbc 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -904,7 +904,7 @@ impl Inner { | MediaType::Tsx => {} MediaType::Wasm | MediaType::SourceMap - | MediaType::TsBuildInfo + | MediaType::Css | MediaType::Unknown => { if path.extension().and_then(|s| s.to_str()) != Some("jsonc") { continue; diff --git a/cli/lsp/resolver.rs b/cli/lsp/resolver.rs index 00587f8f50..9ce76005e5 100644 --- a/cli/lsp/resolver.rs +++ b/cli/lsp/resolver.rs @@ -2,6 +2,8 @@ use dashmap::DashMap; use deno_ast::MediaType; +use deno_ast::ParsedSource; +use deno_cache_dir::npm::NpmCacheDir; use deno_cache_dir::HttpCache; use deno_config::workspace::PackageJsonDepResolution; use deno_config::workspace::WorkspaceResolver; @@ -14,15 +16,15 @@ use deno_path_util::url_to_file_path; use deno_runtime::deno_fs; use deno_runtime::deno_node::NodeResolver; use deno_runtime::deno_node::PackageJson; +use deno_runtime::deno_node::PackageJsonResolver; use deno_semver::jsr::JsrPackageReqReference; use deno_semver::npm::NpmPackageReqReference; use deno_semver::package::PackageNv; use deno_semver::package::PackageReq; use indexmap::IndexMap; use node_resolver::errors::ClosestPkgJsonError; -use node_resolver::NodeResolution; +use node_resolver::InNpmPackageChecker; use node_resolver::NodeResolutionMode; -use node_resolver::NpmResolver; use std::borrow::Cow; use std::collections::BTreeMap; use std::collections::BTreeSet; @@ -36,6 +38,7 @@ use crate::args::create_default_npmrc; use crate::args::CacheSetting; use crate::args::CliLockfile; use crate::args::NpmInstallDepsProvider; +use crate::cache::DenoCacheEnvFsAdapter; use crate::graph_util::CliJsrUrlProvider; use crate::http_util::HttpClientProvider; use crate::lsp::config::Config; @@ -43,26 +46,32 @@ use crate::lsp::config::ConfigData; use crate::lsp::logging::lsp_warn; use crate::npm::create_cli_npm_resolver_for_lsp; use crate::npm::CliByonmNpmResolverCreateOptions; +use crate::npm::CliManagedInNpmPkgCheckerCreateOptions; +use crate::npm::CliManagedNpmResolverCreateOptions; use crate::npm::CliNpmResolver; use crate::npm::CliNpmResolverCreateOptions; -use crate::npm::CliNpmResolverManagedCreateOptions; use crate::npm::CliNpmResolverManagedSnapshotOption; +use crate::npm::CreateInNpmPkgCheckerOptions; use crate::npm::ManagedCliNpmResolver; -use crate::resolver::CjsResolutionStore; +use crate::resolver::CjsTracker; +use crate::resolver::CjsTrackerOptions; use crate::resolver::CliDenoResolverFs; use crate::resolver::CliGraphResolver; use crate::resolver::CliGraphResolverOptions; use crate::resolver::CliNodeResolver; use crate::resolver::WorkerCliNpmGraphResolver; +use crate::tsc::into_specifier_and_media_type; use crate::util::progress_bar::ProgressBar; use crate::util::progress_bar::ProgressBarStyle; #[derive(Debug, Clone)] struct LspScopeResolver { + cjs_tracker: Option>, graph_resolver: Arc, jsr_resolver: Option>, npm_resolver: Option>, node_resolver: Option>, + pkg_json_resolver: Option>, redirect_resolver: Option>, graph_imports: Arc>, config_data: Option>, @@ -71,10 +80,12 @@ struct LspScopeResolver { impl Default for LspScopeResolver { fn default() -> Self { Self { + cjs_tracker: None, graph_resolver: create_graph_resolver(None, None, None), jsr_resolver: None, npm_resolver: None, node_resolver: None, + pkg_json_resolver: None, redirect_resolver: None, graph_imports: Default::default(), config_data: None, @@ -90,14 +101,35 @@ impl LspScopeResolver { ) -> Self { let mut npm_resolver = None; let mut node_resolver = None; + let mut lsp_cjs_tracker = None; + let fs = Arc::new(deno_fs::RealFs); + let pkg_json_resolver = Arc::new(PackageJsonResolver::new( + deno_runtime::deno_node::DenoFsNodeResolverEnv::new(fs.clone()), + )); if let Some(http_client) = http_client_provider { npm_resolver = create_npm_resolver( config_data.map(|d| d.as_ref()), cache, http_client, + &pkg_json_resolver, ) .await; - node_resolver = create_node_resolver(npm_resolver.as_ref()); + if let Some(npm_resolver) = &npm_resolver { + let in_npm_pkg_checker = create_in_npm_pkg_checker(npm_resolver); + let cjs_tracker = create_cjs_tracker( + in_npm_pkg_checker.clone(), + pkg_json_resolver.clone(), + ); + lsp_cjs_tracker = + Some(Arc::new(LspCjsTracker::new(cjs_tracker.clone()))); + node_resolver = Some(create_node_resolver( + cjs_tracker, + fs.clone(), + in_npm_pkg_checker, + npm_resolver, + pkg_json_resolver.clone(), + )); + } } let graph_resolver = create_graph_resolver( config_data.map(|d| d.as_ref()), @@ -134,10 +166,12 @@ impl LspScopeResolver { }) .unwrap_or_default(); Self { + cjs_tracker: lsp_cjs_tracker, graph_resolver, jsr_resolver, npm_resolver, node_resolver, + pkg_json_resolver: Some(pkg_json_resolver), redirect_resolver, graph_imports, config_data: config_data.cloned(), @@ -147,18 +181,40 @@ impl LspScopeResolver { fn snapshot(&self) -> Arc { let npm_resolver = self.npm_resolver.as_ref().map(|r| r.clone_snapshotted()); - let node_resolver = create_node_resolver(npm_resolver.as_ref()); + let fs = Arc::new(deno_fs::RealFs); + let pkg_json_resolver = Arc::new(PackageJsonResolver::new( + deno_runtime::deno_node::DenoFsNodeResolverEnv::new(fs.clone()), + )); + let mut node_resolver = None; + let mut lsp_cjs_tracker = None; + if let Some(npm_resolver) = &npm_resolver { + let in_npm_pkg_checker = create_in_npm_pkg_checker(npm_resolver); + let cjs_tracker = create_cjs_tracker( + in_npm_pkg_checker.clone(), + pkg_json_resolver.clone(), + ); + lsp_cjs_tracker = Some(Arc::new(LspCjsTracker::new(cjs_tracker.clone()))); + node_resolver = Some(create_node_resolver( + cjs_tracker, + fs, + in_npm_pkg_checker, + npm_resolver, + pkg_json_resolver.clone(), + )); + } let graph_resolver = create_graph_resolver( self.config_data.as_deref(), npm_resolver.as_ref(), node_resolver.as_ref(), ); Arc::new(Self { + cjs_tracker: lsp_cjs_tracker, graph_resolver, jsr_resolver: self.jsr_resolver.clone(), npm_resolver, node_resolver, redirect_resolver: self.redirect_resolver.clone(), + pkg_json_resolver: Some(pkg_json_resolver), graph_imports: self.graph_imports.clone(), config_data: self.config_data.clone(), }) @@ -261,6 +317,22 @@ impl LspResolver { resolver.graph_resolver.create_graph_npm_resolver() } + pub fn maybe_cjs_tracker( + &self, + file_referrer: Option<&ModuleSpecifier>, + ) -> Option<&Arc> { + let resolver = self.get_scope_resolver(file_referrer); + resolver.cjs_tracker.as_ref() + } + + pub fn maybe_node_resolver( + &self, + file_referrer: Option<&ModuleSpecifier>, + ) -> Option<&Arc> { + let resolver = self.get_scope_resolver(file_referrer); + resolver.node_resolver.as_ref() + } + pub fn maybe_managed_npm_resolver( &self, file_referrer: Option<&ModuleSpecifier>, @@ -328,7 +400,7 @@ impl LspResolver { ) -> Option<(ModuleSpecifier, MediaType)> { let resolver = self.get_scope_resolver(file_referrer); let node_resolver = resolver.node_resolver.as_ref()?; - Some(NodeResolution::into_specifier_and_media_type(Some( + Some(into_specifier_and_media_type(Some( node_resolver .resolve_req_reference(req_ref, referrer, NodeResolutionMode::Types) .ok()?, @@ -346,14 +418,10 @@ impl LspResolver { .contains("/node_modules/") } - let global_npm_resolver = self - .get_scope_resolver(Some(specifier)) - .npm_resolver - .as_ref() - .and_then(|npm_resolver| npm_resolver.as_managed()) - .filter(|r| r.root_node_modules_path().is_none()); - if let Some(npm_resolver) = &global_npm_resolver { - if npm_resolver.in_npm_package(specifier) { + if let Some(node_resolver) = + &self.get_scope_resolver(Some(specifier)).node_resolver + { + if node_resolver.in_npm_package(specifier) { return true; } } @@ -361,18 +429,6 @@ impl LspResolver { has_node_modules_dir(specifier) } - pub fn node_media_type( - &self, - specifier: &ModuleSpecifier, - ) -> Option { - let resolver = self.get_scope_resolver(Some(specifier)); - let node_resolver = resolver.node_resolver.as_ref()?; - let resolution = node_resolver - .url_to_node_resolution(specifier.clone()) - .ok()?; - Some(NodeResolution::into_specifier_and_media_type(Some(resolution)).1) - } - pub fn is_bare_package_json_dep( &self, specifier_text: &str, @@ -398,10 +454,10 @@ impl LspResolver { referrer: &ModuleSpecifier, ) -> Result>, ClosestPkgJsonError> { let resolver = self.get_scope_resolver(Some(referrer)); - let Some(node_resolver) = resolver.node_resolver.as_ref() else { + let Some(pkg_json_resolver) = resolver.pkg_json_resolver.as_ref() else { return Ok(None); }; - node_resolver.get_closest_package_json(referrer) + pkg_json_resolver.get_closest_package_json(referrer) } pub fn resolve_redirects( @@ -457,11 +513,13 @@ async fn create_npm_resolver( config_data: Option<&ConfigData>, cache: &LspCache, http_client_provider: &Arc, + pkg_json_resolver: &Arc, ) -> Option> { let enable_byonm = config_data.map(|d| d.byonm).unwrap_or(false); let options = if enable_byonm { CliNpmResolverCreateOptions::Byonm(CliByonmNpmResolverCreateOptions { fs: CliDenoResolverFs(Arc::new(deno_fs::RealFs)), + pkg_json_resolver: pkg_json_resolver.clone(), root_node_modules_dir: config_data.and_then(|config_data| { config_data.node_modules_dir.clone().or_else(|| { url_to_file_path(&config_data.scope) @@ -471,7 +529,15 @@ async fn create_npm_resolver( }), }) } else { - CliNpmResolverCreateOptions::Managed(CliNpmResolverManagedCreateOptions { + let npmrc = config_data + .and_then(|d| d.npmrc.clone()) + .unwrap_or_else(create_default_npmrc); + let npm_cache_dir = Arc::new(NpmCacheDir::new( + &DenoCacheEnvFsAdapter(&deno_fs::RealFs), + cache.deno_dir().npm_folder_path(), + npmrc.get_all_known_registries_urls(), + )); + CliNpmResolverCreateOptions::Managed(CliManagedNpmResolverCreateOptions { http_client_provider: http_client_provider.clone(), snapshot: match config_data.and_then(|d| d.lockfile.as_ref()) { Some(lockfile) => { @@ -485,7 +551,7 @@ async fn create_npm_resolver( // updating it. Only the cache request should update the lockfile. maybe_lockfile: None, fs: Arc::new(deno_fs::RealFs), - npm_global_cache_dir: cache.deno_dir().npm_folder_path(), + npm_cache_dir, // Use an "only" cache setting in order to make the // user do an explicit "cache" command and prevent // the cache from being filled with lots of packages while @@ -496,9 +562,7 @@ async fn create_npm_resolver( .and_then(|d| d.node_modules_dir.clone()), // only used for top level install, so we can ignore this npm_install_deps_provider: Arc::new(NpmInstallDepsProvider::empty()), - npmrc: config_data - .and_then(|d| d.npmrc.clone()) - .unwrap_or_else(create_default_npmrc), + npmrc, npm_system_info: NpmSystemInfo::default(), lifecycle_scripts: Default::default(), }) @@ -506,28 +570,59 @@ async fn create_npm_resolver( Some(create_cli_npm_resolver_for_lsp(options).await) } +fn create_cjs_tracker( + in_npm_pkg_checker: Arc, + pkg_json_resolver: Arc, +) -> Arc { + Arc::new(CjsTracker::new( + in_npm_pkg_checker, + pkg_json_resolver, + CjsTrackerOptions { + // todo(dsherret): support in the lsp by stabilizing the feature + // so that we don't have to pipe the config in here + unstable_detect_cjs: false, + }, + )) +} + +fn create_in_npm_pkg_checker( + npm_resolver: &Arc, +) -> Arc { + crate::npm::create_in_npm_pkg_checker(match npm_resolver.as_inner() { + crate::npm::InnerCliNpmResolverRef::Byonm(_) => { + CreateInNpmPkgCheckerOptions::Byonm + } + crate::npm::InnerCliNpmResolverRef::Managed(m) => { + CreateInNpmPkgCheckerOptions::Managed( + CliManagedInNpmPkgCheckerCreateOptions { + root_cache_dir_url: m.global_cache_root_url(), + maybe_node_modules_path: m.maybe_node_modules_path(), + }, + ) + } + }) +} + fn create_node_resolver( - npm_resolver: Option<&Arc>, -) -> Option> { - use once_cell::sync::Lazy; - - // it's not ideal to share this across all scopes and to - // never clear it, but it's fine for the time being - static CJS_RESOLUTIONS: Lazy> = - Lazy::new(Default::default); - - let npm_resolver = npm_resolver?; - let fs = Arc::new(deno_fs::RealFs); + cjs_tracker: Arc, + fs: Arc, + in_npm_pkg_checker: Arc, + npm_resolver: &Arc, + pkg_json_resolver: Arc, +) -> Arc { let node_resolver_inner = Arc::new(NodeResolver::new( deno_runtime::deno_node::DenoFsNodeResolverEnv::new(fs.clone()), + in_npm_pkg_checker.clone(), npm_resolver.clone().into_npm_resolver(), + pkg_json_resolver.clone(), )); - Some(Arc::new(CliNodeResolver::new( - CJS_RESOLUTIONS.clone(), + Arc::new(CliNodeResolver::new( + cjs_tracker.clone(), fs, + in_npm_pkg_checker, node_resolver_inner, npm_resolver.clone(), - ))) + )) } fn create_graph_resolver( @@ -702,6 +797,45 @@ impl RedirectResolver { } } +#[derive(Debug)] +pub struct LspCjsTracker { + cjs_tracker: Arc, +} + +impl LspCjsTracker { + pub fn new(cjs_tracker: Arc) -> Self { + Self { cjs_tracker } + } + + pub fn is_cjs( + &self, + specifier: &ModuleSpecifier, + media_type: MediaType, + maybe_parsed_source: Option<&ParsedSource>, + ) -> bool { + if let Some(module_kind) = + self.cjs_tracker.get_known_kind(specifier, media_type) + { + module_kind.is_cjs() + } else { + let maybe_is_script = maybe_parsed_source.map(|p| p.compute_is_script()); + maybe_is_script + .and_then(|is_script| { + self + .cjs_tracker + .is_cjs_with_known_is_script(specifier, media_type, is_script) + .ok() + }) + .unwrap_or_else(|| { + self + .cjs_tracker + .is_maybe_cjs(specifier, media_type) + .unwrap_or(false) + }) + } + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/cli/lsp/testing/collectors.rs b/cli/lsp/testing/collectors.rs index 2f2ddb8773..2dd7ec0d96 100644 --- a/cli/lsp/testing/collectors.rs +++ b/cli/lsp/testing/collectors.rs @@ -650,7 +650,7 @@ pub mod tests { .unwrap(); let text_info = parsed_module.text_info_lazy().clone(); let mut collector = TestCollector::new(specifier, text_info); - parsed_module.module().visit_with(&mut collector); + parsed_module.program().visit_with(&mut collector); collector.take() } diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 0f31d7dd3b..5fcdb3575a 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -4362,14 +4362,25 @@ fn op_load<'s>( None } else { let asset_or_document = state.get_asset_or_document(&specifier); - asset_or_document.map(|doc| LoadResponse { - data: doc.text(), - script_kind: crate::tsc::as_ts_script_kind(doc.media_type()), - version: state.script_version(&specifier), - is_cjs: matches!( - doc.media_type(), - MediaType::Cjs | MediaType::Cts | MediaType::Dcts - ), + asset_or_document.map(|doc| { + let maybe_cjs_tracker = state + .state_snapshot + .resolver + .maybe_cjs_tracker(Some(&specifier)); + LoadResponse { + data: doc.text(), + script_kind: crate::tsc::as_ts_script_kind(doc.media_type()), + version: state.script_version(&specifier), + is_cjs: maybe_cjs_tracker + .map(|t| { + t.is_cjs( + &specifier, + doc.media_type(), + doc.maybe_parsed_source().and_then(|p| p.as_ref().ok()), + ) + }) + .unwrap_or(false), + } }) }; diff --git a/cli/main.rs b/cli/main.rs index c2639c9088..04daff6700 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -135,7 +135,7 @@ async fn run_subcommand(flags: Arc) -> Result { tools::compile::compile(flags, compile_flags).await }), DenoSubcommand::Coverage(coverage_flags) => spawn_subcommand(async { - tools::coverage::cover_files(flags, coverage_flags).await + tools::coverage::cover_files(flags, coverage_flags) }), DenoSubcommand::Fmt(fmt_flags) => { spawn_subcommand( diff --git a/cli/module_loader.rs b/cli/module_loader.rs index 4a020516e7..43c9e1aa07 100644 --- a/cli/module_loader.rs +++ b/cli/module_loader.rs @@ -2,6 +2,7 @@ use std::borrow::Cow; use std::cell::RefCell; +use std::path::Path; use std::path::PathBuf; use std::pin::Pin; use std::rc::Rc; @@ -23,19 +24,23 @@ use crate::graph_container::ModuleGraphUpdatePermit; use crate::graph_util::CreateGraphOptions; use crate::graph_util::ModuleGraphBuilder; use crate::node; +use crate::node::CliNodeCodeTranslator; use crate::npm::CliNpmResolver; +use crate::resolver::CjsTracker; use crate::resolver::CliGraphResolver; use crate::resolver::CliNodeResolver; use crate::resolver::ModuleCodeStringSource; +use crate::resolver::NotSupportedKindInNpmError; use crate::resolver::NpmModuleLoader; use crate::tools::check; use crate::tools::check::TypeChecker; use crate::util::progress_bar::ProgressBar; use crate::util::text_encoding::code_without_source_map; use crate::util::text_encoding::source_map_from_code; -use crate::worker::ModuleLoaderAndSourceMapGetter; +use crate::worker::CreateModuleLoaderResult; use crate::worker::ModuleLoaderFactory; use deno_ast::MediaType; +use deno_ast::ModuleKind; use deno_core::anyhow::anyhow; use deno_core::anyhow::bail; use deno_core::anyhow::Context; @@ -63,9 +68,12 @@ use deno_graph::Module; use deno_graph::ModuleGraph; use deno_graph::Resolution; use deno_runtime::code_cache; +use deno_runtime::deno_fs::FileSystem; use deno_runtime::deno_node::create_host_defined_options; +use deno_runtime::deno_node::NodeRequireLoader; use deno_runtime::deno_permissions::PermissionsContainer; use deno_semver::npm::NpmPackageReqReference; +use node_resolver::InNpmPackageChecker; use node_resolver::NodeResolutionMode; pub struct ModuleLoadPreparer { @@ -198,11 +206,16 @@ struct SharedCliModuleLoaderState { lib_worker: TsTypeLib, initial_cwd: PathBuf, is_inspecting: bool, + is_npm_main: bool, is_repl: bool, + cjs_tracker: Arc, code_cache: Option>, emitter: Arc, + fs: Arc, + in_npm_pkg_checker: Arc, main_module_graph_container: Arc, module_load_preparer: Arc, + node_code_translator: Arc, node_resolver: Arc, npm_resolver: Arc, npm_module_loader: NpmModuleLoader, @@ -218,10 +231,14 @@ impl CliModuleLoaderFactory { #[allow(clippy::too_many_arguments)] pub fn new( options: &CliOptions, + cjs_tracker: Arc, code_cache: Option>, emitter: Arc, + fs: Arc, + in_npm_pkg_checker: Arc, main_module_graph_container: Arc, module_load_preparer: Arc, + node_code_translator: Arc, node_resolver: Arc, npm_resolver: Arc, npm_module_loader: NpmModuleLoader, @@ -235,14 +252,19 @@ impl CliModuleLoaderFactory { lib_worker: options.ts_type_lib_worker(), initial_cwd: options.initial_cwd().to_path_buf(), is_inspecting: options.is_inspecting(), + is_npm_main: options.is_npm_main(), is_repl: matches!( options.sub_command(), DenoSubcommand::Repl(_) | DenoSubcommand::Jupyter(_) ), + cjs_tracker, code_cache, emitter, + fs, + in_npm_pkg_checker, main_module_graph_container, module_load_preparer, + node_code_translator, node_resolver, npm_resolver, npm_module_loader, @@ -259,19 +281,30 @@ impl CliModuleLoaderFactory { is_worker: bool, parent_permissions: PermissionsContainer, permissions: PermissionsContainer, - ) -> ModuleLoaderAndSourceMapGetter { - let loader = Rc::new(CliModuleLoader(Rc::new(CliModuleLoaderInner { - lib, - is_worker, - parent_permissions, - permissions, + ) -> CreateModuleLoaderResult { + let module_loader = + Rc::new(CliModuleLoader(Rc::new(CliModuleLoaderInner { + lib, + is_worker, + is_npm_main: self.shared.is_npm_main, + parent_permissions, + permissions, + graph_container: graph_container.clone(), + node_code_translator: self.shared.node_code_translator.clone(), + emitter: self.shared.emitter.clone(), + parsed_source_cache: self.shared.parsed_source_cache.clone(), + shared: self.shared.clone(), + }))); + let node_require_loader = Rc::new(CliNodeRequireLoader::new( + self.shared.emitter.clone(), + self.shared.fs.clone(), graph_container, - emitter: self.shared.emitter.clone(), - parsed_source_cache: self.shared.parsed_source_cache.clone(), - shared: self.shared.clone(), - }))); - ModuleLoaderAndSourceMapGetter { - module_loader: loader, + self.shared.in_npm_pkg_checker.clone(), + self.shared.npm_resolver.clone(), + )); + CreateModuleLoaderResult { + module_loader, + node_require_loader, } } } @@ -280,7 +313,7 @@ impl ModuleLoaderFactory for CliModuleLoaderFactory { fn create_for_main( &self, root_permissions: PermissionsContainer, - ) -> ModuleLoaderAndSourceMapGetter { + ) -> CreateModuleLoaderResult { self.create_with_lib( (*self.shared.main_module_graph_container).clone(), self.shared.lib_window, @@ -294,7 +327,7 @@ impl ModuleLoaderFactory for CliModuleLoaderFactory { &self, parent_permissions: PermissionsContainer, permissions: PermissionsContainer, - ) -> ModuleLoaderAndSourceMapGetter { + ) -> CreateModuleLoaderResult { self.create_with_lib( // create a fresh module graph for the worker WorkerModuleGraphContainer::new(Arc::new(ModuleGraph::new( @@ -310,6 +343,7 @@ impl ModuleLoaderFactory for CliModuleLoaderFactory { struct CliModuleLoaderInner { lib: TsTypeLib, + is_npm_main: bool, is_worker: bool, /// The initial set of permissions used to resolve the static imports in the /// worker. These are "allow all" for main worker, and parent thread @@ -318,6 +352,7 @@ struct CliModuleLoaderInner { permissions: PermissionsContainer, shared: Arc, emitter: Arc, + node_code_translator: Arc, parsed_source_cache: Arc, graph_container: TGraphContainer, } @@ -331,24 +366,7 @@ impl maybe_referrer: Option<&ModuleSpecifier>, requested_module_type: RequestedModuleType, ) -> Result { - let code_source = match self.load_prepared_module(specifier).await? { - Some(code_source) => code_source, - None => { - if self.shared.npm_module_loader.if_in_npm_package(specifier) { - self - .shared - .npm_module_loader - .load(specifier, maybe_referrer) - .await? - } else { - let mut msg = format!("Loading unprepared module: {specifier}"); - if let Some(referrer) = maybe_referrer { - msg = format!("{}, imported from: {}", msg, referrer.as_str()); - } - return Err(anyhow!(msg)); - } - } - }; + let code_source = self.load_code_source(specifier, maybe_referrer).await?; let code = if self.shared.is_inspecting { // we need the code with the source map in order for // it to work with --inspect or --inspect-brk @@ -402,6 +420,29 @@ impl )) } + async fn load_code_source( + &self, + specifier: &ModuleSpecifier, + maybe_referrer: Option<&ModuleSpecifier>, + ) -> Result { + if let Some(code_source) = self.load_prepared_module(specifier).await? { + return Ok(code_source); + } + if self.shared.node_resolver.in_npm_package(specifier) { + return self + .shared + .npm_module_loader + .load(specifier, maybe_referrer) + .await; + } + + let mut msg = format!("Loading unprepared module: {specifier}"); + if let Some(referrer) = maybe_referrer { + msg = format!("{}, imported from: {}", msg, referrer.as_str()); + } + Err(anyhow!(msg)) + } + fn resolve_referrer( &self, referrer: &str, @@ -474,15 +515,11 @@ impl if self.shared.is_repl { if let Ok(reference) = NpmPackageReqReference::from_specifier(&specifier) { - return self - .shared - .node_resolver - .resolve_req_reference( - &reference, - referrer, - NodeResolutionMode::Execution, - ) - .map(|res| res.into_url()); + return self.shared.node_resolver.resolve_req_reference( + &reference, + referrer, + NodeResolutionMode::Execution, + ); } } @@ -506,13 +543,15 @@ impl .with_context(|| { format!("Could not resolve '{}'.", module.nv_reference) })? - .into_url() } Some(Module::Node(module)) => module.specifier.clone(), Some(Module::Js(module)) => module.specifier.clone(), Some(Module::Json(module)) => module.specifier.clone(), Some(Module::External(module)) => { - node::resolve_specifier_into_node_modules(&module.specifier) + node::resolve_specifier_into_node_modules( + &module.specifier, + self.shared.fs.as_ref(), + ) } None => specifier.into_owned(), }; @@ -534,7 +573,7 @@ impl }) => { let transpile_result = self .emitter - .emit_parsed_source(specifier, media_type, source) + .emit_parsed_source(specifier, media_type, ModuleKind::Esm, source) .await?; // at this point, we no longer need the parsed source in memory, so free it @@ -547,11 +586,19 @@ impl media_type, })) } + Some(CodeOrDeferredEmit::Cjs { + specifier, + media_type, + source, + }) => self + .load_maybe_cjs(specifier, media_type, source) + .await + .map(Some), None => Ok(None), } } - fn load_prepared_module_sync( + fn load_prepared_module_for_source_map_sync( &self, specifier: &ModuleSpecifier, ) -> Result, AnyError> { @@ -564,9 +611,12 @@ impl media_type, source, }) => { - let transpile_result = self - .emitter - .emit_parsed_source_sync(specifier, media_type, source)?; + let transpile_result = self.emitter.emit_parsed_source_sync( + specifier, + media_type, + ModuleKind::Esm, + source, + )?; // at this point, we no longer need the parsed source in memory, so free it self.parsed_source_cache.free(specifier); @@ -578,6 +628,14 @@ impl media_type, })) } + Some(CodeOrDeferredEmit::Cjs { .. }) => { + self.parsed_source_cache.free(specifier); + + // todo(dsherret): to make this work, we should probably just + // rely on the CJS export cache. At the moment this is hard because + // cjs export analysis is only async + Ok(None) + } None => Ok(None), } } @@ -607,20 +665,40 @@ impl source, media_type, specifier, + is_script, .. })) => { + // todo(dsherret): revert in https://github.com/denoland/deno/pull/26439 + if self.is_npm_main && *is_script + || self.shared.cjs_tracker.is_cjs_with_known_is_script( + specifier, + *media_type, + *is_script, + )? + { + return Ok(Some(CodeOrDeferredEmit::Cjs { + specifier, + media_type: *media_type, + source, + })); + } let code: ModuleCodeString = match media_type { MediaType::JavaScript | MediaType::Unknown - | MediaType::Cjs | MediaType::Mjs | MediaType::Json => source.clone().into(), MediaType::Dts | MediaType::Dcts | MediaType::Dmts => { Default::default() } + MediaType::Cjs | MediaType::Cts => { + return Ok(Some(CodeOrDeferredEmit::Cjs { + specifier, + media_type: *media_type, + source, + })); + } MediaType::TypeScript | MediaType::Mts - | MediaType::Cts | MediaType::Jsx | MediaType::Tsx => { return Ok(Some(CodeOrDeferredEmit::DeferredEmit { @@ -629,7 +707,7 @@ impl source, })); } - MediaType::TsBuildInfo | MediaType::Wasm | MediaType::SourceMap => { + MediaType::Css | MediaType::Wasm | MediaType::SourceMap => { panic!("Unexpected media type {media_type} for {specifier}") } }; @@ -651,6 +729,48 @@ impl | None => Ok(None), } } + + async fn load_maybe_cjs( + &self, + specifier: &ModuleSpecifier, + media_type: MediaType, + original_source: &Arc, + ) -> Result { + let js_source = if media_type.is_emittable() { + Cow::Owned( + self + .emitter + .emit_parsed_source( + specifier, + media_type, + ModuleKind::Cjs, + original_source, + ) + .await?, + ) + } else { + Cow::Borrowed(original_source.as_ref()) + }; + let text = self + .node_code_translator + .translate_cjs_to_esm(specifier, Some(js_source)) + .await?; + // at this point, we no longer need the parsed source in memory, so free it + self.parsed_source_cache.free(specifier); + Ok(ModuleCodeStringSource { + code: match text { + // perf: if the text is borrowed, that means it didn't make any changes + // to the original source, so we can just provide that instead of cloning + // the borrowed text + Cow::Borrowed(_) => { + ModuleSourceCode::String(original_source.clone().into()) + } + Cow::Owned(text) => ModuleSourceCode::String(text.into()), + }, + found_url: specifier.clone(), + media_type, + }) + } } enum CodeOrDeferredEmit<'a> { @@ -660,6 +780,11 @@ enum CodeOrDeferredEmit<'a> { media_type: MediaType, source: &'a Arc, }, + Cjs { + specifier: &'a ModuleSpecifier, + media_type: MediaType, + source: &'a Arc, + }, } // todo(dsherret): this double Rc boxing is not ideal @@ -821,7 +946,10 @@ impl ModuleLoader "wasm" | "file" | "http" | "https" | "data" | "blob" => (), _ => return None, } - let source = self.0.load_prepared_module_sync(&specifier).ok()??; + let source = self + .0 + .load_prepared_module_for_source_map_sync(&specifier) + .ok()??; source_map_from_code(source.code.as_bytes()) } @@ -900,3 +1028,79 @@ impl ModuleGraphUpdatePermit for WorkerModuleGraphUpdatePermit { drop(self.permit); // explicit drop for clarity } } + +#[derive(Debug)] +struct CliNodeRequireLoader { + emitter: Arc, + fs: Arc, + graph_container: TGraphContainer, + in_npm_pkg_checker: Arc, + npm_resolver: Arc, +} + +impl + CliNodeRequireLoader +{ + pub fn new( + emitter: Arc, + fs: Arc, + graph_container: TGraphContainer, + in_npm_pkg_checker: Arc, + npm_resolver: Arc, + ) -> Self { + Self { + emitter, + fs, + graph_container, + in_npm_pkg_checker, + npm_resolver, + } + } +} + +impl NodeRequireLoader + for CliNodeRequireLoader +{ + fn ensure_read_permission<'a>( + &self, + permissions: &mut dyn deno_runtime::deno_node::NodePermissions, + path: &'a Path, + ) -> Result, AnyError> { + if let Ok(url) = deno_path_util::url_from_file_path(path) { + // allow reading if it's in the module graph + if self.graph_container.graph().get(&url).is_some() { + return Ok(std::borrow::Cow::Borrowed(path)); + } + } + self.npm_resolver.ensure_read_permission(permissions, path) + } + + fn load_text_file_lossy(&self, path: &Path) -> Result { + // todo(dsherret): use the preloaded module from the graph if available? + let media_type = MediaType::from_path(path); + let text = self.fs.read_text_file_lossy_sync(path, None)?; + if media_type.is_emittable() { + let specifier = deno_path_util::url_from_file_path(path)?; + if self.in_npm_pkg_checker.in_npm_package(&specifier) { + return Err( + NotSupportedKindInNpmError { + media_type, + specifier, + } + .into(), + ); + } + self.emitter.emit_parsed_source_sync( + &specifier, + media_type, + // this is probably not super accurate due to require esm, but probably ok. + // If we find this causes a lot of churn in the emit cache then we should + // investigate how we can make this better + ModuleKind::Cjs, + &text.into(), + ) + } else { + Ok(text) + } + } +} diff --git a/cli/node.rs b/cli/node.rs index 733d5f8717..1d410a726a 100644 --- a/cli/node.rs +++ b/cli/node.rs @@ -1,11 +1,14 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +use std::borrow::Cow; use std::sync::Arc; use deno_ast::MediaType; use deno_ast::ModuleSpecifier; use deno_core::error::AnyError; use deno_graph::ParsedSourceStore; +use deno_path_util::url_from_file_path; +use deno_path_util::url_to_file_path; use deno_runtime::deno_fs; use deno_runtime::deno_node::DenoFsNodeResolverEnv; use node_resolver::analyze::CjsAnalysis as ExtNodeCjsAnalysis; @@ -18,8 +21,8 @@ use serde::Serialize; use crate::cache::CacheDBHash; use crate::cache::NodeAnalysisCache; use crate::cache::ParsedSourceCache; -use crate::resolver::CliNodeResolver; -use crate::util::fs::canonicalize_path_maybe_not_exists; +use crate::resolver::CjsTracker; +use crate::util::fs::canonicalize_path_maybe_not_exists_with_fs; pub type CliNodeCodeTranslator = NodeCodeTranslator; @@ -32,14 +35,14 @@ pub type CliNodeCodeTranslator = /// because the node_modules folder might not exist at that time. pub fn resolve_specifier_into_node_modules( specifier: &ModuleSpecifier, + fs: &dyn deno_fs::FileSystem, ) -> ModuleSpecifier { - specifier - .to_file_path() + url_to_file_path(specifier) .ok() // this path might not exist at the time the graph is being created // because the node_modules folder might not yet exist - .and_then(|path| canonicalize_path_maybe_not_exists(&path).ok()) - .and_then(|path| ModuleSpecifier::from_file_path(path).ok()) + .and_then(|path| canonicalize_path_maybe_not_exists_with_fs(&path, fs).ok()) + .and_then(|path| url_from_file_path(&path).ok()) .unwrap_or_else(|| specifier.clone()) } @@ -56,23 +59,29 @@ pub enum CliCjsAnalysis { pub struct CliCjsCodeAnalyzer { cache: NodeAnalysisCache, + cjs_tracker: Arc, fs: deno_fs::FileSystemRc, - node_resolver: Arc, parsed_source_cache: Option>, + // todo(dsherret): hack, remove in https://github.com/denoland/deno/pull/26439 + // For example, this does not properly handle if cjs analysis was already done + // and has been cached. + is_npm_main: bool, } impl CliCjsCodeAnalyzer { pub fn new( cache: NodeAnalysisCache, + cjs_tracker: Arc, fs: deno_fs::FileSystemRc, - node_resolver: Arc, parsed_source_cache: Option>, + is_npm_main: bool, ) -> Self { Self { cache, + cjs_tracker, fs, - node_resolver, parsed_source_cache, + is_npm_main, } } @@ -88,7 +97,7 @@ impl CliCjsCodeAnalyzer { return Ok(analysis); } - let mut media_type = MediaType::from_specifier(specifier); + let media_type = MediaType::from_specifier(specifier); if media_type == MediaType::Json { return Ok(CliCjsAnalysis::Cjs { exports: vec![], @@ -96,62 +105,53 @@ impl CliCjsCodeAnalyzer { }); } - if media_type == MediaType::JavaScript { - if let Some(package_json) = - self.node_resolver.get_closest_package_json(specifier)? - { - match package_json.typ.as_str() { - "commonjs" => { - media_type = MediaType::Cjs; - } - "module" => { - media_type = MediaType::Mjs; - } - _ => {} - } - } - } + let cjs_tracker = self.cjs_tracker.clone(); + let is_npm_main = self.is_npm_main; + let is_maybe_cjs = + cjs_tracker.is_maybe_cjs(specifier, media_type)? || is_npm_main; + let analysis = if is_maybe_cjs { + let maybe_parsed_source = self + .parsed_source_cache + .as_ref() + .and_then(|c| c.remove_parsed_source(specifier)); - let maybe_parsed_source = self - .parsed_source_cache - .as_ref() - .and_then(|c| c.remove_parsed_source(specifier)); - - let analysis = deno_core::unsync::spawn_blocking({ - let specifier = specifier.clone(); - let source: Arc = source.into(); - move || -> Result<_, deno_ast::ParseDiagnostic> { - let parsed_source = - maybe_parsed_source.map(Ok).unwrap_or_else(|| { - deno_ast::parse_program(deno_ast::ParseParams { - specifier, - text: source, - media_type, - capture_tokens: true, - scope_analysis: false, - maybe_syntax: None, + deno_core::unsync::spawn_blocking({ + let specifier = specifier.clone(); + let source: Arc = source.into(); + move || -> Result<_, AnyError> { + let parsed_source = + maybe_parsed_source.map(Ok).unwrap_or_else(|| { + deno_ast::parse_program(deno_ast::ParseParams { + specifier, + text: source, + media_type, + capture_tokens: true, + scope_analysis: false, + maybe_syntax: None, + }) + })?; + let is_script = parsed_source.compute_is_script(); + let is_cjs = cjs_tracker.is_cjs_with_known_is_script( + parsed_source.specifier(), + media_type, + is_script, + )? || is_script && is_npm_main; + if is_cjs { + let analysis = parsed_source.analyze_cjs(); + Ok(CliCjsAnalysis::Cjs { + exports: analysis.exports, + reexports: analysis.reexports, }) - })?; - if parsed_source.is_script() { - let analysis = parsed_source.analyze_cjs(); - Ok(CliCjsAnalysis::Cjs { - exports: analysis.exports, - reexports: analysis.reexports, - }) - } else if media_type == MediaType::Cjs { - // FIXME: `deno_ast` should internally handle MediaType::Cjs implying that - // the result must never be Esm - Ok(CliCjsAnalysis::Cjs { - exports: vec![], - reexports: vec![], - }) - } else { - Ok(CliCjsAnalysis::Esm) + } else { + Ok(CliCjsAnalysis::Esm) + } } - } - }) - .await - .unwrap()?; + }) + .await + .unwrap()? + } else { + CliCjsAnalysis::Esm + }; self .cache @@ -163,11 +163,11 @@ impl CliCjsCodeAnalyzer { #[async_trait::async_trait(?Send)] impl CjsCodeAnalyzer for CliCjsCodeAnalyzer { - async fn analyze_cjs( + async fn analyze_cjs<'a>( &self, specifier: &ModuleSpecifier, - source: Option, - ) -> Result { + source: Option>, + ) -> Result, AnyError> { let source = match source { Some(source) => source, None => { @@ -175,7 +175,7 @@ impl CjsCodeAnalyzer for CliCjsCodeAnalyzer { if let Ok(source_from_file) = self.fs.read_text_file_lossy_async(path, None).await { - source_from_file + Cow::Owned(source_from_file) } else { return Ok(ExtNodeCjsAnalysis::Cjs(CjsAnalysisExports { exports: vec![], diff --git a/cli/npm/byonm.rs b/cli/npm/byonm.rs index fc095ab16f..4535b07fc5 100644 --- a/cli/npm/byonm.rs +++ b/cli/npm/byonm.rs @@ -10,8 +10,8 @@ use deno_core::serde_json; use deno_core::url::Url; use deno_resolver::npm::ByonmNpmResolver; use deno_resolver::npm::ByonmNpmResolverCreateOptions; +use deno_runtime::deno_node::DenoFsNodeResolverEnv; use deno_runtime::deno_node::NodePermissions; -use deno_runtime::deno_node::NodeRequireResolver; use deno_runtime::ops::process::NpmProcessStateProvider; use deno_semver::package::PackageReq; use node_resolver::NpmResolver; @@ -25,30 +25,14 @@ use super::InnerCliNpmResolverRef; use super::ResolvePkgFolderFromDenoReqError; pub type CliByonmNpmResolverCreateOptions = - ByonmNpmResolverCreateOptions; -pub type CliByonmNpmResolver = ByonmNpmResolver; + ByonmNpmResolverCreateOptions; +pub type CliByonmNpmResolver = + ByonmNpmResolver; // todo(dsherret): the services hanging off `CliNpmResolver` doesn't seem ideal. We should probably decouple. #[derive(Debug)] struct CliByonmWrapper(Arc); -impl NodeRequireResolver for CliByonmWrapper { - fn ensure_read_permission<'a>( - &self, - permissions: &mut dyn NodePermissions, - path: &'a Path, - ) -> Result, AnyError> { - if !path - .components() - .any(|c| c.as_os_str().to_ascii_lowercase() == "node_modules") - { - permissions.check_read_path(path) - } else { - Ok(Cow::Borrowed(path)) - } - } -} - impl NpmProcessStateProvider for CliByonmWrapper { fn get_npm_process_state(&self) -> String { serde_json::to_string(&NpmProcessState { @@ -67,10 +51,6 @@ impl CliNpmResolver for CliByonmNpmResolver { self } - fn into_require_resolver(self: Arc) -> Arc { - Arc::new(CliByonmWrapper(self)) - } - fn into_process_state_provider( self: Arc, ) -> Arc { @@ -100,6 +80,21 @@ impl CliNpmResolver for CliByonmNpmResolver { .map_err(ResolvePkgFolderFromDenoReqError::Byonm) } + fn ensure_read_permission<'a>( + &self, + permissions: &mut dyn NodePermissions, + path: &'a Path, + ) -> Result, AnyError> { + if !path + .components() + .any(|c| c.as_os_str().to_ascii_lowercase() == "node_modules") + { + permissions.check_read_path(path) + } else { + Ok(Cow::Borrowed(path)) + } + } + fn check_state_hash(&self) -> Option { // it is very difficult to determine the check state hash for byonm // so we just return None to signify check caching is not supported diff --git a/cli/npm/managed/cache/mod.rs b/cli/npm/managed/cache/mod.rs index aaec486681..8ae99f41e0 100644 --- a/cli/npm/managed/cache/mod.rs +++ b/cli/npm/managed/cache/mod.rs @@ -36,7 +36,7 @@ pub use tarball::TarballCache; /// Stores a single copy of npm packages in a cache. #[derive(Debug)] pub struct NpmCache { - cache_dir: NpmCacheDir, + cache_dir: Arc, cache_setting: CacheSetting, npmrc: Arc, /// ensures a package is only downloaded once per run @@ -45,7 +45,7 @@ pub struct NpmCache { impl NpmCache { pub fn new( - cache_dir: NpmCacheDir, + cache_dir: Arc, cache_setting: CacheSetting, npmrc: Arc, ) -> Self { @@ -61,6 +61,10 @@ impl NpmCache { &self.cache_setting } + pub fn root_dir_path(&self) -> &Path { + self.cache_dir.root_dir() + } + pub fn root_dir_url(&self) -> &Url { self.cache_dir.root_dir_url() } @@ -152,10 +156,6 @@ impl NpmCache { self.cache_dir.package_name_folder(name, registry_url) } - pub fn root_folder(&self) -> PathBuf { - self.cache_dir.root_dir().to_owned() - } - pub fn resolve_package_folder_id_from_specifier( &self, specifier: &ModuleSpecifier, diff --git a/cli/npm/managed/mod.rs b/cli/npm/managed/mod.rs index a0754812bb..4a91bc3474 100644 --- a/cli/npm/managed/mod.rs +++ b/cli/npm/managed/mod.rs @@ -12,6 +12,7 @@ use deno_cache_dir::npm::NpmCacheDir; use deno_core::anyhow::Context; use deno_core::error::AnyError; use deno_core::serde_json; +use deno_core::url::Url; use deno_npm::npm_rc::ResolvedNpmRc; use deno_npm::registry::NpmPackageInfo; use deno_npm::registry::NpmRegistryApi; @@ -24,12 +25,12 @@ use deno_npm::NpmSystemInfo; use deno_runtime::colors; use deno_runtime::deno_fs::FileSystem; use deno_runtime::deno_node::NodePermissions; -use deno_runtime::deno_node::NodeRequireResolver; use deno_runtime::ops::process::NpmProcessStateProvider; use deno_semver::package::PackageNv; use deno_semver::package::PackageReq; use node_resolver::errors::PackageFolderResolveError; use node_resolver::errors::PackageFolderResolveIoError; +use node_resolver::InNpmPackageChecker; use node_resolver::NpmResolver; use resolution::AddPkgReqsResult; @@ -39,7 +40,6 @@ use crate::args::NpmInstallDepsProvider; use crate::args::NpmProcessState; use crate::args::NpmProcessStateKind; use crate::args::PackageJsonDepValueParseWithLocationError; -use crate::cache::DenoCacheEnvFsAdapter; use crate::cache::FastInsecureHasher; use crate::http_util::HttpClientProvider; use crate::util::fs::canonicalize_path_maybe_not_exists_with_fs; @@ -66,12 +66,12 @@ pub enum CliNpmResolverManagedSnapshotOption { Specified(Option), } -pub struct CliNpmResolverManagedCreateOptions { +pub struct CliManagedNpmResolverCreateOptions { pub snapshot: CliNpmResolverManagedSnapshotOption, pub maybe_lockfile: Option>, pub fs: Arc, pub http_client_provider: Arc, - pub npm_global_cache_dir: PathBuf, + pub npm_cache_dir: Arc, pub cache_setting: crate::args::CacheSetting, pub text_only_progress_bar: crate::util::progress_bar::ProgressBar, pub maybe_node_modules_path: Option, @@ -82,7 +82,7 @@ pub struct CliNpmResolverManagedCreateOptions { } pub async fn create_managed_npm_resolver_for_lsp( - options: CliNpmResolverManagedCreateOptions, + options: CliManagedNpmResolverCreateOptions, ) -> Arc { let npm_cache = create_cache(&options); let npm_api = create_api(&options, npm_cache.clone()); @@ -115,7 +115,7 @@ pub async fn create_managed_npm_resolver_for_lsp( } pub async fn create_managed_npm_resolver( - options: CliNpmResolverManagedCreateOptions, + options: CliManagedNpmResolverCreateOptions, ) -> Result, AnyError> { let npm_cache = create_cache(&options); let npm_api = create_api(&options, npm_cache.clone()); @@ -189,20 +189,16 @@ fn create_inner( )) } -fn create_cache(options: &CliNpmResolverManagedCreateOptions) -> Arc { +fn create_cache(options: &CliManagedNpmResolverCreateOptions) -> Arc { Arc::new(NpmCache::new( - NpmCacheDir::new( - &DenoCacheEnvFsAdapter(options.fs.as_ref()), - options.npm_global_cache_dir.clone(), - options.npmrc.get_all_known_registries_urls(), - ), + options.npm_cache_dir.clone(), options.cache_setting.clone(), options.npmrc.clone(), )) } fn create_api( - options: &CliNpmResolverManagedCreateOptions, + options: &CliManagedNpmResolverCreateOptions, npm_cache: Arc, ) -> Arc { Arc::new(CliNpmRegistryApi::new( @@ -259,6 +255,35 @@ async fn snapshot_from_lockfile( Ok(snapshot) } +#[derive(Debug)] +struct ManagedInNpmPackageChecker { + root_dir: Url, +} + +impl InNpmPackageChecker for ManagedInNpmPackageChecker { + fn in_npm_package(&self, specifier: &Url) -> bool { + specifier.as_ref().starts_with(self.root_dir.as_str()) + } +} + +pub struct CliManagedInNpmPkgCheckerCreateOptions<'a> { + pub root_cache_dir_url: &'a Url, + pub maybe_node_modules_path: Option<&'a Path>, +} + +pub fn create_managed_in_npm_pkg_checker( + options: CliManagedInNpmPkgCheckerCreateOptions, +) -> Arc { + let root_dir = match options.maybe_node_modules_path { + Some(node_modules_folder) => { + deno_path_util::url_from_directory_path(node_modules_folder).unwrap() + } + None => options.root_cache_dir_url.clone(), + }; + debug_assert!(root_dir.as_str().ends_with('/')); + Arc::new(ManagedInNpmPackageChecker { root_dir }) +} + /// An npm resolver where the resolution is managed by Deno rather than /// the user bringing their own node_modules (BYONM) on the file system. pub struct ManagedCliNpmResolver { @@ -555,8 +580,16 @@ impl ManagedCliNpmResolver { .map_err(|err| err.into()) } - pub fn global_cache_root_folder(&self) -> PathBuf { - self.npm_cache.root_folder() + pub fn maybe_node_modules_path(&self) -> Option<&Path> { + self.fs_resolver.node_modules_path() + } + + pub fn global_cache_root_path(&self) -> &Path { + self.npm_cache.root_dir_path() + } + + pub fn global_cache_root_url(&self) -> &Url { + self.npm_cache.root_dir_url() } } @@ -591,22 +624,6 @@ impl NpmResolver for ManagedCliNpmResolver { log::debug!("Resolved {} from {} to {}", name, referrer, path.display()); Ok(path) } - - fn in_npm_package(&self, specifier: &ModuleSpecifier) -> bool { - let root_dir_url = self.fs_resolver.root_dir_url(); - debug_assert!(root_dir_url.as_str().ends_with('/')); - specifier.as_ref().starts_with(root_dir_url.as_str()) - } -} - -impl NodeRequireResolver for ManagedCliNpmResolver { - fn ensure_read_permission<'a>( - &self, - permissions: &mut dyn NodePermissions, - path: &'a Path, - ) -> Result, AnyError> { - self.fs_resolver.ensure_read_permission(permissions, path) - } } impl NpmProcessStateProvider for ManagedCliNpmResolver { @@ -623,10 +640,6 @@ impl CliNpmResolver for ManagedCliNpmResolver { self } - fn into_require_resolver(self: Arc) -> Arc { - self - } - fn into_process_state_provider( self: Arc, ) -> Arc { @@ -687,6 +700,14 @@ impl CliNpmResolver for ManagedCliNpmResolver { .map_err(ResolvePkgFolderFromDenoReqError::Managed) } + fn ensure_read_permission<'a>( + &self, + permissions: &mut dyn NodePermissions, + path: &'a Path, + ) -> Result, AnyError> { + self.fs_resolver.ensure_read_permission(permissions, path) + } + fn check_state_hash(&self) -> Option { // We could go further and check all the individual // npm packages, but that's probably overkill. diff --git a/cli/npm/managed/resolvers/common.rs b/cli/npm/managed/resolvers/common.rs index 867bb4168a..590f8fb25c 100644 --- a/cli/npm/managed/resolvers/common.rs +++ b/cli/npm/managed/resolvers/common.rs @@ -17,7 +17,6 @@ use deno_core::anyhow::Context; use deno_core::error::AnyError; use deno_core::futures; use deno_core::futures::StreamExt; -use deno_core::url::Url; use deno_npm::NpmPackageCacheFolderId; use deno_npm::NpmPackageId; use deno_npm::NpmResolutionPackage; @@ -30,9 +29,6 @@ use crate::npm::managed::cache::TarballCache; /// Part of the resolution that interacts with the file system. #[async_trait(?Send)] pub trait NpmPackageFsResolver: Send + Sync { - /// Specifier for the root directory. - fn root_dir_url(&self) -> &Url; - /// The local node_modules folder if it is applicable to the implementation. fn node_modules_path(&self) -> Option<&Path>; diff --git a/cli/npm/managed/resolvers/global.rs b/cli/npm/managed/resolvers/global.rs index 5be315e992..f0193e78e9 100644 --- a/cli/npm/managed/resolvers/global.rs +++ b/cli/npm/managed/resolvers/global.rs @@ -11,7 +11,6 @@ use crate::colors; use async_trait::async_trait; use deno_ast::ModuleSpecifier; use deno_core::error::AnyError; -use deno_core::url::Url; use deno_npm::NpmPackageCacheFolderId; use deno_npm::NpmPackageId; use deno_npm::NpmResolutionPackage; @@ -56,7 +55,7 @@ impl GlobalNpmPackageResolver { Self { registry_read_permission_checker: RegistryReadPermissionChecker::new( fs, - cache.root_folder(), + cache.root_dir_path().to_path_buf(), ), cache, tarball_cache, @@ -69,10 +68,6 @@ impl GlobalNpmPackageResolver { #[async_trait(?Send)] impl NpmPackageFsResolver for GlobalNpmPackageResolver { - fn root_dir_url(&self) -> &Url { - self.cache.root_dir_url() - } - fn node_modules_path(&self) -> Option<&Path> { None } diff --git a/cli/npm/managed/resolvers/local.rs b/cli/npm/managed/resolvers/local.rs index 54f7576ade..0968be8a7e 100644 --- a/cli/npm/managed/resolvers/local.rs +++ b/cli/npm/managed/resolvers/local.rs @@ -155,10 +155,6 @@ impl LocalNpmPackageResolver { #[async_trait(?Send)] impl NpmPackageFsResolver for LocalNpmPackageResolver { - fn root_dir_url(&self) -> &Url { - &self.root_node_modules_url - } - fn node_modules_path(&self) -> Option<&Path> { Some(self.root_node_modules_path.as_ref()) } diff --git a/cli/npm/mod.rs b/cli/npm/mod.rs index 3971b1a0b3..0d434ca27f 100644 --- a/cli/npm/mod.rs +++ b/cli/npm/mod.rs @@ -4,6 +4,7 @@ mod byonm; mod common; mod managed; +use std::borrow::Cow; use std::path::Path; use std::path::PathBuf; use std::sync::Arc; @@ -15,13 +16,16 @@ use deno_core::error::AnyError; use deno_core::serde_json; use deno_npm::npm_rc::ResolvedNpmRc; use deno_npm::registry::NpmPackageInfo; +use deno_resolver::npm::ByonmInNpmPackageChecker; use deno_resolver::npm::ByonmNpmResolver; use deno_resolver::npm::ByonmResolvePkgFolderFromDenoReqError; -use deno_runtime::deno_node::NodeRequireResolver; +use deno_runtime::deno_node::NodePermissions; use deno_runtime::ops::process::NpmProcessStateProvider; use deno_semver::package::PackageNv; use deno_semver::package::PackageReq; use managed::cache::registry_info::get_package_url; +use managed::create_managed_in_npm_pkg_checker; +use node_resolver::InNpmPackageChecker; use node_resolver::NpmResolver; use thiserror::Error; @@ -29,7 +33,8 @@ use crate::file_fetcher::FileFetcher; pub use self::byonm::CliByonmNpmResolver; pub use self::byonm::CliByonmNpmResolverCreateOptions; -pub use self::managed::CliNpmResolverManagedCreateOptions; +pub use self::managed::CliManagedInNpmPkgCheckerCreateOptions; +pub use self::managed::CliManagedNpmResolverCreateOptions; pub use self::managed::CliNpmResolverManagedSnapshotOption; pub use self::managed::ManagedCliNpmResolver; @@ -42,7 +47,7 @@ pub enum ResolvePkgFolderFromDenoReqError { } pub enum CliNpmResolverCreateOptions { - Managed(CliNpmResolverManagedCreateOptions), + Managed(CliManagedNpmResolverCreateOptions), Byonm(CliByonmNpmResolverCreateOptions), } @@ -68,6 +73,22 @@ pub async fn create_cli_npm_resolver( } } +pub enum CreateInNpmPkgCheckerOptions<'a> { + Managed(CliManagedInNpmPkgCheckerCreateOptions<'a>), + Byonm, +} + +pub fn create_in_npm_pkg_checker( + options: CreateInNpmPkgCheckerOptions, +) -> Arc { + match options { + CreateInNpmPkgCheckerOptions::Managed(options) => { + create_managed_in_npm_pkg_checker(options) + } + CreateInNpmPkgCheckerOptions::Byonm => Arc::new(ByonmInNpmPackageChecker), + } +} + pub enum InnerCliNpmResolverRef<'a> { Managed(&'a ManagedCliNpmResolver), #[allow(dead_code)] @@ -76,7 +97,6 @@ pub enum InnerCliNpmResolverRef<'a> { pub trait CliNpmResolver: NpmResolver { fn into_npm_resolver(self: Arc) -> Arc; - fn into_require_resolver(self: Arc) -> Arc; fn into_process_state_provider( self: Arc, ) -> Arc; @@ -107,6 +127,12 @@ pub trait CliNpmResolver: NpmResolver { referrer: &ModuleSpecifier, ) -> Result; + fn ensure_read_permission<'a>( + &self, + permissions: &mut dyn NodePermissions, + path: &'a Path, + ) -> Result, AnyError>; + /// Returns a hash returning the state of the npm resolver /// or `None` if the state currently can't be determined. fn check_state_hash(&self) -> Option; diff --git a/cli/resolver.rs b/cli/resolver.rs index 84c671268a..710b975093 100644 --- a/cli/resolver.rs +++ b/cli/resolver.rs @@ -4,6 +4,7 @@ use async_trait::async_trait; use dashmap::DashMap; use dashmap::DashSet; use deno_ast::MediaType; +use deno_ast::ModuleKind; use deno_config::workspace::MappedResolution; use deno_config::workspace::MappedResolutionDiagnostic; use deno_config::workspace::MappedResolutionError; @@ -11,6 +12,7 @@ use deno_config::workspace::WorkspaceResolver; use deno_core::anyhow::anyhow; use deno_core::anyhow::Context; use deno_core::error::AnyError; +use deno_core::url::Url; use deno_core::ModuleSourceCode; use deno_core::ModuleSpecifier; use deno_graph::source::ResolutionMode; @@ -29,6 +31,7 @@ use deno_runtime::deno_fs; use deno_runtime::deno_fs::FileSystem; use deno_runtime::deno_node::is_builtin_node_module; use deno_runtime::deno_node::NodeResolver; +use deno_runtime::deno_node::PackageJsonResolver; use deno_semver::npm::NpmPackageReqReference; use deno_semver::package::PackageReq; use node_resolver::errors::ClosestPkgJsonError; @@ -38,21 +41,22 @@ use node_resolver::errors::PackageFolderResolveErrorKind; use node_resolver::errors::PackageFolderResolveIoError; use node_resolver::errors::PackageNotFoundError; use node_resolver::errors::PackageResolveErrorKind; -use node_resolver::errors::UrlToNodeResolutionError; +use node_resolver::errors::PackageSubpathResolveError; +use node_resolver::InNpmPackageChecker; use node_resolver::NodeModuleKind; use node_resolver::NodeResolution; use node_resolver::NodeResolutionMode; -use node_resolver::PackageJson; +use std::borrow::Cow; use std::path::Path; use std::path::PathBuf; use std::sync::Arc; +use thiserror::Error; use crate::args::JsxImportSourceConfig; use crate::args::DENO_DISABLE_PEDANTIC_NODE_WARNINGS; use crate::node::CliNodeCodeTranslator; use crate::npm::CliNpmResolver; use crate::npm::InnerCliNpmResolverRef; -use crate::util::path::specifier_has_extension; use crate::util::sync::AtomicFlag; use crate::util::text_encoding::from_utf8_lossy_owned; @@ -104,36 +108,32 @@ impl deno_resolver::fs::DenoResolverFs for CliDenoResolverFs { #[derive(Debug)] pub struct CliNodeResolver { - cjs_resolutions: Arc, + cjs_tracker: Arc, fs: Arc, + in_npm_pkg_checker: Arc, node_resolver: Arc, npm_resolver: Arc, } impl CliNodeResolver { pub fn new( - cjs_resolutions: Arc, + cjs_tracker: Arc, fs: Arc, + in_npm_pkg_checker: Arc, node_resolver: Arc, npm_resolver: Arc, ) -> Self { Self { - cjs_resolutions, + cjs_tracker, fs, + in_npm_pkg_checker, node_resolver, npm_resolver, } } pub fn in_npm_package(&self, specifier: &ModuleSpecifier) -> bool { - self.npm_resolver.in_npm_package(specifier) - } - - pub fn get_closest_package_json( - &self, - referrer: &ModuleSpecifier, - ) -> Result>, ClosestPkgJsonError> { - self.node_resolver.get_closest_package_json(referrer) + self.in_npm_pkg_checker.in_npm_package(specifier) } pub fn resolve_if_for_npm_pkg( @@ -153,8 +153,7 @@ impl CliNodeResolver { | NodeResolveErrorKind::UnsupportedEsmUrlScheme(_) | NodeResolveErrorKind::DataUrlReferrer(_) | NodeResolveErrorKind::TypesNotFound(_) - | NodeResolveErrorKind::FinalizeResolution(_) - | NodeResolveErrorKind::UrlToNodeResolution(_) => Err(err.into()), + | NodeResolveErrorKind::FinalizeResolution(_) => Err(err.into()), NodeResolveErrorKind::PackageResolve(err) => { let err = err.into_kind(); match err { @@ -216,7 +215,11 @@ impl CliNodeResolver { referrer: &ModuleSpecifier, mode: NodeResolutionMode, ) -> Result { - let referrer_kind = if self.cjs_resolutions.is_known_cjs(referrer) { + let referrer_kind = if self + .cjs_tracker + .is_maybe_cjs(referrer, MediaType::from_specifier(referrer)) + .map_err(|err| NodeResolveErrorKind::PackageResolve(err.into()))? + { NodeModuleKind::Cjs } else { NodeModuleKind::Esm @@ -226,7 +229,7 @@ impl CliNodeResolver { self .node_resolver .resolve(specifier, referrer, referrer_kind, mode)?; - Ok(self.handle_node_resolution(res)) + Ok(res) } pub fn resolve_req_reference( @@ -234,7 +237,7 @@ impl CliNodeResolver { req_ref: &NpmPackageReqReference, referrer: &ModuleSpecifier, mode: NodeResolutionMode, - ) -> Result { + ) -> Result { self.resolve_req_with_sub_path( req_ref.req(), req_ref.sub_path(), @@ -249,7 +252,7 @@ impl CliNodeResolver { sub_path: Option<&str>, referrer: &ModuleSpecifier, mode: NodeResolutionMode, - ) -> Result { + ) -> Result { let package_folder = self .npm_resolver .resolve_pkg_folder_from_deno_module_req(req, referrer)?; @@ -260,7 +263,7 @@ impl CliNodeResolver { mode, ); match resolution_result { - Ok(resolution) => Ok(resolution), + Ok(url) => Ok(url), Err(err) => { if self.npm_resolver.as_byonm().is_some() { let package_json_path = package_folder.join("package.json"); @@ -271,7 +274,7 @@ impl CliNodeResolver { )); } } - Err(err) + Err(err.into()) } } } @@ -282,16 +285,13 @@ impl CliNodeResolver { sub_path: Option<&str>, maybe_referrer: Option<&ModuleSpecifier>, mode: NodeResolutionMode, - ) -> Result { - let res = self - .node_resolver - .resolve_package_subpath_from_deno_module( - package_folder, - sub_path, - maybe_referrer, - mode, - )?; - Ok(self.handle_node_resolution(res)) + ) -> Result { + self.node_resolver.resolve_package_subpath_from_deno_module( + package_folder, + sub_path, + maybe_referrer, + mode, + ) } pub fn handle_if_in_node_modules( @@ -306,71 +306,45 @@ impl CliNodeResolver { // so canoncalize then check if it's in the node_modules directory. // If so, check if we need to store this specifier as being a CJS // resolution. - let specifier = - crate::node::resolve_specifier_into_node_modules(specifier); - if self.in_npm_package(&specifier) { - let resolution = - self.node_resolver.url_to_node_resolution(specifier)?; - let resolution = self.handle_node_resolution(resolution); - return Ok(Some(resolution.into_url())); - } + let specifier = crate::node::resolve_specifier_into_node_modules( + specifier, + self.fs.as_ref(), + ); + return Ok(Some(specifier)); } Ok(None) } - - pub fn url_to_node_resolution( - &self, - specifier: ModuleSpecifier, - ) -> Result { - self.node_resolver.url_to_node_resolution(specifier) - } - - fn handle_node_resolution( - &self, - resolution: NodeResolution, - ) -> NodeResolution { - if let NodeResolution::CommonJs(specifier) = &resolution { - // remember that this was a common js resolution - self.mark_cjs_resolution(specifier.clone()); - } - resolution - } - - pub fn mark_cjs_resolution(&self, specifier: ModuleSpecifier) { - self.cjs_resolutions.insert(specifier); - } } -// todo(dsherret): move to module_loader.rs +#[derive(Debug, Error)] +#[error("{media_type} files are not supported in npm packages: {specifier}")] +pub struct NotSupportedKindInNpmError { + pub media_type: MediaType, + pub specifier: Url, +} + +// todo(dsherret): move to module_loader.rs (it seems to be here due to use in standalone) #[derive(Clone)] pub struct NpmModuleLoader { - cjs_resolutions: Arc, - node_code_translator: Arc, + cjs_tracker: Arc, fs: Arc, - node_resolver: Arc, + node_code_translator: Arc, } impl NpmModuleLoader { pub fn new( - cjs_resolutions: Arc, - node_code_translator: Arc, + cjs_tracker: Arc, fs: Arc, - node_resolver: Arc, + node_code_translator: Arc, ) -> Self { Self { - cjs_resolutions, + cjs_tracker, node_code_translator, fs, - node_resolver, } } - pub fn if_in_npm_package(&self, specifier: &ModuleSpecifier) -> bool { - self.node_resolver.in_npm_package(specifier) - || self.cjs_resolutions.is_known_cjs(specifier) - } - pub async fn load( &self, specifier: &ModuleSpecifier, @@ -413,20 +387,30 @@ impl NpmModuleLoader { } })?; - let code = if self.cjs_resolutions.is_known_cjs(specifier) { + let media_type = MediaType::from_specifier(specifier); + if media_type.is_emittable() { + return Err(AnyError::from(NotSupportedKindInNpmError { + media_type, + specifier: specifier.clone(), + })); + } + + let code = if self.cjs_tracker.is_maybe_cjs(specifier, media_type)? { // translate cjs to esm if it's cjs and inject node globals let code = from_utf8_lossy_owned(code); ModuleSourceCode::String( self .node_code_translator - .translate_cjs_to_esm(specifier, Some(code)) + .translate_cjs_to_esm(specifier, Some(Cow::Owned(code))) .await? + .into_owned() .into(), ) } else { // esm and json code is untouched ModuleSourceCode::Bytes(code.into_boxed_slice().into()) }; + Ok(ModuleCodeStringSource { code, found_url: specifier.clone(), @@ -435,21 +419,165 @@ impl NpmModuleLoader { } } +pub struct CjsTrackerOptions { + pub unstable_detect_cjs: bool, +} + /// Keeps track of what module specifiers were resolved as CJS. -#[derive(Debug, Default)] -pub struct CjsResolutionStore(DashSet); +/// +/// Modules that are `.js` or `.ts` are only known to be CJS or +/// ESM after they're loaded based on their contents. So these files +/// will be "maybe CJS" until they're loaded. +#[derive(Debug)] +pub struct CjsTracker { + in_npm_pkg_checker: Arc, + pkg_json_resolver: Arc, + unstable_detect_cjs: bool, + known: DashMap, +} -impl CjsResolutionStore { - pub fn is_known_cjs(&self, specifier: &ModuleSpecifier) -> bool { - if specifier.scheme() != "file" { - return false; +impl CjsTracker { + pub fn new( + in_npm_pkg_checker: Arc, + pkg_json_resolver: Arc, + options: CjsTrackerOptions, + ) -> Self { + Self { + in_npm_pkg_checker, + pkg_json_resolver, + unstable_detect_cjs: options.unstable_detect_cjs, + known: Default::default(), } - - specifier_has_extension(specifier, "cjs") || self.0.contains(specifier) } - pub fn insert(&self, specifier: ModuleSpecifier) { - self.0.insert(specifier); + /// Checks whether the file might be treated as CJS, but it's not for sure + /// yet because the source hasn't been loaded to see whether it contains + /// imports or exports. + pub fn is_maybe_cjs( + &self, + specifier: &ModuleSpecifier, + media_type: MediaType, + ) -> Result { + self.treat_as_cjs_with_is_script(specifier, media_type, None) + } + + /// Gets whether the file is CJS. If true, this is for sure + /// cjs because `is_script` is provided. + /// + /// `is_script` should be `true` when the contents of the file at the + /// provided specifier are known to be a script and not an ES module. + pub fn is_cjs_with_known_is_script( + &self, + specifier: &ModuleSpecifier, + media_type: MediaType, + is_script: bool, + ) -> Result { + self.treat_as_cjs_with_is_script(specifier, media_type, Some(is_script)) + } + + fn treat_as_cjs_with_is_script( + &self, + specifier: &ModuleSpecifier, + media_type: MediaType, + is_script: Option, + ) -> Result { + let kind = match self + .get_known_kind_with_is_script(specifier, media_type, is_script) + { + Some(kind) => kind, + None => self.check_based_on_pkg_json(specifier)?, + }; + Ok(kind.is_cjs()) + } + + pub fn get_known_kind( + &self, + specifier: &ModuleSpecifier, + media_type: MediaType, + ) -> Option { + self.get_known_kind_with_is_script(specifier, media_type, None) + } + + fn get_known_kind_with_is_script( + &self, + specifier: &ModuleSpecifier, + media_type: MediaType, + is_script: Option, + ) -> Option { + if specifier.scheme() != "file" { + return Some(ModuleKind::Esm); + } + + match media_type { + MediaType::Mts | MediaType::Mjs | MediaType::Dmts => Some(ModuleKind::Esm), + MediaType::Cjs | MediaType::Cts | MediaType::Dcts => Some(ModuleKind::Cjs), + MediaType::Dts => { + // dts files are always determined based on the package.json because + // they contain imports/exports even when considered CJS + if let Some(value) = self.known.get(specifier).map(|v| *v) { + Some(value) + } else { + let value = self.check_based_on_pkg_json(specifier).ok(); + if let Some(value) = value { + self.known.insert(specifier.clone(), value); + } + Some(value.unwrap_or(ModuleKind::Esm)) + } + } + MediaType::Wasm | + MediaType::Json => Some(ModuleKind::Esm), + MediaType::JavaScript + | MediaType::Jsx + | MediaType::TypeScript + | MediaType::Tsx + // treat these as unknown + | MediaType::Css + | MediaType::SourceMap + | MediaType::Unknown => { + if let Some(value) = self.known.get(specifier).map(|v| *v) { + if value.is_cjs() && is_script == Some(false) { + // we now know this is actually esm + self.known.insert(specifier.clone(), ModuleKind::Esm); + Some(ModuleKind::Esm) + } else { + Some(value) + } + } else if is_script == Some(false) { + // we know this is esm + self.known.insert(specifier.clone(), ModuleKind::Esm); + Some(ModuleKind::Esm) + } else { + None + } + } + } + } + + fn check_based_on_pkg_json( + &self, + specifier: &ModuleSpecifier, + ) -> Result { + if self.in_npm_pkg_checker.in_npm_package(specifier) { + if let Some(pkg_json) = + self.pkg_json_resolver.get_closest_package_json(specifier)? + { + let is_file_location_cjs = pkg_json.typ != "module"; + Ok(ModuleKind::from_is_cjs(is_file_location_cjs)) + } else { + Ok(ModuleKind::Cjs) + } + } else if self.unstable_detect_cjs { + if let Some(pkg_json) = + self.pkg_json_resolver.get_closest_package_json(specifier)? + { + let is_cjs_type = pkg_json.typ == "commonjs"; + Ok(ModuleKind::from_is_cjs(is_cjs_type)) + } else { + Ok(ModuleKind::Esm) + } + } else { + Ok(ModuleKind::Esm) + } } } @@ -633,8 +761,7 @@ impl Resolver for CliGraphResolver { Some(referrer), to_node_mode(mode), ) - .map_err(ResolveError::Other) - .map(|res| res.into_url()), + .map_err(|e| ResolveError::Other(e.into())), MappedResolution::PackageJson { dep_result, alias, @@ -665,19 +792,17 @@ impl Resolver for CliGraphResolver { ) .map_err(|e| ResolveError::Other(e.into())) .and_then(|pkg_folder| { - Ok( - self - .node_resolver - .as_ref() - .unwrap() - .resolve_package_sub_path_from_deno_module( - pkg_folder, - sub_path.as_deref(), - Some(referrer), - to_node_mode(mode), - )? - .into_url(), - ) + self + .node_resolver + .as_ref() + .unwrap() + .resolve_package_sub_path_from_deno_module( + pkg_folder, + sub_path.as_deref(), + Some(referrer), + to_node_mode(mode), + ) + .map_err(|e| ResolveError::Other(e.into())) }), }) } @@ -717,23 +842,20 @@ impl Resolver for CliGraphResolver { npm_req_ref.req(), ) { - return Ok( - node_resolver - .resolve_package_sub_path_from_deno_module( - pkg_folder, - npm_req_ref.sub_path(), - Some(referrer), - to_node_mode(mode), - )? - .into_url(), - ); + return node_resolver + .resolve_package_sub_path_from_deno_module( + pkg_folder, + npm_req_ref.sub_path(), + Some(referrer), + to_node_mode(mode), + ) + .map_err(|e| ResolveError::Other(e.into())); } // do npm resolution for byonm if is_byonm { return node_resolver .resolve_req_reference(&npm_req_ref, referrer, to_node_mode(mode)) - .map(|res| res.into_url()) .map_err(|err| err.into()); } } @@ -751,9 +873,7 @@ impl Resolver for CliGraphResolver { .map_err(ResolveError::Other)?; if let Some(res) = maybe_resolution { match res { - NodeResolution::Esm(url) | NodeResolution::CommonJs(url) => { - return Ok(url) - } + NodeResolution::Module(url) => return Ok(url), NodeResolution::BuiltIn(_) => { // don't resolve bare specifiers for built-in modules via node resolution } diff --git a/cli/standalone/binary.rs b/cli/standalone/binary.rs index f41f3003ff..9e26512268 100644 --- a/cli/standalone/binary.rs +++ b/cli/standalone/binary.rs @@ -21,6 +21,7 @@ use std::process::Command; use std::sync::Arc; use deno_ast::MediaType; +use deno_ast::ModuleKind; use deno_ast::ModuleSpecifier; use deno_config::workspace::PackageJsonDepResolution; use deno_config::workspace::ResolverWorkspaceJsrPackage; @@ -67,6 +68,7 @@ use crate::file_fetcher::FileFetcher; use crate::http_util::HttpClientProvider; use crate::npm::CliNpmResolver; use crate::npm::InnerCliNpmResolverRef; +use crate::resolver::CjsTracker; use crate::shared::ReleaseChannel; use crate::standalone::virtual_fs::VfsEntry; use crate::util::archive; @@ -257,6 +259,10 @@ impl StandaloneModules { } } + pub fn has_file(&self, path: &Path) -> bool { + self.vfs.file_entry(path).is_ok() + } + pub fn read<'a>( &'a self, specifier: &'a ModuleSpecifier, @@ -353,6 +359,7 @@ pub fn extract_standalone( } pub struct DenoCompileBinaryWriter<'a> { + cjs_tracker: &'a CjsTracker, deno_dir: &'a DenoDir, emitter: &'a Emitter, file_fetcher: &'a FileFetcher, @@ -365,6 +372,7 @@ pub struct DenoCompileBinaryWriter<'a> { impl<'a> DenoCompileBinaryWriter<'a> { #[allow(clippy::too_many_arguments)] pub fn new( + cjs_tracker: &'a CjsTracker, deno_dir: &'a DenoDir, emitter: &'a Emitter, file_fetcher: &'a FileFetcher, @@ -374,6 +382,7 @@ impl<'a> DenoCompileBinaryWriter<'a> { npm_system_info: NpmSystemInfo, ) -> Self { Self { + cjs_tracker, deno_dir, emitter, file_fetcher, @@ -599,19 +608,21 @@ impl<'a> DenoCompileBinaryWriter<'a> { } let (maybe_source, media_type) = match module { deno_graph::Module::Js(m) => { - // todo(https://github.com/denoland/deno_media_type/pull/12): use is_emittable() - let is_emittable = matches!( - m.media_type, - MediaType::TypeScript - | MediaType::Mts - | MediaType::Cts - | MediaType::Jsx - | MediaType::Tsx - ); - let source = if is_emittable { + let source = if m.media_type.is_emittable() { + let is_cjs = self.cjs_tracker.is_cjs_with_known_is_script( + &m.specifier, + m.media_type, + m.is_script, + )?; + let module_kind = ModuleKind::from_is_cjs(is_cjs); let source = self .emitter - .emit_parsed_source(&m.specifier, m.media_type, &m.source) + .emit_parsed_source( + &m.specifier, + m.media_type, + module_kind, + &m.source, + ) .await?; source.into_bytes() } else { @@ -745,8 +756,9 @@ impl<'a> DenoCompileBinaryWriter<'a> { } else { // DO NOT include the user's registry url as it may contain credentials, // but also don't make this dependent on the registry url - let global_cache_root_path = npm_resolver.global_cache_root_folder(); - let mut builder = VfsBuilder::new(global_cache_root_path)?; + let global_cache_root_path = npm_resolver.global_cache_root_path(); + let mut builder = + VfsBuilder::new(global_cache_root_path.to_path_buf())?; let mut packages = npm_resolver.all_system_packages(&self.npm_system_info); packages.sort_by(|a, b| a.id.cmp(&b.id)); // determinism diff --git a/cli/standalone/mod.rs b/cli/standalone/mod.rs index 3a62b6ff96..85610f4c20 100644 --- a/cli/standalone/mod.rs +++ b/cli/standalone/mod.rs @@ -19,6 +19,7 @@ use deno_core::error::type_error; use deno_core::error::AnyError; use deno_core::futures::FutureExt; use deno_core::v8_set_flags; +use deno_core::FastString; use deno_core::FeatureChecker; use deno_core::ModuleLoader; use deno_core::ModuleSourceCode; @@ -30,7 +31,9 @@ use deno_npm::npm_rc::ResolvedNpmRc; use deno_package_json::PackageJsonDepValue; use deno_runtime::deno_fs; use deno_runtime::deno_node::create_host_defined_options; +use deno_runtime::deno_node::NodeRequireLoader; use deno_runtime::deno_node::NodeResolver; +use deno_runtime::deno_node::PackageJsonResolver; use deno_runtime::deno_permissions::Permissions; use deno_runtime::deno_permissions::PermissionsContainer; use deno_runtime::deno_tls::rustls::RootCertStore; @@ -43,6 +46,7 @@ use deno_semver::npm::NpmPackageReqReference; use import_map::parse_from_json; use node_resolver::analyze::NodeCodeTranslator; use node_resolver::NodeResolutionMode; +use serialization::DenoCompileModuleSource; use std::borrow::Cow; use std::rc::Rc; use std::sync::Arc; @@ -61,12 +65,18 @@ use crate::cache::NodeAnalysisCache; use crate::cache::RealDenoCacheEnv; use crate::http_util::HttpClientProvider; use crate::node::CliCjsCodeAnalyzer; +use crate::node::CliNodeCodeTranslator; use crate::npm::create_cli_npm_resolver; +use crate::npm::create_in_npm_pkg_checker; use crate::npm::CliByonmNpmResolverCreateOptions; +use crate::npm::CliManagedInNpmPkgCheckerCreateOptions; +use crate::npm::CliManagedNpmResolverCreateOptions; +use crate::npm::CliNpmResolver; use crate::npm::CliNpmResolverCreateOptions; -use crate::npm::CliNpmResolverManagedCreateOptions; use crate::npm::CliNpmResolverManagedSnapshotOption; -use crate::resolver::CjsResolutionStore; +use crate::npm::CreateInNpmPkgCheckerOptions; +use crate::resolver::CjsTracker; +use crate::resolver::CjsTrackerOptions; use crate::resolver::CliDenoResolverFs; use crate::resolver::CliNodeResolver; use crate::resolver::NpmModuleLoader; @@ -75,7 +85,7 @@ use crate::util::progress_bar::ProgressBarStyle; use crate::util::v8::construct_v8_flags; use crate::worker::CliMainWorkerFactory; use crate::worker::CliMainWorkerOptions; -use crate::worker::ModuleLoaderAndSourceMapGetter; +use crate::worker::CreateModuleLoaderResult; use crate::worker::ModuleLoaderFactory; pub mod binary; @@ -91,10 +101,14 @@ use self::binary::Metadata; use self::file_system::DenoCompileFileSystem; struct SharedModuleLoaderState { + cjs_tracker: Arc, + fs: Arc, modules: StandaloneModules, - workspace_resolver: WorkspaceResolver, + node_code_translator: Arc, node_resolver: Arc, npm_module_loader: Arc, + npm_resolver: Arc, + workspace_resolver: WorkspaceResolver, } #[derive(Clone)] @@ -102,6 +116,12 @@ struct EmbeddedModuleLoader { shared: Arc, } +impl std::fmt::Debug for EmbeddedModuleLoader { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("EmbeddedModuleLoader").finish() + } +} + pub const MODULE_NOT_FOUND: &str = "Module not found"; pub const UNSUPPORTED_SCHEME: &str = "Unsupported scheme"; @@ -159,8 +179,7 @@ impl ModuleLoader for EmbeddedModuleLoader { sub_path.as_deref(), Some(&referrer), NodeResolutionMode::Execution, - )? - .into_url(), + )?, ), Ok(MappedResolution::PackageJson { dep_result, @@ -168,16 +187,14 @@ impl ModuleLoader for EmbeddedModuleLoader { alias, .. }) => match dep_result.as_ref().map_err(|e| AnyError::from(e.clone()))? { - PackageJsonDepValue::Req(req) => self - .shared - .node_resolver - .resolve_req_with_sub_path( + PackageJsonDepValue::Req(req) => { + self.shared.node_resolver.resolve_req_with_sub_path( req, sub_path.as_deref(), &referrer, NodeResolutionMode::Execution, ) - .map(|res| res.into_url()), + } PackageJsonDepValue::Workspace(version_req) => { let pkg_folder = self .shared @@ -195,8 +212,7 @@ impl ModuleLoader for EmbeddedModuleLoader { sub_path.as_deref(), Some(&referrer), NodeResolutionMode::Execution, - )? - .into_url(), + )?, ) } }, @@ -205,15 +221,11 @@ impl ModuleLoader for EmbeddedModuleLoader { if let Ok(reference) = NpmPackageReqReference::from_specifier(&specifier) { - return self - .shared - .node_resolver - .resolve_req_reference( - &reference, - &referrer, - NodeResolutionMode::Execution, - ) - .map(|res| res.into_url()); + return self.shared.node_resolver.resolve_req_reference( + &reference, + &referrer, + NodeResolutionMode::Execution, + ); } if specifier.scheme() == "jsr" { @@ -317,17 +329,72 @@ impl ModuleLoader for EmbeddedModuleLoader { match self.shared.modules.read(original_specifier) { Ok(Some(module)) => { + let media_type = module.media_type; let (module_specifier, module_type, module_source) = - module.into_for_v8(); - deno_core::ModuleLoadResponse::Sync(Ok( - deno_core::ModuleSource::new_with_redirect( - module_type, - module_source, - original_specifier, - module_specifier, - None, - ), - )) + module.into_parts(); + let is_maybe_cjs = match self + .shared + .cjs_tracker + .is_maybe_cjs(original_specifier, media_type) + { + Ok(is_maybe_cjs) => is_maybe_cjs, + Err(err) => { + return deno_core::ModuleLoadResponse::Sync(Err(type_error( + format!("{:?}", err), + ))); + } + }; + if is_maybe_cjs { + let original_specifier = original_specifier.clone(); + let module_specifier = module_specifier.clone(); + let shared = self.shared.clone(); + deno_core::ModuleLoadResponse::Async( + async move { + let source = match module_source { + DenoCompileModuleSource::String(string) => { + Cow::Borrowed(string) + } + DenoCompileModuleSource::Bytes(module_code_bytes) => { + match module_code_bytes { + Cow::Owned(bytes) => Cow::Owned( + crate::util::text_encoding::from_utf8_lossy_owned(bytes), + ), + Cow::Borrowed(bytes) => String::from_utf8_lossy(bytes), + } + } + }; + let source = shared + .node_code_translator + .translate_cjs_to_esm(&module_specifier, Some(source)) + .await?; + let module_source = match source { + Cow::Owned(source) => ModuleSourceCode::String(source.into()), + Cow::Borrowed(source) => { + ModuleSourceCode::String(FastString::from_static(source)) + } + }; + Ok(deno_core::ModuleSource::new_with_redirect( + module_type, + module_source, + &original_specifier, + &module_specifier, + None, + )) + } + .boxed_local(), + ) + } else { + let module_source = module_source.into_for_v8(); + deno_core::ModuleLoadResponse::Sync(Ok( + deno_core::ModuleSource::new_with_redirect( + module_type, + module_source, + original_specifier, + module_specifier, + None, + ), + )) + } } Ok(None) => deno_core::ModuleLoadResponse::Sync(Err(type_error( format!("{MODULE_NOT_FOUND}: {}", original_specifier), @@ -339,32 +406,61 @@ impl ModuleLoader for EmbeddedModuleLoader { } } +impl NodeRequireLoader for EmbeddedModuleLoader { + fn ensure_read_permission<'a>( + &self, + permissions: &mut dyn deno_runtime::deno_node::NodePermissions, + path: &'a std::path::Path, + ) -> Result, AnyError> { + if self.shared.modules.has_file(path) { + // allow reading if the file is in the snapshot + return Ok(Cow::Borrowed(path)); + } + + self + .shared + .npm_resolver + .ensure_read_permission(permissions, path) + } + + fn load_text_file_lossy( + &self, + path: &std::path::Path, + ) -> Result { + Ok(self.shared.fs.read_text_file_lossy_sync(path, None)?) + } +} + struct StandaloneModuleLoaderFactory { shared: Arc, } +impl StandaloneModuleLoaderFactory { + pub fn create_result(&self) -> CreateModuleLoaderResult { + let loader = Rc::new(EmbeddedModuleLoader { + shared: self.shared.clone(), + }); + CreateModuleLoaderResult { + module_loader: loader.clone(), + node_require_loader: loader, + } + } +} + impl ModuleLoaderFactory for StandaloneModuleLoaderFactory { fn create_for_main( &self, _root_permissions: PermissionsContainer, - ) -> ModuleLoaderAndSourceMapGetter { - ModuleLoaderAndSourceMapGetter { - module_loader: Rc::new(EmbeddedModuleLoader { - shared: self.shared.clone(), - }), - } + ) -> CreateModuleLoaderResult { + self.create_result() } fn create_for_worker( &self, _parent_permissions: PermissionsContainer, _permissions: PermissionsContainer, - ) -> ModuleLoaderAndSourceMapGetter { - ModuleLoaderAndSourceMapGetter { - module_loader: Rc::new(EmbeddedModuleLoader { - shared: self.shared.clone(), - }), - } + ) -> CreateModuleLoaderResult { + self.create_result() } } @@ -410,106 +506,155 @@ pub async fn run(data: StandaloneData) -> Result { let main_module = root_dir_url.join(&metadata.entrypoint_key).unwrap(); let npm_global_cache_dir = root_path.join(".deno_compile_node_modules"); let cache_setting = CacheSetting::Only; - let npm_resolver = match metadata.node_modules { + let pkg_json_resolver = Arc::new(PackageJsonResolver::new( + deno_runtime::deno_node::DenoFsNodeResolverEnv::new(fs.clone()), + )); + let (in_npm_pkg_checker, npm_resolver) = match metadata.node_modules { Some(binary::NodeModules::Managed { node_modules_dir }) => { + // create an npmrc that uses the fake npm_registry_url to resolve packages + let npmrc = Arc::new(ResolvedNpmRc { + default_config: deno_npm::npm_rc::RegistryConfigWithUrl { + registry_url: npm_registry_url.clone(), + config: Default::default(), + }, + scopes: Default::default(), + registry_configs: Default::default(), + }); + let npm_cache_dir = Arc::new(NpmCacheDir::new( + &DenoCacheEnvFsAdapter(fs.as_ref()), + npm_global_cache_dir, + npmrc.get_all_known_registries_urls(), + )); let snapshot = npm_snapshot.unwrap(); let maybe_node_modules_path = node_modules_dir .map(|node_modules_dir| root_path.join(node_modules_dir)); - create_cli_npm_resolver(CliNpmResolverCreateOptions::Managed( - CliNpmResolverManagedCreateOptions { - snapshot: CliNpmResolverManagedSnapshotOption::Specified(Some( - snapshot, - )), - maybe_lockfile: None, - fs: fs.clone(), - http_client_provider: http_client_provider.clone(), - npm_global_cache_dir, - cache_setting, - text_only_progress_bar: progress_bar, - maybe_node_modules_path, - npm_system_info: Default::default(), - npm_install_deps_provider: Arc::new( - // this is only used for installing packages, which isn't necessary with deno compile - NpmInstallDepsProvider::empty(), - ), - // create an npmrc that uses the fake npm_registry_url to resolve packages - npmrc: Arc::new(ResolvedNpmRc { - default_config: deno_npm::npm_rc::RegistryConfigWithUrl { - registry_url: npm_registry_url.clone(), - config: Default::default(), - }, - scopes: Default::default(), - registry_configs: Default::default(), - }), - lifecycle_scripts: Default::default(), - }, - )) - .await? + let in_npm_pkg_checker = + create_in_npm_pkg_checker(CreateInNpmPkgCheckerOptions::Managed( + CliManagedInNpmPkgCheckerCreateOptions { + root_cache_dir_url: npm_cache_dir.root_dir_url(), + maybe_node_modules_path: maybe_node_modules_path.as_deref(), + }, + )); + let npm_resolver = + create_cli_npm_resolver(CliNpmResolverCreateOptions::Managed( + CliManagedNpmResolverCreateOptions { + snapshot: CliNpmResolverManagedSnapshotOption::Specified(Some( + snapshot, + )), + maybe_lockfile: None, + fs: fs.clone(), + http_client_provider: http_client_provider.clone(), + npm_cache_dir, + cache_setting, + text_only_progress_bar: progress_bar, + maybe_node_modules_path, + npm_system_info: Default::default(), + npm_install_deps_provider: Arc::new( + // this is only used for installing packages, which isn't necessary with deno compile + NpmInstallDepsProvider::empty(), + ), + npmrc, + lifecycle_scripts: Default::default(), + }, + )) + .await?; + (in_npm_pkg_checker, npm_resolver) } Some(binary::NodeModules::Byonm { root_node_modules_dir, }) => { let root_node_modules_dir = root_node_modules_dir.map(|p| vfs.root().join(p)); - create_cli_npm_resolver(CliNpmResolverCreateOptions::Byonm( - CliByonmNpmResolverCreateOptions { + let in_npm_pkg_checker = + create_in_npm_pkg_checker(CreateInNpmPkgCheckerOptions::Byonm); + let npm_resolver = create_cli_npm_resolver( + CliNpmResolverCreateOptions::Byonm(CliByonmNpmResolverCreateOptions { fs: CliDenoResolverFs(fs.clone()), + pkg_json_resolver: pkg_json_resolver.clone(), root_node_modules_dir, - }, - )) - .await? + }), + ) + .await?; + (in_npm_pkg_checker, npm_resolver) } None => { - create_cli_npm_resolver(CliNpmResolverCreateOptions::Managed( - CliNpmResolverManagedCreateOptions { - snapshot: CliNpmResolverManagedSnapshotOption::Specified(None), - maybe_lockfile: None, - fs: fs.clone(), - http_client_provider: http_client_provider.clone(), - npm_global_cache_dir, - cache_setting, - text_only_progress_bar: progress_bar, - maybe_node_modules_path: None, - npm_system_info: Default::default(), - npm_install_deps_provider: Arc::new( - // this is only used for installing packages, which isn't necessary with deno compile - NpmInstallDepsProvider::empty(), - ), - // Packages from different registries are already inlined in the binary, - // so no need to create actual `.npmrc` configuration. - npmrc: create_default_npmrc(), - lifecycle_scripts: Default::default(), - }, - )) - .await? + // Packages from different registries are already inlined in the binary, + // so no need to create actual `.npmrc` configuration. + let npmrc = create_default_npmrc(); + let npm_cache_dir = Arc::new(NpmCacheDir::new( + &DenoCacheEnvFsAdapter(fs.as_ref()), + npm_global_cache_dir, + npmrc.get_all_known_registries_urls(), + )); + let in_npm_pkg_checker = + create_in_npm_pkg_checker(CreateInNpmPkgCheckerOptions::Managed( + CliManagedInNpmPkgCheckerCreateOptions { + root_cache_dir_url: npm_cache_dir.root_dir_url(), + maybe_node_modules_path: None, + }, + )); + let npm_resolver = + create_cli_npm_resolver(CliNpmResolverCreateOptions::Managed( + CliManagedNpmResolverCreateOptions { + snapshot: CliNpmResolverManagedSnapshotOption::Specified(None), + maybe_lockfile: None, + fs: fs.clone(), + http_client_provider: http_client_provider.clone(), + npm_cache_dir, + cache_setting, + text_only_progress_bar: progress_bar, + maybe_node_modules_path: None, + npm_system_info: Default::default(), + npm_install_deps_provider: Arc::new( + // this is only used for installing packages, which isn't necessary with deno compile + NpmInstallDepsProvider::empty(), + ), + npmrc: create_default_npmrc(), + lifecycle_scripts: Default::default(), + }, + )) + .await?; + (in_npm_pkg_checker, npm_resolver) } }; let has_node_modules_dir = npm_resolver.root_node_modules_path().is_some(); let node_resolver = Arc::new(NodeResolver::new( deno_runtime::deno_node::DenoFsNodeResolverEnv::new(fs.clone()), + in_npm_pkg_checker.clone(), npm_resolver.clone().into_npm_resolver(), + pkg_json_resolver.clone(), + )); + let cjs_tracker = Arc::new(CjsTracker::new( + in_npm_pkg_checker.clone(), + pkg_json_resolver.clone(), + CjsTrackerOptions { + unstable_detect_cjs: metadata.unstable_config.detect_cjs, + }, )); - let cjs_resolutions = Arc::new(CjsResolutionStore::default()); let cache_db = Caches::new(deno_dir_provider.clone()); let node_analysis_cache = NodeAnalysisCache::new(cache_db.node_analysis_db()); let cli_node_resolver = Arc::new(CliNodeResolver::new( - cjs_resolutions.clone(), + cjs_tracker.clone(), fs.clone(), + in_npm_pkg_checker.clone(), node_resolver.clone(), npm_resolver.clone(), )); let cjs_esm_code_analyzer = CliCjsCodeAnalyzer::new( node_analysis_cache, + cjs_tracker.clone(), fs.clone(), - cli_node_resolver.clone(), None, + false, ); let node_code_translator = Arc::new(NodeCodeTranslator::new( cjs_esm_code_analyzer, deno_runtime::deno_node::DenoFsNodeResolverEnv::new(fs.clone()), + in_npm_pkg_checker, node_resolver.clone(), npm_resolver.clone().into_npm_resolver(), + pkg_json_resolver.clone(), )); let workspace_resolver = { let import_map = match metadata.workspace_resolver.import_map { @@ -562,15 +707,18 @@ pub async fn run(data: StandaloneData) -> Result { }; let module_loader_factory = StandaloneModuleLoaderFactory { shared: Arc::new(SharedModuleLoaderState { + cjs_tracker: cjs_tracker.clone(), + fs: fs.clone(), modules, - workspace_resolver, + node_code_translator: node_code_translator.clone(), node_resolver: cli_node_resolver.clone(), npm_module_loader: Arc::new(NpmModuleLoader::new( - cjs_resolutions.clone(), - node_code_translator, + cjs_tracker.clone(), fs.clone(), - cli_node_resolver, + node_code_translator, )), + npm_resolver: npm_resolver.clone(), + workspace_resolver, }), }; @@ -609,7 +757,6 @@ pub async fn run(data: StandaloneData) -> Result { }); let worker_factory = CliMainWorkerFactory::new( Arc::new(BlobStore::default()), - cjs_resolutions, // Code cache is not supported for standalone binary yet. None, feature_checker, @@ -620,6 +767,7 @@ pub async fn run(data: StandaloneData) -> Result { Box::new(module_loader_factory), node_resolver, npm_resolver, + pkg_json_resolver, root_cert_store_provider, permissions, StorageKeyResolver::empty(), @@ -635,7 +783,6 @@ pub async fn run(data: StandaloneData) -> Result { inspect_wait: false, strace_ops: None, is_inspecting: false, - is_npm_main: main_module.scheme() == "npm", skip_op_registration: true, location: metadata.location, argv0: NpmPackageReqReference::from_specifier(&main_module) @@ -652,7 +799,6 @@ pub async fn run(data: StandaloneData) -> Result { node_ipc: None, serve_port: None, serve_host: None, - unstable_detect_cjs: metadata.unstable_config.detect_cjs, }, ); diff --git a/cli/standalone/serialization.rs b/cli/standalone/serialization.rs index 7b63c584e7..a5eb649bfd 100644 --- a/cli/standalone/serialization.rs +++ b/cli/standalone/serialization.rs @@ -214,14 +214,13 @@ impl RemoteModulesStoreBuilder { } } -pub struct DenoCompileModuleData<'a> { - pub specifier: &'a Url, - pub media_type: MediaType, - pub data: Cow<'static, [u8]>, +pub enum DenoCompileModuleSource { + String(&'static str), + Bytes(Cow<'static, [u8]>), } -impl<'a> DenoCompileModuleData<'a> { - pub fn into_for_v8(self) -> (&'a Url, ModuleType, ModuleSourceCode) { +impl DenoCompileModuleSource { + pub fn into_for_v8(self) -> ModuleSourceCode { fn into_bytes(data: Cow<'static, [u8]>) -> ModuleSourceCode { ModuleSourceCode::Bytes(match data { Cow::Borrowed(d) => d.into(), @@ -229,16 +228,31 @@ impl<'a> DenoCompileModuleData<'a> { }) } - fn into_string_unsafe(data: Cow<'static, [u8]>) -> ModuleSourceCode { + match self { // todo(https://github.com/denoland/deno_core/pull/943): store whether // the string is ascii or not ahead of time so we can avoid the is_ascii() // check in FastString::from_static + Self::String(s) => ModuleSourceCode::String(FastString::from_static(s)), + Self::Bytes(b) => into_bytes(b), + } + } +} + +pub struct DenoCompileModuleData<'a> { + pub specifier: &'a Url, + pub media_type: MediaType, + pub data: Cow<'static, [u8]>, +} + +impl<'a> DenoCompileModuleData<'a> { + pub fn into_parts(self) -> (&'a Url, ModuleType, DenoCompileModuleSource) { + fn into_string_unsafe(data: Cow<'static, [u8]>) -> DenoCompileModuleSource { match data { - Cow::Borrowed(d) => ModuleSourceCode::String( + Cow::Borrowed(d) => DenoCompileModuleSource::String( // SAFETY: we know this is a valid utf8 string - unsafe { FastString::from_static(std::str::from_utf8_unchecked(d)) }, + unsafe { std::str::from_utf8_unchecked(d) }, ), - Cow::Owned(d) => ModuleSourceCode::Bytes(d.into_boxed_slice().into()), + Cow::Owned(d) => DenoCompileModuleSource::Bytes(Cow::Owned(d)), } } @@ -257,11 +271,14 @@ impl<'a> DenoCompileModuleData<'a> { (ModuleType::JavaScript, into_string_unsafe(self.data)) } MediaType::Json => (ModuleType::Json, into_string_unsafe(self.data)), - MediaType::Wasm => (ModuleType::Wasm, into_bytes(self.data)), - // just assume javascript if we made it here - MediaType::TsBuildInfo | MediaType::SourceMap | MediaType::Unknown => { - (ModuleType::JavaScript, into_bytes(self.data)) + MediaType::Wasm => { + (ModuleType::Wasm, DenoCompileModuleSource::Bytes(self.data)) } + // just assume javascript if we made it here + MediaType::Css | MediaType::SourceMap | MediaType::Unknown => ( + ModuleType::JavaScript, + DenoCompileModuleSource::Bytes(self.data), + ), }; (self.specifier, media_type, source) } @@ -551,7 +568,7 @@ fn serialize_media_type(media_type: MediaType) -> u8 { MediaType::Tsx => 10, MediaType::Json => 11, MediaType::Wasm => 12, - MediaType::TsBuildInfo => 13, + MediaType::Css => 13, MediaType::SourceMap => 14, MediaType::Unknown => 15, } @@ -572,7 +589,7 @@ fn deserialize_media_type(value: u8) -> Result { 10 => Ok(MediaType::Tsx), 11 => Ok(MediaType::Json), 12 => Ok(MediaType::Wasm), - 13 => Ok(MediaType::TsBuildInfo), + 13 => Ok(MediaType::Css), 14 => Ok(MediaType::SourceMap), 15 => Ok(MediaType::Unknown), _ => bail!("Unknown media type value: {}", value), diff --git a/cli/tools/bench/mod.rs b/cli/tools/bench/mod.rs index be5d0ad0e1..272d063355 100644 --- a/cli/tools/bench/mod.rs +++ b/cli/tools/bench/mod.rs @@ -193,7 +193,7 @@ async fn bench_specifier_inner( .await?; // We execute the main module as a side module so that import.meta.main is not set. - worker.execute_side_module_possibly_with_npm().await?; + worker.execute_side_module().await?; let mut worker = worker.into_main_worker(); diff --git a/cli/tools/check.rs b/cli/tools/check.rs index 7edb392d48..d880278884 100644 --- a/cli/tools/check.rs +++ b/cli/tools/check.rs @@ -32,6 +32,7 @@ use crate::graph_util::ModuleGraphBuilder; use crate::npm::CliNpmResolver; use crate::tsc; use crate::tsc::Diagnostics; +use crate::tsc::TypeCheckingCjsTracker; use crate::util::extract; use crate::util::path::to_percent_decoded_str; @@ -99,6 +100,7 @@ pub struct CheckOptions { pub struct TypeChecker { caches: Arc, + cjs_tracker: Arc, cli_options: Arc, module_graph_builder: Arc, node_resolver: Arc, @@ -108,6 +110,7 @@ pub struct TypeChecker { impl TypeChecker { pub fn new( caches: Arc, + cjs_tracker: Arc, cli_options: Arc, module_graph_builder: Arc, node_resolver: Arc, @@ -115,6 +118,7 @@ impl TypeChecker { ) -> Self { Self { caches, + cjs_tracker, cli_options, module_graph_builder, node_resolver, @@ -244,6 +248,7 @@ impl TypeChecker { graph: graph.clone(), hash_data, maybe_npm: Some(tsc::RequestNpmState { + cjs_tracker: self.cjs_tracker.clone(), node_resolver: self.node_resolver.clone(), npm_resolver: self.npm_resolver.clone(), }), @@ -346,7 +351,7 @@ fn get_check_hash( } } MediaType::Json - | MediaType::TsBuildInfo + | MediaType::Css | MediaType::SourceMap | MediaType::Wasm | MediaType::Unknown => continue, @@ -428,7 +433,7 @@ fn get_tsc_roots( } MediaType::Json | MediaType::Wasm - | MediaType::TsBuildInfo + | MediaType::Css | MediaType::SourceMap | MediaType::Unknown => None, }, @@ -536,7 +541,7 @@ fn has_ts_check(media_type: MediaType, file_text: &str) -> bool { | MediaType::Tsx | MediaType::Json | MediaType::Wasm - | MediaType::TsBuildInfo + | MediaType::Css | MediaType::SourceMap | MediaType::Unknown => false, } diff --git a/cli/tools/compile.rs b/cli/tools/compile.rs index 5a4a938bb9..b3e9993379 100644 --- a/cli/tools/compile.rs +++ b/cli/tools/compile.rs @@ -53,16 +53,6 @@ pub async fn compile( ); } - if cli_options.unstable_detect_cjs() { - log::warn!( - concat!( - "{} --unstable-detect-cjs is not properly supported in deno compile. ", - "The compiled executable may encounter runtime errors.", - ), - crate::colors::yellow("Warning"), - ); - } - let output_path = resolve_compile_executable_output_path( http_client, &compile_flags, diff --git a/cli/tools/coverage/mod.rs b/cli/tools/coverage/mod.rs index 48922f1449..f593332475 100644 --- a/cli/tools/coverage/mod.rs +++ b/cli/tools/coverage/mod.rs @@ -6,12 +6,12 @@ use crate::args::FileFlags; use crate::args::Flags; use crate::cdp; use crate::factory::CliFactory; -use crate::npm::CliNpmResolver; use crate::tools::fmt::format_json; use crate::tools::test::is_supported_test_path; use crate::util::text_encoding::source_map_from_code; use deno_ast::MediaType; +use deno_ast::ModuleKind; use deno_ast::ModuleSpecifier; use deno_config::glob::FileCollector; use deno_config::glob::FilePatterns; @@ -25,6 +25,7 @@ use deno_core::serde_json; use deno_core::sourcemap::SourceMap; use deno_core::url::Url; use deno_core::LocalInspectorSession; +use node_resolver::InNpmPackageChecker; use regex::Regex; use std::fs; use std::fs::File; @@ -461,7 +462,7 @@ fn filter_coverages( coverages: Vec, include: Vec, exclude: Vec, - npm_resolver: &dyn CliNpmResolver, + in_npm_pkg_checker: &dyn InNpmPackageChecker, ) -> Vec { let include: Vec = include.iter().map(|e| Regex::new(e).unwrap()).collect(); @@ -485,7 +486,7 @@ fn filter_coverages( || doc_test_re.is_match(e.url.as_str()) || Url::parse(&e.url) .ok() - .map(|url| npm_resolver.in_npm_package(&url)) + .map(|url| in_npm_pkg_checker.in_npm_package(&url)) .unwrap_or(false); let is_included = include.iter().any(|p| p.is_match(&e.url)); @@ -496,7 +497,7 @@ fn filter_coverages( .collect::>() } -pub async fn cover_files( +pub fn cover_files( flags: Arc, coverage_flags: CoverageFlags, ) -> Result<(), AnyError> { @@ -506,9 +507,10 @@ pub async fn cover_files( let factory = CliFactory::from_flags(flags); let cli_options = factory.cli_options()?; - let npm_resolver = factory.npm_resolver().await?; + let in_npm_pkg_checker = factory.in_npm_pkg_checker()?; let file_fetcher = factory.file_fetcher()?; let emitter = factory.emitter()?; + let cjs_tracker = factory.cjs_tracker()?; assert!(!coverage_flags.files.include.is_empty()); @@ -528,7 +530,7 @@ pub async fn cover_files( script_coverages, coverage_flags.include, coverage_flags.exclude, - npm_resolver.as_ref(), + in_npm_pkg_checker.as_ref(), ); if script_coverages.is_empty() { return Err(generic_error("No covered files included in the report")); @@ -585,6 +587,8 @@ pub async fn cover_files( let transpiled_code = match file.media_type { MediaType::JavaScript | MediaType::Unknown + | MediaType::Css + | MediaType::Wasm | MediaType::Cjs | MediaType::Mjs | MediaType::Json => None, @@ -594,7 +598,10 @@ pub async fn cover_files( | MediaType::Mts | MediaType::Cts | MediaType::Tsx => { - Some(match emitter.maybe_cached_emit(&file.specifier, &file.source) { + let module_kind = ModuleKind::from_is_cjs( + cjs_tracker.is_maybe_cjs(&file.specifier, file.media_type)?, + ); + Some(match emitter.maybe_cached_emit(&file.specifier, module_kind, &file.source) { Some(code) => code, None => { return Err(anyhow!( @@ -605,7 +612,7 @@ pub async fn cover_files( } }) } - MediaType::Wasm | MediaType::TsBuildInfo | MediaType::SourceMap => { + MediaType::SourceMap => { unreachable!() } }; diff --git a/cli/tools/doc.rs b/cli/tools/doc.rs index 5e18546a28..e33da4efb2 100644 --- a/cli/tools/doc.rs +++ b/cli/tools/doc.rs @@ -22,9 +22,9 @@ use deno_core::serde_json; use deno_doc as doc; use deno_doc::html::UrlResolveKind; use deno_graph::source::NullFileSystem; +use deno_graph::EsParser; use deno_graph::GraphKind; use deno_graph::ModuleAnalyzer; -use deno_graph::ModuleParser; use deno_graph::ModuleSpecifier; use doc::html::ShortPath; use doc::DocDiagnostic; @@ -37,7 +37,7 @@ const JSON_SCHEMA_VERSION: u8 = 1; async fn generate_doc_nodes_for_builtin_types( doc_flags: DocFlags, - parser: &dyn ModuleParser, + parser: &dyn EsParser, analyzer: &dyn ModuleAnalyzer, ) -> Result>, AnyError> { let source_file_specifier = @@ -96,7 +96,7 @@ pub async fn doc( let module_info_cache = factory.module_info_cache()?; let parsed_source_cache = factory.parsed_source_cache(); let capturing_parser = parsed_source_cache.as_capturing_parser(); - let analyzer = module_info_cache.as_module_analyzer(parsed_source_cache); + let analyzer = module_info_cache.as_module_analyzer(); let doc_nodes_by_url = match doc_flags.source_files { DocSourceFileFlag::Builtin => { diff --git a/cli/tools/registry/tar.rs b/cli/tools/registry/tar.rs index aca125e00b..6d1801ce69 100644 --- a/cli/tools/registry/tar.rs +++ b/cli/tools/registry/tar.rs @@ -120,7 +120,7 @@ fn resolve_content_maybe_unfurling( | MediaType::Unknown | MediaType::Json | MediaType::Wasm - | MediaType::TsBuildInfo => { + | MediaType::Css => { // not unfurlable data return Ok(data); } diff --git a/cli/tools/repl/session.rs b/cli/tools/repl/session.rs index 484664dae4..23b0f11ac5 100644 --- a/cli/tools/repl/session.rs +++ b/cli/tools/repl/session.rs @@ -25,6 +25,7 @@ use deno_ast::swc::visit::noop_visit_type; use deno_ast::swc::visit::Visit; use deno_ast::swc::visit::VisitWith; use deno_ast::ImportsNotUsedAsValues; +use deno_ast::ModuleKind; use deno_ast::ModuleSpecifier; use deno_ast::ParseDiagnosticsError; use deno_ast::ParsedSource; @@ -641,6 +642,10 @@ impl ReplSession { jsx_fragment_factory: self.jsx.frag_factory.clone(), jsx_import_source: self.jsx.import_source.clone(), var_decl_imports: true, + verbatim_module_syntax: false, + }, + &deno_ast::TranspileModuleOptions { + module_kind: Some(ModuleKind::Esm), }, &deno_ast::EmitOptions { source_map: deno_ast::SourceMapOption::None, @@ -651,7 +656,6 @@ impl ReplSession { }, )? .into_source() - .into_string()? .text; let value = self diff --git a/cli/tools/run/hmr.rs b/cli/tools/run/hmr.rs index 6ccf8e344b..6cebedd012 100644 --- a/cli/tools/run/hmr.rs +++ b/cli/tools/run/hmr.rs @@ -1,9 +1,11 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -use crate::cdp; -use crate::emit::Emitter; -use crate::util::file_watcher::WatcherCommunicator; -use crate::util::file_watcher::WatcherRestartMode; +use std::collections::HashMap; +use std::path::PathBuf; +use std::sync::Arc; + +use deno_ast::MediaType; +use deno_ast::ModuleKind; use deno_core::error::generic_error; use deno_core::error::AnyError; use deno_core::futures::StreamExt; @@ -12,11 +14,14 @@ use deno_core::serde_json::{self}; use deno_core::url::Url; use deno_core::LocalInspectorSession; use deno_terminal::colors; -use std::collections::HashMap; -use std::path::PathBuf; -use std::sync::Arc; use tokio::select; +use crate::cdp; +use crate::emit::Emitter; +use crate::resolver::CjsTracker; +use crate::util::file_watcher::WatcherCommunicator; +use crate::util::file_watcher::WatcherRestartMode; + fn explain(status: &cdp::Status) -> &'static str { match status { cdp::Status::Ok => "OK", @@ -58,6 +63,7 @@ pub struct HmrRunner { session: LocalInspectorSession, watcher_communicator: Arc, script_ids: HashMap, + cjs_tracker: Arc, emitter: Arc, } @@ -139,7 +145,8 @@ impl crate::worker::HmrRunner for HmrRunner { }; let source_code = self.emitter.load_and_emit_for_hmr( - &module_url + &module_url, + ModuleKind::from_is_cjs(self.cjs_tracker.is_maybe_cjs(&module_url, MediaType::from_specifier(&module_url))?), ).await?; let mut tries = 1; @@ -172,12 +179,14 @@ impl crate::worker::HmrRunner for HmrRunner { impl HmrRunner { pub fn new( + cjs_tracker: Arc, emitter: Arc, session: LocalInspectorSession, watcher_communicator: Arc, ) -> Self { Self { session, + cjs_tracker, emitter, watcher_communicator, script_ids: HashMap::new(), diff --git a/cli/tools/test/mod.rs b/cli/tools/test/mod.rs index e81abad0b2..fa849614fa 100644 --- a/cli/tools/test/mod.rs +++ b/cli/tools/test/mod.rs @@ -631,7 +631,7 @@ async fn configure_main_worker( "Deno[Deno.internal].core.setLeakTracingEnabled(true);", )?; } - let res = worker.execute_side_module_possibly_with_npm().await; + let res = worker.execute_side_module().await; let mut worker = worker.into_main_worker(); match res { Ok(()) => Ok(()), diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index 6011dece76..bdc4340e33 100644 --- a/cli/tsc/99_main_compiler.js +++ b/cli/tsc/99_main_compiler.js @@ -845,6 +845,8 @@ delete Object.prototype.__proto__; jqueryMessage, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592": jqueryMessage, + "Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set_6263": + "Module '{0}' was resolved to '{1}', but importing these modules is not supported.", }; })()); diff --git a/cli/tsc/diagnostics.rs b/cli/tsc/diagnostics.rs index b0394ec177..d3795706eb 100644 --- a/cli/tsc/diagnostics.rs +++ b/cli/tsc/diagnostics.rs @@ -323,7 +323,7 @@ impl Diagnostics { // todo(dsherret): use a short lived cache to prevent parsing // source maps so often if let Ok(source_map) = - SourceMap::from_slice(&fast_check_module.source_map) + SourceMap::from_slice(fast_check_module.source_map.as_bytes()) { if let Some(start) = d.start.as_mut() { let maybe_token = source_map diff --git a/cli/tsc/mod.rs b/cli/tsc/mod.rs index de91889b62..dc7fc38f7a 100644 --- a/cli/tsc/mod.rs +++ b/cli/tsc/mod.rs @@ -3,9 +3,11 @@ use crate::args::TsConfig; use crate::args::TypeCheckMode; use crate::cache::FastInsecureHasher; +use crate::cache::ModuleInfoCache; use crate::node; use crate::npm::CliNpmResolver; use crate::npm::ResolvePkgFolderFromDenoReqError; +use crate::resolver::CjsTracker; use crate::util::checksum; use crate::util::path::mapped_specifier_for_tsc; @@ -32,13 +34,13 @@ use deno_graph::GraphKind; use deno_graph::Module; use deno_graph::ModuleGraph; use deno_graph::ResolutionResolved; +use deno_runtime::deno_fs; use deno_runtime::deno_node::NodeResolver; use deno_semver::npm::NpmPackageReqReference; use node_resolver::errors::NodeJsErrorCode; use node_resolver::errors::NodeJsErrorCoded; -use node_resolver::errors::ResolvePkgSubpathFromDenoModuleError; +use node_resolver::errors::PackageSubpathResolveError; use node_resolver::NodeModuleKind; -use node_resolver::NodeResolution; use node_resolver::NodeResolutionMode; use once_cell::sync::Lazy; use std::borrow::Cow; @@ -302,8 +304,76 @@ pub struct EmittedFile { pub media_type: MediaType, } +pub fn into_specifier_and_media_type( + specifier: Option, +) -> (ModuleSpecifier, MediaType) { + match specifier { + Some(specifier) => { + let media_type = MediaType::from_specifier(&specifier); + + (specifier, media_type) + } + None => ( + Url::parse("internal:///missing_dependency.d.ts").unwrap(), + MediaType::Dts, + ), + } +} + +#[derive(Debug)] +pub struct TypeCheckingCjsTracker { + cjs_tracker: Arc, + module_info_cache: Arc, +} + +impl TypeCheckingCjsTracker { + pub fn new( + cjs_tracker: Arc, + module_info_cache: Arc, + ) -> Self { + Self { + cjs_tracker, + module_info_cache, + } + } + + pub fn is_cjs( + &self, + specifier: &ModuleSpecifier, + media_type: MediaType, + code: &Arc, + ) -> bool { + if let Some(module_kind) = + self.cjs_tracker.get_known_kind(specifier, media_type) + { + module_kind.is_cjs() + } else { + let maybe_is_script = self + .module_info_cache + .as_module_analyzer() + .analyze_sync(specifier, media_type, code) + .ok() + .map(|info| info.is_script); + maybe_is_script + .and_then(|is_script| { + self + .cjs_tracker + .is_cjs_with_known_is_script(specifier, media_type, is_script) + .ok() + }) + .unwrap_or_else(|| { + self + .cjs_tracker + .is_maybe_cjs(specifier, media_type) + .unwrap_or(false) + }) + } + } +} + #[derive(Debug)] pub struct RequestNpmState { + pub cjs_tracker: Arc, pub node_resolver: Arc, pub npm_resolver: Arc, } @@ -456,7 +526,7 @@ pub fn as_ts_script_kind(media_type: MediaType) -> i32 { MediaType::Tsx => 4, MediaType::Json => 6, MediaType::SourceMap - | MediaType::TsBuildInfo + | MediaType::Css | MediaType::Wasm | MediaType::Unknown => 0, } @@ -489,25 +559,22 @@ fn op_load_inner( ) -> Result, AnyError> { fn load_from_node_modules( specifier: &ModuleSpecifier, - node_resolver: Option<&NodeResolver>, + npm_state: Option<&RequestNpmState>, media_type: &mut MediaType, is_cjs: &mut bool, ) -> Result { *media_type = MediaType::from_specifier(specifier); - *is_cjs = node_resolver - .map(|node_resolver| { - match node_resolver.url_to_node_resolution(specifier.clone()) { - Ok(NodeResolution::CommonJs(_)) => true, - Ok(NodeResolution::Esm(_)) - | Ok(NodeResolution::BuiltIn(_)) - | Err(_) => false, - } - }) - .unwrap_or(false); let file_path = specifier.to_file_path().unwrap(); let code = std::fs::read_to_string(&file_path) .with_context(|| format!("Unable to load {}", file_path.display()))?; - Ok(code) + let code: Arc = code.into(); + *is_cjs = npm_state + .map(|npm_state| { + npm_state.cjs_tracker.is_cjs(specifier, *media_type, &code) + }) + .unwrap_or(false); + // todo(dsherret): how to avoid cloning here? + Ok(code.to_string()) } let state = state.borrow_mut::(); @@ -560,6 +627,9 @@ fn op_load_inner( match module { Module::Js(module) => { media_type = module.media_type; + if matches!(media_type, MediaType::Cjs | MediaType::Cts) { + is_cjs = true; + } let source = module .fast_check_module() .map(|m| &*m.source) @@ -573,11 +643,13 @@ fn op_load_inner( Module::Npm(_) | Module::Node(_) => None, Module::External(module) => { // means it's Deno code importing an npm module - let specifier = - node::resolve_specifier_into_node_modules(&module.specifier); + let specifier = node::resolve_specifier_into_node_modules( + &module.specifier, + &deno_fs::RealFs, + ); Some(Cow::Owned(load_from_node_modules( &specifier, - state.maybe_npm.as_ref().map(|n| n.node_resolver.as_ref()), + state.maybe_npm.as_ref(), &mut media_type, &mut is_cjs, )?)) @@ -590,7 +662,7 @@ fn op_load_inner( { Some(Cow::Owned(load_from_node_modules( specifier, - Some(npm.node_resolver.as_ref()), + Some(npm), &mut media_type, &mut is_cjs, )?)) @@ -739,7 +811,13 @@ fn op_resolve_inner( } } }; - (specifier_str, media_type.as_ts_extension()) + ( + specifier_str, + match media_type { + MediaType::Css => ".js", // surface these as .js for typescript + media_type => media_type.as_ts_extension(), + }, + ) } None => ( MISSING_DEPENDENCY_SPECIFIER.to_string(), @@ -810,29 +888,27 @@ fn resolve_graph_specifier_types( Some(referrer), NodeResolutionMode::Types, ); - let maybe_resolution = match res_result { - Ok(res) => Some(res), + let maybe_url = match res_result { + Ok(url) => Some(url), Err(err) => match err.code() { NodeJsErrorCode::ERR_TYPES_NOT_FOUND | NodeJsErrorCode::ERR_MODULE_NOT_FOUND => None, _ => return Err(err.into()), }, }; - Ok(Some(NodeResolution::into_specifier_and_media_type( - maybe_resolution, - ))) + Ok(Some(into_specifier_and_media_type(maybe_url))) } else { Ok(None) } } Some(Module::External(module)) => { // we currently only use "External" for when the module is in an npm package - Ok(state.maybe_npm.as_ref().map(|npm| { - let specifier = - node::resolve_specifier_into_node_modules(&module.specifier); - NodeResolution::into_specifier_and_media_type( - npm.node_resolver.url_to_node_resolution(specifier).ok(), - ) + Ok(state.maybe_npm.as_ref().map(|_| { + let specifier = node::resolve_specifier_into_node_modules( + &module.specifier, + &deno_fs::RealFs, + ); + into_specifier_and_media_type(Some(specifier)) })) } Some(Module::Node(_)) | None => Ok(None), @@ -844,7 +920,7 @@ enum ResolveNonGraphSpecifierTypesError { #[error(transparent)] ResolvePkgFolderFromDenoReq(#[from] ResolvePkgFolderFromDenoReqError), #[error(transparent)] - ResolvePkgSubpathFromDenoModule(#[from] ResolvePkgSubpathFromDenoModuleError), + PackageSubpathResolve(#[from] PackageSubpathResolveError), } fn resolve_non_graph_specifier_types( @@ -863,7 +939,7 @@ fn resolve_non_graph_specifier_types( let node_resolver = &npm.node_resolver; if node_resolver.in_npm_package(referrer) { // we're in an npm package, so use node resolution - Ok(Some(NodeResolution::into_specifier_and_media_type( + Ok(Some(into_specifier_and_media_type( node_resolver .resolve( raw_specifier, @@ -871,7 +947,8 @@ fn resolve_non_graph_specifier_types( referrer_kind, NodeResolutionMode::Types, ) - .ok(), + .ok() + .map(|res| res.into_url()), ))) } else if let Ok(npm_req_ref) = NpmPackageReqReference::from_str(raw_specifier) @@ -890,17 +967,15 @@ fn resolve_non_graph_specifier_types( Some(referrer), NodeResolutionMode::Types, ); - let maybe_resolution = match res_result { - Ok(res) => Some(res), + let maybe_url = match res_result { + Ok(url) => Some(url), Err(err) => match err.code() { NodeJsErrorCode::ERR_TYPES_NOT_FOUND | NodeJsErrorCode::ERR_MODULE_NOT_FOUND => None, _ => return Err(err.into()), }, }; - Ok(Some(NodeResolution::into_specifier_and_media_type( - maybe_resolution, - ))) + Ok(Some(into_specifier_and_media_type(maybe_url))) } else { Ok(None) } diff --git a/cli/util/extract.rs b/cli/util/extract.rs index 873b7e7f2d..f577cbefec 100644 --- a/cli/util/extract.rs +++ b/cli/util/extract.rs @@ -64,7 +64,7 @@ fn extract_inner( }) { Ok(parsed) => { let mut c = ExportCollector::default(); - c.visit_program(parsed.program_ref()); + c.visit_program(parsed.program().as_ref()); c } Err(_) => ExportCollector::default(), @@ -570,14 +570,14 @@ fn generate_pseudo_file( })?; let top_level_atoms = swc_utils::collect_decls_with_ctxt::( - parsed.program_ref(), + &parsed.program_ref(), parsed.top_level_context(), ); let transformed = parsed .program_ref() - .clone() + .to_owned() .fold_with(&mut as_folder(Transform { specifier: &file.specifier, base_file_specifier, @@ -1416,7 +1416,7 @@ console.log(Foo); }) .unwrap(); - collector.visit_program(parsed.program_ref()); + parsed.program_ref().visit_with(&mut collector); collector } diff --git a/cli/util/logger.rs b/cli/util/logger.rs index cdc89411fe..d93753dfd3 100644 --- a/cli/util/logger.rs +++ b/cli/util/logger.rs @@ -65,6 +65,8 @@ pub fn init(maybe_level: Option) { .filter_module("swc_ecma_parser", log::LevelFilter::Error) // Suppress span lifecycle logs since they are too verbose .filter_module("tracing::span", log::LevelFilter::Off) + // for deno_compile, this is too verbose + .filter_module("editpe", log::LevelFilter::Error) .format(|buf, record| { let mut target = record.target().to_string(); if let Some(line_no) = record.line() { diff --git a/cli/util/path.rs b/cli/util/path.rs index e4ae6e7cb1..58bed664f9 100644 --- a/cli/util/path.rs +++ b/cli/util/path.rs @@ -42,21 +42,6 @@ pub fn get_extension(file_path: &Path) -> Option { .map(|e| e.to_lowercase()); } -pub fn specifier_has_extension( - specifier: &ModuleSpecifier, - searching_ext: &str, -) -> bool { - let Some((_, ext)) = specifier.path().rsplit_once('.') else { - return false; - }; - let searching_ext = searching_ext.strip_prefix('.').unwrap_or(searching_ext); - debug_assert!(!searching_ext.contains('.')); // exts like .d.ts are not implemented here - if ext.len() != searching_ext.len() { - return false; - } - ext.eq_ignore_ascii_case(searching_ext) -} - pub fn get_atomic_dir_path(file_path: &Path) -> PathBuf { let rand = gen_rand_path_component(); let new_file_name = format!( @@ -350,18 +335,6 @@ mod test { } } - #[test] - fn test_specifier_has_extension() { - fn get(specifier: &str, ext: &str) -> bool { - specifier_has_extension(&ModuleSpecifier::parse(specifier).unwrap(), ext) - } - - assert!(get("file:///a/b/c.ts", "ts")); - assert!(get("file:///a/b/c.ts", ".ts")); - assert!(!get("file:///a/b/c.ts", ".cts")); - assert!(get("file:///a/b/c.CtS", ".cts")); - } - #[test] fn test_to_percent_decoded_str() { let str = to_percent_decoded_str("%F0%9F%A6%95"); diff --git a/cli/util/text_encoding.rs b/cli/util/text_encoding.rs index df72cc2be6..8524e63ebb 100644 --- a/cli/util/text_encoding.rs +++ b/cli/util/text_encoding.rs @@ -97,6 +97,7 @@ fn find_source_map_range(code: &[u8]) -> Option> { } /// Converts an `Arc` to an `Arc<[u8]>`. +#[allow(dead_code)] pub fn arc_str_to_bytes(arc_str: Arc) -> Arc<[u8]> { let raw = Arc::into_raw(arc_str); // SAFETY: This is safe because they have the same memory layout. diff --git a/cli/worker.rs b/cli/worker.rs index e230197d2b..baacd681a1 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -14,16 +14,17 @@ use deno_core::v8; use deno_core::CompiledWasmModuleStore; use deno_core::Extension; use deno_core::FeatureChecker; -use deno_core::ModuleId; use deno_core::ModuleLoader; use deno_core::PollEventLoopOptions; use deno_core::SharedArrayBufferStore; use deno_runtime::code_cache; use deno_runtime::deno_broadcast_channel::InMemoryBroadcastChannel; use deno_runtime::deno_fs; -use deno_runtime::deno_node; use deno_runtime::deno_node::NodeExtInitServices; +use deno_runtime::deno_node::NodeRequireLoader; +use deno_runtime::deno_node::NodeRequireLoaderRc; use deno_runtime::deno_node::NodeResolver; +use deno_runtime::deno_node::PackageJsonResolver; use deno_runtime::deno_permissions::PermissionsContainer; use deno_runtime::deno_tls::RootCertStoreProvider; use deno_runtime::deno_web::BlobStore; @@ -42,7 +43,6 @@ use deno_runtime::WorkerExecutionMode; use deno_runtime::WorkerLogLevel; use deno_semver::npm::NpmPackageReqReference; use deno_terminal::colors; -use node_resolver::NodeResolution; use node_resolver::NodeResolutionMode; use tokio::select; @@ -51,28 +51,27 @@ use crate::args::DenoSubcommand; use crate::args::StorageKeyResolver; use crate::errors; use crate::npm::CliNpmResolver; -use crate::resolver::CjsResolutionStore; use crate::util::checksum; use crate::util::file_watcher::WatcherCommunicator; use crate::util::file_watcher::WatcherRestartMode; -use crate::util::path::specifier_has_extension; use crate::version; -pub struct ModuleLoaderAndSourceMapGetter { +pub struct CreateModuleLoaderResult { pub module_loader: Rc, + pub node_require_loader: Rc, } pub trait ModuleLoaderFactory: Send + Sync { fn create_for_main( &self, root_permissions: PermissionsContainer, - ) -> ModuleLoaderAndSourceMapGetter; + ) -> CreateModuleLoaderResult; fn create_for_worker( &self, parent_permissions: PermissionsContainer, permissions: PermissionsContainer, - ) -> ModuleLoaderAndSourceMapGetter; + ) -> CreateModuleLoaderResult; } #[async_trait::async_trait(?Send)] @@ -109,7 +108,6 @@ pub struct CliMainWorkerOptions { pub inspect_wait: bool, pub strace_ops: Option>, pub is_inspecting: bool, - pub is_npm_main: bool, pub location: Option, pub argv0: Option, pub node_debug: Option, @@ -122,13 +120,11 @@ pub struct CliMainWorkerOptions { pub node_ipc: Option, pub serve_port: Option, pub serve_host: Option, - pub unstable_detect_cjs: bool, } struct SharedWorkerState { blob_store: Arc, broadcast_channel: InMemoryBroadcastChannel, - cjs_resolution_store: Arc, code_cache: Option>, compiled_wasm_module_store: CompiledWasmModuleStore, feature_checker: Arc, @@ -139,6 +135,7 @@ struct SharedWorkerState { module_loader_factory: Box, node_resolver: Arc, npm_resolver: Arc, + pkg_json_resolver: Arc, root_cert_store_provider: Arc, root_permissions: PermissionsContainer, shared_array_buffer_store: SharedArrayBufferStore, @@ -148,11 +145,15 @@ struct SharedWorkerState { } impl SharedWorkerState { - pub fn create_node_init_services(&self) -> NodeExtInitServices { + pub fn create_node_init_services( + &self, + node_require_loader: NodeRequireLoaderRc, + ) -> NodeExtInitServices { NodeExtInitServices { - node_require_resolver: self.npm_resolver.clone().into_require_resolver(), + node_require_loader, node_resolver: self.node_resolver.clone(), npm_resolver: self.npm_resolver.clone().into_npm_resolver(), + pkg_json_resolver: self.pkg_json_resolver.clone(), } } @@ -163,7 +164,6 @@ impl SharedWorkerState { pub struct CliMainWorker { main_module: ModuleSpecifier, - is_main_cjs: bool, worker: MainWorker, shared: Arc, } @@ -185,17 +185,7 @@ impl CliMainWorker { log::debug!("main_module {}", self.main_module); - if self.is_main_cjs { - deno_node::load_cjs_module( - &mut self.worker.js_runtime, - &self.main_module.to_file_path().unwrap().to_string_lossy(), - true, - self.shared.options.inspect_brk, - )?; - } else { - self.execute_main_module_possibly_with_npm().await?; - } - + self.execute_main_module().await?; self.worker.dispatch_load_event()?; loop { @@ -283,22 +273,7 @@ impl CliMainWorker { /// Execute the given main module emitting load and unload events before and after execution /// respectively. pub async fn execute(&mut self) -> Result<(), AnyError> { - if self.inner.is_main_cjs { - deno_node::load_cjs_module( - &mut self.inner.worker.js_runtime, - &self - .inner - .main_module - .to_file_path() - .unwrap() - .to_string_lossy(), - true, - self.inner.shared.options.inspect_brk, - )?; - } else { - self.inner.execute_main_module_possibly_with_npm().await?; - } - + self.inner.execute_main_module().await?; self.inner.worker.dispatch_load_event()?; self.pending_unload = true; @@ -339,24 +314,13 @@ impl CliMainWorker { executor.execute().await } - pub async fn execute_main_module_possibly_with_npm( - &mut self, - ) -> Result<(), AnyError> { + pub async fn execute_main_module(&mut self) -> Result<(), AnyError> { let id = self.worker.preload_main_module(&self.main_module).await?; - self.evaluate_module_possibly_with_npm(id).await + self.worker.evaluate_module(id).await } - pub async fn execute_side_module_possibly_with_npm( - &mut self, - ) -> Result<(), AnyError> { + pub async fn execute_side_module(&mut self) -> Result<(), AnyError> { let id = self.worker.preload_side_module(&self.main_module).await?; - self.evaluate_module_possibly_with_npm(id).await - } - - async fn evaluate_module_possibly_with_npm( - &mut self, - id: ModuleId, - ) -> Result<(), AnyError> { self.worker.evaluate_module(id).await } @@ -426,7 +390,6 @@ impl CliMainWorkerFactory { #[allow(clippy::too_many_arguments)] pub fn new( blob_store: Arc, - cjs_resolution_store: Arc, code_cache: Option>, feature_checker: Arc, fs: Arc, @@ -436,6 +399,7 @@ impl CliMainWorkerFactory { module_loader_factory: Box, node_resolver: Arc, npm_resolver: Arc, + pkg_json_resolver: Arc, root_cert_store_provider: Arc, root_permissions: PermissionsContainer, storage_key_resolver: StorageKeyResolver, @@ -446,7 +410,6 @@ impl CliMainWorkerFactory { shared: Arc::new(SharedWorkerState { blob_store, broadcast_channel: Default::default(), - cjs_resolution_store, code_cache, compiled_wasm_module_store: Default::default(), feature_checker, @@ -457,6 +420,7 @@ impl CliMainWorkerFactory { module_loader_factory, node_resolver, npm_resolver, + pkg_json_resolver, root_cert_store_provider, root_permissions, shared_array_buffer_store: Default::default(), @@ -492,10 +456,13 @@ impl CliMainWorkerFactory { stdio: deno_runtime::deno_io::Stdio, ) -> Result { let shared = &self.shared; - let ModuleLoaderAndSourceMapGetter { module_loader } = shared + let CreateModuleLoaderResult { + module_loader, + node_require_loader, + } = shared .module_loader_factory .create_for_main(permissions.clone()); - let (main_module, is_main_cjs) = if let Ok(package_ref) = + let main_module = if let Ok(package_ref) = NpmPackageReqReference::from_specifier(&main_module) { if let Some(npm_resolver) = shared.npm_resolver.as_managed() { @@ -515,9 +482,8 @@ impl CliMainWorkerFactory { package_ref.req(), &referrer, )?; - let node_resolution = self + let main_module = self .resolve_binary_entrypoint(&package_folder, package_ref.sub_path())?; - let is_main_cjs = matches!(node_resolution, NodeResolution::CommonJs(_)); if let Some(lockfile) = &shared.maybe_lockfile { // For npm binary commands, ensure that the lockfile gets updated @@ -526,36 +492,9 @@ impl CliMainWorkerFactory { lockfile.write_if_changed()?; } - (node_resolution.into_url(), is_main_cjs) - } else if shared.options.is_npm_main - || shared.node_resolver.in_npm_package(&main_module) - { - let node_resolution = - shared.node_resolver.url_to_node_resolution(main_module)?; - let is_main_cjs = matches!(node_resolution, NodeResolution::CommonJs(_)); - (node_resolution.into_url(), is_main_cjs) + main_module } else { - let is_maybe_cjs_js_ext = self.shared.options.unstable_detect_cjs - && specifier_has_extension(&main_module, "js") - && self - .shared - .node_resolver - .get_closest_package_json(&main_module) - .ok() - .flatten() - .map(|pkg_json| pkg_json.typ == "commonjs") - .unwrap_or(false); - let is_cjs = if is_maybe_cjs_js_ext { - // fill the cjs resolution store by preparing the module load - module_loader - .prepare_load(&main_module, None, false) - .await?; - self.shared.cjs_resolution_store.is_known_cjs(&main_module) - } else { - main_module.scheme() == "file" - && specifier_has_extension(&main_module, "cjs") - }; - (main_module, is_cjs) + main_module }; let maybe_inspector_server = shared.maybe_inspector_server.clone(); @@ -597,7 +536,9 @@ impl CliMainWorkerFactory { root_cert_store_provider: Some(shared.root_cert_store_provider.clone()), module_loader, fs: shared.fs.clone(), - node_services: Some(shared.create_node_init_services()), + node_services: Some( + shared.create_node_init_services(node_require_loader), + ), npm_process_state_provider: Some(shared.npm_process_state_provider()), blob_store: shared.blob_store.clone(), broadcast_channel: shared.broadcast_channel.clone(), @@ -682,7 +623,6 @@ impl CliMainWorkerFactory { Ok(CliMainWorker { main_module, - is_main_cjs, worker, shared: shared.clone(), }) @@ -692,19 +632,19 @@ impl CliMainWorkerFactory { &self, package_folder: &Path, sub_path: Option<&str>, - ) -> Result { + ) -> Result { match self .shared .node_resolver .resolve_binary_export(package_folder, sub_path) { - Ok(node_resolution) => Ok(node_resolution), + Ok(specifier) => Ok(specifier), Err(original_err) => { // if the binary entrypoint was not found, fallback to regular node resolution let result = self.resolve_binary_entrypoint_fallback(package_folder, sub_path); match result { - Ok(Some(resolution)) => Ok(resolution), + Ok(Some(specifier)) => Ok(specifier), Ok(None) => Err(original_err.into()), Err(fallback_err) => { bail!("{:#}\n\nFallback failed: {:#}", original_err, fallback_err) @@ -719,7 +659,7 @@ impl CliMainWorkerFactory { &self, package_folder: &Path, sub_path: Option<&str>, - ) -> Result, AnyError> { + ) -> Result, AnyError> { // only fallback if the user specified a sub path if sub_path.is_none() { // it's confusing to users if the package doesn't have any binary @@ -728,7 +668,7 @@ impl CliMainWorkerFactory { return Ok(None); } - let resolution = self + let specifier = self .shared .node_resolver .resolve_package_subpath_from_deno_module( @@ -737,19 +677,14 @@ impl CliMainWorkerFactory { /* referrer */ None, NodeResolutionMode::Execution, )?; - match &resolution { - NodeResolution::BuiltIn(_) => Ok(None), - NodeResolution::CommonJs(specifier) | NodeResolution::Esm(specifier) => { - if specifier - .to_file_path() - .map(|p| p.exists()) - .unwrap_or(false) - { - Ok(Some(resolution)) - } else { - bail!("Cannot find module '{}'", specifier) - } - } + if specifier + .to_file_path() + .map(|p| p.exists()) + .unwrap_or(false) + { + Ok(Some(specifier)) + } else { + bail!("Cannot find module '{}'", specifier) } } } @@ -761,11 +696,13 @@ fn create_web_worker_callback( Arc::new(move |args| { let maybe_inspector_server = shared.maybe_inspector_server.clone(); - let ModuleLoaderAndSourceMapGetter { module_loader } = - shared.module_loader_factory.create_for_worker( - args.parent_permissions.clone(), - args.permissions.clone(), - ); + let CreateModuleLoaderResult { + module_loader, + node_require_loader, + } = shared.module_loader_factory.create_for_worker( + args.parent_permissions.clone(), + args.permissions.clone(), + ); let create_web_worker_cb = create_web_worker_callback(shared.clone(), stdio.clone()); @@ -795,7 +732,9 @@ fn create_web_worker_callback( root_cert_store_provider: Some(shared.root_cert_store_provider.clone()), module_loader, fs: shared.fs.clone(), - node_services: Some(shared.create_node_init_services()), + node_services: Some( + shared.create_node_init_services(node_require_loader), + ), blob_store: shared.blob_store.clone(), broadcast_channel: shared.broadcast_channel.clone(), shared_array_buffer_store: Some(shared.shared_array_buffer_store.clone()), diff --git a/ext/node/lib.rs b/ext/node/lib.rs index b34bea815b..db6d08e11e 100644 --- a/ext/node/lib.rs +++ b/ext/node/lib.rs @@ -9,15 +9,11 @@ use std::path::Path; use std::path::PathBuf; use deno_core::error::AnyError; -use deno_core::located_script_name; use deno_core::op2; use deno_core::url::Url; #[allow(unused_imports)] use deno_core::v8; use deno_core::v8::ExternalReference; -use deno_core::JsRuntime; -use deno_fs::sync::MaybeSend; -use deno_fs::sync::MaybeSync; use node_resolver::NpmResolverRc; use once_cell::sync::Lazy; @@ -125,16 +121,17 @@ impl NodePermissions for deno_permissions::PermissionsContainer { } #[allow(clippy::disallowed_types)] -pub type NodeRequireResolverRc = - deno_fs::sync::MaybeArc; +pub type NodeRequireLoaderRc = std::rc::Rc; -pub trait NodeRequireResolver: std::fmt::Debug + MaybeSend + MaybeSync { +pub trait NodeRequireLoader { #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] fn ensure_read_permission<'a>( &self, permissions: &mut dyn NodePermissions, path: &'a Path, ) -> Result, AnyError>; + + fn load_text_file_lossy(&self, path: &Path) -> Result; } pub static NODE_ENV_VAR_ALLOWLIST: Lazy> = Lazy::new(|| { @@ -152,10 +149,12 @@ fn op_node_build_os() -> String { env!("TARGET").split('-').nth(2).unwrap().to_string() } +#[derive(Clone)] pub struct NodeExtInitServices { - pub node_require_resolver: NodeRequireResolverRc, + pub node_require_loader: NodeRequireLoaderRc, pub node_resolver: NodeResolverRc, pub npm_resolver: NpmResolverRc, + pub pkg_json_resolver: PackageJsonResolverRc, } deno_core::extension!(deno_node, @@ -639,9 +638,10 @@ deno_core::extension!(deno_node, state.put(options.fs.clone()); if let Some(init) = &options.maybe_init { - state.put(init.node_require_resolver.clone()); + state.put(init.node_require_loader.clone()); state.put(init.node_resolver.clone()); state.put(init.npm_resolver.clone()); + state.put(init.pkg_json_resolver.clone()); } }, global_template_middleware = global_template_middleware, @@ -761,33 +761,16 @@ deno_core::extension!(deno_node, }, ); -pub fn load_cjs_module( - js_runtime: &mut JsRuntime, - module: &str, - main: bool, - inspect_brk: bool, -) -> Result<(), AnyError> { - fn escape_for_single_quote_string(text: &str) -> String { - text.replace('\\', r"\\").replace('\'', r"\'") - } - - let source_code = format!( - r#"(function loadCjsModule(moduleName, isMain, inspectBrk) {{ - Deno[Deno.internal].node.loadCjsModule(moduleName, isMain, inspectBrk); - }})('{module}', {main}, {inspect_brk});"#, - main = main, - module = escape_for_single_quote_string(module), - inspect_brk = inspect_brk, - ); - - js_runtime.execute_script(located_script_name!(), source_code)?; - Ok(()) -} - pub type NodeResolver = node_resolver::NodeResolver; #[allow(clippy::disallowed_types)] pub type NodeResolverRc = deno_fs::sync::MaybeArc>; +pub type PackageJsonResolver = + node_resolver::PackageJsonResolver; +#[allow(clippy::disallowed_types)] +pub type PackageJsonResolverRc = deno_fs::sync::MaybeArc< + node_resolver::PackageJsonResolver, +>; #[derive(Debug)] pub struct DenoFsNodeResolverEnv { diff --git a/ext/node/ops/require.rs b/ext/node/ops/require.rs index 7524fb43c7..30db8b6293 100644 --- a/ext/node/ops/require.rs +++ b/ext/node/ops/require.rs @@ -9,6 +9,7 @@ use deno_core::OpState; use deno_fs::FileSystemRc; use deno_package_json::PackageJsonRc; use deno_path_util::normalize_path; +use deno_path_util::url_to_file_path; use node_resolver::NodeModuleKind; use node_resolver::NodeResolutionMode; use node_resolver::REQUIRE_CONDITIONS; @@ -19,9 +20,10 @@ use std::path::PathBuf; use std::rc::Rc; use crate::NodePermissions; -use crate::NodeRequireResolverRc; +use crate::NodeRequireLoaderRc; use crate::NodeResolverRc; use crate::NpmResolverRc; +use crate::PackageJsonResolverRc; #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] fn ensure_read_permission<'a, P>( @@ -31,9 +33,9 @@ fn ensure_read_permission<'a, P>( where P: NodePermissions + 'static, { - let resolver = state.borrow::().clone(); + let loader = state.borrow::().clone(); let permissions = state.borrow_mut::

(); - resolver.ensure_read_permission(permissions, file_path) + loader.ensure_read_permission(permissions, file_path) } #[derive(Debug, thiserror::Error)] @@ -54,10 +56,14 @@ pub enum RequireError { PackageImportsResolve( #[from] node_resolver::errors::PackageImportsResolveError, ), - #[error("failed to convert '{0}' to file path")] - FilePathConversion(Url), + #[error(transparent)] + FilePathConversion(#[from] deno_path_util::UrlToFilePathError), + #[error(transparent)] + UrlConversion(#[from] deno_path_util::PathToUrlError), #[error(transparent)] Fs(#[from] deno_io::fs::FsError), + #[error(transparent)] + ReadModule(deno_core::error::AnyError), #[error("Unable to get CWD: {0}")] UnableToGetCwd(deno_io::fs::FsError), } @@ -229,8 +235,11 @@ pub fn op_require_is_deno_dir_package( state: &mut OpState, #[string] path: String, ) -> bool { - let resolver = state.borrow::(); - resolver.in_npm_package_at_file_path(&PathBuf::from(path)) + let resolver = state.borrow::(); + match deno_path_util::url_from_file_path(&PathBuf::from(path)) { + Ok(specifier) => resolver.in_npm_package(&specifier), + Err(_) => false, + } } #[op2] @@ -411,8 +420,8 @@ where return Ok(None); } - let node_resolver = state.borrow::(); - let pkg = node_resolver + let pkg_json_resolver = state.borrow::(); + let pkg = pkg_json_resolver .get_closest_package_json_from_path(&PathBuf::from(parent_path.unwrap())) .ok() .flatten(); @@ -441,6 +450,7 @@ where let referrer = deno_core::url::Url::from_file_path(&pkg.path).unwrap(); if let Some(exports) = &pkg.exports { + let node_resolver = state.borrow::(); let r = node_resolver.package_exports_resolve( &pkg.path, &expansion, @@ -470,10 +480,13 @@ where P: NodePermissions + 'static, { let file_path = PathBuf::from(file_path); + // todo(dsherret): there's multiple borrows to NodeRequireLoaderRc here let file_path = ensure_read_permission::

(state, &file_path) .map_err(RequireError::Permission)?; - let fs = state.borrow::(); - Ok(fs.read_text_file_lossy_sync(&file_path, None)?) + let loader = state.borrow::(); + loader + .load_text_file_lossy(&file_path) + .map_err(RequireError::ReadModule) } #[op2] @@ -503,11 +516,12 @@ where P: NodePermissions + 'static, { let fs = state.borrow::(); - let npm_resolver = state.borrow::(); let node_resolver = state.borrow::(); + let pkg_json_resolver = state.borrow::(); let modules_path = PathBuf::from(&modules_path_str); - let pkg_path = if npm_resolver.in_npm_package_at_file_path(&modules_path) + let modules_specifier = deno_path_util::url_from_file_path(&modules_path)?; + let pkg_path = if node_resolver.in_npm_package(&modules_specifier) && !uses_local_node_modules_dir { modules_path @@ -521,7 +535,7 @@ where } }; let Some(pkg) = - node_resolver.load_package_json(&pkg_path.join("package.json"))? + pkg_json_resolver.load_package_json(&pkg_path.join("package.json"))? else { return Ok(None); }; @@ -561,8 +575,8 @@ where { let filename = PathBuf::from(filename); // permissions: allow reading the closest package.json files - let node_resolver = state.borrow::().clone(); - node_resolver.get_closest_package_json_from_path(&filename) + let pkg_json_resolver = state.borrow::(); + pkg_json_resolver.get_closest_package_json_from_path(&filename) } #[op2] @@ -574,13 +588,13 @@ pub fn op_require_read_package_scope

( where P: NodePermissions + 'static, { - let node_resolver = state.borrow::().clone(); + let pkg_json_resolver = state.borrow::(); let package_json_path = PathBuf::from(package_json_path); if package_json_path.file_name() != Some("package.json".as_ref()) { // permissions: do not allow reading a non-package.json file return None; } - node_resolver + pkg_json_resolver .load_package_json(&package_json_path) .ok() .flatten() @@ -599,14 +613,15 @@ where let referrer_path = PathBuf::from(&referrer_filename); let referrer_path = ensure_read_permission::

(state, &referrer_path) .map_err(RequireError::Permission)?; - let node_resolver = state.borrow::(); + let pkg_json_resolver = state.borrow::(); let Some(pkg) = - node_resolver.get_closest_package_json_from_path(&referrer_path)? + pkg_json_resolver.get_closest_package_json_from_path(&referrer_path)? else { return Ok(None); }; if pkg.imports.is_some() { + let node_resolver = state.borrow::(); let referrer_url = Url::from_file_path(&referrer_filename).unwrap(); let url = node_resolver.package_imports_resolve( &request, @@ -637,13 +652,6 @@ fn url_to_file_path_string(url: &Url) -> Result { Ok(file_path.to_string_lossy().into_owned()) } -fn url_to_file_path(url: &Url) -> Result { - match url.to_file_path() { - Ok(file_path) => Ok(file_path), - Err(()) => Err(RequireError::FilePathConversion(url.clone())), - } -} - #[op2(fast)] pub fn op_require_can_parse_as_esm( scope: &mut v8::HandleScope, diff --git a/ext/node/ops/worker_threads.rs b/ext/node/ops/worker_threads.rs index e33cf91574..d2e5758826 100644 --- a/ext/node/ops/worker_threads.rs +++ b/ext/node/ops/worker_threads.rs @@ -4,14 +4,12 @@ use deno_core::op2; use deno_core::url::Url; use deno_core::OpState; use deno_fs::FileSystemRc; -use node_resolver::NodeResolution; use std::borrow::Cow; use std::path::Path; use std::path::PathBuf; use crate::NodePermissions; -use crate::NodeRequireResolverRc; -use crate::NodeResolverRc; +use crate::NodeRequireLoaderRc; #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] fn ensure_read_permission<'a, P>( @@ -21,9 +19,9 @@ fn ensure_read_permission<'a, P>( where P: NodePermissions + 'static, { - let resolver = state.borrow::().clone(); + let loader = state.borrow::().clone(); let permissions = state.borrow_mut::

(); - resolver.ensure_read_permission(permissions, file_path) + loader.ensure_read_permission(permissions, file_path) } #[derive(Debug, thiserror::Error)] @@ -42,14 +40,11 @@ pub enum WorkerThreadsFilenameError { UrlToPath, #[error("File not found [{0:?}]")] FileNotFound(PathBuf), - #[error("Neither ESM nor CJS")] - NeitherEsmNorCjs, - #[error("{0}")] - UrlToNodeResolution(node_resolver::errors::UrlToNodeResolutionError), #[error(transparent)] Fs(#[from] deno_io::fs::FsError), } +// todo(dsherret): we should remove this and do all this work inside op_create_worker #[op2] #[string] pub fn op_worker_threads_filename

( @@ -88,30 +83,5 @@ where url_path.to_path_buf(), )); } - let node_resolver = state.borrow::(); - match node_resolver - .url_to_node_resolution(url) - .map_err(WorkerThreadsFilenameError::UrlToNodeResolution)? - { - NodeResolution::Esm(u) => Ok(u.to_string()), - NodeResolution::CommonJs(u) => wrap_cjs(u), - NodeResolution::BuiltIn(_) => { - Err(WorkerThreadsFilenameError::NeitherEsmNorCjs) - } - } -} - -/// -/// Wrap a CJS file-URL and the required setup in a stringified `data:`-URL -/// -fn wrap_cjs(url: Url) -> Result { - let path = url - .to_file_path() - .map_err(|_| WorkerThreadsFilenameError::UrlToPath)?; - let filename = path.file_name().unwrap().to_string_lossy(); - Ok(format!( - "data:text/javascript,import {{ createRequire }} from \"node:module\";\ - const require = createRequire(\"{}\"); require(\"./{}\");", - url, filename, - )) + Ok(url.to_string()) } diff --git a/ext/node/polyfills/01_require.js b/ext/node/polyfills/01_require.js index 7935903a8d..296d819aa5 100644 --- a/ext/node/polyfills/01_require.js +++ b/ext/node/polyfills/01_require.js @@ -1071,13 +1071,35 @@ Module._extensions[".js"] = function (module, filename) { } else if (pkg?.type === "commonjs") { format = "commonjs"; } - } else if (StringPrototypeEndsWith(filename, ".cjs")) { - format = "commonjs"; } module._compile(content, filename, format); }; +Module._extensions[".ts"] = + Module._extensions[".jsx"] = + Module._extensions[".tsx"] = + function (module, filename) { + const content = op_require_read_file(filename); + + let format; + const pkg = op_require_read_closest_package_json(filename); + if (pkg?.type === "module") { + format = "module"; + } else if (pkg?.type === "commonjs") { + format = "commonjs"; + } + + module._compile(content, filename, format); + }; + +Module._extensions[".cjs"] = + Module._extensions[".cts"] = + function (module, filename) { + const content = op_require_read_file(filename); + module._compile(content, filename, "commonjs"); + }; + function loadESMFromCJS(module, filename, code) { const namespace = op_import_sync( url.pathToFileURL(filename).toString(), @@ -1087,7 +1109,10 @@ function loadESMFromCJS(module, filename, code) { module.exports = namespace; } -Module._extensions[".mjs"] = function (module, filename) { +Module._extensions[".mjs"] = Module._extensions[".mts"] = function ( + module, + filename, +) { loadESMFromCJS(module, filename); }; diff --git a/resolvers/deno/fs.rs b/resolvers/deno/fs.rs index b08be37982..44495fa7c2 100644 --- a/resolvers/deno/fs.rs +++ b/resolvers/deno/fs.rs @@ -15,13 +15,3 @@ pub trait DenoResolverFs { fn is_dir_sync(&self, path: &Path) -> bool; fn read_dir_sync(&self, dir_path: &Path) -> std::io::Result>; } - -pub(crate) struct DenoPkgJsonFsAdapter<'a, Fs: DenoResolverFs>(pub &'a Fs); - -impl<'a, Fs: DenoResolverFs> deno_package_json::fs::DenoPkgJsonFs - for DenoPkgJsonFsAdapter<'a, Fs> -{ - fn read_to_string_lossy(&self, path: &Path) -> std::io::Result { - self.0.read_to_string_lossy(path) - } -} diff --git a/resolvers/deno/npm/byonm.rs b/resolvers/deno/npm/byonm.rs index 3394b3e501..b85117052c 100644 --- a/resolvers/deno/npm/byonm.rs +++ b/resolvers/deno/npm/byonm.rs @@ -10,16 +10,17 @@ use deno_package_json::PackageJsonDepValue; use deno_path_util::url_to_file_path; use deno_semver::package::PackageReq; use deno_semver::Version; +use node_resolver::env::NodeResolverEnv; use node_resolver::errors::PackageFolderResolveError; use node_resolver::errors::PackageFolderResolveIoError; use node_resolver::errors::PackageJsonLoadError; use node_resolver::errors::PackageNotFoundError; -use node_resolver::load_pkg_json; +use node_resolver::InNpmPackageChecker; use node_resolver::NpmResolver; +use node_resolver::PackageJsonResolverRc; use thiserror::Error; use url::Url; -use crate::fs::DenoPkgJsonFsAdapter; use crate::fs::DenoResolverFs; use super::local::normalize_pkg_name_for_node_modules_deno_folder; @@ -36,32 +37,41 @@ pub enum ByonmResolvePkgFolderFromDenoReqError { Io(#[from] std::io::Error), } -pub struct ByonmNpmResolverCreateOptions { - pub fs: Fs, +pub struct ByonmNpmResolverCreateOptions< + Fs: DenoResolverFs, + TEnv: NodeResolverEnv, +> { // todo(dsherret): investigate removing this pub root_node_modules_dir: Option, + pub fs: Fs, + pub pkg_json_resolver: PackageJsonResolverRc, } #[derive(Debug)] -pub struct ByonmNpmResolver { +pub struct ByonmNpmResolver { fs: Fs, + pkg_json_resolver: PackageJsonResolverRc, root_node_modules_dir: Option, } -impl Clone for ByonmNpmResolver { +impl Clone + for ByonmNpmResolver +{ fn clone(&self) -> Self { Self { fs: self.fs.clone(), + pkg_json_resolver: self.pkg_json_resolver.clone(), root_node_modules_dir: self.root_node_modules_dir.clone(), } } } -impl ByonmNpmResolver { - pub fn new(options: ByonmNpmResolverCreateOptions) -> Self { +impl ByonmNpmResolver { + pub fn new(options: ByonmNpmResolverCreateOptions) -> Self { Self { - fs: options.fs, root_node_modules_dir: options.root_node_modules_dir, + fs: options.fs, + pkg_json_resolver: options.pkg_json_resolver, } } @@ -73,7 +83,7 @@ impl ByonmNpmResolver { &self, path: &Path, ) -> Result>, PackageJsonLoadError> { - load_pkg_json(&DenoPkgJsonFsAdapter(&self.fs), path) + self.pkg_json_resolver.load_package_json(path) } /// Finds the ancestor package.json that contains the specified dependency. @@ -290,8 +300,10 @@ impl ByonmNpmResolver { } } -impl NpmResolver - for ByonmNpmResolver +impl< + Fs: DenoResolverFs + Send + Sync + std::fmt::Debug, + TEnv: NodeResolverEnv, + > NpmResolver for ByonmNpmResolver { fn resolve_package_folder_from_package( &self, @@ -342,7 +354,12 @@ impl NpmResolver .into() }) } +} +#[derive(Debug)] +pub struct ByonmInNpmPackageChecker; + +impl InNpmPackageChecker for ByonmInNpmPackageChecker { fn in_npm_package(&self, specifier: &Url) -> bool { specifier.scheme() == "file" && specifier diff --git a/resolvers/deno/npm/mod.rs b/resolvers/deno/npm/mod.rs index 9d885cad31..45e2341c78 100644 --- a/resolvers/deno/npm/mod.rs +++ b/resolvers/deno/npm/mod.rs @@ -3,6 +3,7 @@ mod byonm; mod local; +pub use byonm::ByonmInNpmPackageChecker; pub use byonm::ByonmNpmResolver; pub use byonm::ByonmNpmResolverCreateOptions; pub use byonm::ByonmResolvePkgFolderFromDenoReqError; diff --git a/resolvers/deno/sloppy_imports.rs b/resolvers/deno/sloppy_imports.rs index e215e87686..7aba5b771a 100644 --- a/resolvers/deno/sloppy_imports.rs +++ b/resolvers/deno/sloppy_imports.rs @@ -232,7 +232,7 @@ impl SloppyImportsResolver { | MediaType::Tsx | MediaType::Json | MediaType::Wasm - | MediaType::TsBuildInfo + | MediaType::Css | MediaType::SourceMap => { return None; } diff --git a/resolvers/node/analyze.rs b/resolvers/node/analyze.rs index 009296006a..c7415933d7 100644 --- a/resolvers/node/analyze.rs +++ b/resolvers/node/analyze.rs @@ -19,18 +19,19 @@ use anyhow::Error as AnyError; use url::Url; use crate::env::NodeResolverEnv; -use crate::package_json::load_pkg_json; +use crate::npm::InNpmPackageCheckerRc; use crate::resolution::NodeResolverRc; use crate::NodeModuleKind; use crate::NodeResolutionMode; use crate::NpmResolverRc; +use crate::PackageJsonResolverRc; use crate::PathClean; #[derive(Debug, Clone)] -pub enum CjsAnalysis { +pub enum CjsAnalysis<'a> { /// File was found to be an ES module and the translator should /// load the code as ESM. - Esm(String), + Esm(Cow<'a, str>), Cjs(CjsAnalysisExports), } @@ -50,11 +51,11 @@ pub trait CjsCodeAnalyzer { /// already has it. If the source is needed by the implementation, /// then it can use the provided source, or otherwise load it if /// necessary. - async fn analyze_cjs( + async fn analyze_cjs<'a>( &self, specifier: &Url, - maybe_source: Option, - ) -> Result; + maybe_source: Option>, + ) -> Result, AnyError>; } pub struct NodeCodeTranslator< @@ -63,8 +64,10 @@ pub struct NodeCodeTranslator< > { cjs_code_analyzer: TCjsCodeAnalyzer, env: TNodeResolverEnv, + in_npm_pkg_checker: InNpmPackageCheckerRc, node_resolver: NodeResolverRc, npm_resolver: NpmResolverRc, + pkg_json_resolver: PackageJsonResolverRc, } impl @@ -73,14 +76,18 @@ impl pub fn new( cjs_code_analyzer: TCjsCodeAnalyzer, env: TNodeResolverEnv, + in_npm_pkg_checker: InNpmPackageCheckerRc, node_resolver: NodeResolverRc, npm_resolver: NpmResolverRc, + pkg_json_resolver: PackageJsonResolverRc, ) -> Self { Self { cjs_code_analyzer, env, + in_npm_pkg_checker, node_resolver, npm_resolver, + pkg_json_resolver, } } @@ -90,11 +97,11 @@ impl /// For all discovered reexports the analysis will be performed recursively. /// /// If successful a source code for equivalent ES module is returned. - pub async fn translate_cjs_to_esm( + pub async fn translate_cjs_to_esm<'a>( &self, entry_specifier: &Url, - source: Option, - ) -> Result { + source: Option>, + ) -> Result, AnyError> { let mut temp_var_count = 0; let analysis = self @@ -108,7 +115,7 @@ impl }; let mut source = vec![ - r#"import {createRequire as __internalCreateRequire} from "node:module"; + r#"import {createRequire as __internalCreateRequire, Module as __internalModule } from "node:module"; const require = __internalCreateRequire(import.meta.url);"# .to_string(), ]; @@ -135,7 +142,12 @@ impl } source.push(format!( - "const mod = require(\"{}\");", + r#"let mod; + if (import.meta.main) {{ + mod = __internalModule._load("{0}", null, true) + }} else {{ + mod = require("{0}"); + }}"#, url_to_file_path(entry_specifier) .unwrap() .to_str() @@ -159,7 +171,7 @@ impl source.push("export default mod;".to_string()); let translated_source = source.join("\n"); - Ok(translated_source) + Ok(Cow::Owned(translated_source)) } async fn analyze_reexports<'a>( @@ -174,7 +186,7 @@ impl struct Analysis { reexport_specifier: url::Url, referrer: url::Url, - analysis: CjsAnalysis, + analysis: CjsAnalysis<'static>, } type AnalysisFuture<'a> = LocalBoxFuture<'a, Result>; @@ -329,8 +341,9 @@ impl }?; let package_json_path = module_dir.join("package.json"); - let maybe_package_json = - load_pkg_json(self.env.pkg_json_fs(), &package_json_path)?; + let maybe_package_json = self + .pkg_json_resolver + .load_package_json(&package_json_path)?; if let Some(package_json) = maybe_package_json { if let Some(exports) = &package_json.exports { return Some( @@ -356,8 +369,9 @@ impl if self.env.is_dir_sync(&d) { // subdir might have a package.json that specifies the entrypoint let package_json_path = d.join("package.json"); - let maybe_package_json = - load_pkg_json(self.env.pkg_json_fs(), &package_json_path)?; + let maybe_package_json = self + .pkg_json_resolver + .load_package_json(&package_json_path)?; if let Some(package_json) = maybe_package_json { if let Some(main) = package_json.main(NodeModuleKind::Cjs) { return Ok(Some(url_from_file_path(&d.join(main).clean())?)); @@ -382,7 +396,7 @@ impl // as a fallback, attempt to resolve it via the ancestor directories let mut last = referrer_path.as_path(); while let Some(parent) = last.parent() { - if !self.npm_resolver.in_npm_package_at_dir_path(parent) { + if !self.in_npm_pkg_checker.in_npm_package_at_dir_path(parent) { break; } let path = if parent.ends_with("node_modules") { diff --git a/resolvers/node/errors.rs b/resolvers/node/errors.rs index 4ba829eda5..aacbecefb4 100644 --- a/resolvers/node/errors.rs +++ b/resolvers/node/errors.rs @@ -81,29 +81,6 @@ pub trait NodeJsErrorCoded { fn code(&self) -> NodeJsErrorCode; } -kinded_err!( - ResolvePkgSubpathFromDenoModuleError, - ResolvePkgSubpathFromDenoModuleErrorKind -); - -impl NodeJsErrorCoded for ResolvePkgSubpathFromDenoModuleError { - fn code(&self) -> NodeJsErrorCode { - use ResolvePkgSubpathFromDenoModuleErrorKind::*; - match self.as_kind() { - PackageSubpathResolve(e) => e.code(), - UrlToNodeResolution(e) => e.code(), - } - } -} - -#[derive(Debug, Error)] -pub enum ResolvePkgSubpathFromDenoModuleErrorKind { - #[error(transparent)] - PackageSubpathResolve(#[from] PackageSubpathResolveError), - #[error(transparent)] - UrlToNodeResolution(#[from] UrlToNodeResolutionError), -} - // todo(https://github.com/denoland/deno_core/issues/810): make this a TypeError #[derive(Debug, Clone, Error)] #[error( @@ -394,37 +371,6 @@ impl NodeJsErrorCoded for CanonicalizingPkgJsonDirError { } } -#[derive(Debug, Error)] -#[error("TypeScript files are not supported in npm packages: {specifier}")] -pub struct TypeScriptNotSupportedInNpmError { - pub specifier: Url, -} - -impl NodeJsErrorCoded for TypeScriptNotSupportedInNpmError { - fn code(&self) -> NodeJsErrorCode { - NodeJsErrorCode::ERR_UNKNOWN_FILE_EXTENSION - } -} - -kinded_err!(UrlToNodeResolutionError, UrlToNodeResolutionErrorKind); - -impl NodeJsErrorCoded for UrlToNodeResolutionError { - fn code(&self) -> NodeJsErrorCode { - match self.as_kind() { - UrlToNodeResolutionErrorKind::TypeScriptNotSupported(e) => e.code(), - UrlToNodeResolutionErrorKind::ClosestPkgJson(e) => e.code(), - } - } -} - -#[derive(Debug, Error)] -pub enum UrlToNodeResolutionErrorKind { - #[error(transparent)] - TypeScriptNotSupported(#[from] TypeScriptNotSupportedInNpmError), - #[error(transparent)] - ClosestPkgJson(#[from] ClosestPkgJsonError), -} - // todo(https://github.com/denoland/deno_core/issues/810): make this a TypeError #[derive(Debug, Error)] #[error( @@ -533,8 +479,6 @@ pub enum NodeResolveErrorKind { TypesNotFound(#[from] TypesNotFoundError), #[error(transparent)] FinalizeResolution(#[from] FinalizeResolutionError), - #[error(transparent)] - UrlToNodeResolution(#[from] UrlToNodeResolutionError), } kinded_err!(FinalizeResolutionError, FinalizeResolutionErrorKind); @@ -728,8 +672,6 @@ pub enum ResolvePkgJsonBinExportError { MissingPkgJson { pkg_json_path: PathBuf }, #[error("Failed resolving binary export. {message}")] InvalidBinProperty { message: String }, - #[error(transparent)] - UrlToNodeResolution(#[from] UrlToNodeResolutionError), } #[derive(Debug, Error)] diff --git a/resolvers/node/lib.rs b/resolvers/node/lib.rs index f03f770486..18b0a85363 100644 --- a/resolvers/node/lib.rs +++ b/resolvers/node/lib.rs @@ -13,9 +13,12 @@ mod resolution; mod sync; pub use deno_package_json::PackageJson; +pub use npm::InNpmPackageChecker; +pub use npm::InNpmPackageCheckerRc; pub use npm::NpmResolver; pub use npm::NpmResolverRc; -pub use package_json::load_pkg_json; +pub use package_json::PackageJsonResolver; +pub use package_json::PackageJsonResolverRc; pub use package_json::PackageJsonThreadLocalCache; pub use path::PathClean; pub use resolution::parse_npm_pkg_name; diff --git a/resolvers/node/npm.rs b/resolvers/node/npm.rs index 6b5f21db62..2132f0b545 100644 --- a/resolvers/node/npm.rs +++ b/resolvers/node/npm.rs @@ -22,7 +22,13 @@ pub trait NpmResolver: std::fmt::Debug + MaybeSend + MaybeSync { specifier: &str, referrer: &Url, ) -> Result; +} +#[allow(clippy::disallowed_types)] +pub type InNpmPackageCheckerRc = crate::sync::MaybeArc; + +/// Checks if a provided specifier is in an npm package. +pub trait InNpmPackageChecker: std::fmt::Debug + MaybeSend + MaybeSync { fn in_npm_package(&self, specifier: &Url) -> bool; fn in_npm_package_at_dir_path(&self, path: &Path) -> bool { diff --git a/resolvers/node/package_json.rs b/resolvers/node/package_json.rs index de750f1d7e..6967779e5d 100644 --- a/resolvers/node/package_json.rs +++ b/resolvers/node/package_json.rs @@ -2,15 +2,21 @@ use deno_package_json::PackageJson; use deno_package_json::PackageJsonRc; +use deno_path_util::strip_unc_prefix; use std::cell::RefCell; use std::collections::HashMap; use std::io::ErrorKind; use std::path::Path; use std::path::PathBuf; +use url::Url; +use crate::env::NodeResolverEnv; +use crate::errors::CanonicalizingPkgJsonDirError; +use crate::errors::ClosestPkgJsonError; use crate::errors::PackageJsonLoadError; -// use a thread local cache so that workers have their own distinct cache +// todo(dsherret): this isn't exactly correct and we should change it to instead +// be created per worker and passed down as a ctor arg to the pkg json resolver thread_local! { static CACHE: RefCell> = RefCell::new(HashMap::new()); } @@ -33,21 +39,91 @@ impl deno_package_json::PackageJsonCache for PackageJsonThreadLocalCache { } } -/// Helper to load a package.json file using the thread local cache -/// in node_resolver. -pub fn load_pkg_json( - fs: &dyn deno_package_json::fs::DenoPkgJsonFs, - path: &Path, -) -> Result, PackageJsonLoadError> { - let result = - PackageJson::load_from_path(path, fs, Some(&PackageJsonThreadLocalCache)); - match result { - Ok(pkg_json) => Ok(Some(pkg_json)), - Err(deno_package_json::PackageJsonLoadError::Io { source, .. }) - if source.kind() == ErrorKind::NotFound => - { +#[allow(clippy::disallowed_types)] +pub type PackageJsonResolverRc = + crate::sync::MaybeArc>; + +#[derive(Debug)] +pub struct PackageJsonResolver { + env: TEnv, +} + +impl PackageJsonResolver { + pub fn new(env: TEnv) -> Self { + Self { env } + } + + pub fn get_closest_package_json( + &self, + url: &Url, + ) -> Result, ClosestPkgJsonError> { + let Ok(file_path) = deno_path_util::url_to_file_path(url) else { + return Ok(None); + }; + self.get_closest_package_json_from_path(&file_path) + } + + pub fn get_closest_package_json_from_path( + &self, + file_path: &Path, + ) -> Result, ClosestPkgJsonError> { + // we use this for deno compile using byonm because the script paths + // won't be in virtual file system, but the package.json paths will be + fn canonicalize_first_ancestor_exists( + dir_path: &Path, + env: &TEnv, + ) -> Result, std::io::Error> { + for ancestor in dir_path.ancestors() { + match env.realpath_sync(ancestor) { + Ok(dir_path) => return Ok(Some(dir_path)), + Err(err) if err.kind() == std::io::ErrorKind::NotFound => { + // keep searching + } + Err(err) => return Err(err), + } + } Ok(None) } - Err(err) => Err(PackageJsonLoadError(err)), + + let parent_dir = file_path.parent().unwrap(); + let Some(start_dir) = canonicalize_first_ancestor_exists( + parent_dir, &self.env, + ) + .map_err(|source| CanonicalizingPkgJsonDirError { + dir_path: parent_dir.to_path_buf(), + source, + })? + else { + return Ok(None); + }; + let start_dir = strip_unc_prefix(start_dir); + for current_dir in start_dir.ancestors() { + let package_json_path = current_dir.join("package.json"); + if let Some(pkg_json) = self.load_package_json(&package_json_path)? { + return Ok(Some(pkg_json)); + } + } + + Ok(None) + } + + pub fn load_package_json( + &self, + path: &Path, + ) -> Result, PackageJsonLoadError> { + let result = PackageJson::load_from_path( + path, + self.env.pkg_json_fs(), + Some(&PackageJsonThreadLocalCache), + ); + match result { + Ok(pkg_json) => Ok(Some(pkg_json)), + Err(deno_package_json::PackageJsonLoadError::Io { source, .. }) + if source.kind() == ErrorKind::NotFound => + { + Ok(None) + } + Err(err) => Err(PackageJsonLoadError(err)), + } } } diff --git a/resolvers/node/resolution.rs b/resolvers/node/resolution.rs index 811583a5ee..d44539e978 100644 --- a/resolvers/node/resolution.rs +++ b/resolvers/node/resolution.rs @@ -6,9 +6,6 @@ use std::path::PathBuf; use anyhow::bail; use anyhow::Error as AnyError; -use deno_media_type::MediaType; -use deno_package_json::PackageJsonRc; -use deno_path_util::strip_unc_prefix; use deno_path_util::url_from_file_path; use serde_json::Map; use serde_json::Value; @@ -16,8 +13,6 @@ use url::Url; use crate::env::NodeResolverEnv; use crate::errors; -use crate::errors::CanonicalizingPkgJsonDirError; -use crate::errors::ClosestPkgJsonError; use crate::errors::DataUrlReferrerError; use crate::errors::FinalizeResolutionError; use crate::errors::InvalidModuleSpecifierError; @@ -32,7 +27,6 @@ use crate::errors::PackageExportsResolveError; use crate::errors::PackageImportNotDefinedError; use crate::errors::PackageImportsResolveError; use crate::errors::PackageImportsResolveErrorKind; -use crate::errors::PackageJsonLoadError; use crate::errors::PackagePathNotExportedError; use crate::errors::PackageResolveError; use crate::errors::PackageSubpathResolveError; @@ -42,14 +36,13 @@ use crate::errors::PackageTargetResolveError; use crate::errors::PackageTargetResolveErrorKind; use crate::errors::ResolveBinaryCommandsError; use crate::errors::ResolvePkgJsonBinExportError; -use crate::errors::ResolvePkgSubpathFromDenoModuleError; -use crate::errors::TypeScriptNotSupportedInNpmError; use crate::errors::TypesNotFoundError; use crate::errors::TypesNotFoundErrorData; use crate::errors::UnsupportedDirImportError; use crate::errors::UnsupportedEsmUrlSchemeError; -use crate::errors::UrlToNodeResolutionError; +use crate::npm::InNpmPackageCheckerRc; use crate::NpmResolverRc; +use crate::PackageJsonResolverRc; use crate::PathClean; use deno_package_json::PackageJson; @@ -73,16 +66,14 @@ impl NodeResolutionMode { #[derive(Debug)] pub enum NodeResolution { - Esm(Url), - CommonJs(Url), + Module(Url), BuiltIn(String), } impl NodeResolution { pub fn into_url(self) -> Url { match self { - Self::Esm(u) => u, - Self::CommonJs(u) => u, + Self::Module(u) => u, Self::BuiltIn(specifier) => { if specifier.starts_with("node:") { Url::parse(&specifier).unwrap() @@ -92,42 +83,6 @@ impl NodeResolution { } } } - - pub fn into_specifier_and_media_type( - resolution: Option, - ) -> (Url, MediaType) { - match resolution { - Some(NodeResolution::CommonJs(specifier)) => { - let media_type = MediaType::from_specifier(&specifier); - ( - specifier, - match media_type { - MediaType::JavaScript | MediaType::Jsx => MediaType::Cjs, - MediaType::TypeScript | MediaType::Tsx => MediaType::Cts, - MediaType::Dts => MediaType::Dcts, - _ => media_type, - }, - ) - } - Some(NodeResolution::Esm(specifier)) => { - let media_type = MediaType::from_specifier(&specifier); - ( - specifier, - match media_type { - MediaType::JavaScript | MediaType::Jsx => MediaType::Mjs, - MediaType::TypeScript | MediaType::Tsx => MediaType::Mts, - MediaType::Dts => MediaType::Dmts, - _ => media_type, - }, - ) - } - Some(resolution) => (resolution.into_url(), MediaType::Dts), - None => ( - Url::parse("internal:///missing_dependency.d.ts").unwrap(), - MediaType::Dts, - ), - } - } } #[allow(clippy::disallowed_types)] @@ -136,16 +91,28 @@ pub type NodeResolverRc = crate::sync::MaybeArc>; #[derive(Debug)] pub struct NodeResolver { env: TEnv, + in_npm_pkg_checker: InNpmPackageCheckerRc, npm_resolver: NpmResolverRc, + pkg_json_resolver: PackageJsonResolverRc, } impl NodeResolver { - pub fn new(env: TEnv, npm_resolver: NpmResolverRc) -> Self { - Self { env, npm_resolver } + pub fn new( + env: TEnv, + in_npm_pkg_checker: InNpmPackageCheckerRc, + npm_resolver: NpmResolverRc, + pkg_json_resolver: PackageJsonResolverRc, + ) -> Self { + Self { + env, + in_npm_pkg_checker, + npm_resolver, + pkg_json_resolver, + } } pub fn in_npm_package(&self, specifier: &Url) -> bool { - self.npm_resolver.in_npm_package(specifier) + self.in_npm_pkg_checker.in_npm_package(specifier) } /// This function is an implementation of `defaultResolve` in @@ -166,7 +133,7 @@ impl NodeResolver { if let Ok(url) = Url::parse(specifier) { if url.scheme() == "data" { - return Ok(NodeResolution::Esm(url)); + return Ok(NodeResolution::Module(url)); } if let Some(module_name) = @@ -191,7 +158,7 @@ impl NodeResolver { let url = referrer .join(specifier) .map_err(|source| DataUrlReferrerError { source })?; - return Ok(NodeResolution::Esm(url)); + return Ok(NodeResolution::Module(url)); } } @@ -212,7 +179,7 @@ impl NodeResolver { }; let url = self.finalize_resolution(url, Some(referrer))?; - let resolve_response = self.url_to_node_resolution(url)?; + let resolve_response = NodeResolution::Module(url); // TODO(bartlomieju): skipped checking errors for commonJS resolution and // "preserveSymlinksMain"/"preserveSymlinks" options. Ok(resolve_response) @@ -236,6 +203,7 @@ impl NodeResolver { })?) } else if specifier.starts_with('#') { let pkg_config = self + .pkg_json_resolver .get_closest_package_json(referrer) .map_err(PackageImportsResolveErrorKind::ClosestPkgJson) .map_err(|err| PackageImportsResolveError(Box::new(err)))?; @@ -332,7 +300,7 @@ impl NodeResolver { package_subpath: Option<&str>, maybe_referrer: Option<&Url>, mode: NodeResolutionMode, - ) -> Result { + ) -> Result { let node_module_kind = NodeModuleKind::Esm; let package_subpath = package_subpath .map(|s| format!("./{s}")) @@ -345,10 +313,9 @@ impl NodeResolver { DEFAULT_CONDITIONS, mode, )?; - let resolve_response = self.url_to_node_resolution(resolved_url)?; // TODO(bartlomieju): skipped checking errors for commonJS resolution and // "preserveSymlinksMain"/"preserveSymlinks" options. - Ok(resolve_response) + Ok(resolved_url) } pub fn resolve_binary_commands( @@ -356,7 +323,9 @@ impl NodeResolver { package_folder: &Path, ) -> Result, ResolveBinaryCommandsError> { let pkg_json_path = package_folder.join("package.json"); - let Some(package_json) = self.load_package_json(&pkg_json_path)? else { + let Some(package_json) = + self.pkg_json_resolver.load_package_json(&pkg_json_path)? + else { return Ok(Vec::new()); }; @@ -381,9 +350,11 @@ impl NodeResolver { &self, package_folder: &Path, sub_path: Option<&str>, - ) -> Result { + ) -> Result { let pkg_json_path = package_folder.join("package.json"); - let Some(package_json) = self.load_package_json(&pkg_json_path)? else { + let Some(package_json) = + self.pkg_json_resolver.load_package_json(&pkg_json_path)? + else { return Err(ResolvePkgJsonBinExportError::MissingPkgJson { pkg_json_path, }); @@ -396,37 +367,9 @@ impl NodeResolver { })?; let url = url_from_file_path(&package_folder.join(bin_entry)).unwrap(); - let resolve_response = self.url_to_node_resolution(url)?; // TODO(bartlomieju): skipped checking errors for commonJS resolution and // "preserveSymlinksMain"/"preserveSymlinks" options. - Ok(resolve_response) - } - - pub fn url_to_node_resolution( - &self, - url: Url, - ) -> Result { - let url_str = url.as_str().to_lowercase(); - if url_str.starts_with("http") || url_str.ends_with(".json") { - Ok(NodeResolution::Esm(url)) - } else if url_str.ends_with(".js") || url_str.ends_with(".d.ts") { - let maybe_package_config = self.get_closest_package_json(&url)?; - match maybe_package_config { - Some(c) if c.typ == "module" => Ok(NodeResolution::Esm(url)), - Some(_) => Ok(NodeResolution::CommonJs(url)), - None => Ok(NodeResolution::Esm(url)), - } - } else if url_str.ends_with(".mjs") || url_str.ends_with(".d.mts") { - Ok(NodeResolution::Esm(url)) - } else if url_str.ends_with(".ts") || url_str.ends_with(".mts") { - if self.in_npm_package(&url) { - Err(TypeScriptNotSupportedInNpmError { specifier: url }.into()) - } else { - Ok(NodeResolution::Esm(url)) - } - } else { - Ok(NodeResolution::CommonJs(url)) - } + Ok(url) } /// Checks if the resolved file has a corresponding declaration file. @@ -1101,7 +1044,9 @@ impl NodeResolver { let (package_name, package_subpath, _is_scoped) = parse_npm_pkg_name(specifier, referrer)?; - if let Some(package_config) = self.get_closest_package_json(referrer)? { + if let Some(package_config) = + self.pkg_json_resolver.get_closest_package_json(referrer)? + { // ResolveSelf if package_config.name.as_ref() == Some(&package_name) { if let Some(exports) = &package_config.exports { @@ -1216,7 +1161,10 @@ impl NodeResolver { mode: NodeResolutionMode, ) -> Result { let package_json_path = package_dir_path.join("package.json"); - match self.load_package_json(&package_json_path)? { + match self + .pkg_json_resolver + .load_package_json(&package_json_path)? + { Some(pkg_json) => self.resolve_package_subpath( &pkg_json, package_subpath, @@ -1337,70 +1285,6 @@ impl NodeResolver { } } - pub fn get_closest_package_json( - &self, - url: &Url, - ) -> Result, ClosestPkgJsonError> { - let Ok(file_path) = deno_path_util::url_to_file_path(url) else { - return Ok(None); - }; - self.get_closest_package_json_from_path(&file_path) - } - - pub fn get_closest_package_json_from_path( - &self, - file_path: &Path, - ) -> Result, ClosestPkgJsonError> { - // we use this for deno compile using byonm because the script paths - // won't be in virtual file system, but the package.json paths will be - fn canonicalize_first_ancestor_exists( - dir_path: &Path, - env: &dyn NodeResolverEnv, - ) -> Result, std::io::Error> { - for ancestor in dir_path.ancestors() { - match env.realpath_sync(ancestor) { - Ok(dir_path) => return Ok(Some(dir_path)), - Err(err) if err.kind() == std::io::ErrorKind::NotFound => { - // keep searching - } - Err(err) => return Err(err), - } - } - Ok(None) - } - - let parent_dir = file_path.parent().unwrap(); - let Some(start_dir) = canonicalize_first_ancestor_exists( - parent_dir, &self.env, - ) - .map_err(|source| CanonicalizingPkgJsonDirError { - dir_path: parent_dir.to_path_buf(), - source, - })? - else { - return Ok(None); - }; - let start_dir = strip_unc_prefix(start_dir); - for current_dir in start_dir.ancestors() { - let package_json_path = current_dir.join("package.json"); - if let Some(pkg_json) = self.load_package_json(&package_json_path)? { - return Ok(Some(pkg_json)); - } - } - - Ok(None) - } - - pub fn load_package_json( - &self, - package_json_path: &Path, - ) -> Result, PackageJsonLoadError> { - crate::package_json::load_pkg_json( - self.env.pkg_json_fs(), - package_json_path, - ) - } - pub(super) fn legacy_main_resolve( &self, package_json: &PackageJson, diff --git a/runtime/errors.rs b/runtime/errors.rs index a5c436e751..ada26ec35f 100644 --- a/runtime/errors.rs +++ b/runtime/errors.rs @@ -1048,8 +1048,6 @@ mod node { WorkerThreadsFilenameError::UrlToPathString => "Error", WorkerThreadsFilenameError::UrlToPath => "Error", WorkerThreadsFilenameError::FileNotFound(_) => "Error", - WorkerThreadsFilenameError::NeitherEsmNorCjs => "Error", - WorkerThreadsFilenameError::UrlToNodeResolution(_) => "Error", WorkerThreadsFilenameError::Fs(e) => super::get_fs_error(e), } } @@ -1058,11 +1056,13 @@ mod node { match error { RequireError::UrlParse(e) => get_url_parse_error_class(e), RequireError::Permission(e) => get_error_class_name(e).unwrap_or("Error"), - RequireError::PackageExportsResolve(_) => "Error", - RequireError::PackageJsonLoad(_) => "Error", - RequireError::ClosestPkgJson(_) => "Error", - RequireError::FilePathConversion(_) => "Error", - RequireError::PackageImportsResolve(_) => "Error", + RequireError::PackageExportsResolve(_) + | RequireError::PackageJsonLoad(_) + | RequireError::ClosestPkgJson(_) + | RequireError::FilePathConversion(_) + | RequireError::UrlConversion(_) + | RequireError::ReadModule(_) + | RequireError::PackageImportsResolve(_) => "Error", RequireError::Fs(e) | RequireError::UnableToGetCwd(e) => { super::get_fs_error(e) } diff --git a/runtime/shared.rs b/runtime/shared.rs index 02dfd18719..f7d76f67a7 100644 --- a/runtime/shared.rs +++ b/runtime/shared.rs @@ -98,6 +98,7 @@ pub fn maybe_transpile_source( imports_not_used_as_values: deno_ast::ImportsNotUsedAsValues::Remove, ..Default::default() }, + &deno_ast::TranspileModuleOptions::default(), &deno_ast::EmitOptions { source_map: if cfg!(debug_assertions) { SourceMapOption::Separate @@ -109,9 +110,9 @@ pub fn maybe_transpile_source( )? .into_source(); - let maybe_source_map: Option = - transpiled_source.source_map.map(|sm| sm.into()); - let source_text = String::from_utf8(transpiled_source.source)?; - + let maybe_source_map: Option = transpiled_source + .source_map + .map(|sm| sm.into_bytes().into()); + let source_text = transpiled_source.text; Ok((source_text.into(), maybe_source_map)) } diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index db9f79556e..a07dd56c83 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -3605,7 +3605,8 @@ fn running_declaration_files() { temp_dir.write(file, ""); context .new_command() - .args_vec(["run", file]) + // todo(dsherret): investigate why --allow-read is required here + .args_vec(["run", "--allow-read", file]) .run() .skip_output_check() .assert_exit_code(0); diff --git a/tests/registry/npm/@denotest/type-commonjs/1.0.0/index.js b/tests/registry/npm/@denotest/type-commonjs/1.0.0/index.js index cb0ff5c3b5..d3f80a0495 100644 --- a/tests/registry/npm/@denotest/type-commonjs/1.0.0/index.js +++ b/tests/registry/npm/@denotest/type-commonjs/1.0.0/index.js @@ -1 +1,5 @@ -export {}; +// this module is declared as CommonJS, but during loading we'll +// discover it's ESM and load it fine +export function add(a, b) { + return a + b; +} diff --git a/tests/specs/check/css_import/exists_run_with_check.out b/tests/specs/check/css_import/exists_run_with_check.out index 1a1dafeb74..315769e40c 100644 --- a/tests/specs/check/css_import/exists_run_with_check.out +++ b/tests/specs/check/css_import/exists_run_with_check.out @@ -1,3 +1,3 @@ -error: Expected a JavaScript or TypeScript module, but identified a Unknown module. Importing these types of modules is currently not supported. +error: Expected a JavaScript or TypeScript module, but identified a Css module. Importing these types of modules is currently not supported. Specifier: file:///[WILDLINE]/app.css at file:///[WILDLINE]/exists.ts:2:8 diff --git a/tests/specs/compile/cjs/__test__.jsonc b/tests/specs/compile/cjs/__test__.jsonc new file mode 100644 index 0000000000..9bdcf4724f --- /dev/null +++ b/tests/specs/compile/cjs/__test__.jsonc @@ -0,0 +1,24 @@ +{ + "tempDir": true, + "steps": [{ + "if": "unix", + "args": "compile --output main main.js", + "output": "[WILDCARD]" + }, { + "if": "unix", + "commandName": "./main", + "args": [], + "output": "output.out", + "exitCode": 0 + }, { + "if": "windows", + "args": "compile --output main.exe main.js", + "output": "[WILDCARD]" + }, { + "if": "windows", + "commandName": "./main.exe", + "args": [], + "output": "output.out", + "exitCode": 0 + }] +} diff --git a/tests/specs/compile/cjs/add.cjs b/tests/specs/compile/cjs/add.cjs new file mode 100644 index 0000000000..bf90601267 --- /dev/null +++ b/tests/specs/compile/cjs/add.cjs @@ -0,0 +1 @@ +module.exports = (a, b) => a + b; diff --git a/tests/specs/compile/cjs/divide.cts b/tests/specs/compile/cjs/divide.cts new file mode 100644 index 0000000000..d89a600a4e --- /dev/null +++ b/tests/specs/compile/cjs/divide.cts @@ -0,0 +1 @@ +module.exports.divide = (a: number, b: number) => a / b; diff --git a/tests/specs/compile/cjs/main.js b/tests/specs/compile/cjs/main.js new file mode 100644 index 0000000000..c2a8c7be02 --- /dev/null +++ b/tests/specs/compile/cjs/main.js @@ -0,0 +1,5 @@ +import { add } from "./reexport.cjs"; +import { multiply } from "./multiply.cts"; + +console.log(add(1, 2)); +console.log(multiply(2, 3)); diff --git a/tests/specs/compile/cjs/multiply.cts b/tests/specs/compile/cjs/multiply.cts new file mode 100644 index 0000000000..3c0618cfc5 --- /dev/null +++ b/tests/specs/compile/cjs/multiply.cts @@ -0,0 +1,4 @@ +/// +exports.multiply = function (a: number, b: number): number { + return require("./divide.cts").divide(a, 1 / b); +}; diff --git a/tests/specs/compile/cjs/output.out b/tests/specs/compile/cjs/output.out new file mode 100644 index 0000000000..2559e5c49e --- /dev/null +++ b/tests/specs/compile/cjs/output.out @@ -0,0 +1,2 @@ +3 +6 diff --git a/tests/specs/compile/cjs/reexport.cjs b/tests/specs/compile/cjs/reexport.cjs new file mode 100644 index 0000000000..af7cecfdf4 --- /dev/null +++ b/tests/specs/compile/cjs/reexport.cjs @@ -0,0 +1 @@ +module.exports.add = require("./add.cjs"); diff --git a/tests/specs/compile/detect_cjs/__test__.jsonc b/tests/specs/compile/detect_cjs/__test__.jsonc index 32bebb7a57..0abf121f05 100644 --- a/tests/specs/compile/detect_cjs/__test__.jsonc +++ b/tests/specs/compile/detect_cjs/__test__.jsonc @@ -1,24 +1,27 @@ { "tempDir": true, "steps": [{ + "args": "install", + "output": "[WILDCARD]" + }, { "if": "unix", - "args": "compile --allow-read --output main main.js", + "args": "compile --output main main.js", "output": "compile.out" }, { "if": "unix", "commandName": "./main", "args": [], "output": "output.out", - "exitCode": 1 + "exitCode": 0 }, { "if": "windows", - "args": "compile --allow-read --output main.exe main.js", + "args": "compile --output main.exe main.js", "output": "compile.out" }, { "if": "windows", "commandName": "./main.exe", "args": [], "output": "output.out", - "exitCode": 1 + "exitCode": 0 }] } diff --git a/tests/specs/compile/detect_cjs/add.js b/tests/specs/compile/detect_cjs/add.js index 2a886fbc18..94b0263f0e 100644 --- a/tests/specs/compile/detect_cjs/add.js +++ b/tests/specs/compile/detect_cjs/add.js @@ -1,3 +1,3 @@ module.exports.add = function (a, b) { - return a + b; + return require("./subtract.ts").subtract(a, -b); }; diff --git a/tests/specs/compile/detect_cjs/compile.out b/tests/specs/compile/detect_cjs/compile.out index 6509b7f29c..913e363c3e 100644 --- a/tests/specs/compile/detect_cjs/compile.out +++ b/tests/specs/compile/detect_cjs/compile.out @@ -1,3 +1,2 @@ -Warning --unstable-detect-cjs is not properly supported in deno compile. The compiled executable may encounter runtime errors. Check file:///[WILDLINE]/main.js Compile file:///[WILDLINE] diff --git a/tests/specs/compile/detect_cjs/output.out b/tests/specs/compile/detect_cjs/output.out index e1c27b8dcf..00750edc07 100644 --- a/tests/specs/compile/detect_cjs/output.out +++ b/tests/specs/compile/detect_cjs/output.out @@ -1,2 +1 @@ -error: Uncaught SyntaxError: The requested module './add.js' does not provide an export named 'add' - at (file:///[WILDLINE]) +3 diff --git a/tests/specs/compile/detect_cjs/package.json b/tests/specs/compile/detect_cjs/package.json index 5bbefffbab..6e65b32ed5 100644 --- a/tests/specs/compile/detect_cjs/package.json +++ b/tests/specs/compile/detect_cjs/package.json @@ -1,3 +1,6 @@ { - "type": "commonjs" + "type": "commonjs", + "dependencies": { + "@types/node": "*" + } } diff --git a/tests/specs/compile/detect_cjs/subtract.ts b/tests/specs/compile/detect_cjs/subtract.ts new file mode 100644 index 0000000000..e4f6760b77 --- /dev/null +++ b/tests/specs/compile/detect_cjs/subtract.ts @@ -0,0 +1,2 @@ +/// +module.exports.subtract = (a: number, b: number) => a - b; diff --git a/tests/specs/npm/require_type_commonjs/__test__.jsonc b/tests/specs/npm/require_type_commonjs/__test__.jsonc index c9ba97ff52..a71173ce37 100644 --- a/tests/specs/npm/require_type_commonjs/__test__.jsonc +++ b/tests/specs/npm/require_type_commonjs/__test__.jsonc @@ -1,5 +1,4 @@ { "args": "run --allow-read --quiet main.ts", - "output": "main.out", - "exitCode": 1 + "output": "main.out" } diff --git a/tests/specs/npm/require_type_commonjs/main.out b/tests/specs/npm/require_type_commonjs/main.out index d715db8a94..00750edc07 100644 --- a/tests/specs/npm/require_type_commonjs/main.out +++ b/tests/specs/npm/require_type_commonjs/main.out @@ -1,4 +1 @@ -error: 'import', and 'export' cannot be used outside of module code at file://[WILDCARD]/@denotest/type-commonjs/1.0.0/index.js:1:1 - - export {}; - ~~~~~~ +3 diff --git a/tests/specs/npm/require_type_commonjs/main.ts b/tests/specs/npm/require_type_commonjs/main.ts index 243eb216e4..95ec6099ec 100644 --- a/tests/specs/npm/require_type_commonjs/main.ts +++ b/tests/specs/npm/require_type_commonjs/main.ts @@ -1 +1,2 @@ -import "npm:@denotest/type-commonjs"; +import { add } from "npm:@denotest/type-commonjs"; +console.log(add(1, 2)); diff --git a/tests/specs/npm/typescript_file_in_package/__test__.jsonc b/tests/specs/npm/typescript_file_in_package/__test__.jsonc index 08979ed257..7b5c5e1b67 100644 --- a/tests/specs/npm/typescript_file_in_package/__test__.jsonc +++ b/tests/specs/npm/typescript_file_in_package/__test__.jsonc @@ -1,5 +1,5 @@ { - "args": "run typescript_file_in_package/main.ts", - "output": "typescript_file_in_package/main.out", + "args": "run main.ts", + "output": "main.out", "exitCode": 1 } diff --git a/tests/specs/npm/typescript_file_in_package/main.out b/tests/specs/npm/typescript_file_in_package/main.out new file mode 100644 index 0000000000..58290a8737 --- /dev/null +++ b/tests/specs/npm/typescript_file_in_package/main.out @@ -0,0 +1,3 @@ +Download http://localhost:4260/@denotest%2ftypescript-file +Download http://localhost:4260/@denotest/typescript-file/1.0.0.tgz +error: TypeScript files are not supported in npm packages: file:///[WILDCARD]/@denotest/typescript-file/1.0.0/index.ts diff --git a/tests/specs/npm/typescript_file_in_package/typescript_file_in_package/main.ts b/tests/specs/npm/typescript_file_in_package/main.ts similarity index 100% rename from tests/specs/npm/typescript_file_in_package/typescript_file_in_package/main.ts rename to tests/specs/npm/typescript_file_in_package/main.ts diff --git a/tests/specs/npm/typescript_file_in_package/typescript_file_in_package/main.out b/tests/specs/npm/typescript_file_in_package/typescript_file_in_package/main.out deleted file mode 100644 index b3faa87900..0000000000 --- a/tests/specs/npm/typescript_file_in_package/typescript_file_in_package/main.out +++ /dev/null @@ -1,6 +0,0 @@ -Download http://localhost:4260/@denotest%2ftypescript-file -Download http://localhost:4260/@denotest/typescript-file/1.0.0.tgz -error: Could not resolve 'npm:@denotest/typescript-file@1.0.0'. - -Caused by: - TypeScript files are not supported in npm packages: file:///[WILDCARD]/@denotest/typescript-file/1.0.0/index.ts diff --git a/tests/specs/run/cjs/main_module/__test__.jsonc b/tests/specs/run/cjs/main_module/__test__.jsonc new file mode 100644 index 0000000000..e756a63627 --- /dev/null +++ b/tests/specs/run/cjs/main_module/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read main.cjs", + "output": "main.out" +} diff --git a/tests/specs/run/cjs/main_module/main.cjs b/tests/specs/run/cjs/main_module/main.cjs new file mode 100644 index 0000000000..2a4c57ab1c --- /dev/null +++ b/tests/specs/run/cjs/main_module/main.cjs @@ -0,0 +1 @@ +console.log(require.main); diff --git a/tests/specs/run/cjs/main_module/main.out b/tests/specs/run/cjs/main_module/main.out new file mode 100644 index 0000000000..93b86d27e3 --- /dev/null +++ b/tests/specs/run/cjs/main_module/main.out @@ -0,0 +1,5 @@ +Module { + id: ".", + [WILDCARD] + filename: "[WILDCARD]main.cjs", +[WILDCARD] \ No newline at end of file diff --git a/tests/specs/run/cjs_reexport_non_analyzable/__test__.jsonc b/tests/specs/run/cjs/reexport_non_analyzable/__test__.jsonc similarity index 100% rename from tests/specs/run/cjs_reexport_non_analyzable/__test__.jsonc rename to tests/specs/run/cjs/reexport_non_analyzable/__test__.jsonc diff --git a/tests/specs/run/cjs_reexport_non_analyzable/deno.json b/tests/specs/run/cjs/reexport_non_analyzable/deno.json similarity index 100% rename from tests/specs/run/cjs_reexport_non_analyzable/deno.json rename to tests/specs/run/cjs/reexport_non_analyzable/deno.json diff --git a/tests/specs/run/cjs_reexport_non_analyzable/main.ts b/tests/specs/run/cjs/reexport_non_analyzable/main.ts similarity index 100% rename from tests/specs/run/cjs_reexport_non_analyzable/main.ts rename to tests/specs/run/cjs/reexport_non_analyzable/main.ts diff --git a/tests/specs/run/cjs_reexport_non_analyzable/node_modules/foo.cjs b/tests/specs/run/cjs/reexport_non_analyzable/node_modules/foo.cjs similarity index 100% rename from tests/specs/run/cjs_reexport_non_analyzable/node_modules/foo.cjs rename to tests/specs/run/cjs/reexport_non_analyzable/node_modules/foo.cjs diff --git a/tests/specs/run/cjs/unprepared/__test__.jsonc b/tests/specs/run/cjs/unprepared/__test__.jsonc new file mode 100644 index 0000000000..f816bad869 --- /dev/null +++ b/tests/specs/run/cjs/unprepared/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run -A main.ts", + "output": "main.out" +} diff --git a/tests/specs/run/cjs/unprepared/file.cjs b/tests/specs/run/cjs/unprepared/file.cjs new file mode 100644 index 0000000000..ba0c6fa6ff --- /dev/null +++ b/tests/specs/run/cjs/unprepared/file.cjs @@ -0,0 +1,7 @@ +// non-analyzable +const moduleName = "./output.cjs"; +function getModuleName() { + return moduleName; +} + +require(getModuleName()); diff --git a/tests/specs/run/cjs/unprepared/main.out b/tests/specs/run/cjs/unprepared/main.out new file mode 100644 index 0000000000..e965047ad7 --- /dev/null +++ b/tests/specs/run/cjs/unprepared/main.out @@ -0,0 +1 @@ +Hello diff --git a/tests/specs/run/cjs/unprepared/main.ts b/tests/specs/run/cjs/unprepared/main.ts new file mode 100644 index 0000000000..5630b4fbc3 --- /dev/null +++ b/tests/specs/run/cjs/unprepared/main.ts @@ -0,0 +1,7 @@ +// non-analyzable +const moduleName = "./output.cjs"; +function getModuleName() { + return moduleName; +} + +await import(getModuleName()); diff --git a/tests/specs/run/cjs/unprepared/output.cjs b/tests/specs/run/cjs/unprepared/output.cjs new file mode 100644 index 0000000000..54ed3702f5 --- /dev/null +++ b/tests/specs/run/cjs/unprepared/output.cjs @@ -0,0 +1,3 @@ +console.log("Hello"); + +module.exports = 1; diff --git a/tests/specs/run/cts/cjs_import_cts/__test__.jsonc b/tests/specs/run/cts/cjs_import_cts/__test__.jsonc new file mode 100644 index 0000000000..2205183d07 --- /dev/null +++ b/tests/specs/run/cts/cjs_import_cts/__test__.jsonc @@ -0,0 +1,13 @@ +{ + "tests": { + "no_check": { + "args": "run --allow-read main.js", + "output": "main.out" + }, + "check": { + "args": "check main.js", + "output": "check.out", + "exitCode": 1 + } + } +} diff --git a/tests/specs/run/package_json_type/commonjs/add.js b/tests/specs/run/cts/cjs_import_cts/add.cts similarity index 100% rename from tests/specs/run/package_json_type/commonjs/add.js rename to tests/specs/run/cts/cjs_import_cts/add.cts diff --git a/tests/specs/run/cts/cjs_import_cts/check.out b/tests/specs/run/cts/cjs_import_cts/check.out new file mode 100644 index 0000000000..a27e8d7af7 --- /dev/null +++ b/tests/specs/run/cts/cjs_import_cts/check.out @@ -0,0 +1,17 @@ +Check file:///[WILDLINE]main.js +error: TS2580 [ERROR]: Cannot find name 'module'. +module.exports.add = function (a, b) { +~~~~~~ + at file:///[WILDLINE] + +TS7006 [ERROR]: Parameter 'a' implicitly has an 'any' type. +module.exports.add = function (a, b) { + ^ + at file:///[WILDLINE] + +TS7006 [ERROR]: Parameter 'b' implicitly has an 'any' type. +module.exports.add = function (a, b) { + ^ + at file:///[WILDLINE] + +Found 3 errors. diff --git a/tests/specs/run/cts/cjs_import_cts/main.js b/tests/specs/run/cts/cjs_import_cts/main.js new file mode 100644 index 0000000000..9546a0fea5 --- /dev/null +++ b/tests/specs/run/cts/cjs_import_cts/main.js @@ -0,0 +1,3 @@ +import { subtract } from "./subtract.cjs"; + +console.log(subtract(1, 2)); diff --git a/tests/specs/run/cts/cjs_import_cts/main.out b/tests/specs/run/cts/cjs_import_cts/main.out new file mode 100644 index 0000000000..3a2e3f4984 --- /dev/null +++ b/tests/specs/run/cts/cjs_import_cts/main.out @@ -0,0 +1 @@ +-1 diff --git a/tests/specs/run/cts/cjs_import_cts/subtract.cjs b/tests/specs/run/cts/cjs_import_cts/subtract.cjs new file mode 100644 index 0000000000..7dee54346f --- /dev/null +++ b/tests/specs/run/cts/cjs_import_cts/subtract.cjs @@ -0,0 +1,3 @@ +module.exports.subtract = function (a, b) { + return require("./add.cts").add(a, -b); +}; diff --git a/tests/specs/run/cts/import_export_equals/__test__.jsonc b/tests/specs/run/cts/import_export_equals/__test__.jsonc new file mode 100644 index 0000000000..6a5c6db420 --- /dev/null +++ b/tests/specs/run/cts/import_export_equals/__test__.jsonc @@ -0,0 +1,17 @@ +{ + "tests": { + "main": { + "args": "run --check --allow-read=. main.cts", + "output": "main.out" + }, + "mts": { + "args": "run --allow-read=. mod.mts", + "output": "mod.mts.out" + }, + "mts_check": { + "args": "check mod.mts", + "output": "mod.mts.check.out", + "exitCode": 1 + } + } +} diff --git a/tests/specs/run/cts/import_export_equals/add.cts b/tests/specs/run/cts/import_export_equals/add.cts new file mode 100644 index 0000000000..adf3503ac5 --- /dev/null +++ b/tests/specs/run/cts/import_export_equals/add.cts @@ -0,0 +1,3 @@ +export = function (a: number, b: number) { + return a + b; +}; diff --git a/tests/specs/run/cts/import_export_equals/main.cts b/tests/specs/run/cts/import_export_equals/main.cts new file mode 100644 index 0000000000..e5c45f92e0 --- /dev/null +++ b/tests/specs/run/cts/import_export_equals/main.cts @@ -0,0 +1,3 @@ +import add = require("./add.cts"); + +console.log(add(1, 2)); diff --git a/tests/specs/run/cts/import_export_equals/main.out b/tests/specs/run/cts/import_export_equals/main.out new file mode 100644 index 0000000000..e7a973a7d0 --- /dev/null +++ b/tests/specs/run/cts/import_export_equals/main.out @@ -0,0 +1,2 @@ +Check file:///[WILDLINE]/main.cts +3 diff --git a/tests/specs/run/cts/import_export_equals/mod.mts b/tests/specs/run/cts/import_export_equals/mod.mts new file mode 100644 index 0000000000..5fbbd6c6a0 --- /dev/null +++ b/tests/specs/run/cts/import_export_equals/mod.mts @@ -0,0 +1,3 @@ +import add from "./add.cts"; + +console.log(add(1, "test")); diff --git a/tests/specs/run/cts/import_export_equals/mod.mts.check.out b/tests/specs/run/cts/import_export_equals/mod.mts.check.out new file mode 100644 index 0000000000..8703539019 --- /dev/null +++ b/tests/specs/run/cts/import_export_equals/mod.mts.check.out @@ -0,0 +1,5 @@ +Check file:///[WILDLINE]/mod.mts +error: TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'number'. +console.log(add(1, "test")); + ~~~~~~ + at file:///[WILDLINE]/mod.mts:3:20 diff --git a/tests/specs/run/cts/import_export_equals/mod.mts.out b/tests/specs/run/cts/import_export_equals/mod.mts.out new file mode 100644 index 0000000000..208465a080 --- /dev/null +++ b/tests/specs/run/cts/import_export_equals/mod.mts.out @@ -0,0 +1 @@ +1test diff --git a/tests/specs/run/cts/main/__test__.jsonc b/tests/specs/run/cts/main/__test__.jsonc new file mode 100644 index 0000000000..0157b44e96 --- /dev/null +++ b/tests/specs/run/cts/main/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read main.cts", + "output": "main.out" +} diff --git a/tests/specs/run/cts/main/import_main.cjs b/tests/specs/run/cts/main/import_main.cjs new file mode 100644 index 0000000000..f61e0da2a6 --- /dev/null +++ b/tests/specs/run/cts/main/import_main.cjs @@ -0,0 +1 @@ +require("./main.cts").sayHello(); diff --git a/tests/specs/run/cts/main/main.cts b/tests/specs/run/cts/main/main.cts new file mode 100644 index 0000000000..0b0330686b --- /dev/null +++ b/tests/specs/run/cts/main/main.cts @@ -0,0 +1,5 @@ +module.exports.sayHello = function () { + console.log("Hello"); +}; + +require("./import_main.cjs"); diff --git a/tests/specs/run/cts/main/main.out b/tests/specs/run/cts/main/main.out new file mode 100644 index 0000000000..e965047ad7 --- /dev/null +++ b/tests/specs/run/cts/main/main.out @@ -0,0 +1 @@ +Hello diff --git a/tests/specs/run/package_json_type/commonjs/__test__.jsonc b/tests/specs/run/package_json_type/commonjs/basic/__test__.jsonc similarity index 100% rename from tests/specs/run/package_json_type/commonjs/__test__.jsonc rename to tests/specs/run/package_json_type/commonjs/basic/__test__.jsonc diff --git a/tests/specs/run/package_json_type/commonjs/basic/add.js b/tests/specs/run/package_json_type/commonjs/basic/add.js new file mode 100644 index 0000000000..2a886fbc18 --- /dev/null +++ b/tests/specs/run/package_json_type/commonjs/basic/add.js @@ -0,0 +1,3 @@ +module.exports.add = function (a, b) { + return a + b; +}; diff --git a/tests/specs/run/package_json_type/commonjs/deno.jsonc b/tests/specs/run/package_json_type/commonjs/basic/deno.jsonc similarity index 100% rename from tests/specs/run/package_json_type/commonjs/deno.jsonc rename to tests/specs/run/package_json_type/commonjs/basic/deno.jsonc diff --git a/tests/specs/run/package_json_type/commonjs/import_import_meta.js b/tests/specs/run/package_json_type/commonjs/basic/import_import_meta.js similarity index 100% rename from tests/specs/run/package_json_type/commonjs/import_import_meta.js rename to tests/specs/run/package_json_type/commonjs/basic/import_import_meta.js diff --git a/tests/specs/run/package_json_type/commonjs/import_meta.js b/tests/specs/run/package_json_type/commonjs/basic/import_meta.js similarity index 100% rename from tests/specs/run/package_json_type/commonjs/import_meta.js rename to tests/specs/run/package_json_type/commonjs/basic/import_meta.js diff --git a/tests/specs/run/package_json_type/commonjs/main_cjs.js b/tests/specs/run/package_json_type/commonjs/basic/main_cjs.js similarity index 100% rename from tests/specs/run/package_json_type/commonjs/main_cjs.js rename to tests/specs/run/package_json_type/commonjs/basic/main_cjs.js diff --git a/tests/specs/run/package_json_type/commonjs/main_esm.js b/tests/specs/run/package_json_type/commonjs/basic/main_esm.js similarity index 100% rename from tests/specs/run/package_json_type/commonjs/main_esm.js rename to tests/specs/run/package_json_type/commonjs/basic/main_esm.js diff --git a/tests/specs/run/package_json_type/commonjs/main_esm_import_meta.js b/tests/specs/run/package_json_type/commonjs/basic/main_esm_import_meta.js similarity index 100% rename from tests/specs/run/package_json_type/commonjs/main_esm_import_meta.js rename to tests/specs/run/package_json_type/commonjs/basic/main_esm_import_meta.js diff --git a/tests/specs/run/package_json_type/commonjs/main_esm_import_meta.out b/tests/specs/run/package_json_type/commonjs/basic/main_esm_import_meta.out similarity index 100% rename from tests/specs/run/package_json_type/commonjs/main_esm_import_meta.out rename to tests/specs/run/package_json_type/commonjs/basic/main_esm_import_meta.out diff --git a/tests/specs/run/package_json_type/commonjs/main_mix.js b/tests/specs/run/package_json_type/commonjs/basic/main_mix.js similarity index 100% rename from tests/specs/run/package_json_type/commonjs/main_mix.js rename to tests/specs/run/package_json_type/commonjs/basic/main_mix.js diff --git a/tests/specs/run/package_json_type/commonjs/main_mix.out b/tests/specs/run/package_json_type/commonjs/basic/main_mix.out similarity index 100% rename from tests/specs/run/package_json_type/commonjs/main_mix.out rename to tests/specs/run/package_json_type/commonjs/basic/main_mix.out diff --git a/tests/specs/run/package_json_type/commonjs/not_import_meta.js b/tests/specs/run/package_json_type/commonjs/basic/not_import_meta.js similarity index 100% rename from tests/specs/run/package_json_type/commonjs/not_import_meta.js rename to tests/specs/run/package_json_type/commonjs/basic/not_import_meta.js diff --git a/tests/specs/run/package_json_type/commonjs/package.json b/tests/specs/run/package_json_type/commonjs/basic/package.json similarity index 100% rename from tests/specs/run/package_json_type/commonjs/package.json rename to tests/specs/run/package_json_type/commonjs/basic/package.json diff --git a/tests/specs/run/package_json_type/commonjs/tla.js b/tests/specs/run/package_json_type/commonjs/basic/tla.js similarity index 100% rename from tests/specs/run/package_json_type/commonjs/tla.js rename to tests/specs/run/package_json_type/commonjs/basic/tla.js diff --git a/tests/specs/run/package_json_type/commonjs/jsx/__test__.jsonc b/tests/specs/run/package_json_type/commonjs/jsx/__test__.jsonc new file mode 100644 index 0000000000..f815fd72cb --- /dev/null +++ b/tests/specs/run/package_json_type/commonjs/jsx/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "tempDir": true, + "args": "run -A --quiet main.jsx", + "output": "main.out" +} diff --git a/tests/specs/run/package_json_type/commonjs/jsx/add.js b/tests/specs/run/package_json_type/commonjs/jsx/add.js new file mode 100644 index 0000000000..2a886fbc18 --- /dev/null +++ b/tests/specs/run/package_json_type/commonjs/jsx/add.js @@ -0,0 +1,3 @@ +module.exports.add = function (a, b) { + return a + b; +}; diff --git a/tests/specs/run/package_json_type/commonjs/jsx/deno.jsonc b/tests/specs/run/package_json_type/commonjs/jsx/deno.jsonc new file mode 100644 index 0000000000..192ddb98c4 --- /dev/null +++ b/tests/specs/run/package_json_type/commonjs/jsx/deno.jsonc @@ -0,0 +1,10 @@ +{ + "nodeModulesDir": "auto", + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "react" + }, + "unstable": [ + "detect-cjs" + ] +} diff --git a/tests/specs/run/package_json_type/commonjs/jsx/main.jsx b/tests/specs/run/package_json_type/commonjs/jsx/main.jsx new file mode 100644 index 0000000000..1922fce1bb --- /dev/null +++ b/tests/specs/run/package_json_type/commonjs/jsx/main.jsx @@ -0,0 +1,7 @@ +const { add } = require("./add.js"); + +console.log(add(1, 2)); + +console.log(

!= null); + +require("./tsx.tsx"); diff --git a/tests/specs/run/package_json_type/commonjs/jsx/main.out b/tests/specs/run/package_json_type/commonjs/jsx/main.out new file mode 100644 index 0000000000..cdcf045418 --- /dev/null +++ b/tests/specs/run/package_json_type/commonjs/jsx/main.out @@ -0,0 +1,4 @@ +3 +true +4 +true diff --git a/tests/specs/run/package_json_type/commonjs/jsx/package.json b/tests/specs/run/package_json_type/commonjs/jsx/package.json new file mode 100644 index 0000000000..88afcdcd95 --- /dev/null +++ b/tests/specs/run/package_json_type/commonjs/jsx/package.json @@ -0,0 +1,7 @@ +{ + "type": "commonjs", + "dependencies": { + "@types/react": "*", + "react": "*" + } +} diff --git a/tests/specs/run/package_json_type/commonjs/jsx/tsx.tsx b/tests/specs/run/package_json_type/commonjs/jsx/tsx.tsx new file mode 100644 index 0000000000..ad8f0c0a9c --- /dev/null +++ b/tests/specs/run/package_json_type/commonjs/jsx/tsx.tsx @@ -0,0 +1,5 @@ +import mod = require("./add.js"); + +console.log(mod.add(2, 2)); + +console.log(
!= null); diff --git a/tests/specs/run/remote_cjs_main/output.out b/tests/specs/run/remote_cjs_main/output.out index f75c33907a..360934acb7 100644 --- a/tests/specs/run/remote_cjs_main/output.out +++ b/tests/specs/run/remote_cjs_main/output.out @@ -1,3 +1,3 @@ Download http://localhost:4545/run/add.cjs -error: Expected a JavaScript or TypeScript module, but identified a Cjs module. Importing these types of modules is currently not supported. +error: Remote CJS modules are not supported. Specifier: http://localhost:4545/run/add.cjs diff --git a/tests/specs/run/require_esm/main.out b/tests/specs/run/require_esm/main.out index d17b1ead55..57b842b345 100644 --- a/tests/specs/run/require_esm/main.out +++ b/tests/specs/run/require_esm/main.out @@ -1,6 +1,6 @@ [Module: null prototype] { sync_js: 1 } [Module: null prototype] { sync_mjs: 1 } -error: Uncaught Error: Top-level await is not allowed in synchronous evaluation +error: Uncaught (in promise) Error: Top-level await is not allowed in synchronous evaluation at loadESMFromCJS (node:module:[WILDCARD]) at Module._compile (node:module:[WILDCARD]) at Object.Module._extensions..js (node:module:[WILDCARD]) diff --git a/tests/testdata/npm/deno_run_cowsay_no_permissions.out b/tests/testdata/npm/deno_run_cowsay_no_permissions.out index 6434620e2e..25b79d9a7d 100644 --- a/tests/testdata/npm/deno_run_cowsay_no_permissions.out +++ b/tests/testdata/npm/deno_run_cowsay_no_permissions.out @@ -1,2 +1,2 @@ -error: Uncaught NotCapable: Requires read access to , specify the required permissions during compilation using `deno compile --allow-read` +error: Uncaught (in promise) NotCapable: Requires read access to , specify the required permissions during compilation using `deno compile --allow-read` [WILDCARD] From 2c8a0e791732ab00907ca11c3a4918ad26ead03f Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Fri, 1 Nov 2024 19:10:35 -0700 Subject: [PATCH 18/40] fix(add): only add npm deps to package.json if it's at least as close as deno.json (#26683) Fixes https://github.com/denoland/deno/issues/26653 --- cli/tools/registry/pm.rs | 26 ++++++++++++++++++- .../package_json_and_deno_json/__test__.jsonc | 23 ++++++++++++++++ .../subdir/deno.json | 4 +++ .../package_json_and_deno_json/subdir/mod.ts | 0 .../subdir/prefer_if_closer_deno.json.out | 9 +++++++ 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 tests/specs/add/package_json_and_deno_json/subdir/deno.json create mode 100644 tests/specs/add/package_json_and_deno_json/subdir/mod.ts create mode 100644 tests/specs/add/package_json_and_deno_json/subdir/prefer_if_closer_deno.json.out diff --git a/cli/tools/registry/pm.rs b/cli/tools/registry/pm.rs index d1be901d67..4e03879983 100644 --- a/cli/tools/registry/pm.rs +++ b/cli/tools/registry/pm.rs @@ -1,5 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +use std::path::Path; use std::path::PathBuf; use std::sync::Arc; @@ -333,6 +334,14 @@ fn load_configs( Ok((cli_factory, npm_config, deno_config)) } +fn path_distance(a: &Path, b: &Path) -> usize { + let diff = pathdiff::diff_paths(a, b); + let Some(diff) = diff else { + return usize::MAX; + }; + diff.components().count() +} + pub async fn add( flags: Arc, add_flags: AddFlags, @@ -357,6 +366,21 @@ pub async fn add( } } + let start_dir = cli_factory.cli_options()?.start_dir.dir_path(); + + // only prefer to add npm deps to `package.json` if there isn't a closer deno.json. + // example: if deno.json is in the CWD and package.json is in the parent, we should add + // npm deps to deno.json, since it's closer + let prefer_npm_config = match (npm_config.as_ref(), deno_config.as_ref()) { + (Some(npm), Some(deno)) => { + let npm_distance = path_distance(&npm.path, &start_dir); + let deno_distance = path_distance(&deno.path, &start_dir); + npm_distance <= deno_distance + } + (Some(_), None) => true, + (None, _) => false, + }; + let http_client = cli_factory.http_client_provider(); let deps_http_cache = cli_factory.global_http_cache()?; let mut deps_file_fetcher = FileFetcher::new( @@ -455,7 +479,7 @@ pub async fn add( selected_package.selected_version ); - if selected_package.package_name.starts_with("npm:") { + if selected_package.package_name.starts_with("npm:") && prefer_npm_config { if let Some(npm) = &mut npm_config { npm.add(selected_package, dev); } else { diff --git a/tests/specs/add/package_json_and_deno_json/__test__.jsonc b/tests/specs/add/package_json_and_deno_json/__test__.jsonc index 0beee02d15..8d67a07c82 100644 --- a/tests/specs/add/package_json_and_deno_json/__test__.jsonc +++ b/tests/specs/add/package_json_and_deno_json/__test__.jsonc @@ -41,6 +41,29 @@ "output": "good\n" } ] + }, + "only_prefers_package_json_if_closer": { + "steps": [ + { + "cwd": "./subdir", + "args": "add npm:@denotest/esm-basic jsr:@denotest/add npm:@denotest/say-hello", + "output": "[WILDCARD]" + }, + { + "args": [ + "eval", + "console.log(Deno.readTextFileSync('package.json').trim())" + ], + "output": "{}\n" + }, + { + "args": [ + "eval", + "console.log(Deno.readTextFileSync('./subdir/deno.json').trim())" + ], + "output": "subdir/prefer_if_closer_deno.json.out" + } + ] } } } diff --git a/tests/specs/add/package_json_and_deno_json/subdir/deno.json b/tests/specs/add/package_json_and_deno_json/subdir/deno.json new file mode 100644 index 0000000000..cc54bbd8a2 --- /dev/null +++ b/tests/specs/add/package_json_and_deno_json/subdir/deno.json @@ -0,0 +1,4 @@ +{ + "name": "@test/subdir", + "exports": "./mod.ts" +} diff --git a/tests/specs/add/package_json_and_deno_json/subdir/mod.ts b/tests/specs/add/package_json_and_deno_json/subdir/mod.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/specs/add/package_json_and_deno_json/subdir/prefer_if_closer_deno.json.out b/tests/specs/add/package_json_and_deno_json/subdir/prefer_if_closer_deno.json.out new file mode 100644 index 0000000000..8a5819d503 --- /dev/null +++ b/tests/specs/add/package_json_and_deno_json/subdir/prefer_if_closer_deno.json.out @@ -0,0 +1,9 @@ +{ + "name": "@test/subdir", + "exports": "./mod.ts", + "imports": { + "@denotest/add": "jsr:@denotest/add@^1.0.0", + "@denotest/esm-basic": "npm:@denotest/esm-basic@^1.0.0", + "@denotest/say-hello": "npm:@denotest/say-hello@^1.0.0" + } +} From d95f06f20b97839d9a2aaeb590f4ed30b6383b0f Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Mon, 4 Nov 2024 16:36:21 +0000 Subject: [PATCH 19/40] perf(lsp): don't walk coverage directory (#26715) --- cli/lsp/language_server.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 4fa0e3afbc..61a02f036e 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -863,7 +863,10 @@ impl Inner { // We ignore these directories by default because there is a // high likelihood they aren't relevant. Someone can opt-into // them by specifying one of them as an enabled path. - if matches!(dir_name.as_str(), "vendor" | "node_modules" | ".git") { + if matches!( + dir_name.as_str(), + "vendor" | "coverage" | "node_modules" | ".git" + ) { continue; } // ignore cargo target directories for anyone using Deno with Rust @@ -3944,7 +3947,9 @@ mod tests { fn test_walk_workspace() { let temp_dir = TempDir::new(); temp_dir.create_dir_all("root1/vendor/"); + temp_dir.create_dir_all("root1/coverage/"); temp_dir.write("root1/vendor/mod.ts", ""); // no, vendor + temp_dir.write("root1/coverage/mod.ts", ""); // no, coverage temp_dir.create_dir_all("root1/node_modules/"); temp_dir.write("root1/node_modules/mod.ts", ""); // no, node_modules From fb1d33a7111e45e9b414cfe922a5db5ee4daf3ea Mon Sep 17 00:00:00 2001 From: Kenta Moriuchi Date: Tue, 5 Nov 2024 02:17:11 +0900 Subject: [PATCH 20/40] chore: update dlint to v0.68.0 for internal (#26711) --- cli/bench/encode_into.js | 3 +-- cli/bench/getrandom.js | 3 +-- cli/bench/op_now.js | 3 +-- cli/bench/secure_curves.js | 3 +-- cli/bench/tty.js | 3 +-- cli/bench/url_parse.js | 3 +-- cli/bench/write_file.js | 3 +-- ext/node/polyfills/_fs/_fs_common.ts | 1 + ext/node/polyfills/_fs/_fs_open.ts | 4 ++-- ext/node/polyfills/_fs/_fs_readv.ts | 1 + ext/node/polyfills/internal/crypto/keygen.ts | 1 + ext/node/polyfills/internal/crypto/random.ts | 1 + ext/node/polyfills/internal_binding/http_parser.ts | 1 + ext/node/polyfills/vm.js | 1 + runtime/js/99_main.js | 1 + tests/node_compat/test/fixtures/child-process-spawn-node.js | 1 + tests/unit/globals_test.ts | 1 + tools/lint.js | 3 ++- tools/util.js | 4 ++-- 19 files changed, 22 insertions(+), 19 deletions(-) diff --git a/cli/bench/encode_into.js b/cli/bench/encode_into.js index 11f5a56d90..ab5e11b04d 100644 --- a/cli/bench/encode_into.js +++ b/cli/bench/encode_into.js @@ -1,6 +1,5 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -// deno-lint-ignore-file no-console +// deno-lint-ignore-file no-console no-process-globals let [total, count] = typeof Deno !== "undefined" ? Deno.args diff --git a/cli/bench/getrandom.js b/cli/bench/getrandom.js index 3c3ec4aa19..fe99bbcbdf 100644 --- a/cli/bench/getrandom.js +++ b/cli/bench/getrandom.js @@ -1,6 +1,5 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -// deno-lint-ignore-file no-console +// deno-lint-ignore-file no-console no-process-globals let [total, count] = typeof Deno !== "undefined" ? Deno.args diff --git a/cli/bench/op_now.js b/cli/bench/op_now.js index bcc3ea3c56..7c1427c809 100644 --- a/cli/bench/op_now.js +++ b/cli/bench/op_now.js @@ -1,6 +1,5 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -// deno-lint-ignore-file no-console +// deno-lint-ignore-file no-console no-process-globals const queueMicrotask = globalThis.queueMicrotask || process.nextTick; let [total, count] = typeof Deno !== "undefined" diff --git a/cli/bench/secure_curves.js b/cli/bench/secure_curves.js index 02d248b23f..912b75cccd 100644 --- a/cli/bench/secure_curves.js +++ b/cli/bench/secure_curves.js @@ -1,6 +1,5 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -// deno-lint-ignore-file no-console +// deno-lint-ignore-file no-console no-process-globals let [total, count] = typeof Deno !== "undefined" ? Deno.args diff --git a/cli/bench/tty.js b/cli/bench/tty.js index 248a901137..e494e76af7 100644 --- a/cli/bench/tty.js +++ b/cli/bench/tty.js @@ -1,6 +1,5 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -// deno-lint-ignore-file no-console +// deno-lint-ignore-file no-console no-process-globals const queueMicrotask = globalThis.queueMicrotask || process.nextTick; let [total, count] = typeof Deno !== "undefined" diff --git a/cli/bench/url_parse.js b/cli/bench/url_parse.js index 367cf73f46..9cb0045f64 100644 --- a/cli/bench/url_parse.js +++ b/cli/bench/url_parse.js @@ -1,6 +1,5 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -// deno-lint-ignore-file no-console +// deno-lint-ignore-file no-console no-process-globals const queueMicrotask = globalThis.queueMicrotask || process.nextTick; let [total, count] = typeof Deno !== "undefined" diff --git a/cli/bench/write_file.js b/cli/bench/write_file.js index 104a23a8db..747503ce2a 100644 --- a/cli/bench/write_file.js +++ b/cli/bench/write_file.js @@ -1,6 +1,5 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -// deno-lint-ignore-file no-console +// deno-lint-ignore-file no-console no-process-globals const queueMicrotask = globalThis.queueMicrotask || process.nextTick; let [total, count] = typeof Deno !== "undefined" diff --git a/ext/node/polyfills/_fs/_fs_common.ts b/ext/node/polyfills/_fs/_fs_common.ts index ac0bf5a551..a29548bb36 100644 --- a/ext/node/polyfills/_fs/_fs_common.ts +++ b/ext/node/polyfills/_fs/_fs_common.ts @@ -20,6 +20,7 @@ import { notImplemented, TextEncodings, } from "ext:deno_node/_utils.ts"; +import { type Buffer } from "node:buffer"; export type CallbackWithError = (err: ErrnoException | null) => void; diff --git a/ext/node/polyfills/_fs/_fs_open.ts b/ext/node/polyfills/_fs/_fs_open.ts index 8bd989790b..31ca4bb619 100644 --- a/ext/node/polyfills/_fs/_fs_open.ts +++ b/ext/node/polyfills/_fs/_fs_open.ts @@ -147,8 +147,8 @@ export function open( export function openPromise( path: string | Buffer | URL, - flags?: openFlags = "r", - mode? = 0o666, + flags: openFlags = "r", + mode = 0o666, ): Promise { return new Promise((resolve, reject) => { open(path, flags, mode, (err, fd) => { diff --git a/ext/node/polyfills/_fs/_fs_readv.ts b/ext/node/polyfills/_fs/_fs_readv.ts index 384f5e319a..2259f029ae 100644 --- a/ext/node/polyfills/_fs/_fs_readv.ts +++ b/ext/node/polyfills/_fs/_fs_readv.ts @@ -15,6 +15,7 @@ import { maybeCallback } from "ext:deno_node/_fs/_fs_common.ts"; import { validateInteger } from "ext:deno_node/internal/validators.mjs"; import * as io from "ext:deno_io/12_io.js"; import { op_fs_seek_async, op_fs_seek_sync } from "ext:core/ops"; +import process from "node:process"; type Callback = ( err: ErrnoException | null, diff --git a/ext/node/polyfills/internal/crypto/keygen.ts b/ext/node/polyfills/internal/crypto/keygen.ts index a40c76c0d7..44bfd83277 100644 --- a/ext/node/polyfills/internal/crypto/keygen.ts +++ b/ext/node/polyfills/internal/crypto/keygen.ts @@ -29,6 +29,7 @@ import { } from "ext:deno_node/internal/validators.mjs"; import { Buffer } from "node:buffer"; import { KeyFormat, KeyType } from "ext:deno_node/internal/crypto/types.ts"; +import process from "node:process"; import { op_node_generate_dh_group_key, diff --git a/ext/node/polyfills/internal/crypto/random.ts b/ext/node/polyfills/internal/crypto/random.ts index 4219414dc1..a41b868190 100644 --- a/ext/node/polyfills/internal/crypto/random.ts +++ b/ext/node/polyfills/internal/crypto/random.ts @@ -38,6 +38,7 @@ import { ERR_INVALID_ARG_TYPE, ERR_OUT_OF_RANGE, } from "ext:deno_node/internal/errors.ts"; +import { Buffer } from "node:buffer"; export { default as randomBytes } from "ext:deno_node/internal/crypto/_randomBytes.ts"; export { diff --git a/ext/node/polyfills/internal_binding/http_parser.ts b/ext/node/polyfills/internal_binding/http_parser.ts index ca4f896e20..bad10d9851 100644 --- a/ext/node/polyfills/internal_binding/http_parser.ts +++ b/ext/node/polyfills/internal_binding/http_parser.ts @@ -126,6 +126,7 @@ ObjectSetPrototypeOf(HTTPParser.prototype, AsyncWrap.prototype); function defineProps(obj: object, props: Record) { for (const entry of new SafeArrayIterator(ObjectEntries(props))) { ObjectDefineProperty(obj, entry[0], { + __proto__: null, value: entry[1], enumerable: true, writable: true, diff --git a/ext/node/polyfills/vm.js b/ext/node/polyfills/vm.js index 183ddad2f4..b64c847c58 100644 --- a/ext/node/polyfills/vm.js +++ b/ext/node/polyfills/vm.js @@ -182,6 +182,7 @@ function getContextOptions(options) { let defaultContextNameIndex = 1; export function createContext( + // deno-lint-ignore prefer-primordials contextObject = {}, options = { __proto__: null }, ) { diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 56a5b411bb..4d391dcc3a 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -696,6 +696,7 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) { // are lost. let jupyterNs = undefined; ObjectDefineProperty(finalDenoNs, "jupyter", { + __proto__: null, get() { if (jupyterNs) { return jupyterNs; diff --git a/tests/node_compat/test/fixtures/child-process-spawn-node.js b/tests/node_compat/test/fixtures/child-process-spawn-node.js index d403aabf91..7112567e01 100644 --- a/tests/node_compat/test/fixtures/child-process-spawn-node.js +++ b/tests/node_compat/test/fixtures/child-process-spawn-node.js @@ -1,5 +1,6 @@ const assert = require("assert"); const debug = require('util').debuglog('test'); +const process = require("process"); function onmessage(m) { debug("CHILD got message:", m); diff --git a/tests/unit/globals_test.ts b/tests/unit/globals_test.ts index 45a0458357..6de228e1c9 100644 --- a/tests/unit/globals_test.ts +++ b/tests/unit/globals_test.ts @@ -1,4 +1,5 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +// deno-lint-ignore-file no-node-globals import { assert, diff --git a/tools/lint.js b/tools/lint.js index 1f3f56498b..b591cae0ba 100755 --- a/tools/lint.js +++ b/tools/lint.js @@ -56,12 +56,13 @@ async function dlint() { ":!:cli/tsc/compiler.d.ts", ":!:runtime/examples/", ":!:target/", + ":!:tests/ffi/tests/test.js", ":!:tests/registry/**", ":!:tests/specs/**", ":!:tests/testdata/**", ":!:tests/unit_node/testdata/**", - ":!:tests/wpt/suite/**", ":!:tests/wpt/runner/**", + ":!:tests/wpt/suite/**", ]); if (!sourceFiles.length) { diff --git a/tools/util.js b/tools/util.js index 99133628ce..8c7cea15d8 100644 --- a/tools/util.js +++ b/tools/util.js @@ -11,7 +11,7 @@ export { delay } from "@std/async/delay"; // [toolName] --version output const versions = { - "dlint": "dlint 0.60.0", + "dlint": "dlint 0.68.0", }; const compressed = new Set(["ld64.lld", "rcodesign"]); @@ -178,7 +178,7 @@ export function getPrebuiltToolPath(toolName) { return join(PREBUILT_TOOL_DIR, toolName + executableSuffix); } -const commitId = "b8aac22e0cd7c1c6557a56a813fe0c25486fafee"; +const commitId = "7a3a6fee951b3381c59aa4c907274957f324ce8c"; const downloadUrl = `https://raw.githubusercontent.com/denoland/deno_third_party/${commitId}/prebuilt/${platformDirName}`; From fe9f0ee5934871175758857899fe64e56c397fd5 Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Mon, 4 Nov 2024 09:17:21 -0800 Subject: [PATCH 21/40] refactor(runtime/permissions): use concrete error types (#26464) --- Cargo.lock | 1 + cli/args/flags.rs | 3 +- cli/args/flags_net.rs | 2 +- cli/npm/byonm.rs | 2 +- cli/npm/managed/resolvers/common.rs | 2 +- cli/tools/info.rs | 10 +- ext/fetch/lib.rs | 23 +- ext/ffi/call.rs | 14 +- ext/ffi/callback.rs | 6 +- ext/ffi/dlfcn.rs | 6 +- ext/ffi/lib.rs | 11 +- ext/ffi/repr.rs | 86 +-- ext/fs/lib.rs | 50 +- ext/fs/ops.rs | 217 +++----- ext/kv/remote.rs | 13 +- ext/kv/sqlite.rs | 12 +- ext/napi/lib.rs | 15 +- ext/net/lib.rs | 17 +- ext/net/ops.rs | 36 +- ext/node/lib.rs | 34 +- ext/node/ops/fs.rs | 35 +- ext/node/ops/http.rs | 4 +- ext/node/ops/os/mod.rs | 14 +- ext/websocket/lib.rs | 18 +- runtime/errors.rs | 147 ++++-- runtime/ops/fs_events.rs | 5 +- runtime/ops/os/mod.rs | 23 +- runtime/ops/permissions.rs | 43 +- runtime/ops/process.rs | 24 +- runtime/ops/worker_host.rs | 2 +- runtime/permissions.rs | 44 +- runtime/permissions/Cargo.toml | 1 + runtime/permissions/lib.rs | 776 ++++++++++++++++++---------- runtime/permissions/prompter.rs | 69 ++- runtime/snapshot.rs | 64 +-- 35 files changed, 999 insertions(+), 830 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c7b35ca9f..a8a501716c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1972,6 +1972,7 @@ dependencies = [ "once_cell", "percent-encoding", "serde", + "thiserror", "which 4.4.2", "winapi", ] diff --git a/cli/args/flags.rs b/cli/args/flags.rs index 1a1213aac2..eb77971748 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -3388,8 +3388,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command { .value_name("IP_OR_HOSTNAME") .help("Allow network access. Optionally specify allowed IP addresses and host names, with ports as necessary") .value_parser(flags_net::validator) - .hide(true) - ; + .hide(true); if let Some(requires) = requires { arg = arg.requires(requires) } diff --git a/cli/args/flags_net.rs b/cli/args/flags_net.rs index 88ffcf0e46..abfcf28382 100644 --- a/cli/args/flags_net.rs +++ b/cli/args/flags_net.rs @@ -51,7 +51,7 @@ pub fn parse(paths: Vec) -> clap::error::Result> { } } else { NetDescriptor::parse(&host_and_port).map_err(|e| { - clap::Error::raw(clap::error::ErrorKind::InvalidValue, format!("{e:?}")) + clap::Error::raw(clap::error::ErrorKind::InvalidValue, e.to_string()) })?; out.push(host_and_port) } diff --git a/cli/npm/byonm.rs b/cli/npm/byonm.rs index 4535b07fc5..45fa4cfd1f 100644 --- a/cli/npm/byonm.rs +++ b/cli/npm/byonm.rs @@ -89,7 +89,7 @@ impl CliNpmResolver for CliByonmNpmResolver { .components() .any(|c| c.as_os_str().to_ascii_lowercase() == "node_modules") { - permissions.check_read_path(path) + permissions.check_read_path(path).map_err(Into::into) } else { Ok(Cow::Borrowed(path)) } diff --git a/cli/npm/managed/resolvers/common.rs b/cli/npm/managed/resolvers/common.rs index 590f8fb25c..eee11c7604 100644 --- a/cli/npm/managed/resolvers/common.rs +++ b/cli/npm/managed/resolvers/common.rs @@ -133,7 +133,7 @@ impl RegistryReadPermissionChecker { } } - permissions.check_read_path(path) + permissions.check_read_path(path).map_err(Into::into) } } diff --git a/cli/tools/info.rs b/cli/tools/info.rs index b53485bd6b..c2f5a8cb8d 100644 --- a/cli/tools/info.rs +++ b/cli/tools/info.rs @@ -645,10 +645,12 @@ impl<'a> GraphDisplayContext<'a> { let message = match err { HttpsChecksumIntegrity(_) => "(checksum integrity error)", Decode(_) => "(loading decode error)", - Loader(err) => match deno_core::error::get_custom_error_class(err) { - Some("NotCapable") => "(not capable, requires --allow-import)", - _ => "(loading error)", - }, + Loader(err) => { + match deno_runtime::errors::get_error_class_name(err) { + Some("NotCapable") => "(not capable, requires --allow-import)", + _ => "(loading error)", + } + } Jsr(_) => "(loading error)", NodeUnknownBuiltinModule(_) => "(unknown node built-in error)", Npm(_) => "(npm loading error)", diff --git a/ext/fetch/lib.rs b/ext/fetch/lib.rs index 4df8dc3d72..7ef26431c2 100644 --- a/ext/fetch/lib.rs +++ b/ext/fetch/lib.rs @@ -39,6 +39,7 @@ use deno_core::OpState; use deno_core::RcRef; use deno_core::Resource; use deno_core::ResourceId; +use deno_permissions::PermissionCheckError; use deno_tls::rustls::RootCertStore; use deno_tls::Proxy; use deno_tls::RootCertStoreProvider; @@ -149,7 +150,7 @@ pub enum FetchError { #[error(transparent)] Resource(deno_core::error::AnyError), #[error(transparent)] - Permission(deno_core::error::AnyError), + Permission(#[from] PermissionCheckError), #[error("NetworkError when attempting to fetch resource")] NetworkError, #[error("Fetching files only supports the GET method: received {0}")] @@ -346,13 +347,13 @@ pub trait FetchPermissions { &mut self, url: &Url, api_name: &str, - ) -> Result<(), deno_core::error::AnyError>; + ) -> Result<(), PermissionCheckError>; #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] fn check_read<'a>( &mut self, p: &'a Path, api_name: &str, - ) -> Result, deno_core::error::AnyError>; + ) -> Result, PermissionCheckError>; } impl FetchPermissions for deno_permissions::PermissionsContainer { @@ -361,7 +362,7 @@ impl FetchPermissions for deno_permissions::PermissionsContainer { &mut self, url: &Url, api_name: &str, - ) -> Result<(), deno_core::error::AnyError> { + ) -> Result<(), PermissionCheckError> { deno_permissions::PermissionsContainer::check_net_url(self, url, api_name) } @@ -370,7 +371,7 @@ impl FetchPermissions for deno_permissions::PermissionsContainer { &mut self, path: &'a Path, api_name: &str, - ) -> Result, deno_core::error::AnyError> { + ) -> Result, PermissionCheckError> { deno_permissions::PermissionsContainer::check_read_path( self, path, @@ -414,9 +415,7 @@ where "file" => { let path = url.to_file_path().map_err(|_| FetchError::NetworkError)?; let permissions = state.borrow_mut::(); - let path = permissions - .check_read(&path, "fetch()") - .map_err(FetchError::Permission)?; + let path = permissions.check_read(&path, "fetch()")?; let url = match path { Cow::Owned(path) => Url::from_file_path(path).unwrap(), Cow::Borrowed(_) => url, @@ -442,9 +441,7 @@ where } "http" | "https" => { let permissions = state.borrow_mut::(); - permissions - .check_net_url(&url, "fetch()") - .map_err(FetchError::Resource)?; + permissions.check_net_url(&url, "fetch()")?; let maybe_authority = extract_authority(&mut url); let uri = url @@ -863,9 +860,7 @@ where if let Some(proxy) = args.proxy.clone() { let permissions = state.borrow_mut::(); let url = Url::parse(&proxy.url)?; - permissions - .check_net_url(&url, "Deno.createHttpClient()") - .map_err(FetchError::Permission)?; + permissions.check_net_url(&url, "Deno.createHttpClient()")?; } let options = state.borrow::(); diff --git a/ext/ffi/call.rs b/ext/ffi/call.rs index ef61dc383e..bbff0ee48f 100644 --- a/ext/ffi/call.rs +++ b/ext/ffi/call.rs @@ -32,7 +32,9 @@ pub enum CallError { #[error("Invalid FFI symbol name: '{0}'")] InvalidSymbol(String), #[error(transparent)] - Permission(deno_core::error::AnyError), + Permission(#[from] deno_permissions::PermissionCheckError), + #[error(transparent)] + Resource(deno_core::error::AnyError), #[error(transparent)] Callback(#[from] super::CallbackError), } @@ -301,9 +303,7 @@ where { let mut state = state.borrow_mut(); let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(CallError::Permission)?; + permissions.check_partial_no_path()?; }; let symbol = PtrSymbol::new(pointer, &def)?; @@ -347,7 +347,7 @@ pub fn op_ffi_call_nonblocking( let resource = state .resource_table .get::(rid) - .map_err(CallError::Permission)?; + .map_err(CallError::Resource)?; let symbols = &resource.symbols; *symbols .get(&symbol) @@ -401,9 +401,7 @@ where { let mut state = state.borrow_mut(); let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(CallError::Permission)?; + permissions.check_partial_no_path()?; }; let symbol = PtrSymbol::new(pointer, &def)?; diff --git a/ext/ffi/callback.rs b/ext/ffi/callback.rs index f33e0413a3..29583c800c 100644 --- a/ext/ffi/callback.rs +++ b/ext/ffi/callback.rs @@ -38,7 +38,7 @@ pub enum CallbackError { #[error(transparent)] Resource(deno_core::error::AnyError), #[error(transparent)] - Permission(deno_core::error::AnyError), + Permission(#[from] deno_permissions::PermissionCheckError), #[error(transparent)] Other(deno_core::error::AnyError), } @@ -572,9 +572,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(CallbackError::Permission)?; + permissions.check_partial_no_path()?; let thread_id: u32 = LOCAL_THREAD_ID.with(|s| { let value = *s.borrow(); diff --git a/ext/ffi/dlfcn.rs b/ext/ffi/dlfcn.rs index 53bdcbc5cc..55909468f8 100644 --- a/ext/ffi/dlfcn.rs +++ b/ext/ffi/dlfcn.rs @@ -30,7 +30,7 @@ pub enum DlfcnError { #[error(transparent)] Dlopen(#[from] dlopen2::Error), #[error(transparent)] - Permission(deno_core::error::AnyError), + Permission(#[from] deno_permissions::PermissionCheckError), #[error(transparent)] Other(deno_core::error::AnyError), } @@ -133,9 +133,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - let path = permissions - .check_partial_with_path(&args.path) - .map_err(DlfcnError::Permission)?; + let path = permissions.check_partial_with_path(&args.path)?; let lib = Library::open(&path).map_err(|e| { dlopen2::Error::OpeningLibraryError(std::io::Error::new( diff --git a/ext/ffi/lib.rs b/ext/ffi/lib.rs index 237f8c3b05..73ec7757ab 100644 --- a/ext/ffi/lib.rs +++ b/ext/ffi/lib.rs @@ -1,7 +1,5 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -use deno_core::error::AnyError; - use std::mem::size_of; use std::os::raw::c_char; use std::os::raw::c_short; @@ -31,6 +29,7 @@ use symbol::Symbol; pub use call::CallError; pub use callback::CallbackError; +use deno_permissions::PermissionCheckError; pub use dlfcn::DlfcnError; pub use ir::IRError; pub use r#static::StaticError; @@ -48,17 +47,17 @@ const _: () = { pub const UNSTABLE_FEATURE_NAME: &str = "ffi"; pub trait FfiPermissions { - fn check_partial_no_path(&mut self) -> Result<(), AnyError>; + fn check_partial_no_path(&mut self) -> Result<(), PermissionCheckError>; #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] fn check_partial_with_path( &mut self, path: &str, - ) -> Result; + ) -> Result; } impl FfiPermissions for deno_permissions::PermissionsContainer { #[inline(always)] - fn check_partial_no_path(&mut self) -> Result<(), AnyError> { + fn check_partial_no_path(&mut self) -> Result<(), PermissionCheckError> { deno_permissions::PermissionsContainer::check_ffi_partial_no_path(self) } @@ -66,7 +65,7 @@ impl FfiPermissions for deno_permissions::PermissionsContainer { fn check_partial_with_path( &mut self, path: &str, - ) -> Result { + ) -> Result { deno_permissions::PermissionsContainer::check_ffi_partial_with_path( self, path, ) diff --git a/ext/ffi/repr.rs b/ext/ffi/repr.rs index 2f04f4feb4..fd8a2c8e70 100644 --- a/ext/ffi/repr.rs +++ b/ext/ffi/repr.rs @@ -46,7 +46,7 @@ pub enum ReprError { #[error("Invalid pointer pointer, pointer is null")] InvalidPointer, #[error(transparent)] - Permission(deno_core::error::AnyError), + Permission(#[from] deno_permissions::PermissionCheckError), } #[op2(fast)] @@ -58,9 +58,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; Ok(ptr_number as *mut c_void) } @@ -75,9 +73,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; Ok(a == b) } @@ -91,9 +87,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; Ok(buf as *mut c_void) } @@ -107,9 +101,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; let Some(buf) = buf.get_backing_store() else { return Ok(0 as _); @@ -130,9 +122,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; if ptr.is_null() { return Err(ReprError::InvalidOffset); @@ -162,9 +152,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; Ok(ptr as usize) } @@ -181,9 +169,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; if ptr.is_null() { return Err(ReprError::InvalidArrayBuffer); @@ -215,9 +201,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; if src.is_null() { Err(ReprError::InvalidArrayBuffer) @@ -246,9 +230,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; if ptr.is_null() { return Err(ReprError::InvalidCString); @@ -272,9 +254,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; if ptr.is_null() { return Err(ReprError::InvalidBool); @@ -294,9 +274,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; if ptr.is_null() { return Err(ReprError::InvalidU8); @@ -318,9 +296,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; if ptr.is_null() { return Err(ReprError::InvalidI8); @@ -342,9 +318,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; if ptr.is_null() { return Err(ReprError::InvalidU16); @@ -366,9 +340,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; if ptr.is_null() { return Err(ReprError::InvalidI16); @@ -390,9 +362,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; if ptr.is_null() { return Err(ReprError::InvalidU32); @@ -412,9 +382,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; if ptr.is_null() { return Err(ReprError::InvalidI32); @@ -437,9 +405,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; if ptr.is_null() { return Err(ReprError::InvalidU64); @@ -465,9 +431,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; if ptr.is_null() { return Err(ReprError::InvalidI64); @@ -490,9 +454,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; if ptr.is_null() { return Err(ReprError::InvalidF32); @@ -512,9 +474,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; if ptr.is_null() { return Err(ReprError::InvalidF64); @@ -534,9 +494,7 @@ where FP: FfiPermissions + 'static, { let permissions = state.borrow_mut::(); - permissions - .check_partial_no_path() - .map_err(ReprError::Permission)?; + permissions.check_partial_no_path()?; if ptr.is_null() { return Err(ReprError::InvalidPointer); diff --git a/ext/fs/lib.rs b/ext/fs/lib.rs index cd2baf22a9..dd852e6be8 100644 --- a/ext/fs/lib.rs +++ b/ext/fs/lib.rs @@ -22,8 +22,8 @@ pub use crate::sync::MaybeSync; use crate::ops::*; -use deno_core::error::AnyError; use deno_io::fs::FsError; +use deno_permissions::PermissionCheckError; use std::borrow::Cow; use std::path::Path; use std::path::PathBuf; @@ -42,45 +42,51 @@ pub trait FsPermissions { &mut self, path: &str, api_name: &str, - ) -> Result; + ) -> Result; #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] fn check_read_path<'a>( &mut self, path: &'a Path, api_name: &str, - ) -> Result, AnyError>; - fn check_read_all(&mut self, api_name: &str) -> Result<(), AnyError>; + ) -> Result, PermissionCheckError>; + fn check_read_all( + &mut self, + api_name: &str, + ) -> Result<(), PermissionCheckError>; fn check_read_blind( &mut self, p: &Path, display: &str, api_name: &str, - ) -> Result<(), AnyError>; + ) -> Result<(), PermissionCheckError>; #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] fn check_write( &mut self, path: &str, api_name: &str, - ) -> Result; + ) -> Result; #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] fn check_write_path<'a>( &mut self, path: &'a Path, api_name: &str, - ) -> Result, AnyError>; + ) -> Result, PermissionCheckError>; #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] fn check_write_partial( &mut self, path: &str, api_name: &str, - ) -> Result; - fn check_write_all(&mut self, api_name: &str) -> Result<(), AnyError>; + ) -> Result; + fn check_write_all( + &mut self, + api_name: &str, + ) -> Result<(), PermissionCheckError>; fn check_write_blind( &mut self, p: &Path, display: &str, api_name: &str, - ) -> Result<(), AnyError>; + ) -> Result<(), PermissionCheckError>; fn check<'a>( &mut self, @@ -140,7 +146,7 @@ impl FsPermissions for deno_permissions::PermissionsContainer { &mut self, path: &str, api_name: &str, - ) -> Result { + ) -> Result { deno_permissions::PermissionsContainer::check_read(self, path, api_name) } @@ -148,7 +154,7 @@ impl FsPermissions for deno_permissions::PermissionsContainer { &mut self, path: &'a Path, api_name: &str, - ) -> Result, AnyError> { + ) -> Result, PermissionCheckError> { deno_permissions::PermissionsContainer::check_read_path( self, path, @@ -160,7 +166,7 @@ impl FsPermissions for deno_permissions::PermissionsContainer { path: &Path, display: &str, api_name: &str, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionCheckError> { deno_permissions::PermissionsContainer::check_read_blind( self, path, display, api_name, ) @@ -170,7 +176,7 @@ impl FsPermissions for deno_permissions::PermissionsContainer { &mut self, path: &str, api_name: &str, - ) -> Result { + ) -> Result { deno_permissions::PermissionsContainer::check_write(self, path, api_name) } @@ -178,7 +184,7 @@ impl FsPermissions for deno_permissions::PermissionsContainer { &mut self, path: &'a Path, api_name: &str, - ) -> Result, AnyError> { + ) -> Result, PermissionCheckError> { deno_permissions::PermissionsContainer::check_write_path( self, path, api_name, ) @@ -188,7 +194,7 @@ impl FsPermissions for deno_permissions::PermissionsContainer { &mut self, path: &str, api_name: &str, - ) -> Result { + ) -> Result { deno_permissions::PermissionsContainer::check_write_partial( self, path, api_name, ) @@ -199,17 +205,23 @@ impl FsPermissions for deno_permissions::PermissionsContainer { p: &Path, display: &str, api_name: &str, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionCheckError> { deno_permissions::PermissionsContainer::check_write_blind( self, p, display, api_name, ) } - fn check_read_all(&mut self, api_name: &str) -> Result<(), AnyError> { + fn check_read_all( + &mut self, + api_name: &str, + ) -> Result<(), PermissionCheckError> { deno_permissions::PermissionsContainer::check_read_all(self, api_name) } - fn check_write_all(&mut self, api_name: &str) -> Result<(), AnyError> { + fn check_write_all( + &mut self, + api_name: &str, + ) -> Result<(), PermissionCheckError> { deno_permissions::PermissionsContainer::check_write_all(self, api_name) } } diff --git a/ext/fs/ops.rs b/ext/fs/ops.rs index a3f59da4ea..9b76b49e61 100644 --- a/ext/fs/ops.rs +++ b/ext/fs/ops.rs @@ -10,6 +10,12 @@ use std::path::PathBuf; use std::path::StripPrefixError; use std::rc::Rc; +use crate::interface::AccessCheckFn; +use crate::interface::FileSystemRc; +use crate::interface::FsDirEntry; +use crate::interface::FsFileType; +use crate::FsPermissions; +use crate::OpenOptions; use deno_core::op2; use deno_core::CancelFuture; use deno_core::CancelHandle; @@ -20,18 +26,12 @@ use deno_core::ToJsBuffer; use deno_io::fs::FileResource; use deno_io::fs::FsError; use deno_io::fs::FsStat; +use deno_permissions::PermissionCheckError; use rand::rngs::ThreadRng; use rand::thread_rng; use rand::Rng; use serde::Serialize; -use crate::interface::AccessCheckFn; -use crate::interface::FileSystemRc; -use crate::interface::FsDirEntry; -use crate::interface::FsFileType; -use crate::FsPermissions; -use crate::OpenOptions; - #[derive(Debug, thiserror::Error)] pub enum FsOpsError { #[error("{0}")] @@ -39,7 +39,7 @@ pub enum FsOpsError { #[error("{0}")] OperationError(#[source] OperationError), #[error(transparent)] - Permission(deno_core::error::AnyError), + Permission(#[from] PermissionCheckError), #[error(transparent)] Resource(deno_core::error::AnyError), #[error("File name or path {0:?} is not valid UTF-8")] @@ -150,8 +150,7 @@ where let path = fs.cwd()?; state .borrow_mut::

() - .check_read_blind(&path, "CWD", "Deno.cwd()") - .map_err(FsOpsError::Permission)?; + .check_read_blind(&path, "CWD", "Deno.cwd()")?; let path_str = path_into_string(path.into_os_string())?; Ok(path_str) } @@ -166,8 +165,7 @@ where { let d = state .borrow_mut::

() - .check_read(directory, "Deno.chdir()") - .map_err(FsOpsError::Permission)?; + .check_read(directory, "Deno.chdir()")?; state .borrow::() .chdir(&d) @@ -253,8 +251,7 @@ where let path = state .borrow_mut::

() - .check_write(&path, "Deno.mkdirSync()") - .map_err(FsOpsError::Permission)?; + .check_write(&path, "Deno.mkdirSync()")?; let fs = state.borrow::(); fs.mkdir_sync(&path, recursive, Some(mode)) @@ -277,10 +274,7 @@ where let (fs, path) = { let mut state = state.borrow_mut(); - let path = state - .borrow_mut::

() - .check_write(&path, "Deno.mkdir()") - .map_err(FsOpsError::Permission)?; + let path = state.borrow_mut::

().check_write(&path, "Deno.mkdir()")?; (state.borrow::().clone(), path) }; @@ -302,8 +296,7 @@ where { let path = state .borrow_mut::

() - .check_write(&path, "Deno.chmodSync()") - .map_err(FsOpsError::Permission)?; + .check_write(&path, "Deno.chmodSync()")?; let fs = state.borrow::(); fs.chmod_sync(&path, mode).context_path("chmod", &path)?; Ok(()) @@ -320,10 +313,7 @@ where { let (fs, path) = { let mut state = state.borrow_mut(); - let path = state - .borrow_mut::

() - .check_write(&path, "Deno.chmod()") - .map_err(FsOpsError::Permission)?; + let path = state.borrow_mut::

().check_write(&path, "Deno.chmod()")?; (state.borrow::().clone(), path) }; fs.chmod_async(path.clone(), mode) @@ -344,8 +334,7 @@ where { let path = state .borrow_mut::

() - .check_write(&path, "Deno.chownSync()") - .map_err(FsOpsError::Permission)?; + .check_write(&path, "Deno.chownSync()")?; let fs = state.borrow::(); fs.chown_sync(&path, uid, gid) .context_path("chown", &path)?; @@ -364,10 +353,7 @@ where { let (fs, path) = { let mut state = state.borrow_mut(); - let path = state - .borrow_mut::

() - .check_write(&path, "Deno.chown()") - .map_err(FsOpsError::Permission)?; + let path = state.borrow_mut::

().check_write(&path, "Deno.chown()")?; (state.borrow::().clone(), path) }; fs.chown_async(path.clone(), uid, gid) @@ -387,8 +373,7 @@ where { let path = state .borrow_mut::

() - .check_write(path, "Deno.removeSync()") - .map_err(FsOpsError::Permission)?; + .check_write(path, "Deno.removeSync()")?; let fs = state.borrow::(); fs.remove_sync(&path, recursive) @@ -411,13 +396,11 @@ where let path = if recursive { state .borrow_mut::

() - .check_write(&path, "Deno.remove()") - .map_err(FsOpsError::Permission)? + .check_write(&path, "Deno.remove()")? } else { state .borrow_mut::

() - .check_write_partial(&path, "Deno.remove()") - .map_err(FsOpsError::Permission)? + .check_write_partial(&path, "Deno.remove()")? }; (state.borrow::().clone(), path) @@ -440,12 +423,8 @@ where P: FsPermissions + 'static, { let permissions = state.borrow_mut::

(); - let from = permissions - .check_read(from, "Deno.copyFileSync()") - .map_err(FsOpsError::Permission)?; - let to = permissions - .check_write(to, "Deno.copyFileSync()") - .map_err(FsOpsError::Permission)?; + let from = permissions.check_read(from, "Deno.copyFileSync()")?; + let to = permissions.check_write(to, "Deno.copyFileSync()")?; let fs = state.borrow::(); fs.copy_file_sync(&from, &to) @@ -466,12 +445,8 @@ where let (fs, from, to) = { let mut state = state.borrow_mut(); let permissions = state.borrow_mut::

(); - let from = permissions - .check_read(&from, "Deno.copyFile()") - .map_err(FsOpsError::Permission)?; - let to = permissions - .check_write(&to, "Deno.copyFile()") - .map_err(FsOpsError::Permission)?; + let from = permissions.check_read(&from, "Deno.copyFile()")?; + let to = permissions.check_write(&to, "Deno.copyFile()")?; (state.borrow::().clone(), from, to) }; @@ -493,8 +468,7 @@ where { let path = state .borrow_mut::

() - .check_read(&path, "Deno.statSync()") - .map_err(FsOpsError::Permission)?; + .check_read(&path, "Deno.statSync()")?; let fs = state.borrow::(); let stat = fs.stat_sync(&path).context_path("stat", &path)?; let serializable_stat = SerializableStat::from(stat); @@ -514,9 +488,7 @@ where let (fs, path) = { let mut state = state.borrow_mut(); let permissions = state.borrow_mut::

(); - let path = permissions - .check_read(&path, "Deno.stat()") - .map_err(FsOpsError::Permission)?; + let path = permissions.check_read(&path, "Deno.stat()")?; (state.borrow::().clone(), path) }; let stat = fs @@ -537,8 +509,7 @@ where { let path = state .borrow_mut::

() - .check_read(&path, "Deno.lstatSync()") - .map_err(FsOpsError::Permission)?; + .check_read(&path, "Deno.lstatSync()")?; let fs = state.borrow::(); let stat = fs.lstat_sync(&path).context_path("lstat", &path)?; let serializable_stat = SerializableStat::from(stat); @@ -558,9 +529,7 @@ where let (fs, path) = { let mut state = state.borrow_mut(); let permissions = state.borrow_mut::

(); - let path = permissions - .check_read(&path, "Deno.lstat()") - .map_err(FsOpsError::Permission)?; + let path = permissions.check_read(&path, "Deno.lstat()")?; (state.borrow::().clone(), path) }; let stat = fs @@ -581,13 +550,9 @@ where { let fs = state.borrow::().clone(); let permissions = state.borrow_mut::

(); - let path = permissions - .check_read(&path, "Deno.realPathSync()") - .map_err(FsOpsError::Permission)?; + let path = permissions.check_read(&path, "Deno.realPathSync()")?; if path.is_relative() { - permissions - .check_read_blind(&fs.cwd()?, "CWD", "Deno.realPathSync()") - .map_err(FsOpsError::Permission)?; + permissions.check_read_blind(&fs.cwd()?, "CWD", "Deno.realPathSync()")?; } let resolved_path = @@ -610,13 +575,9 @@ where let mut state = state.borrow_mut(); let fs = state.borrow::().clone(); let permissions = state.borrow_mut::

(); - let path = permissions - .check_read(&path, "Deno.realPath()") - .map_err(FsOpsError::Permission)?; + let path = permissions.check_read(&path, "Deno.realPath()")?; if path.is_relative() { - permissions - .check_read_blind(&fs.cwd()?, "CWD", "Deno.realPath()") - .map_err(FsOpsError::Permission)?; + permissions.check_read_blind(&fs.cwd()?, "CWD", "Deno.realPath()")?; } (fs, path) }; @@ -640,8 +601,7 @@ where { let path = state .borrow_mut::

() - .check_read(&path, "Deno.readDirSync()") - .map_err(FsOpsError::Permission)?; + .check_read(&path, "Deno.readDirSync()")?; let fs = state.borrow::(); let entries = fs.read_dir_sync(&path).context_path("readdir", &path)?; @@ -662,8 +622,7 @@ where let mut state = state.borrow_mut(); let path = state .borrow_mut::

() - .check_read(&path, "Deno.readDir()") - .map_err(FsOpsError::Permission)?; + .check_read(&path, "Deno.readDir()")?; (state.borrow::().clone(), path) }; @@ -685,15 +644,9 @@ where P: FsPermissions + 'static, { let permissions = state.borrow_mut::

(); - let _ = permissions - .check_read(&oldpath, "Deno.renameSync()") - .map_err(FsOpsError::Permission)?; - let oldpath = permissions - .check_write(&oldpath, "Deno.renameSync()") - .map_err(FsOpsError::Permission)?; - let newpath = permissions - .check_write(&newpath, "Deno.renameSync()") - .map_err(FsOpsError::Permission)?; + let _ = permissions.check_read(&oldpath, "Deno.renameSync()")?; + let oldpath = permissions.check_write(&oldpath, "Deno.renameSync()")?; + let newpath = permissions.check_write(&newpath, "Deno.renameSync()")?; let fs = state.borrow::(); fs.rename_sync(&oldpath, &newpath) @@ -714,15 +667,9 @@ where let (fs, oldpath, newpath) = { let mut state = state.borrow_mut(); let permissions = state.borrow_mut::

(); - _ = permissions - .check_read(&oldpath, "Deno.rename()") - .map_err(FsOpsError::Permission)?; - let oldpath = permissions - .check_write(&oldpath, "Deno.rename()") - .map_err(FsOpsError::Permission)?; - let newpath = permissions - .check_write(&newpath, "Deno.rename()") - .map_err(FsOpsError::Permission)?; + _ = permissions.check_read(&oldpath, "Deno.rename()")?; + let oldpath = permissions.check_write(&oldpath, "Deno.rename()")?; + let newpath = permissions.check_write(&newpath, "Deno.rename()")?; (state.borrow::().clone(), oldpath, newpath) }; @@ -743,18 +690,10 @@ where P: FsPermissions + 'static, { let permissions = state.borrow_mut::

(); - _ = permissions - .check_read(oldpath, "Deno.linkSync()") - .map_err(FsOpsError::Permission)?; - let oldpath = permissions - .check_write(oldpath, "Deno.linkSync()") - .map_err(FsOpsError::Permission)?; - _ = permissions - .check_read(newpath, "Deno.linkSync()") - .map_err(FsOpsError::Permission)?; - let newpath = permissions - .check_write(newpath, "Deno.linkSync()") - .map_err(FsOpsError::Permission)?; + _ = permissions.check_read(oldpath, "Deno.linkSync()")?; + let oldpath = permissions.check_write(oldpath, "Deno.linkSync()")?; + _ = permissions.check_read(newpath, "Deno.linkSync()")?; + let newpath = permissions.check_write(newpath, "Deno.linkSync()")?; let fs = state.borrow::(); fs.link_sync(&oldpath, &newpath) @@ -775,18 +714,10 @@ where let (fs, oldpath, newpath) = { let mut state = state.borrow_mut(); let permissions = state.borrow_mut::

(); - _ = permissions - .check_read(&oldpath, "Deno.link()") - .map_err(FsOpsError::Permission)?; - let oldpath = permissions - .check_write(&oldpath, "Deno.link()") - .map_err(FsOpsError::Permission)?; - _ = permissions - .check_read(&newpath, "Deno.link()") - .map_err(FsOpsError::Permission)?; - let newpath = permissions - .check_write(&newpath, "Deno.link()") - .map_err(FsOpsError::Permission)?; + _ = permissions.check_read(&oldpath, "Deno.link()")?; + let oldpath = permissions.check_write(&oldpath, "Deno.link()")?; + _ = permissions.check_read(&newpath, "Deno.link()")?; + let newpath = permissions.check_write(&newpath, "Deno.link()")?; (state.borrow::().clone(), oldpath, newpath) }; @@ -811,12 +742,8 @@ where let newpath = PathBuf::from(newpath); let permissions = state.borrow_mut::

(); - permissions - .check_write_all("Deno.symlinkSync()") - .map_err(FsOpsError::Permission)?; - permissions - .check_read_all("Deno.symlinkSync()") - .map_err(FsOpsError::Permission)?; + permissions.check_write_all("Deno.symlinkSync()")?; + permissions.check_read_all("Deno.symlinkSync()")?; let fs = state.borrow::(); fs.symlink_sync(&oldpath, &newpath, file_type) @@ -841,12 +768,8 @@ where let fs = { let mut state = state.borrow_mut(); let permissions = state.borrow_mut::

(); - permissions - .check_write_all("Deno.symlink()") - .map_err(FsOpsError::Permission)?; - permissions - .check_read_all("Deno.symlink()") - .map_err(FsOpsError::Permission)?; + permissions.check_write_all("Deno.symlink()")?; + permissions.check_read_all("Deno.symlink()")?; state.borrow::().clone() }; @@ -868,8 +791,7 @@ where { let path = state .borrow_mut::

() - .check_read(&path, "Deno.readLink()") - .map_err(FsOpsError::Permission)?; + .check_read(&path, "Deno.readLink()")?; let fs = state.borrow::(); @@ -891,8 +813,7 @@ where let mut state = state.borrow_mut(); let path = state .borrow_mut::

() - .check_read(&path, "Deno.readLink()") - .map_err(FsOpsError::Permission)?; + .check_read(&path, "Deno.readLink()")?; (state.borrow::().clone(), path) }; @@ -915,8 +836,7 @@ where { let path = state .borrow_mut::

() - .check_write(path, "Deno.truncateSync()") - .map_err(FsOpsError::Permission)?; + .check_write(path, "Deno.truncateSync()")?; let fs = state.borrow::(); fs.truncate_sync(&path, len) @@ -938,8 +858,7 @@ where let mut state = state.borrow_mut(); let path = state .borrow_mut::

() - .check_write(&path, "Deno.truncate()") - .map_err(FsOpsError::Permission)?; + .check_write(&path, "Deno.truncate()")?; (state.borrow::().clone(), path) }; @@ -962,10 +881,7 @@ pub fn op_fs_utime_sync

( where P: FsPermissions + 'static, { - let path = state - .borrow_mut::

() - .check_write(path, "Deno.utime()") - .map_err(FsOpsError::Permission)?; + let path = state.borrow_mut::

().check_write(path, "Deno.utime()")?; let fs = state.borrow::(); fs.utime_sync(&path, atime_secs, atime_nanos, mtime_secs, mtime_nanos) @@ -988,10 +904,7 @@ where { let (fs, path) = { let mut state = state.borrow_mut(); - let path = state - .borrow_mut::

() - .check_write(&path, "Deno.utime()") - .map_err(FsOpsError::Permission)?; + let path = state.borrow_mut::

().check_write(&path, "Deno.utime()")?; (state.borrow::().clone(), path) }; @@ -1219,16 +1132,12 @@ where { let fs = state.borrow::().clone(); let dir = match dir { - Some(dir) => state - .borrow_mut::

() - .check_write(dir, api_name) - .map_err(FsOpsError::Permission)?, + Some(dir) => state.borrow_mut::

().check_write(dir, api_name)?, None => { let dir = fs.tmp_dir().context("tmpdir")?; state .borrow_mut::

() - .check_write_blind(&dir, "TMP", api_name) - .map_err(FsOpsError::Permission)?; + .check_write_blind(&dir, "TMP", api_name)?; dir } }; @@ -1246,16 +1155,12 @@ where let mut state = state.borrow_mut(); let fs = state.borrow::().clone(); let dir = match dir { - Some(dir) => state - .borrow_mut::

() - .check_write(dir, api_name) - .map_err(FsOpsError::Permission)?, + Some(dir) => state.borrow_mut::

().check_write(dir, api_name)?, None => { let dir = fs.tmp_dir().context("tmpdir")?; state .borrow_mut::

() - .check_write_blind(&dir, "TMP", api_name) - .map_err(FsOpsError::Permission)?; + .check_write_blind(&dir, "TMP", api_name)?; dir } }; diff --git a/ext/kv/remote.rs b/ext/kv/remote.rs index 922853588a..4930aacfe3 100644 --- a/ext/kv/remote.rs +++ b/ext/kv/remote.rs @@ -15,6 +15,7 @@ use deno_core::futures::Stream; use deno_core::OpState; use deno_fetch::create_http_client; use deno_fetch::CreateHttpClientOptions; +use deno_permissions::PermissionCheckError; use deno_tls::rustls::RootCertStore; use deno_tls::Proxy; use deno_tls::RootCertStoreProvider; @@ -45,17 +46,17 @@ impl HttpOptions { } pub trait RemoteDbHandlerPermissions { - fn check_env(&mut self, var: &str) -> Result<(), AnyError>; + fn check_env(&mut self, var: &str) -> Result<(), PermissionCheckError>; fn check_net_url( &mut self, url: &Url, api_name: &str, - ) -> Result<(), AnyError>; + ) -> Result<(), PermissionCheckError>; } impl RemoteDbHandlerPermissions for deno_permissions::PermissionsContainer { #[inline(always)] - fn check_env(&mut self, var: &str) -> Result<(), AnyError> { + fn check_env(&mut self, var: &str) -> Result<(), PermissionCheckError> { deno_permissions::PermissionsContainer::check_env(self, var) } @@ -64,7 +65,7 @@ impl RemoteDbHandlerPermissions for deno_permissions::PermissionsContainer { &mut self, url: &Url, api_name: &str, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionCheckError> { deno_permissions::PermissionsContainer::check_net_url(self, url, api_name) } } @@ -103,7 +104,9 @@ impl denokv_remote::RemotePermissions fn check_net_url(&self, url: &Url) -> Result<(), anyhow::Error> { let mut state = self.state.borrow_mut(); let permissions = state.borrow_mut::

(); - permissions.check_net_url(url, "Deno.openKv") + permissions + .check_net_url(url, "Deno.openKv") + .map_err(Into::into) } } diff --git a/ext/kv/sqlite.rs b/ext/kv/sqlite.rs index 0b4a3693c4..9de5209275 100644 --- a/ext/kv/sqlite.rs +++ b/ext/kv/sqlite.rs @@ -13,20 +13,20 @@ use std::sync::Arc; use std::sync::Mutex; use std::sync::OnceLock; +use crate::DatabaseHandler; use async_trait::async_trait; use deno_core::error::type_error; use deno_core::error::AnyError; use deno_core::unsync::spawn_blocking; use deno_core::OpState; use deno_path_util::normalize_path; +use deno_permissions::PermissionCheckError; pub use denokv_sqlite::SqliteBackendError; use denokv_sqlite::SqliteConfig; use denokv_sqlite::SqliteNotifier; use rand::SeedableRng; use rusqlite::OpenFlags; -use crate::DatabaseHandler; - static SQLITE_NOTIFIERS_MAP: OnceLock>> = OnceLock::new(); @@ -42,13 +42,13 @@ pub trait SqliteDbHandlerPermissions { &mut self, p: &str, api_name: &str, - ) -> Result; + ) -> Result; #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] fn check_write<'a>( &mut self, p: &'a Path, api_name: &str, - ) -> Result, AnyError>; + ) -> Result, PermissionCheckError>; } impl SqliteDbHandlerPermissions for deno_permissions::PermissionsContainer { @@ -57,7 +57,7 @@ impl SqliteDbHandlerPermissions for deno_permissions::PermissionsContainer { &mut self, p: &str, api_name: &str, - ) -> Result { + ) -> Result { deno_permissions::PermissionsContainer::check_read(self, p, api_name) } @@ -66,7 +66,7 @@ impl SqliteDbHandlerPermissions for deno_permissions::PermissionsContainer { &mut self, p: &'a Path, api_name: &str, - ) -> Result, AnyError> { + ) -> Result, PermissionCheckError> { deno_permissions::PermissionsContainer::check_write_path(self, p, api_name) } } diff --git a/ext/napi/lib.rs b/ext/napi/lib.rs index 20f924bdbf..88b8c238df 100644 --- a/ext/napi/lib.rs +++ b/ext/napi/lib.rs @@ -43,7 +43,7 @@ pub enum NApiError { #[error("Unable to find register Node-API module at {}", .0.display())] ModuleNotFound(PathBuf), #[error(transparent)] - Permission(deno_core::error::AnyError), + Permission(#[from] PermissionCheckError), } #[cfg(unix)] @@ -55,6 +55,7 @@ use libloading::os::windows::*; // Expose common stuff for ease of use. // `use deno_napi::*` pub use deno_core::v8; +use deno_permissions::PermissionCheckError; pub use std::ffi::CStr; pub use std::os::raw::c_char; pub use std::os::raw::c_void; @@ -508,20 +509,14 @@ deno_core::extension!(deno_napi, pub trait NapiPermissions { #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] - fn check( - &mut self, - path: &str, - ) -> Result; + fn check(&mut self, path: &str) -> Result; } // NOTE(bartlomieju): for now, NAPI uses `--allow-ffi` flag, but that might // change in the future. impl NapiPermissions for deno_permissions::PermissionsContainer { #[inline(always)] - fn check( - &mut self, - path: &str, - ) -> Result { + fn check(&mut self, path: &str) -> Result { deno_permissions::PermissionsContainer::check_ffi(self, path) } } @@ -553,7 +548,7 @@ where let (async_work_sender, cleanup_hooks, external_ops_tracker, path) = { let mut op_state = op_state.borrow_mut(); let permissions = op_state.borrow_mut::(); - let path = permissions.check(&path).map_err(NApiError::Permission)?; + let path = permissions.check(&path)?; let napi_state = op_state.borrow::(); ( op_state.borrow::().clone(), diff --git a/ext/net/lib.rs b/ext/net/lib.rs index b039965d4c..bf8f58aa27 100644 --- a/ext/net/lib.rs +++ b/ext/net/lib.rs @@ -11,6 +11,7 @@ mod tcp; use deno_core::error::AnyError; use deno_core::OpState; +use deno_permissions::PermissionCheckError; use deno_tls::rustls::RootCertStore; use deno_tls::RootCertStoreProvider; use std::borrow::Cow; @@ -25,25 +26,25 @@ pub trait NetPermissions { &mut self, host: &(T, Option), api_name: &str, - ) -> Result<(), AnyError>; + ) -> Result<(), PermissionCheckError>; #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] fn check_read( &mut self, p: &str, api_name: &str, - ) -> Result; + ) -> Result; #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] fn check_write( &mut self, p: &str, api_name: &str, - ) -> Result; + ) -> Result; #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] fn check_write_path<'a>( &mut self, p: &'a Path, api_name: &str, - ) -> Result, AnyError>; + ) -> Result, PermissionCheckError>; } impl NetPermissions for deno_permissions::PermissionsContainer { @@ -52,7 +53,7 @@ impl NetPermissions for deno_permissions::PermissionsContainer { &mut self, host: &(T, Option), api_name: &str, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionCheckError> { deno_permissions::PermissionsContainer::check_net(self, host, api_name) } @@ -61,7 +62,7 @@ impl NetPermissions for deno_permissions::PermissionsContainer { &mut self, path: &str, api_name: &str, - ) -> Result { + ) -> Result { deno_permissions::PermissionsContainer::check_read(self, path, api_name) } @@ -70,7 +71,7 @@ impl NetPermissions for deno_permissions::PermissionsContainer { &mut self, path: &str, api_name: &str, - ) -> Result { + ) -> Result { deno_permissions::PermissionsContainer::check_write(self, path, api_name) } @@ -79,7 +80,7 @@ impl NetPermissions for deno_permissions::PermissionsContainer { &mut self, path: &'a Path, api_name: &str, - ) -> Result, AnyError> { + ) -> Result, PermissionCheckError> { deno_permissions::PermissionsContainer::check_write_path( self, path, api_name, ) diff --git a/ext/net/ops.rs b/ext/net/ops.rs index 0f92dead0c..35bcff8dcf 100644 --- a/ext/net/ops.rs +++ b/ext/net/ops.rs @@ -81,8 +81,8 @@ pub enum NetError { Io(#[from] std::io::Error), #[error("Another accept task is ongoing")] AcceptTaskOngoing, - #[error("{0}")] - Permission(deno_core::error::AnyError), + #[error(transparent)] + Permission(#[from] deno_permissions::PermissionCheckError), #[error("{0}")] Resource(deno_core::error::AnyError), #[error("No resolved address found")] @@ -195,12 +195,10 @@ where { { let mut s = state.borrow_mut(); - s.borrow_mut::() - .check_net( - &(&addr.hostname, Some(addr.port)), - "Deno.DatagramConn.send()", - ) - .map_err(NetError::Permission)?; + s.borrow_mut::().check_net( + &(&addr.hostname, Some(addr.port)), + "Deno.DatagramConn.send()", + )?; } let addr = resolve_addr(&addr.hostname, addr.port) .await? @@ -369,8 +367,7 @@ where let mut state_ = state.borrow_mut(); state_ .borrow_mut::() - .check_net(&(&addr.hostname, Some(addr.port)), "Deno.connect()") - .map_err(NetError::Permission)?; + .check_net(&(&addr.hostname, Some(addr.port)), "Deno.connect()")?; } let addr = resolve_addr(&addr.hostname, addr.port) @@ -420,8 +417,7 @@ where } state .borrow_mut::() - .check_net(&(&addr.hostname, Some(addr.port)), "Deno.listen()") - .map_err(NetError::Permission)?; + .check_net(&(&addr.hostname, Some(addr.port)), "Deno.listen()")?; let addr = resolve_addr_sync(&addr.hostname, addr.port)? .next() .ok_or_else(|| NetError::NoResolvedAddress)?; @@ -449,8 +445,7 @@ where { state .borrow_mut::() - .check_net(&(&addr.hostname, Some(addr.port)), "Deno.listenDatagram()") - .map_err(NetError::Permission)?; + .check_net(&(&addr.hostname, Some(addr.port)), "Deno.listenDatagram()")?; let addr = resolve_addr_sync(&addr.hostname, addr.port)? .next() .ok_or_else(|| NetError::NoResolvedAddress)?; @@ -647,9 +642,7 @@ where let socker_addr = &ns.socket_addr; let ip = socker_addr.ip().to_string(); let port = socker_addr.port(); - perm - .check_net(&(ip, Some(port)), "Deno.resolveDns()") - .map_err(NetError::Permission)?; + perm.check_net(&(ip, Some(port)), "Deno.resolveDns()")?; } } @@ -834,6 +827,7 @@ mod tests { use deno_core::futures::FutureExt; use deno_core::JsRuntime; use deno_core::RuntimeOptions; + use deno_permissions::PermissionCheckError; use socket2::SockRef; use std::net::Ipv4Addr; use std::net::Ipv6Addr; @@ -1041,7 +1035,7 @@ mod tests { &mut self, _host: &(T, Option), _api_name: &str, - ) -> Result<(), deno_core::error::AnyError> { + ) -> Result<(), PermissionCheckError> { Ok(()) } @@ -1049,7 +1043,7 @@ mod tests { &mut self, p: &str, _api_name: &str, - ) -> Result { + ) -> Result { Ok(PathBuf::from(p)) } @@ -1057,7 +1051,7 @@ mod tests { &mut self, p: &str, _api_name: &str, - ) -> Result { + ) -> Result { Ok(PathBuf::from(p)) } @@ -1065,7 +1059,7 @@ mod tests { &mut self, p: &'a Path, _api_name: &str, - ) -> Result, deno_core::error::AnyError> { + ) -> Result, PermissionCheckError> { Ok(Cow::Borrowed(p)) } } diff --git a/ext/node/lib.rs b/ext/node/lib.rs index db6d08e11e..b08b0493b0 100644 --- a/ext/node/lib.rs +++ b/ext/node/lib.rs @@ -24,6 +24,7 @@ pub mod ops; mod polyfill; pub use deno_package_json::PackageJson; +use deno_permissions::PermissionCheckError; pub use node_resolver::PathClean; pub use ops::ipc::ChildPipeFd; pub use ops::ipc::IpcJsonStreamResource; @@ -45,10 +46,13 @@ pub trait NodePermissions { &mut self, url: &Url, api_name: &str, - ) -> Result<(), AnyError>; + ) -> Result<(), PermissionCheckError>; #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] #[inline(always)] - fn check_read(&mut self, path: &str) -> Result { + fn check_read( + &mut self, + path: &str, + ) -> Result { self.check_read_with_api_name(path, None) } #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] @@ -56,20 +60,24 @@ pub trait NodePermissions { &mut self, path: &str, api_name: Option<&str>, - ) -> Result; + ) -> Result; #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] fn check_read_path<'a>( &mut self, path: &'a Path, - ) -> Result, AnyError>; + ) -> Result, PermissionCheckError>; fn query_read_all(&mut self) -> bool; - fn check_sys(&mut self, kind: &str, api_name: &str) -> Result<(), AnyError>; + fn check_sys( + &mut self, + kind: &str, + api_name: &str, + ) -> Result<(), PermissionCheckError>; #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] fn check_write_with_api_name( &mut self, path: &str, api_name: Option<&str>, - ) -> Result; + ) -> Result; } impl NodePermissions for deno_permissions::PermissionsContainer { @@ -78,7 +86,7 @@ impl NodePermissions for deno_permissions::PermissionsContainer { &mut self, url: &Url, api_name: &str, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionCheckError> { deno_permissions::PermissionsContainer::check_net_url(self, url, api_name) } @@ -87,7 +95,7 @@ impl NodePermissions for deno_permissions::PermissionsContainer { &mut self, path: &str, api_name: Option<&str>, - ) -> Result { + ) -> Result { deno_permissions::PermissionsContainer::check_read_with_api_name( self, path, api_name, ) @@ -96,7 +104,7 @@ impl NodePermissions for deno_permissions::PermissionsContainer { fn check_read_path<'a>( &mut self, path: &'a Path, - ) -> Result, AnyError> { + ) -> Result, PermissionCheckError> { deno_permissions::PermissionsContainer::check_read_path(self, path, None) } @@ -109,13 +117,17 @@ impl NodePermissions for deno_permissions::PermissionsContainer { &mut self, path: &str, api_name: Option<&str>, - ) -> Result { + ) -> Result { deno_permissions::PermissionsContainer::check_write_with_api_name( self, path, api_name, ) } - fn check_sys(&mut self, kind: &str, api_name: &str) -> Result<(), AnyError> { + fn check_sys( + &mut self, + kind: &str, + api_name: &str, + ) -> Result<(), PermissionCheckError> { deno_permissions::PermissionsContainer::check_sys(self, kind, api_name) } } diff --git a/ext/node/ops/fs.rs b/ext/node/ops/fs.rs index 98b3c46a14..9c0e4e1ccf 100644 --- a/ext/node/ops/fs.rs +++ b/ext/node/ops/fs.rs @@ -13,7 +13,7 @@ use crate::NodePermissions; #[derive(Debug, thiserror::Error)] pub enum FsError { #[error(transparent)] - Permission(deno_core::error::AnyError), + Permission(#[from] deno_permissions::PermissionCheckError), #[error("{0}")] Io(#[from] std::io::Error), #[cfg(windows)] @@ -53,8 +53,7 @@ where let mut state = state.borrow_mut(); let path = state .borrow_mut::

() - .check_read_with_api_name(&path, Some("node:fs.exists()")) - .map_err(FsError::Permission)?; + .check_read_with_api_name(&path, Some("node:fs.exists()"))?; (state.borrow::().clone(), path) }; @@ -72,12 +71,10 @@ where { let path = state .borrow_mut::

() - .check_read_with_api_name(path, Some("node:fs.cpSync")) - .map_err(FsError::Permission)?; + .check_read_with_api_name(path, Some("node:fs.cpSync"))?; let new_path = state .borrow_mut::

() - .check_write_with_api_name(new_path, Some("node:fs.cpSync")) - .map_err(FsError::Permission)?; + .check_write_with_api_name(new_path, Some("node:fs.cpSync"))?; let fs = state.borrow::(); fs.cp_sync(&path, &new_path)?; @@ -97,12 +94,10 @@ where let mut state = state.borrow_mut(); let path = state .borrow_mut::

() - .check_read_with_api_name(&path, Some("node:fs.cpSync")) - .map_err(FsError::Permission)?; + .check_read_with_api_name(&path, Some("node:fs.cpSync"))?; let new_path = state .borrow_mut::

() - .check_write_with_api_name(&new_path, Some("node:fs.cpSync")) - .map_err(FsError::Permission)?; + .check_write_with_api_name(&new_path, Some("node:fs.cpSync"))?; (state.borrow::().clone(), path, new_path) }; @@ -136,12 +131,10 @@ where let mut state = state.borrow_mut(); let path = state .borrow_mut::

() - .check_read_with_api_name(&path, Some("node:fs.statfs")) - .map_err(FsError::Permission)?; + .check_read_with_api_name(&path, Some("node:fs.statfs"))?; state .borrow_mut::

() - .check_sys("statfs", "node:fs.statfs") - .map_err(FsError::Permission)?; + .check_sys("statfs", "node:fs.statfs")?; path }; #[cfg(unix)] @@ -279,8 +272,7 @@ where { let path = state .borrow_mut::

() - .check_write_with_api_name(path, Some("node:fs.lutimes")) - .map_err(FsError::Permission)?; + .check_write_with_api_name(path, Some("node:fs.lutimes"))?; let fs = state.borrow::(); fs.lutime_sync(&path, atime_secs, atime_nanos, mtime_secs, mtime_nanos)?; @@ -303,8 +295,7 @@ where let mut state = state.borrow_mut(); let path = state .borrow_mut::

() - .check_write_with_api_name(&path, Some("node:fs.lutimesSync")) - .map_err(FsError::Permission)?; + .check_write_with_api_name(&path, Some("node:fs.lutimesSync"))?; (state.borrow::().clone(), path) }; @@ -326,8 +317,7 @@ where { let path = state .borrow_mut::

() - .check_write_with_api_name(&path, Some("node:fs.lchownSync")) - .map_err(FsError::Permission)?; + .check_write_with_api_name(&path, Some("node:fs.lchownSync"))?; let fs = state.borrow::(); fs.lchown_sync(&path, uid, gid)?; Ok(()) @@ -347,8 +337,7 @@ where let mut state = state.borrow_mut(); let path = state .borrow_mut::

() - .check_write_with_api_name(&path, Some("node:fs.lchown")) - .map_err(FsError::Permission)?; + .check_write_with_api_name(&path, Some("node:fs.lchown"))?; (state.borrow::().clone(), path) }; fs.lchown_async(path, uid, gid).await?; diff --git a/ext/node/ops/http.rs b/ext/node/ops/http.rs index 730e1e482b..69571078fe 100644 --- a/ext/node/ops/http.rs +++ b/ext/node/ops/http.rs @@ -78,9 +78,7 @@ where { let permissions = state.borrow_mut::

(); - permissions - .check_net_url(&url, "ClientRequest") - .map_err(FetchError::Permission)?; + permissions.check_net_url(&url, "ClientRequest")?; } let mut header_map = HeaderMap::new(); diff --git a/ext/node/ops/os/mod.rs b/ext/node/ops/os/mod.rs index ea7e6b99fd..d291277ad4 100644 --- a/ext/node/ops/os/mod.rs +++ b/ext/node/ops/os/mod.rs @@ -14,7 +14,7 @@ pub enum OsError { #[error(transparent)] Priority(priority::PriorityError), #[error(transparent)] - Permission(deno_core::error::AnyError), + Permission(#[from] deno_permissions::PermissionCheckError), #[error("Failed to get cpu info")] FailedToGetCpuInfo, #[error("Failed to get user info")] @@ -31,9 +31,7 @@ where { { let permissions = state.borrow_mut::

(); - permissions - .check_sys("getPriority", "node:os.getPriority()") - .map_err(OsError::Permission)?; + permissions.check_sys("getPriority", "node:os.getPriority()")?; } priority::get_priority(pid).map_err(OsError::Priority) @@ -50,9 +48,7 @@ where { { let permissions = state.borrow_mut::

(); - permissions - .check_sys("setPriority", "node:os.setPriority()") - .map_err(OsError::Permission)?; + permissions.check_sys("setPriority", "node:os.setPriority()")?; } priority::set_priority(pid, priority).map_err(OsError::Priority) @@ -266,9 +262,7 @@ where { { let permissions = state.borrow_mut::

(); - permissions - .check_sys("cpus", "node:os.cpus()") - .map_err(OsError::Permission)?; + permissions.check_sys("cpus", "node:os.cpus()")?; } cpus::cpu_info().ok_or(OsError::FailedToGetCpuInfo) diff --git a/ext/websocket/lib.rs b/ext/websocket/lib.rs index 2a67ac5a17..a5734271cf 100644 --- a/ext/websocket/lib.rs +++ b/ext/websocket/lib.rs @@ -50,6 +50,7 @@ use tokio::io::ReadHalf; use tokio::io::WriteHalf; use tokio::net::TcpStream; +use deno_permissions::PermissionCheckError; use fastwebsockets::CloseCode; use fastwebsockets::FragmentCollectorRead; use fastwebsockets::Frame; @@ -75,7 +76,7 @@ pub enum WebsocketError { #[error(transparent)] Url(url::ParseError), #[error(transparent)] - Permission(deno_core::error::AnyError), + Permission(#[from] PermissionCheckError), #[error(transparent)] Resource(deno_core::error::AnyError), #[error(transparent)] @@ -112,7 +113,7 @@ pub trait WebSocketPermissions { &mut self, _url: &url::Url, _api_name: &str, - ) -> Result<(), deno_core::error::AnyError>; + ) -> Result<(), PermissionCheckError>; } impl WebSocketPermissions for deno_permissions::PermissionsContainer { @@ -121,7 +122,7 @@ impl WebSocketPermissions for deno_permissions::PermissionsContainer { &mut self, url: &url::Url, api_name: &str, - ) -> Result<(), deno_core::error::AnyError> { + ) -> Result<(), PermissionCheckError> { deno_permissions::PermissionsContainer::check_net_url(self, url, api_name) } } @@ -158,13 +159,10 @@ pub fn op_ws_check_permission_and_cancel_handle( where WP: WebSocketPermissions + 'static, { - state - .borrow_mut::() - .check_net_url( - &url::Url::parse(&url).map_err(WebsocketError::Url)?, - &api_name, - ) - .map_err(WebsocketError::Permission)?; + state.borrow_mut::().check_net_url( + &url::Url::parse(&url).map_err(WebsocketError::Url)?, + &api_name, + )?; if cancel_handle { let rid = state diff --git a/runtime/errors.rs b/runtime/errors.rs index ada26ec35f..5051150f27 100644 --- a/runtime/errors.rs +++ b/runtime/errors.rs @@ -12,6 +12,8 @@ use crate::ops::fs_events::FsEventsError; use crate::ops::http::HttpStartError; use crate::ops::os::OsError; +use crate::ops::permissions::PermissionError; +use crate::ops::process::CheckRunPermissionError; use crate::ops::process::ProcessError; use crate::ops::signal::SignalError; use crate::ops::tty::TtyError; @@ -48,6 +50,12 @@ use deno_kv::KvError; use deno_kv::KvMutationError; use deno_napi::NApiError; use deno_net::ops::NetError; +use deno_permissions::ChildPermissionError; +use deno_permissions::NetDescriptorFromUrlParseError; +use deno_permissions::PathResolveError; +use deno_permissions::PermissionCheckError; +use deno_permissions::RunDescriptorParseError; +use deno_permissions::SysDescriptorParseError; use deno_tls::TlsError; use deno_web::BlobError; use deno_web::CompressionError; @@ -63,6 +71,54 @@ use std::error::Error; use std::io; use std::sync::Arc; +fn get_run_descriptor_parse_error(e: &RunDescriptorParseError) -> &'static str { + match e { + RunDescriptorParseError::Which(_) => "Error", + RunDescriptorParseError::PathResolve(e) => get_path_resolve_error(e), + RunDescriptorParseError::EmptyRunQuery => "Error", + } +} + +fn get_sys_descriptor_parse_error(e: &SysDescriptorParseError) -> &'static str { + match e { + SysDescriptorParseError::InvalidKind(_) => "TypeError", + SysDescriptorParseError::Empty => "Error", + } +} + +fn get_path_resolve_error(e: &PathResolveError) -> &'static str { + match e { + PathResolveError::CwdResolve(e) => get_io_error_class(e), + PathResolveError::EmptyPath => "Error", + } +} + +fn get_permission_error_class(e: &PermissionError) -> &'static str { + match e { + PermissionError::InvalidPermissionName(_) => "ReferenceError", + PermissionError::PathResolve(e) => get_path_resolve_error(e), + PermissionError::NetDescriptorParse(_) => "URIError", + PermissionError::SysDescriptorParse(e) => get_sys_descriptor_parse_error(e), + PermissionError::RunDescriptorParse(e) => get_run_descriptor_parse_error(e), + } +} + +fn get_permission_check_error_class(e: &PermissionCheckError) -> &'static str { + match e { + PermissionCheckError::PermissionDenied(_) => "NotCapable", + PermissionCheckError::InvalidFilePath(_) => "URIError", + PermissionCheckError::NetDescriptorForUrlParse(e) => match e { + NetDescriptorFromUrlParseError::MissingHost(_) => "TypeError", + NetDescriptorFromUrlParseError::Host(_) => "URIError", + }, + PermissionCheckError::SysDescriptorParse(e) => { + get_sys_descriptor_parse_error(e) + } + PermissionCheckError::PathResolve(e) => get_path_resolve_error(e), + PermissionCheckError::HostParse(_) => "URIError", + } +} + fn get_dlopen_error_class(error: &dlopen2::Error) -> &'static str { use dlopen2::Error::*; match error { @@ -445,7 +501,7 @@ fn get_napi_error_class(e: &NApiError) -> &'static str { NApiError::InvalidPath | NApiError::LibLoading(_) | NApiError::ModuleNotFound(_) => "TypeError", - NApiError::Permission(e) => get_error_class_name(e).unwrap_or("Error"), + NApiError::Permission(e) => get_permission_check_error_class(e), } } @@ -523,7 +579,7 @@ fn get_ffi_repr_error_class(e: &ReprError) -> &'static str { ReprError::InvalidF32 => "TypeError", ReprError::InvalidF64 => "TypeError", ReprError::InvalidPointer => "TypeError", - ReprError::Permission(e) => get_error_class_name(e).unwrap_or("Error"), + ReprError::Permission(e) => get_permission_check_error_class(e), } } @@ -531,7 +587,7 @@ fn get_ffi_dlfcn_error_class(e: &DlfcnError) -> &'static str { match e { DlfcnError::RegisterSymbol { .. } => "Error", DlfcnError::Dlopen(_) => "Error", - DlfcnError::Permission(e) => get_error_class_name(e).unwrap_or("Error"), + DlfcnError::Permission(e) => get_permission_check_error_class(e), DlfcnError::Other(e) => get_error_class_name(e).unwrap_or("Error"), } } @@ -549,7 +605,7 @@ fn get_ffi_callback_error_class(e: &CallbackError) -> &'static str { match e { CallbackError::Resource(e) => get_error_class_name(e).unwrap_or("Error"), CallbackError::Other(e) => get_error_class_name(e).unwrap_or("Error"), - CallbackError::Permission(e) => get_error_class_name(e).unwrap_or("Error"), + CallbackError::Permission(e) => get_permission_check_error_class(e), } } @@ -558,8 +614,9 @@ fn get_ffi_call_error_class(e: &CallError) -> &'static str { CallError::IR(_) => "TypeError", CallError::NonblockingCallFailure(_) => "Error", CallError::InvalidSymbol(_) => "TypeError", - CallError::Permission(e) => get_error_class_name(e).unwrap_or("Error"), + CallError::Permission(e) => get_permission_check_error_class(e), CallError::Callback(e) => get_ffi_callback_error_class(e), + CallError::Resource(e) => get_error_class_name(e).unwrap_or("Error"), } } @@ -633,9 +690,8 @@ fn get_broadcast_channel_error(error: &BroadcastChannelError) -> &'static str { fn get_fetch_error(error: &FetchError) -> &'static str { match error { - FetchError::Resource(e) | FetchError::Permission(e) => { - get_error_class_name(e).unwrap_or("Error") - } + FetchError::Resource(e) => get_error_class_name(e).unwrap_or("Error"), + FetchError::Permission(e) => get_permission_check_error_class(e), FetchError::NetworkError => "TypeError", FetchError::FsNotGet(_) => "TypeError", FetchError::InvalidUrl(_) => "TypeError", @@ -669,9 +725,8 @@ fn get_http_client_create_error(error: &HttpClientCreateError) -> &'static str { fn get_websocket_error(error: &WebsocketError) -> &'static str { match error { - WebsocketError::Permission(e) | WebsocketError::Resource(e) => { - get_error_class_name(e).unwrap_or("Error") - } + WebsocketError::Resource(e) => get_error_class_name(e).unwrap_or("Error"), + WebsocketError::Permission(e) => get_permission_check_error_class(e), WebsocketError::Url(e) => get_url_parse_error_class(e), WebsocketError::Io(e) => get_io_error_class(e), WebsocketError::WebSocket(_) => "TypeError", @@ -708,9 +763,10 @@ fn get_fs_ops_error(error: &FsOpsError) -> &'static str { match error { FsOpsError::Io(e) => get_io_error_class(e), FsOpsError::OperationError(e) => get_fs_error(&e.err), - FsOpsError::Permission(e) - | FsOpsError::Resource(e) - | FsOpsError::Other(e) => get_error_class_name(e).unwrap_or("Error"), + FsOpsError::Permission(e) => get_permission_check_error_class(e), + FsOpsError::Resource(e) | FsOpsError::Other(e) => { + get_error_class_name(e).unwrap_or("Error") + } FsOpsError::InvalidUtf8(_) => "InvalidData", FsOpsError::StripPrefix(_) => "Error", FsOpsError::Canceled(e) => { @@ -777,9 +833,10 @@ fn get_net_error(error: &NetError) -> &'static str { NetError::SocketBusy => "Busy", NetError::Io(e) => get_io_error_class(e), NetError::AcceptTaskOngoing => "Busy", - NetError::RootCertStore(e) - | NetError::Permission(e) - | NetError::Resource(e) => get_error_class_name(e).unwrap_or("Error"), + NetError::RootCertStore(e) | NetError::Resource(e) => { + get_error_class_name(e).unwrap_or("Error") + } + NetError::Permission(e) => get_permission_check_error_class(e), NetError::NoResolvedAddress => "Error", NetError::AddrParse(_) => "Error", NetError::Map(e) => get_net_map_error(e), @@ -810,12 +867,25 @@ fn get_net_map_error(error: &deno_net::io::MapError) -> &'static str { } } +fn get_child_permission_error(e: &ChildPermissionError) -> &'static str { + match e { + ChildPermissionError::Escalation => "NotCapable", + ChildPermissionError::PathResolve(e) => get_path_resolve_error(e), + ChildPermissionError::NetDescriptorParse(_) => "URIError", + ChildPermissionError::EnvDescriptorParse(_) => "Error", + ChildPermissionError::SysDescriptorParse(e) => { + get_sys_descriptor_parse_error(e) + } + ChildPermissionError::RunDescriptorParse(e) => { + get_run_descriptor_parse_error(e) + } + } +} + fn get_create_worker_error(error: &CreateWorkerError) -> &'static str { match error { CreateWorkerError::ClassicWorkers => "DOMExceptionNotSupportedError", - CreateWorkerError::Permission(e) => { - get_error_class_name(e).unwrap_or("Error") - } + CreateWorkerError::Permission(e) => get_child_permission_error(e), CreateWorkerError::ModuleResolution(e) => { get_module_resolution_error_class(e) } @@ -862,9 +932,8 @@ fn get_signal_error(error: &SignalError) -> &'static str { fn get_fs_events_error(error: &FsEventsError) -> &'static str { match error { - FsEventsError::Resource(e) | FsEventsError::Permission(e) => { - get_error_class_name(e).unwrap_or("Error") - } + FsEventsError::Resource(e) => get_error_class_name(e).unwrap_or("Error"), + FsEventsError::Permission(e) => get_permission_check_error_class(e), FsEventsError::Notify(e) => get_notify_error_class(e), FsEventsError::Canceled(e) => { let io_err: io::Error = e.to_owned().into(); @@ -892,9 +961,8 @@ fn get_process_error(error: &ProcessError) -> &'static str { ProcessError::FailedResolvingCwd(e) | ProcessError::Io(e) => { get_io_error_class(e) } - ProcessError::Permission(e) | ProcessError::Resource(e) => { - get_error_class_name(e).unwrap_or("Error") - } + ProcessError::Permission(e) => get_permission_check_error_class(e), + ProcessError::Resource(e) => get_error_class_name(e).unwrap_or("Error"), ProcessError::BorrowMut(_) => "Error", ProcessError::Which(_) => "Error", ProcessError::ChildProcessAlreadyTerminated => "TypeError", @@ -903,6 +971,14 @@ fn get_process_error(error: &ProcessError) -> &'static str { ProcessError::InvalidPid => "TypeError", #[cfg(unix)] ProcessError::Nix(e) => get_nix_error_class(e), + ProcessError::RunPermission(e) => match e { + CheckRunPermissionError::Permission(e) => { + get_permission_check_error_class(e) + } + CheckRunPermissionError::Other(e) => { + get_error_class_name(e).unwrap_or("Error") + } + }, } } @@ -971,6 +1047,7 @@ fn get_fs_error(e: &FsError) -> &'static str { mod node { use super::get_error_class_name; use super::get_io_error_class; + use super::get_permission_check_error_class; use super::get_serde_json_error_class; use super::get_url_parse_error_class; pub use deno_node::ops::blocklist::BlocklistError; @@ -998,7 +1075,7 @@ mod node { pub fn get_fs_error(error: &FsError) -> &'static str { match error { - FsError::Permission(e) => get_error_class_name(e).unwrap_or("Error"), + FsError::Permission(e) => get_permission_check_error_class(e), FsError::Io(e) => get_io_error_class(e), #[cfg(windows)] FsError::PathHasNoRoot => "Error", @@ -1084,7 +1161,7 @@ mod node { #[cfg(windows)] PriorityError::InvalidPriority => "TypeError", }, - OsError::Permission(e) => get_error_class_name(e).unwrap_or("Error"), + OsError::Permission(e) => get_permission_check_error_class(e), OsError::FailedToGetCpuInfo => "TypeError", OsError::FailedToGetUserInfo(e) => get_io_error_class(e), } @@ -1116,7 +1193,7 @@ mod node { fn get_os_error(error: &OsError) -> &'static str { match error { - OsError::Permission(e) => get_error_class_name(e).unwrap_or("Error"), + OsError::Permission(e) => get_permission_check_error_class(e), OsError::InvalidUtf8(_) => "InvalidData", OsError::EnvEmptyKey => "TypeError", OsError::EnvInvalidKey(_) => "TypeError", @@ -1144,6 +1221,18 @@ fn get_sync_fetch_error(error: &SyncFetchError) -> &'static str { pub fn get_error_class_name(e: &AnyError) -> Option<&'static str> { deno_core::error::get_custom_error_class(e) + .or_else(|| { + e.downcast_ref::() + .map(get_child_permission_error) + }) + .or_else(|| { + e.downcast_ref::() + .map(get_permission_check_error_class) + }) + .or_else(|| { + e.downcast_ref::() + .map(get_permission_error_class) + }) .or_else(|| e.downcast_ref::().map(get_fs_error)) .or_else(|| { e.downcast_ref::() diff --git a/runtime/ops/fs_events.rs b/runtime/ops/fs_events.rs index 648553376a..c8e0228bc0 100644 --- a/runtime/ops/fs_events.rs +++ b/runtime/ops/fs_events.rs @@ -114,7 +114,7 @@ pub enum FsEventsError { #[error(transparent)] Resource(deno_core::error::AnyError), #[error(transparent)] - Permission(deno_core::error::AnyError), + Permission(#[from] deno_permissions::PermissionCheckError), #[error(transparent)] Notify(#[from] NotifyError), #[error(transparent)] @@ -181,8 +181,7 @@ fn op_fs_events_open( for path in &paths { let path = state .borrow_mut::() - .check_read(path, "Deno.watchFs()") - .map_err(FsEventsError::Permission)?; + .check_read(path, "Deno.watchFs()")?; let watcher = state.borrow_mut::(); watcher.watcher.watch(&path, recursive_mode)?; diff --git a/runtime/ops/os/mod.rs b/runtime/ops/os/mod.rs index 24b0389e16..9bee9d8234 100644 --- a/runtime/ops/os/mod.rs +++ b/runtime/ops/os/mod.rs @@ -73,7 +73,7 @@ deno_core::extension!( #[derive(Debug, thiserror::Error)] pub enum OsError { #[error(transparent)] - Permission(deno_core::error::AnyError), + Permission(#[from] deno_permissions::PermissionCheckError), #[error("File name or path {0:?} is not valid UTF-8")] InvalidUtf8(std::ffi::OsString), #[error("Key is an empty string.")] @@ -94,8 +94,7 @@ fn op_exec_path(state: &mut OpState) -> Result { let current_exe = env::current_exe().unwrap(); state .borrow_mut::() - .check_read_blind(¤t_exe, "exec_path", "Deno.execPath()") - .map_err(OsError::Permission)?; + .check_read_blind(¤t_exe, "exec_path", "Deno.execPath()")?; // normalize path so it doesn't include '.' or '..' components let path = normalize_path(current_exe); @@ -111,10 +110,7 @@ fn op_set_env( #[string] key: &str, #[string] value: &str, ) -> Result<(), OsError> { - state - .borrow_mut::() - .check_env(key) - .map_err(OsError::Permission)?; + state.borrow_mut::().check_env(key)?; if key.is_empty() { return Err(OsError::EnvEmptyKey); } @@ -146,10 +142,7 @@ fn op_get_env( let skip_permission_check = NODE_ENV_VAR_ALLOWLIST.contains(&key); if !skip_permission_check { - state - .borrow_mut::() - .check_env(&key) - .map_err(OsError::Permission)?; + state.borrow_mut::().check_env(&key)?; } if key.is_empty() { @@ -172,10 +165,7 @@ fn op_delete_env( state: &mut OpState, #[string] key: String, ) -> Result<(), OsError> { - state - .borrow_mut::() - .check_env(&key) - .map_err(OsError::Permission)?; + state.borrow_mut::().check_env(&key)?; if key.is_empty() || key.contains(&['=', '\0'] as &[char]) { return Err(OsError::EnvInvalidKey(key.to_string())); } @@ -240,8 +230,7 @@ fn op_network_interfaces( ) -> Result, OsError> { state .borrow_mut::() - .check_sys("networkInterfaces", "Deno.networkInterfaces()") - .map_err(OsError::Permission)?; + .check_sys("networkInterfaces", "Deno.networkInterfaces()")?; Ok(netif::up()?.map(NetworkInterface::from).collect()) } diff --git a/runtime/ops/permissions.rs b/runtime/ops/permissions.rs index 1dbc852596..9ad963f3bc 100644 --- a/runtime/ops/permissions.rs +++ b/runtime/ops/permissions.rs @@ -2,8 +2,6 @@ use ::deno_permissions::PermissionState; use ::deno_permissions::PermissionsContainer; -use deno_core::error::custom_error; -use deno_core::error::AnyError; use deno_core::op2; use deno_core::OpState; use serde::Deserialize; @@ -47,12 +45,26 @@ impl From for PermissionStatus { } } +#[derive(Debug, thiserror::Error)] +pub enum PermissionError { + #[error("No such permission name: {0}")] + InvalidPermissionName(String), + #[error("{0}")] + PathResolve(#[from] ::deno_permissions::PathResolveError), + #[error("{0}")] + NetDescriptorParse(#[from] ::deno_permissions::NetDescriptorParseError), + #[error("{0}")] + SysDescriptorParse(#[from] ::deno_permissions::SysDescriptorParseError), + #[error("{0}")] + RunDescriptorParse(#[from] ::deno_permissions::RunDescriptorParseError), +} + #[op2] #[serde] pub fn op_query_permission( state: &mut OpState, #[serde] args: PermissionArgs, -) -> Result { +) -> Result { let permissions = state.borrow::(); let perm = match args.name.as_ref() { "read" => permissions.query_read(args.path.as_deref())?, @@ -62,12 +74,7 @@ pub fn op_query_permission( "sys" => permissions.query_sys(args.kind.as_deref())?, "run" => permissions.query_run(args.command.as_deref())?, "ffi" => permissions.query_ffi(args.path.as_deref())?, - n => { - return Err(custom_error( - "ReferenceError", - format!("No such permission name: {n}"), - )) - } + _ => return Err(PermissionError::InvalidPermissionName(args.name)), }; Ok(PermissionStatus::from(perm)) } @@ -77,7 +84,7 @@ pub fn op_query_permission( pub fn op_revoke_permission( state: &mut OpState, #[serde] args: PermissionArgs, -) -> Result { +) -> Result { let permissions = state.borrow::(); let perm = match args.name.as_ref() { "read" => permissions.revoke_read(args.path.as_deref())?, @@ -87,12 +94,7 @@ pub fn op_revoke_permission( "sys" => permissions.revoke_sys(args.kind.as_deref())?, "run" => permissions.revoke_run(args.command.as_deref())?, "ffi" => permissions.revoke_ffi(args.path.as_deref())?, - n => { - return Err(custom_error( - "ReferenceError", - format!("No such permission name: {n}"), - )) - } + _ => return Err(PermissionError::InvalidPermissionName(args.name)), }; Ok(PermissionStatus::from(perm)) } @@ -102,7 +104,7 @@ pub fn op_revoke_permission( pub fn op_request_permission( state: &mut OpState, #[serde] args: PermissionArgs, -) -> Result { +) -> Result { let permissions = state.borrow::(); let perm = match args.name.as_ref() { "read" => permissions.request_read(args.path.as_deref())?, @@ -112,12 +114,7 @@ pub fn op_request_permission( "sys" => permissions.request_sys(args.kind.as_deref())?, "run" => permissions.request_run(args.command.as_deref())?, "ffi" => permissions.request_ffi(args.path.as_deref())?, - n => { - return Err(custom_error( - "ReferenceError", - format!("No such permission name: {n}"), - )) - } + _ => return Err(PermissionError::InvalidPermissionName(args.name)), }; Ok(PermissionStatus::from(perm)) } diff --git a/runtime/ops/process.rs b/runtime/ops/process.rs index 28913f7c16..de3141f1f9 100644 --- a/runtime/ops/process.rs +++ b/runtime/ops/process.rs @@ -206,7 +206,9 @@ pub enum ProcessError { #[error("failed resolving cwd: {0}")] FailedResolvingCwd(#[source] std::io::Error), #[error(transparent)] - Permission(deno_core::error::AnyError), + Permission(#[from] deno_permissions::PermissionCheckError), + #[error(transparent)] + RunPermission(#[from] CheckRunPermissionError), #[error(transparent)] Resource(deno_core::error::AnyError), #[error(transparent)] @@ -653,8 +655,7 @@ fn compute_run_cmd_and_check_permissions( }, &run_env, api_name, - ) - .map_err(ProcessError::Permission)?; + )?; Ok((cmd, run_env)) } @@ -734,12 +735,20 @@ fn resolve_path(path: &str, cwd: &Path) -> PathBuf { deno_path_util::normalize_path(cwd.join(path)) } +#[derive(Debug, thiserror::Error)] +pub enum CheckRunPermissionError { + #[error(transparent)] + Permission(#[from] deno_permissions::PermissionCheckError), + #[error("{0}")] + Other(deno_core::error::AnyError), +} + fn check_run_permission( state: &mut OpState, cmd: &RunQueryDescriptor, run_env: &RunEnv, api_name: &str, -) -> Result<(), deno_core::error::AnyError> { +) -> Result<(), CheckRunPermissionError> { let permissions = state.borrow_mut::(); if !permissions.query_run_all(api_name) { // error the same on all platforms @@ -747,14 +756,14 @@ fn check_run_permission( if !env_var_names.is_empty() { // we don't allow users to launch subprocesses with any LD_ or DYLD_* // env vars set because this allows executing code (ex. LD_PRELOAD) - return Err(deno_core::error::custom_error( + return Err(CheckRunPermissionError::Other(deno_core::error::custom_error( "NotCapable", format!( "Requires --allow-all permissions to spawn subprocess with {} environment variable{}.", env_var_names.join(", "), if env_var_names.len() != 1 { "s" } else { "" } ) - )); + ))); } permissions.check_run(cmd, api_name)?; } @@ -1126,8 +1135,7 @@ mod deprecated { ) -> Result<(), ProcessError> { state .borrow_mut::() - .check_run_all(&api_name) - .map_err(ProcessError::Permission)?; + .check_run_all(&api_name)?; kill(pid, &signal) } } diff --git a/runtime/ops/worker_host.rs b/runtime/ops/worker_host.rs index 82cc949242..521284a6a0 100644 --- a/runtime/ops/worker_host.rs +++ b/runtime/ops/worker_host.rs @@ -123,7 +123,7 @@ pub enum CreateWorkerError { #[error("Classic workers are not supported.")] ClassicWorkers, #[error(transparent)] - Permission(deno_core::error::AnyError), + Permission(deno_permissions::ChildPermissionError), #[error(transparent)] ModuleResolution(#[from] deno_core::ModuleResolutionError), #[error(transparent)] diff --git a/runtime/permissions.rs b/runtime/permissions.rs index fa62227e0d..e8460e03f8 100644 --- a/runtime/permissions.rs +++ b/runtime/permissions.rs @@ -3,9 +3,6 @@ use std::path::Path; use std::path::PathBuf; -use deno_core::anyhow::bail; -use deno_core::anyhow::Context; -use deno_core::error::AnyError; use deno_path_util::normalize_path; use deno_permissions::AllowRunDescriptor; use deno_permissions::AllowRunDescriptorParseResult; @@ -15,9 +12,12 @@ use deno_permissions::FfiDescriptor; use deno_permissions::ImportDescriptor; use deno_permissions::NetDescriptor; use deno_permissions::PathQueryDescriptor; +use deno_permissions::PathResolveError; use deno_permissions::ReadDescriptor; +use deno_permissions::RunDescriptorParseError; use deno_permissions::RunQueryDescriptor; use deno_permissions::SysDescriptor; +use deno_permissions::SysDescriptorParseError; use deno_permissions::WriteDescriptor; #[derive(Debug)] @@ -30,9 +30,9 @@ impl RuntimePermissionDescriptorParser { Self { fs } } - fn resolve_from_cwd(&self, path: &str) -> Result { + fn resolve_from_cwd(&self, path: &str) -> Result { if path.is_empty() { - bail!("Empty path is not allowed"); + return Err(PathResolveError::EmptyPath); } let path = Path::new(path); if path.is_absolute() { @@ -43,12 +43,11 @@ impl RuntimePermissionDescriptorParser { } } - fn resolve_cwd(&self) -> Result { + fn resolve_cwd(&self) -> Result { self .fs .cwd() - .map_err(|e| e.into_io_error()) - .context("failed resolving cwd") + .map_err(|e| PathResolveError::CwdResolve(e.into_io_error())) } } @@ -58,37 +57,37 @@ impl deno_permissions::PermissionDescriptorParser fn parse_read_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { Ok(ReadDescriptor(self.resolve_from_cwd(text)?)) } fn parse_write_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { Ok(WriteDescriptor(self.resolve_from_cwd(text)?)) } fn parse_net_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { NetDescriptor::parse(text) } fn parse_import_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { ImportDescriptor::parse(text) } fn parse_env_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { if text.is_empty() { - Err(AnyError::msg("Empty env not allowed")) + Err(deno_permissions::EnvDescriptorParseError) } else { Ok(EnvDescriptor::new(text)) } @@ -97,9 +96,9 @@ impl deno_permissions::PermissionDescriptorParser fn parse_sys_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { if text.is_empty() { - Err(AnyError::msg("Empty sys not allowed")) + Err(SysDescriptorParseError::Empty) } else { Ok(SysDescriptor::parse(text.to_string())?) } @@ -108,21 +107,21 @@ impl deno_permissions::PermissionDescriptorParser fn parse_allow_run_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { Ok(AllowRunDescriptor::parse(text, &self.resolve_cwd()?)?) } fn parse_deny_run_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { Ok(DenyRunDescriptor::parse(text, &self.resolve_cwd()?)) } fn parse_ffi_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { Ok(FfiDescriptor(self.resolve_from_cwd(text)?)) } @@ -131,7 +130,7 @@ impl deno_permissions::PermissionDescriptorParser fn parse_path_query( &self, path: &str, - ) -> Result { + ) -> Result { Ok(PathQueryDescriptor { resolved: self.resolve_from_cwd(path)?, requested: path.to_string(), @@ -141,11 +140,12 @@ impl deno_permissions::PermissionDescriptorParser fn parse_run_query( &self, requested: &str, - ) -> Result { + ) -> Result { if requested.is_empty() { - bail!("Empty run query is not allowed"); + return Err(RunDescriptorParseError::EmptyRunQuery); } RunQueryDescriptor::parse(requested) + .map_err(RunDescriptorParseError::PathResolve) } } diff --git a/runtime/permissions/Cargo.toml b/runtime/permissions/Cargo.toml index bfa37b4898..f0b2e71b55 100644 --- a/runtime/permissions/Cargo.toml +++ b/runtime/permissions/Cargo.toml @@ -23,6 +23,7 @@ log.workspace = true once_cell.workspace = true percent-encoding = { version = "2.3.1", features = [] } serde.workspace = true +thiserror.workspace = true which.workspace = true [target.'cfg(windows)'.dependencies] diff --git a/runtime/permissions/lib.rs b/runtime/permissions/lib.rs index 84503f025b..6480f4bf58 100644 --- a/runtime/permissions/lib.rs +++ b/runtime/permissions/lib.rs @@ -1,11 +1,5 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -use deno_core::anyhow::bail; -use deno_core::anyhow::Context; -use deno_core::error::custom_error; -use deno_core::error::type_error; -use deno_core::error::uri_error; -use deno_core::error::AnyError; use deno_core::parking_lot::Mutex; use deno_core::serde::de; use deno_core::serde::Deserialize; @@ -43,6 +37,21 @@ pub use prompter::PermissionPrompter; pub use prompter::PromptCallback; pub use prompter::PromptResponse; +#[derive(Debug, thiserror::Error)] +#[error("Requires {access}, {}", format_permission_error(.name))] +pub struct PermissionDeniedError { + access: String, + name: &'static str, +} + +fn format_permission_error(name: &'static str) -> String { + if is_standalone() { + format!("specify the required permissions during compilation using `deno compile --allow-{name}`") + } else { + format!("run again with the --allow-{name} flag") + } +} + /// Fast exit from permission check routines if this permission /// is in the "fully-granted" state. macro_rules! skip_check_if_is_permission_fully_granted { @@ -104,7 +113,10 @@ impl From for AllowPartial { impl PermissionState { #[inline(always)] - fn log_perm_access(name: &str, info: impl FnOnce() -> Option) { + fn log_perm_access( + name: &'static str, + info: impl FnOnce() -> Option, + ) { // Eliminates log overhead (when logging is disabled), // log_enabled!(Debug) check in a hot path still has overhead // TODO(AaronO): generalize or upstream this optimization @@ -120,53 +132,47 @@ impl PermissionState { } } - fn fmt_access(name: &str, info: impl FnOnce() -> Option) -> String { + fn fmt_access( + name: &'static str, + info: impl FnOnce() -> Option, + ) -> String { format!( "{} access{}", name, - info() - .map(|info| { format!(" to {info}") }) - .unwrap_or_default(), + info().map(|info| format!(" to {info}")).unwrap_or_default(), ) } - fn error(name: &str, info: impl FnOnce() -> Option) -> AnyError { - let msg = if is_standalone() { - format!( - "Requires {}, specify the required permissions during compilation using `deno compile --allow-{}`", - Self::fmt_access(name, info), - name - ) - } else { - format!( - "Requires {}, run again with the --allow-{} flag", - Self::fmt_access(name, info), - name - ) - }; - custom_error("NotCapable", msg) + fn error( + name: &'static str, + info: impl FnOnce() -> Option, + ) -> PermissionDeniedError { + PermissionDeniedError { + access: Self::fmt_access(name, info), + name, + } } /// Check the permission state. bool is whether a prompt was issued. #[inline] fn check( self, - name: &str, + name: &'static str, api_name: Option<&str>, info: Option<&str>, prompt: bool, - ) -> (Result<(), AnyError>, bool, bool) { + ) -> (Result<(), PermissionDeniedError>, bool, bool) { self.check2(name, api_name, || info.map(|s| s.to_string()), prompt) } #[inline] fn check2( self, - name: &str, + name: &'static str, api_name: Option<&str>, info: impl Fn() -> Option, prompt: bool, - ) -> (Result<(), AnyError>, bool, bool) { + ) -> (Result<(), PermissionDeniedError>, bool, bool) { match self { PermissionState::Granted => { Self::log_perm_access(name, info); @@ -246,7 +252,7 @@ impl UnitPermission { self.state } - pub fn check(&mut self) -> Result<(), AnyError> { + pub fn check(&mut self) -> Result<(), PermissionDeniedError> { let (result, prompted, _is_allow_all) = self.state.check(self.name, None, None, self.prompt); if prompted { @@ -262,7 +268,7 @@ impl UnitPermission { fn create_child_permissions( &mut self, flag: ChildUnitPermissionArg, - ) -> Result { + ) -> Result { let mut perm = self.clone(); match flag { ChildUnitPermissionArg::Inherit => { @@ -270,7 +276,7 @@ impl UnitPermission { } ChildUnitPermissionArg::Granted => { if self.check().is_err() { - return Err(escalation_error()); + return Err(ChildPermissionError::Escalation); } perm.state = PermissionState::Granted; } @@ -327,7 +333,7 @@ pub trait QueryDescriptor: Debug { &self, perm: &mut UnaryPermission, api_name: Option<&str>, - ) -> Result<(), AnyError>; + ) -> Result<(), PermissionDeniedError>; fn matches_allow(&self, other: &Self::AllowDesc) -> bool; fn matches_deny(&self, other: &Self::DenyDesc) -> bool; @@ -402,7 +408,7 @@ impl UnaryPermission { pub fn check_all_api( &mut self, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(None, false, api_name) } @@ -412,7 +418,7 @@ impl UnaryPermission { desc: Option<&TQuery>, assert_non_partial: bool, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { let (result, prompted, is_allow_all) = self .query_desc(desc, AllowPartial::from(!assert_non_partial)) .check2( @@ -599,11 +605,14 @@ impl UnaryPermission { } } - fn create_child_permissions( + fn create_child_permissions( &mut self, flag: ChildUnaryPermissionArg, - parse: impl Fn(&str) -> Result, AnyError>, - ) -> Result, AnyError> { + parse: impl Fn(&str) -> Result, E>, + ) -> Result, ChildPermissionError> + where + ChildPermissionError: From, + { let mut perms = Self::default(); match flag { @@ -612,7 +621,7 @@ impl UnaryPermission { } ChildUnaryPermissionArg::Granted => { if self.check_all_api(None).is_err() { - return Err(escalation_error()); + return Err(ChildPermissionError::Escalation); } perms.granted_global = true; } @@ -621,13 +630,13 @@ impl UnaryPermission { perms.granted_list = granted_list .iter() .filter_map(|i| parse(i).transpose()) - .collect::>()?; + .collect::>()?; if !perms.granted_list.iter().all(|desc| { TQuery::from_allow(desc) .check_in_permission(self, None) .is_ok() }) { - return Err(escalation_error()); + return Err(ChildPermissionError::Escalation); } } } @@ -698,7 +707,7 @@ impl QueryDescriptor for ReadQueryDescriptor { &self, perm: &mut UnaryPermission, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(perm); perm.check_desc(Some(self), true, api_name) } @@ -761,7 +770,7 @@ impl QueryDescriptor for WriteQueryDescriptor { &self, perm: &mut UnaryPermission, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(perm); perm.check_desc(Some(self), true, api_name) } @@ -796,22 +805,37 @@ pub enum Host { Ip(IpAddr), } +#[derive(Debug, thiserror::Error)] +pub enum HostParseError { + #[error("invalid IPv6 address: '{0}'")] + InvalidIpv6(String), + #[error("invalid host: '{0}'")] + InvalidHost(String), + #[error("invalid empty host: '{0}'")] + InvalidEmptyHost(String), + #[error("invalid host '{host}': {error}")] + Fqdn { + #[source] + error: fqdn::Error, + host: String, + }, +} + impl Host { - // TODO(bartlomieju): rewrite to not use `AnyError` but a specific error implementations - fn parse(s: &str) -> Result { + fn parse(s: &str) -> Result { if s.starts_with('[') && s.ends_with(']') { let ip = s[1..s.len() - 1] .parse::() - .map_err(|_| uri_error(format!("invalid IPv6 address: '{s}'")))?; + .map_err(|_| HostParseError::InvalidIpv6(s.to_string()))?; return Ok(Host::Ip(IpAddr::V6(ip))); } let (without_trailing_dot, has_trailing_dot) = s.strip_suffix('.').map_or((s, false), |s| (s, true)); if let Ok(ip) = without_trailing_dot.parse::() { if has_trailing_dot { - return Err(uri_error(format!( - "invalid host: '{without_trailing_dot}'" - ))); + return Err(HostParseError::InvalidHost( + without_trailing_dot.to_string(), + )); } Ok(Host::Ip(ip)) } else { @@ -822,11 +846,13 @@ impl Host { }; let fqdn = { use std::str::FromStr; - FQDN::from_str(&lower) - .with_context(|| format!("invalid host: '{s}'"))? + FQDN::from_str(&lower).map_err(|e| HostParseError::Fqdn { + error: e, + host: s.to_string(), + })? }; if fqdn.is_root() { - return Err(uri_error(format!("invalid empty host: '{s}'"))); + return Err(HostParseError::InvalidEmptyHost(s.to_string())); } Ok(Host::Fqdn(fqdn)) } @@ -870,7 +896,7 @@ impl QueryDescriptor for NetDescriptor { &self, perm: &mut UnaryPermission, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(perm); perm.check_desc(Some(self), false, api_name) } @@ -896,39 +922,72 @@ impl QueryDescriptor for NetDescriptor { } } -// TODO(bartlomieju): rewrite to not use `AnyError` but a specific error implementations +#[derive(Debug, thiserror::Error)] +pub enum NetDescriptorParseError { + #[error("invalid value '{0}': URLs are not supported, only domains and ips")] + Url(String), + #[error("invalid IPv6 address in '{hostname}': '{ip}'")] + InvalidIpv6 { hostname: String, ip: String }, + #[error("invalid port in '{hostname}': '{port}'")] + InvalidPort { hostname: String, port: String }, + #[error("invalid host: '{0}'")] + InvalidHost(String), + #[error("invalid empty port in '{0}'")] + EmptyPort(String), + #[error("ipv6 addresses must be enclosed in square brackets: '{0}'")] + Ipv6MissingSquareBrackets(String), + #[error("{0}")] + Host(#[from] HostParseError), +} + +#[derive(Debug, thiserror::Error)] +pub enum NetDescriptorFromUrlParseError { + #[error("Missing host in url: '{0}'")] + MissingHost(Url), + #[error("{0}")] + Host(#[from] HostParseError), +} + impl NetDescriptor { - pub fn parse(hostname: &str) -> Result { + pub fn parse(hostname: &str) -> Result { if hostname.starts_with("http://") || hostname.starts_with("https://") { - return Err(uri_error(format!("invalid value '{hostname}': URLs are not supported, only domains and ips"))); + return Err(NetDescriptorParseError::Url(hostname.to_string())); } // If this is a IPv6 address enclosed in square brackets, parse it as such. if hostname.starts_with('[') { if let Some((ip, after)) = hostname.split_once(']') { let ip = ip[1..].parse::().map_err(|_| { - uri_error(format!("invalid IPv6 address in '{hostname}': '{ip}'")) + NetDescriptorParseError::InvalidIpv6 { + hostname: hostname.to_string(), + ip: ip.to_string(), + } })?; let port = if let Some(port) = after.strip_prefix(':') { let port = port.parse::().map_err(|_| { - uri_error(format!("invalid port in '{hostname}': '{port}'")) + NetDescriptorParseError::InvalidPort { + hostname: hostname.to_string(), + port: port.to_string(), + } })?; Some(port) } else if after.is_empty() { None } else { - return Err(uri_error(format!("invalid host: '{hostname}'"))); + return Err(NetDescriptorParseError::InvalidHost( + hostname.to_string(), + )); }; return Ok(NetDescriptor(Host::Ip(IpAddr::V6(ip)), port)); } else { - return Err(uri_error(format!("invalid host: '{hostname}'"))); + return Err(NetDescriptorParseError::InvalidHost(hostname.to_string())); } } // Otherwise it is an IPv4 address or a FQDN with an optional port. let (host, port) = match hostname.split_once(':') { Some((_, "")) => { - return Err(uri_error(format!("invalid empty port in '{hostname}'"))); + return Err(NetDescriptorParseError::EmptyPort(hostname.to_string())); } Some((host, port)) => (host, port), None => (hostname, ""), @@ -943,11 +1002,14 @@ impl NetDescriptor { // should give them a hint. There are always at least two colons in an // IPv6 address, so this heuristic finds likely a bare IPv6 address. if port.contains(':') { - uri_error(format!( - "ipv6 addresses must be enclosed in square brackets: '{hostname}'" - )) + NetDescriptorParseError::Ipv6MissingSquareBrackets( + hostname.to_string(), + ) } else { - uri_error(format!("invalid port in '{hostname}': '{port}'")) + NetDescriptorParseError::InvalidPort { + hostname: hostname.to_string(), + port: port.to_string(), + } } })?; Some(port) @@ -956,10 +1018,10 @@ impl NetDescriptor { Ok(NetDescriptor(host, port)) } - pub fn from_url(url: &Url) -> Result { - let host = url - .host_str() - .ok_or_else(|| type_error(format!("Missing host in url: '{}'", url)))?; + pub fn from_url(url: &Url) -> Result { + let host = url.host_str().ok_or_else(|| { + NetDescriptorFromUrlParseError::MissingHost(url.clone()) + })?; let host = Host::parse(host)?; let port = url.port_or_known_default(); Ok(NetDescriptor(host, port)) @@ -1011,7 +1073,7 @@ impl QueryDescriptor for ImportDescriptor { &self, perm: &mut UnaryPermission, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(perm); perm.check_desc(Some(self), false, api_name) } @@ -1038,15 +1100,19 @@ impl QueryDescriptor for ImportDescriptor { } impl ImportDescriptor { - pub fn parse(specifier: &str) -> Result { + pub fn parse(specifier: &str) -> Result { Ok(ImportDescriptor(NetDescriptor::parse(specifier)?)) } - pub fn from_url(url: &Url) -> Result { + pub fn from_url(url: &Url) -> Result { Ok(ImportDescriptor(NetDescriptor::from_url(url)?)) } } +#[derive(Debug, thiserror::Error)] +#[error("Empty env not allowed")] +pub struct EnvDescriptorParseError; + #[derive(Clone, Eq, PartialEq, Hash, Debug)] pub struct EnvDescriptor(EnvVarName); @@ -1084,7 +1150,7 @@ impl QueryDescriptor for EnvDescriptor { &self, perm: &mut UnaryPermission, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(perm); perm.check_desc(Some(self), false, api_name) } @@ -1131,14 +1197,25 @@ pub enum RunQueryDescriptor { Name(String), } +#[derive(Debug, thiserror::Error)] +pub enum PathResolveError { + #[error("failed resolving cwd: {0}")] + CwdResolve(#[source] std::io::Error), + #[error("Empty path is not allowed")] + EmptyPath, +} + impl RunQueryDescriptor { - pub fn parse(requested: &str) -> Result { + pub fn parse( + requested: &str, + ) -> Result { if is_path(requested) { let path = PathBuf::from(requested); let resolved = if path.is_absolute() { normalize_path(path) } else { - let cwd = std::env::current_dir().context("failed resolving cwd")?; + let cwd = + std::env::current_dir().map_err(PathResolveError::CwdResolve)?; normalize_path(cwd.join(path)) }; Ok(RunQueryDescriptor::Path { @@ -1210,7 +1287,7 @@ impl QueryDescriptor for RunQueryDescriptor { &self, perm: &mut UnaryPermission, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(perm); perm.check_desc(Some(self), false, api_name) } @@ -1280,6 +1357,16 @@ pub enum AllowRunDescriptorParseResult { Descriptor(AllowRunDescriptor), } +#[derive(Debug, thiserror::Error)] +pub enum RunDescriptorParseError { + #[error("{0}")] + Which(#[from] which::Error), + #[error("{0}")] + PathResolve(#[from] PathResolveError), + #[error("Empty run query is not allowed")] + EmptyRunQuery, +} + #[derive(Debug, Clone, Hash, Eq, PartialEq)] pub struct AllowRunDescriptor(pub PathBuf); @@ -1360,11 +1447,19 @@ fn denies_run_name(name: &str, cmd_path: &Path) -> bool { suffix.is_empty() || suffix.starts_with('.') } +#[derive(Debug, thiserror::Error)] +pub enum SysDescriptorParseError { + #[error("unknown system info kind \"{0}\"")] + InvalidKind(String), // TypeError + #[error("Empty sys not allowed")] + Empty, // Error +} + #[derive(Clone, Eq, PartialEq, Hash, Debug)] pub struct SysDescriptor(String); impl SysDescriptor { - pub fn parse(kind: String) -> Result { + pub fn parse(kind: String) -> Result { match kind.as_str() { "hostname" | "osRelease" | "osUptime" | "loadavg" | "networkInterfaces" | "systemMemoryInfo" | "uid" | "gid" | "cpus" @@ -1374,7 +1469,7 @@ impl SysDescriptor { // the underlying permission check changed to `userInfo` to better match the API, // alias this to avoid breaking existing projects with `--allow-sys=username` "username" => Ok(Self("userInfo".into())), - _ => Err(type_error(format!("unknown system info kind \"{kind}\""))), + _ => Err(SysDescriptorParseError::InvalidKind(kind)), } } @@ -1411,7 +1506,7 @@ impl QueryDescriptor for SysDescriptor { &self, perm: &mut UnaryPermission, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(perm); perm.check_desc(Some(self), false, api_name) } @@ -1472,7 +1567,7 @@ impl QueryDescriptor for FfiQueryDescriptor { &self, perm: &mut UnaryPermission, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(perm); perm.check_desc(Some(self), true, api_name) } @@ -1524,7 +1619,7 @@ impl UnaryPermission { &mut self, desc: &ReadQueryDescriptor, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(Some(desc), true, api_name) } @@ -1534,12 +1629,15 @@ impl UnaryPermission { &mut self, desc: &ReadQueryDescriptor, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(Some(desc), false, api_name) } - pub fn check_all(&mut self, api_name: Option<&str>) -> Result<(), AnyError> { + pub fn check_all( + &mut self, + api_name: Option<&str>, + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(None, false, api_name) } @@ -1568,7 +1666,7 @@ impl UnaryPermission { &mut self, path: &WriteQueryDescriptor, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(Some(path), true, api_name) } @@ -1578,12 +1676,15 @@ impl UnaryPermission { &mut self, path: &WriteQueryDescriptor, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(Some(path), false, api_name) } - pub fn check_all(&mut self, api_name: Option<&str>) -> Result<(), AnyError> { + pub fn check_all( + &mut self, + api_name: Option<&str>, + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(None, false, api_name) } @@ -1606,12 +1707,12 @@ impl UnaryPermission { &mut self, host: &NetDescriptor, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(Some(host), false, api_name) } - pub fn check_all(&mut self) -> Result<(), AnyError> { + pub fn check_all(&mut self) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(None, false, None) } @@ -1637,12 +1738,12 @@ impl UnaryPermission { &mut self, host: &ImportDescriptor, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(Some(host), false, api_name) } - pub fn check_all(&mut self) -> Result<(), AnyError> { + pub fn check_all(&mut self) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(None, false, None) } @@ -1668,12 +1769,12 @@ impl UnaryPermission { &mut self, env: &str, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(Some(&EnvDescriptor::new(env)), false, api_name) } - pub fn check_all(&mut self) -> Result<(), AnyError> { + pub fn check_all(&mut self) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(None, false, None) } @@ -1696,12 +1797,12 @@ impl UnaryPermission { &mut self, kind: &SysDescriptor, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(Some(kind), false, api_name) } - pub fn check_all(&mut self) -> Result<(), AnyError> { + pub fn check_all(&mut self) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(None, false, None) } @@ -1730,11 +1831,14 @@ impl UnaryPermission { &mut self, cmd: &RunQueryDescriptor, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { self.check_desc(Some(cmd), false, api_name) } - pub fn check_all(&mut self, api_name: Option<&str>) -> Result<(), AnyError> { + pub fn check_all( + &mut self, + api_name: Option<&str>, + ) -> Result<(), PermissionDeniedError> { self.check_desc(None, false, api_name) } @@ -1777,7 +1881,7 @@ impl UnaryPermission { &mut self, path: &FfiQueryDescriptor, api_name: Option<&str>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(Some(path), true, api_name) } @@ -1785,12 +1889,12 @@ impl UnaryPermission { pub fn check_partial( &mut self, path: Option<&FfiQueryDescriptor>, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(path, false, None) } - pub fn check_all(&mut self) -> Result<(), AnyError> { + pub fn check_all(&mut self) -> Result<(), PermissionDeniedError> { skip_check_if_is_permission_fully_granted!(self); self.check_desc(None, false, Some("all")) } @@ -1830,23 +1934,39 @@ pub struct PermissionsOptions { pub prompt: bool, } +#[derive(Debug, thiserror::Error)] +pub enum PermissionsFromOptionsError { + #[error("{0}")] + PathResolve(#[from] PathResolveError), + #[error("{0}")] + SysDescriptorParse(#[from] SysDescriptorParseError), + #[error("{0}")] + NetDescriptorParse(#[from] NetDescriptorParseError), + #[error("{0}")] + EnvDescriptorParse(#[from] EnvDescriptorParseError), + #[error("{0}")] + RunDescriptorParse(#[from] RunDescriptorParseError), + #[error("Empty command name not allowed in --allow-run=...")] + RunEmptyCommandName, +} + impl Permissions { pub fn new_unary( allow_list: Option>, deny_list: Option>, prompt: bool, - ) -> Result, AnyError> + ) -> UnaryPermission where TQuery: QueryDescriptor, { - Ok(UnaryPermission:: { + UnaryPermission:: { granted_global: global_from_option(allow_list.as_ref()), granted_list: allow_list.unwrap_or_default(), flag_denied_global: global_from_option(deny_list.as_ref()), flag_denied_list: deny_list.unwrap_or_default(), prompt, ..Default::default() - }) + } } pub const fn new_all(allow_state: bool) -> UnitPermission { @@ -1862,15 +1982,15 @@ impl Permissions { pub fn from_options( parser: &dyn PermissionDescriptorParser, opts: &PermissionsOptions, - ) -> Result { + ) -> Result { fn resolve_allow_run( parser: &dyn PermissionDescriptorParser, allow_run: &[String], - ) -> Result, AnyError> { + ) -> Result, PermissionsFromOptionsError> { let mut new_allow_run = HashSet::with_capacity(allow_run.len()); for unresolved in allow_run { if unresolved.is_empty() { - bail!("Empty command name not allowed in --allow-run=...") + return Err(PermissionsFromOptionsError::RunEmptyCommandName); } match parser.parse_allow_run_descriptor(unresolved)? { AllowRunDescriptorParseResult::Descriptor(descriptor) => { @@ -1889,10 +2009,13 @@ impl Permissions { Ok(new_allow_run) } - fn parse_maybe_vec( + fn parse_maybe_vec( items: Option<&[String]>, - parse: impl Fn(&str) -> Result, - ) -> Result>, AnyError> { + parse: impl Fn(&str) -> Result, + ) -> Result>, PermissionsFromOptionsError> + where + PermissionsFromOptionsError: From, + { match items { Some(items) => Ok(Some( items @@ -1944,14 +2067,14 @@ impl Permissions { parser.parse_read_descriptor(item) })?, opts.prompt, - )?, + ), write: Permissions::new_unary( parse_maybe_vec(opts.allow_write.as_deref(), |item| { parser.parse_write_descriptor(item) })?, deny_write, opts.prompt, - )?, + ), net: Permissions::new_unary( parse_maybe_vec(opts.allow_net.as_deref(), |item| { parser.parse_net_descriptor(item) @@ -1960,7 +2083,7 @@ impl Permissions { parser.parse_net_descriptor(item) })?, opts.prompt, - )?, + ), env: Permissions::new_unary( parse_maybe_vec(opts.allow_env.as_deref(), |item| { parser.parse_env_descriptor(item) @@ -1969,7 +2092,7 @@ impl Permissions { parser.parse_env_descriptor(text) })?, opts.prompt, - )?, + ), sys: Permissions::new_unary( parse_maybe_vec(opts.allow_sys.as_deref(), |text| { parser.parse_sys_descriptor(text) @@ -1978,14 +2101,14 @@ impl Permissions { parser.parse_sys_descriptor(text) })?, opts.prompt, - )?, + ), run: Permissions::new_unary( allow_run, parse_maybe_vec(opts.deny_run.as_deref(), |text| { parser.parse_deny_run_descriptor(text) })?, opts.prompt, - )?, + ), ffi: Permissions::new_unary( parse_maybe_vec(opts.allow_ffi.as_deref(), |text| { parser.parse_ffi_descriptor(text) @@ -1994,14 +2117,14 @@ impl Permissions { parser.parse_ffi_descriptor(text) })?, opts.prompt, - )?, + ), import: Permissions::new_unary( parse_maybe_vec(opts.allow_import.as_deref(), |item| { parser.parse_import_descriptor(item) })?, None, opts.prompt, - )?, + ), all: Permissions::new_all(opts.allow_all), }) } @@ -2033,14 +2156,14 @@ impl Permissions { fn none(prompt: bool) -> Self { Self { - read: Permissions::new_unary(None, None, prompt).unwrap(), - write: Permissions::new_unary(None, None, prompt).unwrap(), - net: Permissions::new_unary(None, None, prompt).unwrap(), - env: Permissions::new_unary(None, None, prompt).unwrap(), - sys: Permissions::new_unary(None, None, prompt).unwrap(), - run: Permissions::new_unary(None, None, prompt).unwrap(), - ffi: Permissions::new_unary(None, None, prompt).unwrap(), - import: Permissions::new_unary(None, None, prompt).unwrap(), + read: Permissions::new_unary(None, None, prompt), + write: Permissions::new_unary(None, None, prompt), + net: Permissions::new_unary(None, None, prompt), + env: Permissions::new_unary(None, None, prompt), + sys: Permissions::new_unary(None, None, prompt), + run: Permissions::new_unary(None, None, prompt), + ffi: Permissions::new_unary(None, None, prompt), + import: Permissions::new_unary(None, None, prompt), all: Permissions::new_all(false), } } @@ -2052,6 +2175,38 @@ pub enum CheckSpecifierKind { Dynamic, } +#[derive(Debug, thiserror::Error)] +pub enum ChildPermissionError { + #[error("Can't escalate parent thread permissions")] + Escalation, + #[error("{0}")] + PathResolve(#[from] PathResolveError), + #[error("{0}")] + NetDescriptorParse(#[from] NetDescriptorParseError), + #[error("{0}")] + EnvDescriptorParse(#[from] EnvDescriptorParseError), + #[error("{0}")] + SysDescriptorParse(#[from] SysDescriptorParseError), + #[error("{0}")] + RunDescriptorParse(#[from] RunDescriptorParseError), +} + +#[derive(Debug, thiserror::Error)] +pub enum PermissionCheckError { + #[error(transparent)] + PermissionDenied(#[from] PermissionDeniedError), + #[error("Invalid file path.\n Specifier: {0}")] + InvalidFilePath(Url), + #[error(transparent)] + NetDescriptorForUrlParse(#[from] NetDescriptorFromUrlParseError), + #[error(transparent)] + SysDescriptorParse(#[from] SysDescriptorParseError), + #[error(transparent)] + PathResolve(#[from] PathResolveError), + #[error(transparent)] + HostParse(#[from] HostParseError), +} + /// Wrapper struct for `Permissions` that can be shared across threads. /// /// We need a way to have internal mutability for permissions as they might get @@ -2084,7 +2239,7 @@ impl PermissionsContainer { pub fn create_child_permissions( &self, child_permissions_arg: ChildPermissionsArg, - ) -> Result { + ) -> Result { fn is_granted_unary(arg: &ChildUnaryPermissionArg) -> bool { match arg { ChildUnaryPermissionArg::Inherit | ChildUnaryPermissionArg::Granted => { @@ -2122,48 +2277,71 @@ impl PermissionsContainer { // WARNING: When adding a permission here, ensure it is handled // in the worker_perms.all block above - worker_perms.read = inner - .read - .create_child_permissions(child_permissions_arg.read, |text| { - Ok(Some(self.descriptor_parser.parse_read_descriptor(text)?)) - })?; - worker_perms.write = inner - .write - .create_child_permissions(child_permissions_arg.write, |text| { - Ok(Some(self.descriptor_parser.parse_write_descriptor(text)?)) - })?; - worker_perms.import = inner - .import - .create_child_permissions(child_permissions_arg.import, |text| { - Ok(Some(self.descriptor_parser.parse_import_descriptor(text)?)) - })?; - worker_perms.net = inner - .net - .create_child_permissions(child_permissions_arg.net, |text| { - Ok(Some(self.descriptor_parser.parse_net_descriptor(text)?)) - })?; - worker_perms.env = inner - .env - .create_child_permissions(child_permissions_arg.env, |text| { - Ok(Some(self.descriptor_parser.parse_env_descriptor(text)?)) - })?; - worker_perms.sys = inner - .sys - .create_child_permissions(child_permissions_arg.sys, |text| { - Ok(Some(self.descriptor_parser.parse_sys_descriptor(text)?)) - })?; + worker_perms.read = inner.read.create_child_permissions( + child_permissions_arg.read, + |text| { + Ok::<_, PathResolveError>(Some( + self.descriptor_parser.parse_read_descriptor(text)?, + )) + }, + )?; + worker_perms.write = inner.write.create_child_permissions( + child_permissions_arg.write, + |text| { + Ok::<_, PathResolveError>(Some( + self.descriptor_parser.parse_write_descriptor(text)?, + )) + }, + )?; + worker_perms.import = inner.import.create_child_permissions( + child_permissions_arg.import, + |text| { + Ok::<_, NetDescriptorParseError>(Some( + self.descriptor_parser.parse_import_descriptor(text)?, + )) + }, + )?; + worker_perms.net = inner.net.create_child_permissions( + child_permissions_arg.net, + |text| { + Ok::<_, NetDescriptorParseError>(Some( + self.descriptor_parser.parse_net_descriptor(text)?, + )) + }, + )?; + worker_perms.env = inner.env.create_child_permissions( + child_permissions_arg.env, + |text| { + Ok::<_, EnvDescriptorParseError>(Some( + self.descriptor_parser.parse_env_descriptor(text)?, + )) + }, + )?; + worker_perms.sys = inner.sys.create_child_permissions( + child_permissions_arg.sys, + |text| { + Ok::<_, SysDescriptorParseError>(Some( + self.descriptor_parser.parse_sys_descriptor(text)?, + )) + }, + )?; worker_perms.run = inner.run.create_child_permissions( child_permissions_arg.run, |text| match self.descriptor_parser.parse_allow_run_descriptor(text)? { - AllowRunDescriptorParseResult::Unresolved(_) => Ok(None), + AllowRunDescriptorParseResult::Unresolved(_) => { + Ok::<_, RunDescriptorParseError>(None) + } AllowRunDescriptorParseResult::Descriptor(desc) => Ok(Some(desc)), }, )?; - worker_perms.ffi = inner - .ffi - .create_child_permissions(child_permissions_arg.ffi, |text| { - Ok(Some(self.descriptor_parser.parse_ffi_descriptor(text)?)) - })?; + worker_perms.ffi = inner.ffi.create_child_permissions( + child_permissions_arg.ffi, + |text| { + Ok::<_, PathResolveError>(Some( + self.descriptor_parser.parse_ffi_descriptor(text)?, + )) + }, + )?; Ok(PermissionsContainer::new( self.descriptor_parser.clone(), @@ -2176,7 +2354,7 @@ impl PermissionsContainer { &self, specifier: &ModuleSpecifier, kind: CheckSpecifierKind, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionCheckError> { let mut inner = self.inner.lock(); match specifier.scheme() { "file" => { @@ -2185,17 +2363,20 @@ impl PermissionsContainer { } match url_to_file_path(specifier) { - Ok(path) => inner.read.check( - &PathQueryDescriptor { - requested: path.to_string_lossy().into_owned(), - resolved: path, - } - .into_read(), - Some("import()"), - ), - Err(_) => Err(uri_error(format!( - "Invalid file path.\n Specifier: {specifier}" - ))), + Ok(path) => inner + .read + .check( + &PathQueryDescriptor { + requested: path.to_string_lossy().into_owned(), + resolved: path, + } + .into_read(), + Some("import()"), + ) + .map_err(PermissionCheckError::PermissionDenied), + Err(_) => { + Err(PermissionCheckError::InvalidFilePath(specifier.clone())) + } } } "data" => Ok(()), @@ -2220,7 +2401,7 @@ impl PermissionsContainer { &self, path: &str, api_name: &str, - ) -> Result { + ) -> Result { self.check_read_with_api_name(path, Some(api_name)) } @@ -2230,7 +2411,7 @@ impl PermissionsContainer { &self, path: &str, api_name: Option<&str>, - ) -> Result { + ) -> Result { let mut inner = self.inner.lock(); let inner = &mut inner.read; if inner.is_allow_all() { @@ -2248,7 +2429,7 @@ impl PermissionsContainer { &self, path: &'a Path, api_name: Option<&str>, - ) -> Result, AnyError> { + ) -> Result, PermissionCheckError> { let mut inner = self.inner.lock(); let inner = &mut inner.read; if inner.is_allow_all() { @@ -2272,7 +2453,7 @@ impl PermissionsContainer { path: &Path, display: &str, api_name: &str, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionCheckError> { let mut inner = self.inner.lock(); let inner = &mut inner.read; skip_check_if_is_permission_fully_granted!(inner); @@ -2283,12 +2464,17 @@ impl PermissionsContainer { } .into_read(), Some(api_name), - ) + )?; + Ok(()) } #[inline(always)] - pub fn check_read_all(&self, api_name: &str) -> Result<(), AnyError> { - self.inner.lock().read.check_all(Some(api_name)) + pub fn check_read_all( + &self, + api_name: &str, + ) -> Result<(), PermissionCheckError> { + self.inner.lock().read.check_all(Some(api_name))?; + Ok(()) } #[inline(always)] @@ -2302,7 +2488,7 @@ impl PermissionsContainer { &self, path: &str, api_name: &str, - ) -> Result { + ) -> Result { self.check_write_with_api_name(path, Some(api_name)) } @@ -2312,7 +2498,7 @@ impl PermissionsContainer { &self, path: &str, api_name: Option<&str>, - ) -> Result { + ) -> Result { let mut inner = self.inner.lock(); let inner = &mut inner.write; if inner.is_allow_all() { @@ -2330,7 +2516,7 @@ impl PermissionsContainer { &self, path: &'a Path, api_name: &str, - ) -> Result, AnyError> { + ) -> Result, PermissionCheckError> { let mut inner = self.inner.lock(); let inner = &mut inner.write; if inner.is_allow_all() { @@ -2347,8 +2533,12 @@ impl PermissionsContainer { } #[inline(always)] - pub fn check_write_all(&self, api_name: &str) -> Result<(), AnyError> { - self.inner.lock().write.check_all(Some(api_name)) + pub fn check_write_all( + &self, + api_name: &str, + ) -> Result<(), PermissionCheckError> { + self.inner.lock().write.check_all(Some(api_name))?; + Ok(()) } /// As `check_write()`, but permission error messages will anonymize the path @@ -2359,7 +2549,7 @@ impl PermissionsContainer { path: &Path, display: &str, api_name: &str, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionCheckError> { let mut inner = self.inner.lock(); let inner = &mut inner.write; skip_check_if_is_permission_fully_granted!(inner); @@ -2370,7 +2560,8 @@ impl PermissionsContainer { } .into_write(), Some(api_name), - ) + )?; + Ok(()) } #[inline(always)] @@ -2378,7 +2569,7 @@ impl PermissionsContainer { &mut self, path: &str, api_name: &str, - ) -> Result { + ) -> Result { let mut inner = self.inner.lock(); let inner = &mut inner.write; if inner.is_allow_all() { @@ -2395,13 +2586,18 @@ impl PermissionsContainer { &mut self, cmd: &RunQueryDescriptor, api_name: &str, - ) -> Result<(), AnyError> { - self.inner.lock().run.check(cmd, Some(api_name)) + ) -> Result<(), PermissionCheckError> { + self.inner.lock().run.check(cmd, Some(api_name))?; + Ok(()) } #[inline(always)] - pub fn check_run_all(&mut self, api_name: &str) -> Result<(), AnyError> { - self.inner.lock().run.check_all(Some(api_name)) + pub fn check_run_all( + &mut self, + api_name: &str, + ) -> Result<(), PermissionCheckError> { + self.inner.lock().run.check_all(Some(api_name))?; + Ok(()) } #[inline(always)] @@ -2410,38 +2606,50 @@ impl PermissionsContainer { } #[inline(always)] - pub fn check_sys(&self, kind: &str, api_name: &str) -> Result<(), AnyError> { + pub fn check_sys( + &self, + kind: &str, + api_name: &str, + ) -> Result<(), PermissionCheckError> { self.inner.lock().sys.check( &self.descriptor_parser.parse_sys_descriptor(kind)?, Some(api_name), - ) + )?; + Ok(()) } #[inline(always)] - pub fn check_env(&mut self, var: &str) -> Result<(), AnyError> { - self.inner.lock().env.check(var, None) + pub fn check_env(&mut self, var: &str) -> Result<(), PermissionCheckError> { + self.inner.lock().env.check(var, None)?; + Ok(()) } #[inline(always)] - pub fn check_env_all(&mut self) -> Result<(), AnyError> { - self.inner.lock().env.check_all() + pub fn check_env_all(&mut self) -> Result<(), PermissionCheckError> { + self.inner.lock().env.check_all()?; + Ok(()) } #[inline(always)] - pub fn check_sys_all(&mut self) -> Result<(), AnyError> { - self.inner.lock().sys.check_all() + pub fn check_sys_all(&mut self) -> Result<(), PermissionCheckError> { + self.inner.lock().sys.check_all()?; + Ok(()) } #[inline(always)] - pub fn check_ffi_all(&mut self) -> Result<(), AnyError> { - self.inner.lock().ffi.check_all() + pub fn check_ffi_all(&mut self) -> Result<(), PermissionCheckError> { + self.inner.lock().ffi.check_all()?; + Ok(()) } /// This checks to see if the allow-all flag was passed, not whether all /// permissions are enabled! #[inline(always)] - pub fn check_was_allow_all_flag_passed(&mut self) -> Result<(), AnyError> { - self.inner.lock().all.check() + pub fn check_was_allow_all_flag_passed( + &mut self, + ) -> Result<(), PermissionCheckError> { + self.inner.lock().all.check()?; + Ok(()) } /// Checks special file access, returning the failed permission type if @@ -2553,13 +2761,14 @@ impl PermissionsContainer { &mut self, url: &Url, api_name: &str, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionCheckError> { let mut inner = self.inner.lock(); if inner.net.is_allow_all() { return Ok(()); } let desc = self.descriptor_parser.parse_net_descriptor_from_url(url)?; - inner.net.check(&desc, Some(api_name)) + inner.net.check(&desc, Some(api_name))?; + Ok(()) } #[inline(always)] @@ -2567,17 +2776,21 @@ impl PermissionsContainer { &mut self, host: &(T, Option), api_name: &str, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionCheckError> { let mut inner = self.inner.lock(); let inner = &mut inner.net; skip_check_if_is_permission_fully_granted!(inner); let hostname = Host::parse(host.0.as_ref())?; let descriptor = NetDescriptor(hostname, host.1); - inner.check(&descriptor, Some(api_name)) + inner.check(&descriptor, Some(api_name))?; + Ok(()) } #[inline(always)] - pub fn check_ffi(&mut self, path: &str) -> Result { + pub fn check_ffi( + &mut self, + path: &str, + ) -> Result { let mut inner = self.inner.lock(); let inner = &mut inner.ffi; if inner.is_allow_all() { @@ -2591,14 +2804,15 @@ impl PermissionsContainer { #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] #[inline(always)] - pub fn check_ffi_partial_no_path(&mut self) -> Result<(), AnyError> { + pub fn check_ffi_partial_no_path( + &mut self, + ) -> Result<(), PermissionCheckError> { let mut inner = self.inner.lock(); let inner = &mut inner.ffi; - if inner.is_allow_all() { - Ok(()) - } else { - inner.check_partial(None) + if !inner.is_allow_all() { + inner.check_partial(None)?; } + Ok(()) } #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] @@ -2606,7 +2820,7 @@ impl PermissionsContainer { pub fn check_ffi_partial_with_path( &mut self, path: &str, - ) -> Result { + ) -> Result { let mut inner = self.inner.lock(); let inner = &mut inner.ffi; if inner.is_allow_all() { @@ -2624,7 +2838,7 @@ impl PermissionsContainer { pub fn query_read( &self, path: Option<&str>, - ) -> Result { + ) -> Result { let inner = self.inner.lock(); let permission = &inner.read; if permission.is_allow_all() { @@ -2634,7 +2848,7 @@ impl PermissionsContainer { permission.query( path .map(|path| { - Result::<_, AnyError>::Ok( + Ok::<_, PathResolveError>( self.descriptor_parser.parse_path_query(path)?.into_read(), ) }) @@ -2648,7 +2862,7 @@ impl PermissionsContainer { pub fn query_write( &self, path: Option<&str>, - ) -> Result { + ) -> Result { let inner = self.inner.lock(); let permission = &inner.write; if permission.is_allow_all() { @@ -2658,7 +2872,7 @@ impl PermissionsContainer { permission.query( path .map(|path| { - Result::<_, AnyError>::Ok( + Ok::<_, PathResolveError>( self.descriptor_parser.parse_path_query(path)?.into_write(), ) }) @@ -2672,7 +2886,7 @@ impl PermissionsContainer { pub fn query_net( &self, host: Option<&str>, - ) -> Result { + ) -> Result { let inner = self.inner.lock(); let permission = &inner.net; if permission.is_allow_all() { @@ -2703,7 +2917,7 @@ impl PermissionsContainer { pub fn query_sys( &self, kind: Option<&str>, - ) -> Result { + ) -> Result { let inner = self.inner.lock(); let permission = &inner.sys; if permission.is_allow_all() { @@ -2723,7 +2937,7 @@ impl PermissionsContainer { pub fn query_run( &self, cmd: Option<&str>, - ) -> Result { + ) -> Result { let inner = self.inner.lock(); let permission = &inner.run; if permission.is_allow_all() { @@ -2743,7 +2957,7 @@ impl PermissionsContainer { pub fn query_ffi( &self, path: Option<&str>, - ) -> Result { + ) -> Result { let inner = self.inner.lock(); let permission = &inner.ffi; if permission.is_allow_all() { @@ -2753,7 +2967,7 @@ impl PermissionsContainer { permission.query( path .map(|path| { - Result::<_, AnyError>::Ok( + Ok::<_, PathResolveError>( self.descriptor_parser.parse_path_query(path)?.into_ffi(), ) }) @@ -2769,12 +2983,12 @@ impl PermissionsContainer { pub fn revoke_read( &self, path: Option<&str>, - ) -> Result { + ) -> Result { Ok( self.inner.lock().read.revoke( path .map(|path| { - Result::<_, AnyError>::Ok( + Ok::<_, PathResolveError>( self.descriptor_parser.parse_path_query(path)?.into_read(), ) }) @@ -2788,12 +3002,12 @@ impl PermissionsContainer { pub fn revoke_write( &self, path: Option<&str>, - ) -> Result { + ) -> Result { Ok( self.inner.lock().write.revoke( path .map(|path| { - Result::<_, AnyError>::Ok( + Ok::<_, PathResolveError>( self.descriptor_parser.parse_path_query(path)?.into_write(), ) }) @@ -2807,7 +3021,7 @@ impl PermissionsContainer { pub fn revoke_net( &self, host: Option<&str>, - ) -> Result { + ) -> Result { Ok( self.inner.lock().net.revoke( match host { @@ -2828,7 +3042,7 @@ impl PermissionsContainer { pub fn revoke_sys( &self, kind: Option<&str>, - ) -> Result { + ) -> Result { Ok( self.inner.lock().sys.revoke( kind @@ -2843,7 +3057,7 @@ impl PermissionsContainer { pub fn revoke_run( &self, cmd: Option<&str>, - ) -> Result { + ) -> Result { Ok( self.inner.lock().run.revoke( cmd @@ -2858,12 +3072,12 @@ impl PermissionsContainer { pub fn revoke_ffi( &self, path: Option<&str>, - ) -> Result { + ) -> Result { Ok( self.inner.lock().ffi.revoke( path .map(|path| { - Result::<_, AnyError>::Ok( + Ok::<_, PathResolveError>( self.descriptor_parser.parse_path_query(path)?.into_ffi(), ) }) @@ -2879,12 +3093,12 @@ impl PermissionsContainer { pub fn request_read( &self, path: Option<&str>, - ) -> Result { + ) -> Result { Ok( self.inner.lock().read.request( path .map(|path| { - Result::<_, AnyError>::Ok( + Ok::<_, PathResolveError>( self.descriptor_parser.parse_path_query(path)?.into_read(), ) }) @@ -2898,12 +3112,12 @@ impl PermissionsContainer { pub fn request_write( &self, path: Option<&str>, - ) -> Result { + ) -> Result { Ok( self.inner.lock().write.request( path .map(|path| { - Result::<_, AnyError>::Ok( + Ok::<_, PathResolveError>( self.descriptor_parser.parse_path_query(path)?.into_write(), ) }) @@ -2917,7 +3131,7 @@ impl PermissionsContainer { pub fn request_net( &self, host: Option<&str>, - ) -> Result { + ) -> Result { Ok( self.inner.lock().net.request( match host { @@ -2938,7 +3152,7 @@ impl PermissionsContainer { pub fn request_sys( &self, kind: Option<&str>, - ) -> Result { + ) -> Result { Ok( self.inner.lock().sys.request( kind @@ -2953,7 +3167,7 @@ impl PermissionsContainer { pub fn request_run( &self, cmd: Option<&str>, - ) -> Result { + ) -> Result { Ok( self.inner.lock().run.request( cmd @@ -2968,12 +3182,12 @@ impl PermissionsContainer { pub fn request_ffi( &self, path: Option<&str>, - ) -> Result { + ) -> Result { Ok( self.inner.lock().ffi.request( path .map(|path| { - Result::<_, AnyError>::Ok( + Ok::<_, PathResolveError>( self.descriptor_parser.parse_path_query(path)?.into_ffi(), ) }) @@ -3009,10 +3223,6 @@ fn global_from_option(flag: Option<&HashSet>) -> bool { matches!(flag, Some(v) if v.is_empty()) } -fn escalation_error() -> AnyError { - custom_error("NotCapable", "Can't escalate parent thread permissions") -} - #[derive(Debug, Eq, PartialEq)] pub enum ChildUnitPermissionArg { Inherit, @@ -3273,65 +3483,73 @@ pub trait PermissionDescriptorParser: Debug + Send + Sync { fn parse_read_descriptor( &self, text: &str, - ) -> Result; + ) -> Result; fn parse_write_descriptor( &self, text: &str, - ) -> Result; + ) -> Result; - fn parse_net_descriptor(&self, text: &str) - -> Result; + fn parse_net_descriptor( + &self, + text: &str, + ) -> Result; fn parse_net_descriptor_from_url( &self, url: &Url, - ) -> Result { + ) -> Result { NetDescriptor::from_url(url) } fn parse_import_descriptor( &self, text: &str, - ) -> Result; + ) -> Result; fn parse_import_descriptor_from_url( &self, url: &Url, - ) -> Result { + ) -> Result { ImportDescriptor::from_url(url) } - fn parse_env_descriptor(&self, text: &str) - -> Result; + fn parse_env_descriptor( + &self, + text: &str, + ) -> Result; - fn parse_sys_descriptor(&self, text: &str) - -> Result; + fn parse_sys_descriptor( + &self, + text: &str, + ) -> Result; fn parse_allow_run_descriptor( &self, text: &str, - ) -> Result; + ) -> Result; fn parse_deny_run_descriptor( &self, text: &str, - ) -> Result; + ) -> Result; - fn parse_ffi_descriptor(&self, text: &str) - -> Result; + fn parse_ffi_descriptor( + &self, + text: &str, + ) -> Result; // queries fn parse_path_query( &self, path: &str, - ) -> Result; + ) -> Result; fn parse_run_query( &self, requested: &str, - ) -> Result; + ) -> Result; } static IS_STANDALONE: AtomicFlag = AtomicFlag::lowered(); @@ -3374,49 +3592,49 @@ mod tests { fn parse_read_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { Ok(ReadDescriptor(self.join_path_with_root(text))) } fn parse_write_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { Ok(WriteDescriptor(self.join_path_with_root(text))) } fn parse_net_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { NetDescriptor::parse(text) } fn parse_import_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { ImportDescriptor::parse(text) } fn parse_env_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { Ok(EnvDescriptor::new(text)) } fn parse_sys_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { SysDescriptor::parse(text.to_string()) } fn parse_allow_run_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { Ok(AllowRunDescriptorParseResult::Descriptor( AllowRunDescriptor(self.join_path_with_root(text)), )) @@ -3425,7 +3643,7 @@ mod tests { fn parse_deny_run_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { if text.contains("/") { Ok(DenyRunDescriptor::Path(self.join_path_with_root(text))) } else { @@ -3436,14 +3654,14 @@ mod tests { fn parse_ffi_descriptor( &self, text: &str, - ) -> Result { + ) -> Result { Ok(FfiDescriptor(self.join_path_with_root(text))) } fn parse_path_query( &self, path: &str, - ) -> Result { + ) -> Result { Ok(PathQueryDescriptor { resolved: self.join_path_with_root(path), requested: path.to_string(), @@ -3453,8 +3671,8 @@ mod tests { fn parse_run_query( &self, requested: &str, - ) -> Result { - RunQueryDescriptor::parse(requested) + ) -> Result { + RunQueryDescriptor::parse(requested).map_err(Into::into) } } @@ -4335,7 +4553,6 @@ mod tests { None, false, ) - .unwrap() }; prompt_value.set(true); @@ -4562,13 +4779,12 @@ mod tests { .lock() .clone(), Permissions { - env: Permissions::new_unary(Some(HashSet::new()), None, false).unwrap(), + env: Permissions::new_unary(Some(HashSet::new()), None, false), net: Permissions::new_unary( Some(HashSet::from([NetDescriptor::parse("foo").unwrap()])), None, false - ) - .unwrap(), + ), ..Permissions::none_without_prompt() } ); diff --git a/runtime/permissions/prompter.rs b/runtime/permissions/prompter.rs index b582b4f53e..168a845a29 100644 --- a/runtime/permissions/prompter.rs +++ b/runtime/permissions/prompter.rs @@ -1,6 +1,5 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -use deno_core::error::AnyError; use deno_core::parking_lot::Mutex; use deno_terminal::colors; use once_cell::sync::Lazy; @@ -101,8 +100,7 @@ pub struct TtyPrompter; fn clear_stdin( _stdin_lock: &mut StdinLock, _stderr_lock: &mut StderrLock, -) -> Result<(), AnyError> { - use deno_core::anyhow::bail; +) -> Result<(), std::io::Error> { use std::mem::MaybeUninit; const STDIN_FD: i32 = 0; @@ -117,7 +115,10 @@ fn clear_stdin( loop { let r = libc::tcflush(STDIN_FD, libc::TCIFLUSH); if r != 0 { - bail!("clear_stdin failed (tcflush)"); + return Err(std::io::Error::new( + std::io::ErrorKind::Other, + "clear_stdin failed (tcflush)", + )); } // Initialize timeout for select to be 100ms @@ -137,7 +138,10 @@ fn clear_stdin( // Check if select returned an error if r < 0 { - bail!("clear_stdin failed (select)"); + return Err(std::io::Error::new( + std::io::ErrorKind::Other, + "clear_stdin failed (select)", + )); } // Check if select returned due to timeout (stdin is quiescent) @@ -156,8 +160,7 @@ fn clear_stdin( fn clear_stdin( stdin_lock: &mut StdinLock, stderr_lock: &mut StderrLock, -) -> Result<(), AnyError> { - use deno_core::anyhow::bail; +) -> Result<(), std::io::Error> { use winapi::shared::minwindef::TRUE; use winapi::shared::minwindef::UINT; use winapi::shared::minwindef::WORD; @@ -194,18 +197,23 @@ fn clear_stdin( return Ok(()); - unsafe fn flush_input_buffer(stdin: HANDLE) -> Result<(), AnyError> { + unsafe fn flush_input_buffer(stdin: HANDLE) -> Result<(), std::io::Error> { let success = FlushConsoleInputBuffer(stdin); if success != TRUE { - bail!( - "Could not flush the console input buffer: {}", - std::io::Error::last_os_error() - ) + return Err(std::io::Error::new( + std::io::ErrorKind::Other, + format!( + "Could not flush the console input buffer: {}", + std::io::Error::last_os_error() + ), + )); } Ok(()) } - unsafe fn emulate_enter_key_press(stdin: HANDLE) -> Result<(), AnyError> { + unsafe fn emulate_enter_key_press( + stdin: HANDLE, + ) -> Result<(), std::io::Error> { // https://github.com/libuv/libuv/blob/a39009a5a9252a566ca0704d02df8dabc4ce328f/src/win/tty.c#L1121-L1131 let mut input_record: INPUT_RECORD = std::mem::zeroed(); input_record.EventType = KEY_EVENT; @@ -220,34 +228,43 @@ fn clear_stdin( let success = WriteConsoleInputW(stdin, &input_record, 1, &mut record_written); if success != TRUE { - bail!( - "Could not emulate enter key press: {}", - std::io::Error::last_os_error() - ); + return Err(std::io::Error::new( + std::io::ErrorKind::Other, + format!( + "Could not emulate enter key press: {}", + std::io::Error::last_os_error() + ), + )); } Ok(()) } - unsafe fn is_input_buffer_empty(stdin: HANDLE) -> Result { + unsafe fn is_input_buffer_empty( + stdin: HANDLE, + ) -> Result { let mut buffer = Vec::with_capacity(1); let mut events_read = 0; let success = PeekConsoleInputW(stdin, buffer.as_mut_ptr(), 1, &mut events_read); if success != TRUE { - bail!( - "Could not peek the console input buffer: {}", - std::io::Error::last_os_error() - ) + return Err(std::io::Error::new( + std::io::ErrorKind::Other, + format!( + "Could not peek the console input buffer: {}", + std::io::Error::last_os_error() + ), + )); } Ok(events_read == 0) } - fn move_cursor_up(stderr_lock: &mut StderrLock) -> Result<(), AnyError> { - write!(stderr_lock, "\x1B[1A")?; - Ok(()) + fn move_cursor_up( + stderr_lock: &mut StderrLock, + ) -> Result<(), std::io::Error> { + write!(stderr_lock, "\x1B[1A") } - fn read_stdin_line(stdin_lock: &mut StdinLock) -> Result<(), AnyError> { + fn read_stdin_line(stdin_lock: &mut StdinLock) -> Result<(), std::io::Error> { let mut input = String::new(); stdin_lock.read_line(&mut input)?; Ok(()) diff --git a/runtime/snapshot.rs b/runtime/snapshot.rs index 041132f971..0d81af6e74 100644 --- a/runtime/snapshot.rs +++ b/runtime/snapshot.rs @@ -5,12 +5,12 @@ use crate::ops::bootstrap::SnapshotOptions; use crate::shared::maybe_transpile_source; use crate::shared::runtime; use deno_cache::SqliteBackedCache; -use deno_core::error::AnyError; use deno_core::snapshot::*; use deno_core::v8; use deno_core::Extension; use deno_http::DefaultHttpPropertyExtractor; use deno_io::fs::FsError; +use deno_permissions::PermissionCheckError; use std::borrow::Cow; use std::io::Write; use std::path::Path; @@ -26,7 +26,7 @@ impl deno_websocket::WebSocketPermissions for Permissions { &mut self, _url: &deno_core::url::Url, _api_name: &str, - ) -> Result<(), deno_core::error::AnyError> { + ) -> Result<(), PermissionCheckError> { unreachable!("snapshotting!") } } @@ -42,7 +42,7 @@ impl deno_fetch::FetchPermissions for Permissions { &mut self, _url: &deno_core::url::Url, _api_name: &str, - ) -> Result<(), deno_core::error::AnyError> { + ) -> Result<(), PermissionCheckError> { unreachable!("snapshotting!") } @@ -50,28 +50,26 @@ impl deno_fetch::FetchPermissions for Permissions { &mut self, _p: &'a Path, _api_name: &str, - ) -> Result, AnyError> { + ) -> Result, PermissionCheckError> { unreachable!("snapshotting!") } } impl deno_ffi::FfiPermissions for Permissions { - fn check_partial_no_path( - &mut self, - ) -> Result<(), deno_core::error::AnyError> { + fn check_partial_no_path(&mut self) -> Result<(), PermissionCheckError> { unreachable!("snapshotting!") } fn check_partial_with_path( &mut self, _path: &str, - ) -> Result { + ) -> Result { unreachable!("snapshotting!") } } impl deno_napi::NapiPermissions for Permissions { - fn check(&mut self, _path: &str) -> std::result::Result { + fn check(&mut self, _path: &str) -> Result { unreachable!("snapshotting!") } } @@ -81,20 +79,20 @@ impl deno_node::NodePermissions for Permissions { &mut self, _url: &deno_core::url::Url, _api_name: &str, - ) -> Result<(), deno_core::error::AnyError> { + ) -> Result<(), PermissionCheckError> { unreachable!("snapshotting!") } fn check_read_path<'a>( &mut self, _path: &'a Path, - ) -> Result, AnyError> { + ) -> Result, PermissionCheckError> { unreachable!("snapshotting!") } fn check_read_with_api_name( &mut self, _p: &str, _api_name: Option<&str>, - ) -> Result { + ) -> Result { unreachable!("snapshotting!") } fn query_read_all(&mut self) -> bool { @@ -104,14 +102,14 @@ impl deno_node::NodePermissions for Permissions { &mut self, _p: &str, _api_name: Option<&str>, - ) -> Result { + ) -> Result { unreachable!("snapshotting!") } fn check_sys( &mut self, _kind: &str, _api_name: &str, - ) -> Result<(), deno_core::error::AnyError> { + ) -> Result<(), PermissionCheckError> { unreachable!("snapshotting!") } } @@ -121,7 +119,7 @@ impl deno_net::NetPermissions for Permissions { &mut self, _host: &(T, Option), _api_name: &str, - ) -> Result<(), deno_core::error::AnyError> { + ) -> Result<(), PermissionCheckError> { unreachable!("snapshotting!") } @@ -129,7 +127,7 @@ impl deno_net::NetPermissions for Permissions { &mut self, _p: &str, _api_name: &str, - ) -> Result { + ) -> Result { unreachable!("snapshotting!") } @@ -137,7 +135,7 @@ impl deno_net::NetPermissions for Permissions { &mut self, _p: &str, _api_name: &str, - ) -> Result { + ) -> Result { unreachable!("snapshotting!") } @@ -145,7 +143,7 @@ impl deno_net::NetPermissions for Permissions { &mut self, _p: &'a Path, _api_name: &str, - ) -> Result, AnyError> { + ) -> Result, PermissionCheckError> { unreachable!("snapshotting!") } } @@ -158,7 +156,7 @@ impl deno_fs::FsPermissions for Permissions { _write: bool, _path: &'a Path, _api_name: &str, - ) -> Result, FsError> { + ) -> Result, FsError> { unreachable!("snapshotting!") } @@ -166,11 +164,14 @@ impl deno_fs::FsPermissions for Permissions { &mut self, _path: &str, _api_name: &str, - ) -> Result { + ) -> Result { unreachable!("snapshotting!") } - fn check_read_all(&mut self, _api_name: &str) -> Result<(), AnyError> { + fn check_read_all( + &mut self, + _api_name: &str, + ) -> Result<(), PermissionCheckError> { unreachable!("snapshotting!") } @@ -179,7 +180,7 @@ impl deno_fs::FsPermissions for Permissions { _path: &Path, _display: &str, _api_name: &str, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionCheckError> { unreachable!("snapshotting!") } @@ -187,7 +188,7 @@ impl deno_fs::FsPermissions for Permissions { &mut self, _path: &str, _api_name: &str, - ) -> Result { + ) -> Result { unreachable!("snapshotting!") } @@ -195,11 +196,14 @@ impl deno_fs::FsPermissions for Permissions { &mut self, _path: &str, _api_name: &str, - ) -> Result { + ) -> Result { unreachable!("snapshotting!") } - fn check_write_all(&mut self, _api_name: &str) -> Result<(), AnyError> { + fn check_write_all( + &mut self, + _api_name: &str, + ) -> Result<(), PermissionCheckError> { unreachable!("snapshotting!") } @@ -208,7 +212,7 @@ impl deno_fs::FsPermissions for Permissions { _path: &Path, _display: &str, _api_name: &str, - ) -> Result<(), AnyError> { + ) -> Result<(), PermissionCheckError> { unreachable!("snapshotting!") } @@ -216,7 +220,7 @@ impl deno_fs::FsPermissions for Permissions { &mut self, _path: &'a Path, _api_name: &str, - ) -> Result, AnyError> { + ) -> Result, PermissionCheckError> { unreachable!("snapshotting!") } @@ -224,7 +228,7 @@ impl deno_fs::FsPermissions for Permissions { &mut self, _path: &'a Path, _api_name: &str, - ) -> Result, AnyError> { + ) -> Result, PermissionCheckError> { unreachable!("snapshotting!") } } @@ -234,7 +238,7 @@ impl deno_kv::sqlite::SqliteDbHandlerPermissions for Permissions { &mut self, _path: &str, _api_name: &str, - ) -> Result { + ) -> Result { unreachable!("snapshotting!") } @@ -242,7 +246,7 @@ impl deno_kv::sqlite::SqliteDbHandlerPermissions for Permissions { &mut self, _path: &'a Path, _api_name: &str, - ) -> Result, AnyError> { + ) -> Result, PermissionCheckError> { unreachable!("snapshotting!") } } From 9a39a98b57de4183e054ab170592c85c97fac183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 4 Nov 2024 17:57:29 +0000 Subject: [PATCH 22/40] fix(fmt): ignore file directive for YAML files (#26717) Closes https://github.com/denoland/deno/issues/26712 Support `# deno-fmt-ignore-file` directive for YAML files. Also added tests for single line ignores. --- cli/tools/fmt.rs | 15 +++++++++++++ tests/specs/fmt/yaml/__test__.jsonc | 24 +++++++++++++++++++++ tests/specs/fmt/yaml/ignore_file.yaml | 2 ++ tests/specs/fmt/yaml/ignore_file2.yaml | 2 ++ tests/specs/fmt/yaml/ignore_file3.yaml | 5 +++++ tests/specs/fmt/yaml/ignore_file4.yaml | 2 ++ tests/specs/fmt/yaml/ignore_line.yml | 2 ++ tests/specs/fmt/yaml/wrong_file_ignore.out | 7 ++++++ tests/specs/fmt/yaml/wrong_file_ignore.yaml | 5 +++++ 9 files changed, 64 insertions(+) create mode 100644 tests/specs/fmt/yaml/ignore_file.yaml create mode 100644 tests/specs/fmt/yaml/ignore_file2.yaml create mode 100644 tests/specs/fmt/yaml/ignore_file3.yaml create mode 100644 tests/specs/fmt/yaml/ignore_file4.yaml create mode 100644 tests/specs/fmt/yaml/ignore_line.yml create mode 100644 tests/specs/fmt/yaml/wrong_file_ignore.out create mode 100644 tests/specs/fmt/yaml/wrong_file_ignore.yaml diff --git a/cli/tools/fmt.rs b/cli/tools/fmt.rs index 81af25c34b..8378835612 100644 --- a/cli/tools/fmt.rs +++ b/cli/tools/fmt.rs @@ -353,6 +353,21 @@ fn format_yaml( file_text: &str, fmt_options: &FmtOptionsConfig, ) -> Result, AnyError> { + let ignore_file = file_text + .lines() + .take_while(|line| line.starts_with('#')) + .any(|line| { + line + .strip_prefix('#') + .unwrap() + .trim() + .starts_with("deno-fmt-ignore-file") + }); + + if ignore_file { + return Ok(None); + } + let formatted_str = pretty_yaml::format_text(file_text, &get_resolved_yaml_config(fmt_options)) .map_err(AnyError::from)?; diff --git a/tests/specs/fmt/yaml/__test__.jsonc b/tests/specs/fmt/yaml/__test__.jsonc index 499b4144b7..71a2e06827 100644 --- a/tests/specs/fmt/yaml/__test__.jsonc +++ b/tests/specs/fmt/yaml/__test__.jsonc @@ -8,6 +8,30 @@ "well_formatted": { "args": "fmt --check well_formatted.yml", "output": "Checked 1 file\n" + }, + "ignore_line": { + "args": "fmt --check ignore_line.yml", + "output": "Checked 1 file\n" + }, + "ignore_file": { + "args": "fmt ignore_file.yaml", + "output": "Checked 1 file\n" + }, + "ignore_file2": { + "args": "fmt ignore_file2.yaml", + "output": "Checked 1 file\n" + }, + "ignore_file3": { + "args": "fmt ignore_file3.yaml", + "output": "Checked 1 file\n" + }, + "ignore_file4": { + "args": "fmt ignore_file4.yaml", + "output": "Checked 1 file\n" + }, + "wrong_file_ignore": { + "args": "fmt wrong_file_ignore.yaml", + "output": "wrong_file_ignore.out" } } } diff --git a/tests/specs/fmt/yaml/ignore_file.yaml b/tests/specs/fmt/yaml/ignore_file.yaml new file mode 100644 index 0000000000..c724c7bde5 --- /dev/null +++ b/tests/specs/fmt/yaml/ignore_file.yaml @@ -0,0 +1,2 @@ +# deno-fmt-ignore-file +{{something crazy \ No newline at end of file diff --git a/tests/specs/fmt/yaml/ignore_file2.yaml b/tests/specs/fmt/yaml/ignore_file2.yaml new file mode 100644 index 0000000000..a2053533ef --- /dev/null +++ b/tests/specs/fmt/yaml/ignore_file2.yaml @@ -0,0 +1,2 @@ +#deno-fmt-ignore-file +{{something crazy \ No newline at end of file diff --git a/tests/specs/fmt/yaml/ignore_file3.yaml b/tests/specs/fmt/yaml/ignore_file3.yaml new file mode 100644 index 0000000000..a3927a7b19 --- /dev/null +++ b/tests/specs/fmt/yaml/ignore_file3.yaml @@ -0,0 +1,5 @@ +# Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor +# incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, +# quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. +# deno-fmt-ignore-file +{{something crazy \ No newline at end of file diff --git a/tests/specs/fmt/yaml/ignore_file4.yaml b/tests/specs/fmt/yaml/ignore_file4.yaml new file mode 100644 index 0000000000..c32fe9f2be --- /dev/null +++ b/tests/specs/fmt/yaml/ignore_file4.yaml @@ -0,0 +1,2 @@ +# deno-fmt-ignore-file Because this is templated yaml file +{{something crazy \ No newline at end of file diff --git a/tests/specs/fmt/yaml/ignore_line.yml b/tests/specs/fmt/yaml/ignore_line.yml new file mode 100644 index 0000000000..490adcb5f7 --- /dev/null +++ b/tests/specs/fmt/yaml/ignore_line.yml @@ -0,0 +1,2 @@ +# deno-fmt-ignore +- Test diff --git a/tests/specs/fmt/yaml/wrong_file_ignore.out b/tests/specs/fmt/yaml/wrong_file_ignore.out new file mode 100644 index 0000000000..065dc98db0 --- /dev/null +++ b/tests/specs/fmt/yaml/wrong_file_ignore.out @@ -0,0 +1,7 @@ +Error formatting: [WILDCARD]wrong_file_ignore.yaml + parse error at line 5, column 1 + | +5 | {{something crazy + | ^ + +Checked 1 file diff --git a/tests/specs/fmt/yaml/wrong_file_ignore.yaml b/tests/specs/fmt/yaml/wrong_file_ignore.yaml new file mode 100644 index 0000000000..8019d989d3 --- /dev/null +++ b/tests/specs/fmt/yaml/wrong_file_ignore.yaml @@ -0,0 +1,5 @@ +# File ignore directive only works if it's in the first cluster +# of comment, ie. there are no empty lines after the first n-leading lines. + +# deno-fmt-ignore-file +{{something crazy \ No newline at end of file From d55e30f41855d40b36019f347a15b6c8984eb3e9 Mon Sep 17 00:00:00 2001 From: Scott Twiname Date: Tue, 5 Nov 2024 07:20:34 +1300 Subject: [PATCH 23/40] fix(types): missing `import` permission on `PermissionOptionsObject` (#26627) --- cli/tsc/dts/lib.deno.ns.d.ts | 37 ++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts index 36592e10dc..6e0e84b687 100644 --- a/cli/tsc/dts/lib.deno.ns.d.ts +++ b/cli/tsc/dts/lib.deno.ns.d.ts @@ -556,14 +556,23 @@ declare namespace Deno { */ env?: "inherit" | boolean | string[]; - /** Specifies if the `sys` permission should be requested or revoked. - * If set to `"inherit"`, the current `sys` permission will be inherited. - * If set to `true`, the global `sys` permission will be requested. - * If set to `false`, the global `sys` permission will be revoked. + /** Specifies if the `ffi` permission should be requested or revoked. + * If set to `"inherit"`, the current `ffi` permission will be inherited. + * If set to `true`, the global `ffi` permission will be requested. + * If set to `false`, the global `ffi` permission will be revoked. * * @default {false} */ - sys?: "inherit" | boolean | string[]; + ffi?: "inherit" | boolean | Array; + + /** Specifies if the `import` permission should be requested or revoked. + * If set to `"inherit"` the current `import` permission will be inherited. + * If set to `true`, the global `import` permission will be requested. + * If set to `false`, the global `import` permission will be revoked. + * If set to `Array`, the `import` permissions will be requested with the + * specified domains. + */ + import?: "inherit" | boolean | Array; /** Specifies if the `net` permission should be requested or revoked. * if set to `"inherit"`, the current `net` permission will be inherited. @@ -638,15 +647,6 @@ declare namespace Deno { */ net?: "inherit" | boolean | string[]; - /** Specifies if the `ffi` permission should be requested or revoked. - * If set to `"inherit"`, the current `ffi` permission will be inherited. - * If set to `true`, the global `ffi` permission will be requested. - * If set to `false`, the global `ffi` permission will be revoked. - * - * @default {false} - */ - ffi?: "inherit" | boolean | Array; - /** Specifies if the `read` permission should be requested or revoked. * If set to `"inherit"`, the current `read` permission will be inherited. * If set to `true`, the global `read` permission will be requested. @@ -667,6 +667,15 @@ declare namespace Deno { */ run?: "inherit" | boolean | Array; + /** Specifies if the `sys` permission should be requested or revoked. + * If set to `"inherit"`, the current `sys` permission will be inherited. + * If set to `true`, the global `sys` permission will be requested. + * If set to `false`, the global `sys` permission will be revoked. + * + * @default {false} + */ + sys?: "inherit" | boolean | string[]; + /** Specifies if the `write` permission should be requested or revoked. * If set to `"inherit"`, the current `write` permission will be inherited. * If set to `true`, the global `write` permission will be requested. From d67765b0b48d711cd0878e168ccb1e28178c4006 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Mon, 4 Nov 2024 20:01:31 +0000 Subject: [PATCH 24/40] fix(lsp): scope attribution for lazily loaded assets (#26699) --- cli/tsc/99_main_compiler.js | 17 +++++++++------ tests/integration/lsp_tests.rs | 39 ++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index bdc4340e33..52c9134dad 100644 --- a/cli/tsc/99_main_compiler.js +++ b/cli/tsc/99_main_compiler.js @@ -801,13 +801,18 @@ delete Object.prototype.__proto__; if (logDebug) { debug(`host.getScriptSnapshot("${specifier}")`); } - const sourceFile = sourceFileCache.get(specifier); - if (sourceFile) { - if (!assetScopes.has(specifier)) { - assetScopes.set(specifier, lastRequestScope); + if (specifier.startsWith(ASSETS_URL_PREFIX)) { + const sourceFile = this.getSourceFile( + specifier, + ts.ScriptTarget.ESNext, + ); + if (sourceFile) { + if (!assetScopes.has(specifier)) { + assetScopes.set(specifier, lastRequestScope); + } + // This case only occurs for assets. + return ts.ScriptSnapshot.fromString(sourceFile.text); } - // This case only occurs for assets. - return ts.ScriptSnapshot.fromString(sourceFile.text); } let sourceText = sourceTextCache.get(specifier); if (sourceText == undefined) { diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index 2376aebd90..56221a0269 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -6396,6 +6396,45 @@ fn lsp_cache_on_save() { client.shutdown(); } +// Regression test for https://github.com/denoland/deno/issues/25999. +#[test] +fn lsp_asset_document_dom_code_action() { + let context = TestContextBuilder::new().use_temp_cwd().build(); + let temp_dir = context.temp_dir(); + temp_dir.write( + "deno.json", + json!({ + "compilerOptions": { + "lib": ["deno.window", "dom"], + }, + }) + .to_string(), + ); + let mut client = context.new_lsp_command().build(); + client.initialize_default(); + client.did_open(json!({ + "textDocument": { + "uri": temp_dir.url().join("file.ts").unwrap(), + "languageId": "typescript", + "version": 1, + "text": r#""#, + }, + })); + let res = client.write_request( + "textDocument/codeAction", + json!({ + "textDocument": { "uri": "asset:///lib.dom.d.ts" }, + "range": { + "start": { "line": 0, "character": 0 }, + "end": { "line": 0, "character": 0 }, + }, + "context": { "diagnostics": [], "only": ["quickfix"] }, + }), + ); + assert_eq!(res, json!(null)); + client.shutdown(); +} + // Regression test for https://github.com/denoland/deno/issues/22122. #[test] fn lsp_cache_then_definition() { From bb3ca84e6d8f4f9f2a30de93bd87e243048a8d74 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 4 Nov 2024 15:40:05 -0500 Subject: [PATCH 25/40] fix(fmt): do not panic for jsx ignore container followed by jsx text (#26723) --- .dprint.json | 2 +- Cargo.lock | 4 ++-- cli/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.dprint.json b/.dprint.json index ea99f2aeda..489a61e571 100644 --- a/.dprint.json +++ b/.dprint.json @@ -68,7 +68,7 @@ "third_party" ], "plugins": [ - "https://plugins.dprint.dev/typescript-0.93.1.wasm", + "https://plugins.dprint.dev/typescript-0.93.2.wasm", "https://plugins.dprint.dev/json-0.19.4.wasm", "https://plugins.dprint.dev/markdown-0.17.8.wasm", "https://plugins.dprint.dev/toml-0.6.3.wasm", diff --git a/Cargo.lock b/Cargo.lock index a8a501716c..40b0bc171b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2609,9 +2609,9 @@ dependencies = [ [[package]] name = "dprint-plugin-typescript" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5abfd78fe3cde4f5a6699d65f760c8d44da130cf446b6f80a7a9bc6580e156ab" +checksum = "3ff29fd136541e59d51946f0d2d353fefc886776f61a799ebfb5838b06cef13b" dependencies = [ "anyhow", "deno_ast", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index a3e2b71f00..b4f2e614f0 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -107,7 +107,7 @@ dotenvy = "0.15.7" dprint-plugin-json = "=0.19.4" dprint-plugin-jupyter = "=0.1.5" dprint-plugin-markdown = "=0.17.8" -dprint-plugin-typescript = "=0.93.1" +dprint-plugin-typescript = "=0.93.2" env_logger = "=0.10.0" fancy-regex = "=0.10.0" faster-hex.workspace = true From 84aee0be9aac53499a757973a8a2054d2a44e479 Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:08:29 -0800 Subject: [PATCH 26/40] fix(ext/node): add `findSourceMap` to the default export of `node:module` (#26720) Next.js 15.0.2 tries to use this and errors out --- ext/node/polyfills/01_require.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/node/polyfills/01_require.js b/ext/node/polyfills/01_require.js index 296d819aa5..d818bb5727 100644 --- a/ext/node/polyfills/01_require.js +++ b/ext/node/polyfills/01_require.js @@ -1312,6 +1312,8 @@ export function findSourceMap(_path) { return undefined; } +Module.findSourceMap = findSourceMap; + /** * @param {string | URL} _specifier * @param {string | URL} _parentUrl From 051552172c07e42bf666d04863bc511667471509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 4 Nov 2024 23:42:18 +0000 Subject: [PATCH 27/40] fix(workspace): support wildcard packages (#26568) This commit adds support for wildcard packages in `workspace` configuration option in `deno.json`. This is now supported: ``` { "workspace": [ "./packages/*" ] } ``` Closes https://github.com/denoland/deno/issues/25783 --- Cargo.lock | 4 ++-- cli/Cargo.toml | 2 +- .../run/workspaces/wildcard/__test__.jsonc | 5 +++++ tests/specs/run/workspaces/wildcard/deno.json | 8 +++++++ tests/specs/run/workspaces/wildcard/main.out | 22 +++++++++++++++++++ tests/specs/run/workspaces/wildcard/main.ts | 5 +++++ .../wildcard/packages/bar/deno.json | 8 +++++++ .../wildcard/packages/bar/fizz/buzz.ts | 1 + .../workspaces/wildcard/packages/bar/mod.ts | 5 +++++ .../wildcard/packages/bar/some_mod/hello.ts | 1 + .../wildcard/packages/foo/bar/hello.ts | 1 + .../wildcard/packages/foo/deno.json | 8 +++++++ .../wildcard/packages/foo/fizz/buzz.ts | 1 + .../workspaces/wildcard/packages/foo/mod.ts | 5 +++++ 14 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 tests/specs/run/workspaces/wildcard/__test__.jsonc create mode 100644 tests/specs/run/workspaces/wildcard/deno.json create mode 100644 tests/specs/run/workspaces/wildcard/main.out create mode 100644 tests/specs/run/workspaces/wildcard/main.ts create mode 100644 tests/specs/run/workspaces/wildcard/packages/bar/deno.json create mode 100644 tests/specs/run/workspaces/wildcard/packages/bar/fizz/buzz.ts create mode 100644 tests/specs/run/workspaces/wildcard/packages/bar/mod.ts create mode 100644 tests/specs/run/workspaces/wildcard/packages/bar/some_mod/hello.ts create mode 100644 tests/specs/run/workspaces/wildcard/packages/foo/bar/hello.ts create mode 100644 tests/specs/run/workspaces/wildcard/packages/foo/deno.json create mode 100644 tests/specs/run/workspaces/wildcard/packages/foo/fizz/buzz.ts create mode 100644 tests/specs/run/workspaces/wildcard/packages/foo/mod.ts diff --git a/Cargo.lock b/Cargo.lock index 40b0bc171b..c22d49c41c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1387,9 +1387,9 @@ dependencies = [ [[package]] name = "deno_config" -version = "0.37.2" +version = "0.38.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5900bfb37538d83b19ba0b157cdc785770e38422ee4632411e3bd3d90ac0f537" +checksum = "966825073480a6ac7e01977a3879d13edc8d6ea2d65ea164b37156a5fb206e9a" dependencies = [ "anyhow", "deno_package_json", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index b4f2e614f0..1fa9692a4d 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -70,7 +70,7 @@ winres.workspace = true [dependencies] deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] } deno_cache_dir = { workspace = true } -deno_config = { version = "=0.37.2", features = ["workspace", "sync"] } +deno_config = { version = "=0.38.2", features = ["workspace", "sync"] } deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] } deno_doc = { version = "0.156.0", default-features = false, features = ["rust", "html", "syntect"] } deno_graph = { version = "=0.84.1" } diff --git a/tests/specs/run/workspaces/wildcard/__test__.jsonc b/tests/specs/run/workspaces/wildcard/__test__.jsonc new file mode 100644 index 0000000000..ea467e51b4 --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run -L debug -A main.ts", + "output": "main.out", + "tempDir": true +} diff --git a/tests/specs/run/workspaces/wildcard/deno.json b/tests/specs/run/workspaces/wildcard/deno.json new file mode 100644 index 0000000000..8c39ec6564 --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/deno.json @@ -0,0 +1,8 @@ +{ + "workspace": [ + "./packages/*" + ], + "imports": { + "chalk": "npm:chalk" + } +} diff --git a/tests/specs/run/workspaces/wildcard/main.out b/tests/specs/run/workspaces/wildcard/main.out new file mode 100644 index 0000000000..72165dbdea --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/main.out @@ -0,0 +1,22 @@ +[WILDCARD]Workspace config generated this import map { + "imports": { + "chalk": "npm:chalk", + "chalk/": "npm:/chalk/" + }, + "scopes": { + "./packages/bar/": { + "@/": "./packages/bar/", + "secret_mod/": "./packages/bar/some_mod/" + }, + "./packages/foo/": { + "~/": "./packages/foo/", + "foo/": "./packages/foo/bar/" + } + } +} +[WILDCARD] +hello from foo +buzz from foo +hello from bar +buzz from bar +[Function: chalk][WILDCARD] \ No newline at end of file diff --git a/tests/specs/run/workspaces/wildcard/main.ts b/tests/specs/run/workspaces/wildcard/main.ts new file mode 100644 index 0000000000..e69143370d --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/main.ts @@ -0,0 +1,5 @@ +import chalk from "chalk"; +import "./packages/foo/mod.ts"; +import "./packages/bar/mod.ts"; + +console.log(chalk); diff --git a/tests/specs/run/workspaces/wildcard/packages/bar/deno.json b/tests/specs/run/workspaces/wildcard/packages/bar/deno.json new file mode 100644 index 0000000000..ef3bfc37af --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/packages/bar/deno.json @@ -0,0 +1,8 @@ +{ + "name": "asdfasdfasdf", + "version": "0.0.0", + "imports": { + "@/": "./", + "secret_mod/": "./some_mod/" + } +} diff --git a/tests/specs/run/workspaces/wildcard/packages/bar/fizz/buzz.ts b/tests/specs/run/workspaces/wildcard/packages/bar/fizz/buzz.ts new file mode 100644 index 0000000000..f88d62fcc8 --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/packages/bar/fizz/buzz.ts @@ -0,0 +1 @@ +export const buzz = "buzz from bar"; diff --git a/tests/specs/run/workspaces/wildcard/packages/bar/mod.ts b/tests/specs/run/workspaces/wildcard/packages/bar/mod.ts new file mode 100644 index 0000000000..6f898e3898 --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/packages/bar/mod.ts @@ -0,0 +1,5 @@ +import { hello } from "secret_mod/hello.ts"; +import { buzz } from "@/fizz/buzz.ts"; + +console.log(hello); +console.log(buzz); diff --git a/tests/specs/run/workspaces/wildcard/packages/bar/some_mod/hello.ts b/tests/specs/run/workspaces/wildcard/packages/bar/some_mod/hello.ts new file mode 100644 index 0000000000..1013de8d2e --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/packages/bar/some_mod/hello.ts @@ -0,0 +1 @@ +export const hello = "hello from bar"; diff --git a/tests/specs/run/workspaces/wildcard/packages/foo/bar/hello.ts b/tests/specs/run/workspaces/wildcard/packages/foo/bar/hello.ts new file mode 100644 index 0000000000..c8a7e57c4d --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/packages/foo/bar/hello.ts @@ -0,0 +1 @@ +export const hello = "hello from foo"; diff --git a/tests/specs/run/workspaces/wildcard/packages/foo/deno.json b/tests/specs/run/workspaces/wildcard/packages/foo/deno.json new file mode 100644 index 0000000000..46d84f06fa --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/packages/foo/deno.json @@ -0,0 +1,8 @@ +{ + "name": "qwerqwer", + "version": "0.0.0", + "imports": { + "~/": "./", + "foo/": "./bar/" + } +} diff --git a/tests/specs/run/workspaces/wildcard/packages/foo/fizz/buzz.ts b/tests/specs/run/workspaces/wildcard/packages/foo/fizz/buzz.ts new file mode 100644 index 0000000000..4e03777d1b --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/packages/foo/fizz/buzz.ts @@ -0,0 +1 @@ +export const buzz = "buzz from foo"; diff --git a/tests/specs/run/workspaces/wildcard/packages/foo/mod.ts b/tests/specs/run/workspaces/wildcard/packages/foo/mod.ts new file mode 100644 index 0000000000..d7b16dcc05 --- /dev/null +++ b/tests/specs/run/workspaces/wildcard/packages/foo/mod.ts @@ -0,0 +1,5 @@ +import { hello } from "foo/hello.ts"; +import { buzz } from "~/fizz/buzz.ts"; + +console.log(hello); +console.log(buzz); From 25ed90baaec420e6496593406494d3747d9a6db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 4 Nov 2024 23:56:09 +0000 Subject: [PATCH 28/40] ci: use self-hosted mac arm runner for building on tags (#26727) --- .github/workflows/ci.generate.ts | 4 +++- .github/workflows/ci.yml | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.generate.ts b/.github/workflows/ci.generate.ts index 49d11107d5..0faf08a1a8 100755 --- a/.github/workflows/ci.generate.ts +++ b/.github/workflows/ci.generate.ts @@ -14,6 +14,7 @@ const windowsX86Runner = "windows-2022"; const windowsX86XlRunner = "windows-2022-xl"; const macosX86Runner = "macos-13"; const macosArmRunner = "macos-14"; +const selfHostedMacosArmRunner = "self-hosted"; const Runners = { linuxX86: { @@ -40,7 +41,8 @@ const Runners = { macosArm: { os: "macos", arch: "aarch64", - runner: macosArmRunner, + runner: + `\${{ github.repository == 'denoland/deno' && startsWith(github.ref, 'refs/tags/') && '${selfHostedMacosArmRunner}' || '${macosArmRunner}' }}`, }, windowsX86: { os: "windows", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9c06de17a..5aafe89d27 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,12 +68,12 @@ jobs: skip: '${{ !contains(github.event.pull_request.labels.*.name, ''ci-full'') && (github.event_name == ''pull_request'') }}' - os: macos arch: aarch64 - runner: macos-14 + runner: '${{ github.repository == ''denoland/deno'' && startsWith(github.ref, ''refs/tags/'') && ''self-hosted'' || ''macos-14'' }}' job: test profile: debug - os: macos arch: aarch64 - runner: '${{ (!contains(github.event.pull_request.labels.*.name, ''ci-full'') && (github.event_name == ''pull_request'')) && ''ubuntu-24.04'' || ''macos-14'' }}' + runner: '${{ (!contains(github.event.pull_request.labels.*.name, ''ci-full'') && (github.event_name == ''pull_request'')) && ''ubuntu-24.04'' || github.repository == ''denoland/deno'' && startsWith(github.ref, ''refs/tags/'') && ''self-hosted'' || ''macos-14'' }}' job: test profile: release skip: '${{ !contains(github.event.pull_request.labels.*.name, ''ci-full'') && (github.event_name == ''pull_request'') }}' From 44eca0505c35201c6b67ba073834402b7681914f Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:09:17 -0800 Subject: [PATCH 29/40] chore: fix serve_watch_all test (#26725) It's been failing a ton lately, it looks like the test is just incorrectly using TS syntax in a JS file https://github.com/denoland/deno/actions/runs/11672972415/job/32502710624?pr=26724#step:43:2791 I'm not really sure how this ever passes --- tests/integration/watcher_tests.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/integration/watcher_tests.rs b/tests/integration/watcher_tests.rs index d4705b8d53..e8f264632d 100644 --- a/tests/integration/watcher_tests.rs +++ b/tests/integration/watcher_tests.rs @@ -572,16 +572,19 @@ async fn serve_watch_all() { let main_file_to_watch = t.path().join("main_file_to_watch.js"); main_file_to_watch.write( "export default { - fetch(_request: Request) { + fetch(_request) { return new Response(\"aaaaaaqqq!\"); }, };", ); + let another_file = t.path().join("another_file.js"); + another_file.write(""); + let mut child = util::deno_cmd() .current_dir(t.path()) .arg("serve") - .arg("--watch=another_file.js") + .arg(format!("--watch={another_file}")) .arg("-L") .arg("debug") .arg(&main_file_to_watch) @@ -596,7 +599,7 @@ async fn serve_watch_all() { // Change content of the file main_file_to_watch.write( "export default { - fetch(_request: Request) { + fetch(_request) { return new Response(\"aaaaaaqqq123!\"); }, };", @@ -604,18 +607,20 @@ async fn serve_watch_all() { wait_contains("Restarting", &mut stderr_lines).await; wait_for_watcher("main_file_to_watch.js", &mut stderr_lines).await; - let another_file = t.path().join("another_file.js"); another_file.write("export const foo = 0;"); // Confirm that the added file is watched as well wait_contains("Restarting", &mut stderr_lines).await; + wait_for_watcher("main_file_to_watch.js", &mut stderr_lines).await; main_file_to_watch .write("import { foo } from './another_file.js'; console.log(foo);"); wait_contains("Restarting", &mut stderr_lines).await; + wait_for_watcher("main_file_to_watch.js", &mut stderr_lines).await; wait_contains("0", &mut stdout_lines).await; another_file.write("export const foo = 42;"); wait_contains("Restarting", &mut stderr_lines).await; + wait_for_watcher("main_file_to_watch.js", &mut stderr_lines).await; wait_contains("42", &mut stdout_lines).await; // Confirm that watch continues even with wrong syntax error @@ -623,10 +628,11 @@ async fn serve_watch_all() { wait_contains("Restarting", &mut stderr_lines).await; wait_contains("error:", &mut stderr_lines).await; + wait_for_watcher("main_file_to_watch.js", &mut stderr_lines).await; main_file_to_watch.write( "export default { - fetch(_request: Request) { + fetch(_request) { return new Response(\"aaaaaaqqq!\"); }, };", From 706b1dfcea8ab6bf7d155893ab795669107516a8 Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Mon, 4 Nov 2024 18:45:00 -0800 Subject: [PATCH 30/40] fix(add): better error message when adding package that only has pre-release versions (#26724) Fixes https://github.com/denoland/deno/issues/26597 A small refactor as well to reduce some code duplication --- cli/tools/registry/pm.rs | 205 +++++++++++++----- .../@denotest/unstable/1.0.0-beta.1/mod.ts | 3 + .../@denotest/unstable/1.0.0-beta.1_meta.json | 5 + .../@denotest/unstable/1.0.0-beta.2/mod.ts | 3 + .../@denotest/unstable/1.0.0-beta.2_meta.json | 5 + .../registry/jsr/@denotest/unstable/meta.json | 6 + .../add/only_unstable_versions/__test__.jsonc | 23 +- .../add/only_unstable_versions/add_jsr.out | 1 + 8 files changed, 187 insertions(+), 64 deletions(-) create mode 100644 tests/registry/jsr/@denotest/unstable/1.0.0-beta.1/mod.ts create mode 100644 tests/registry/jsr/@denotest/unstable/1.0.0-beta.1_meta.json create mode 100644 tests/registry/jsr/@denotest/unstable/1.0.0-beta.2/mod.ts create mode 100644 tests/registry/jsr/@denotest/unstable/1.0.0-beta.2_meta.json create mode 100644 tests/registry/jsr/@denotest/unstable/meta.json create mode 100644 tests/specs/add/only_unstable_versions/add_jsr.out diff --git a/cli/tools/registry/pm.rs b/cli/tools/registry/pm.rs index 4e03879983..68913e2591 100644 --- a/cli/tools/registry/pm.rs +++ b/cli/tools/registry/pm.rs @@ -12,7 +12,9 @@ use deno_core::futures::StreamExt; use deno_path_util::url_to_file_path; use deno_semver::jsr::JsrPackageReqReference; use deno_semver::npm::NpmPackageReqReference; +use deno_semver::package::PackageNv; use deno_semver::package::PackageReq; +use deno_semver::Version; use deno_semver::VersionReq; use jsonc_parser::cst::CstObject; use jsonc_parser::cst::CstObjectProp; @@ -455,15 +457,32 @@ pub async fn add( match package_and_version { PackageAndVersion::NotFound { package: package_name, - found_npm_package, + help, package_req, - } => { - if found_npm_package { - bail!("{} was not found, but a matching npm package exists. Did you mean `{}`?", crate::colors::red(package_name), crate::colors::yellow(format!("deno {cmd_name} npm:{package_req}"))); - } else { - bail!("{} was not found.", crate::colors::red(package_name)); + } => match help { + Some(NotFoundHelp::NpmPackage) => { + bail!( + "{} was not found, but a matching npm package exists. Did you mean `{}`?", + crate::colors::red(package_name), + crate::colors::yellow(format!("deno {cmd_name} npm:{package_req}")) + ); } - } + Some(NotFoundHelp::JsrPackage) => { + bail!( + "{} was not found, but a matching jsr package exists. Did you mean `{}`?", + crate::colors::red(package_name), + crate::colors::yellow(format!("deno {cmd_name} jsr:{package_req}")) + ) + } + Some(NotFoundHelp::PreReleaseVersion(version)) => { + bail!( + "{} has only pre-release versions available. Try specifying a version: `{}`", + crate::colors::red(&package_name), + crate::colors::yellow(format!("deno {cmd_name} {package_name}@^{version}")) + ) + } + None => bail!("{} was not found.", crate::colors::red(package_name)), + }, PackageAndVersion::Selected(selected) => { selected_packages.push(selected); } @@ -511,76 +530,144 @@ struct SelectedPackage { selected_version: String, } +enum NotFoundHelp { + NpmPackage, + JsrPackage, + PreReleaseVersion(Version), +} + enum PackageAndVersion { NotFound { package: String, - found_npm_package: bool, package_req: PackageReq, + help: Option, }, Selected(SelectedPackage), } +fn best_version<'a>( + versions: impl Iterator, +) -> Option<&'a Version> { + let mut maybe_best_version: Option<&Version> = None; + for version in versions { + let is_best_version = maybe_best_version + .as_ref() + .map(|best_version| (*best_version).cmp(version).is_lt()) + .unwrap_or(true); + if is_best_version { + maybe_best_version = Some(version); + } + } + maybe_best_version +} + +trait PackageInfoProvider { + const SPECIFIER_PREFIX: &str; + /// The help to return if a package is found by this provider + const HELP: NotFoundHelp; + async fn req_to_nv(&self, req: &PackageReq) -> Option; + async fn latest_version<'a>(&self, req: &PackageReq) -> Option; +} + +impl PackageInfoProvider for Arc { + const HELP: NotFoundHelp = NotFoundHelp::JsrPackage; + const SPECIFIER_PREFIX: &str = "jsr"; + async fn req_to_nv(&self, req: &PackageReq) -> Option { + (**self).req_to_nv(req).await + } + + async fn latest_version<'a>(&self, req: &PackageReq) -> Option { + let info = self.package_info(&req.name).await?; + best_version( + info + .versions + .iter() + .filter(|(_, version_info)| !version_info.yanked) + .map(|(version, _)| version), + ) + .cloned() + } +} + +impl PackageInfoProvider for Arc { + const HELP: NotFoundHelp = NotFoundHelp::NpmPackage; + const SPECIFIER_PREFIX: &str = "npm"; + async fn req_to_nv(&self, req: &PackageReq) -> Option { + (**self).req_to_nv(req).await + } + + async fn latest_version<'a>(&self, req: &PackageReq) -> Option { + let info = self.package_info(&req.name).await?; + best_version(info.versions.keys()).cloned() + } +} + async fn find_package_and_select_version_for_req( jsr_resolver: Arc, npm_resolver: Arc, add_package_req: AddRmPackageReq, ) -> Result { - match add_package_req.value { - AddRmPackageReqValue::Jsr(req) => { - let jsr_prefixed_name = format!("jsr:{}", &req.name); - let Some(nv) = jsr_resolver.req_to_nv(&req).await else { - if npm_resolver.req_to_nv(&req).await.is_some() { + async fn select( + main_resolver: T, + fallback_resolver: S, + add_package_req: AddRmPackageReq, + ) -> Result { + let req = match &add_package_req.value { + AddRmPackageReqValue::Jsr(req) => req, + AddRmPackageReqValue::Npm(req) => req, + }; + let prefixed_name = format!("{}:{}", T::SPECIFIER_PREFIX, req.name); + let help_if_found_in_fallback = S::HELP; + let Some(nv) = main_resolver.req_to_nv(req).await else { + if fallback_resolver.req_to_nv(req).await.is_some() { + // it's in the other registry + return Ok(PackageAndVersion::NotFound { + package: prefixed_name, + help: Some(help_if_found_in_fallback), + package_req: req.clone(), + }); + } + if req.version_req.version_text() == "*" { + if let Some(pre_release_version) = + main_resolver.latest_version(req).await + { return Ok(PackageAndVersion::NotFound { - package: jsr_prefixed_name, - found_npm_package: true, - package_req: req, + package: prefixed_name, + package_req: req.clone(), + help: Some(NotFoundHelp::PreReleaseVersion( + pre_release_version.clone(), + )), }); } + } - return Ok(PackageAndVersion::NotFound { - package: jsr_prefixed_name, - found_npm_package: false, - package_req: req, - }); - }; - let range_symbol = if req.version_req.version_text().starts_with('~') { - "~" - } else if req.version_req.version_text() == nv.version.to_string() { - "" - } else { - "^" - }; - Ok(PackageAndVersion::Selected(SelectedPackage { - import_name: add_package_req.alias, - package_name: jsr_prefixed_name, - version_req: format!("{}{}", range_symbol, &nv.version), - selected_version: nv.version.to_string(), - })) + return Ok(PackageAndVersion::NotFound { + package: prefixed_name, + help: None, + package_req: req.clone(), + }); + }; + let range_symbol = if req.version_req.version_text().starts_with('~') { + "~" + } else if req.version_req.version_text() == nv.version.to_string() { + "" + } else { + "^" + }; + Ok(PackageAndVersion::Selected(SelectedPackage { + import_name: add_package_req.alias, + package_name: prefixed_name, + version_req: format!("{}{}", range_symbol, &nv.version), + selected_version: nv.version.to_string(), + })) + } + + match &add_package_req.value { + AddRmPackageReqValue::Jsr(_) => { + select(jsr_resolver, npm_resolver, add_package_req).await } - AddRmPackageReqValue::Npm(req) => { - let npm_prefixed_name = format!("npm:{}", &req.name); - let Some(nv) = npm_resolver.req_to_nv(&req).await else { - return Ok(PackageAndVersion::NotFound { - package: npm_prefixed_name, - found_npm_package: false, - package_req: req, - }); - }; - - let range_symbol = if req.version_req.version_text().starts_with('~') { - "~" - } else if req.version_req.version_text() == nv.version.to_string() { - "" - } else { - "^" - }; - - Ok(PackageAndVersion::Selected(SelectedPackage { - import_name: add_package_req.alias, - package_name: npm_prefixed_name, - version_req: format!("{}{}", range_symbol, &nv.version), - selected_version: nv.version.to_string(), - })) + AddRmPackageReqValue::Npm(_) => { + select(npm_resolver, jsr_resolver, add_package_req).await } } } diff --git a/tests/registry/jsr/@denotest/unstable/1.0.0-beta.1/mod.ts b/tests/registry/jsr/@denotest/unstable/1.0.0-beta.1/mod.ts new file mode 100644 index 0000000000..de63686189 --- /dev/null +++ b/tests/registry/jsr/@denotest/unstable/1.0.0-beta.1/mod.ts @@ -0,0 +1,3 @@ +export function doThing() { + return "thing"; +} \ No newline at end of file diff --git a/tests/registry/jsr/@denotest/unstable/1.0.0-beta.1_meta.json b/tests/registry/jsr/@denotest/unstable/1.0.0-beta.1_meta.json new file mode 100644 index 0000000000..631a18d0e5 --- /dev/null +++ b/tests/registry/jsr/@denotest/unstable/1.0.0-beta.1_meta.json @@ -0,0 +1,5 @@ +{ + "exports": { + ".": "./mod.ts" + } +} diff --git a/tests/registry/jsr/@denotest/unstable/1.0.0-beta.2/mod.ts b/tests/registry/jsr/@denotest/unstable/1.0.0-beta.2/mod.ts new file mode 100644 index 0000000000..4e599641ef --- /dev/null +++ b/tests/registry/jsr/@denotest/unstable/1.0.0-beta.2/mod.ts @@ -0,0 +1,3 @@ +export function doThing() { + return "thing2"; +} \ No newline at end of file diff --git a/tests/registry/jsr/@denotest/unstable/1.0.0-beta.2_meta.json b/tests/registry/jsr/@denotest/unstable/1.0.0-beta.2_meta.json new file mode 100644 index 0000000000..631a18d0e5 --- /dev/null +++ b/tests/registry/jsr/@denotest/unstable/1.0.0-beta.2_meta.json @@ -0,0 +1,5 @@ +{ + "exports": { + ".": "./mod.ts" + } +} diff --git a/tests/registry/jsr/@denotest/unstable/meta.json b/tests/registry/jsr/@denotest/unstable/meta.json new file mode 100644 index 0000000000..7c5c9971ef --- /dev/null +++ b/tests/registry/jsr/@denotest/unstable/meta.json @@ -0,0 +1,6 @@ +{ + "versions": { + "1.0.0-beta.1": {}, + "1.0.0-beta.2": {} + } +} diff --git a/tests/specs/add/only_unstable_versions/__test__.jsonc b/tests/specs/add/only_unstable_versions/__test__.jsonc index d05628b6f5..ea5a270b9c 100644 --- a/tests/specs/add/only_unstable_versions/__test__.jsonc +++ b/tests/specs/add/only_unstable_versions/__test__.jsonc @@ -1,9 +1,22 @@ { "tempDir": true, - "steps": [ - { - "args": "add npm:@denotest/unstable", - "output": "add.out" + "tests": { + "npm_package": { + "steps": [ + { + "args": "add npm:@denotest/unstable", + "output": "add.out" + } + ] + }, + "jsr_package": { + "steps": [ + { + "args": "add jsr:@denotest/unstable", + "output": "add_jsr.out", + "exitCode": 1 + } + ] } - ] + } } diff --git a/tests/specs/add/only_unstable_versions/add_jsr.out b/tests/specs/add/only_unstable_versions/add_jsr.out new file mode 100644 index 0000000000..95f0630bf3 --- /dev/null +++ b/tests/specs/add/only_unstable_versions/add_jsr.out @@ -0,0 +1 @@ +error: jsr:@denotest/unstable has only pre-release versions available. Try specifying a version: `deno add jsr:@denotest/unstable@^1.0.0-beta.2` From 383cb85a730e42a2951ead84233ccef0ed3a23e8 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Tue, 5 Nov 2024 09:13:54 +0530 Subject: [PATCH 31/40] fix: op_run_microtasks crash (#26718) Upgrade deno_core to 0.318.0 Fixes https://github.com/denoland/deno_core/issues/951 Fixes https://github.com/denoland/deno/issues/26468 --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c22d49c41c..73d417baae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1418,9 +1418,9 @@ dependencies = [ [[package]] name = "deno_core" -version = "0.316.0" +version = "0.318.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94f68061c88ced959c6b0417f0f0d0b3dbeaeb18013b55f86c505e9fba705cf8" +checksum = "10cae2393219ff9278123f7b24799cdfab37c7d6561b69ca06ced115cac92111" dependencies = [ "anyhow", "bincode", @@ -1921,9 +1921,9 @@ dependencies = [ [[package]] name = "deno_ops" -version = "0.192.0" +version = "0.194.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb7096887508456349d7e7e09e326d157d4dba46ef1f5849bc544592ea3042a" +checksum = "f760b492bd638c1dc3e992d11672c259fbe9a233162099a8347591c9e22d0391" dependencies = [ "proc-macro-rules", "proc-macro2", @@ -6170,9 +6170,9 @@ dependencies = [ [[package]] name = "serde_v8" -version = "0.225.0" +version = "0.227.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce4b71200ef49a9e629edaea3d13fc98c25ede07e1496558df7f09354e37976f" +checksum = "0a8294c2223c53bed343be8b80564ece4dc0d03b643b06fa86c4ccc0e064eda0" dependencies = [ "num-bigint", "serde", diff --git a/Cargo.toml b/Cargo.toml index f57563e0b8..28ef2829e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ repository = "https://github.com/denoland/deno" [workspace.dependencies] deno_ast = { version = "=0.43.3", features = ["transpiling"] } -deno_core = { version = "0.316.0" } +deno_core = { version = "0.318.0" } deno_bench_util = { version = "0.169.0", path = "./bench_util" } deno_lockfile = "=0.23.1" From f9a05068d6de247574fb764044a446d1d7ed2e9b Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Mon, 4 Nov 2024 20:16:53 -0800 Subject: [PATCH 32/40] fix(install): handle invalid function error, and fallback to junctions regardless of the error (#26730) Fixes #26116. Handle the new error and treat is as lacking permission to make symlinks, but also to make this more robust, just always fall back to junctions no matter what the actual error is. Instead, warn if the error isn't one we've handled, but go on to attempt creating the junction --- cli/npm/managed/resolvers/local.rs | 16 +++++++++++----- cli/util/fs.rs | 4 +++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cli/npm/managed/resolvers/local.rs b/cli/npm/managed/resolvers/local.rs index 0968be8a7e..eddb0dc9b6 100644 --- a/cli/npm/managed/resolvers/local.rs +++ b/cli/npm/managed/resolvers/local.rs @@ -1035,12 +1035,18 @@ fn junction_or_symlink_dir( if symlink_err.kind() == std::io::ErrorKind::PermissionDenied => { USE_JUNCTIONS.store(true, std::sync::atomic::Ordering::Relaxed); - junction::create(old_path, new_path).map_err(Into::into) + junction::create(old_path, new_path) + .context("Failed creating junction in node_modules folder") + } + Err(symlink_err) => { + log::warn!( + "{} Unexpected error symlinking node_modules: {symlink_err}", + colors::yellow("Warning") + ); + USE_JUNCTIONS.store(true, std::sync::atomic::Ordering::Relaxed); + junction::create(old_path, new_path) + .context("Failed creating junction in node_modules folder") } - Err(symlink_err) => Err( - AnyError::from(symlink_err) - .context("Failed creating symlink in node_modules folder"), - ), } } diff --git a/cli/util/fs.rs b/cli/util/fs.rs index 2c34f486ad..d36c02242c 100644 --- a/cli/util/fs.rs +++ b/cli/util/fs.rs @@ -565,7 +565,9 @@ pub fn symlink_dir(oldpath: &Path, newpath: &Path) -> Result<(), Error> { use std::os::windows::fs::symlink_dir; symlink_dir(oldpath, newpath).map_err(|err| { if let Some(code) = err.raw_os_error() { - if code as u32 == winapi::shared::winerror::ERROR_PRIVILEGE_NOT_HELD { + if code as u32 == winapi::shared::winerror::ERROR_PRIVILEGE_NOT_HELD + || code as u32 == winapi::shared::winerror::ERROR_INVALID_FUNCTION + { return err_mapper(err, Some(ErrorKind::PermissionDenied)); } } From 89f0b796bd442ff352c3f93f69156ca6d85bfd5e Mon Sep 17 00:00:00 2001 From: Mohammad Sulaiman Date: Tue, 5 Nov 2024 08:39:05 +0200 Subject: [PATCH 33/40] chore: deprecate run itests (#26444) --- .dprint.json | 6 +- tests/integration/run_tests.rs | 1801 ----------------- tests/specs/run/_001_hello/001_hello.js | 1 + .../run/_001_hello}/001_hello.js.out | 0 tests/specs/run/_001_hello/__test__.jsonc | 4 + tests/specs/run/_002_hello/002_hello.ts | 1 + .../run/_002_hello}/002_hello.ts.out | 0 tests/specs/run/_002_hello/__test__.jsonc | 4 + .../003_relative_import.ts | 3 + .../003_relative_import.ts.out | 0 .../run/_003_relative_import/__test__.jsonc | 4 + .../run/_003_relative_import/print_hello.ts | 3 + .../run/_004_set_timeout}/004_set_timeout.ts | 0 .../_004_set_timeout}/004_set_timeout.ts.out | 0 .../specs/run/_004_set_timeout/__test__.jsonc | 4 + .../_005_more_imports}/005_more_imports.ts | 2 +- .../005_more_imports.ts.out | 0 .../run/_005_more_imports/__test__.jsonc | 4 + tests/specs/run/_005_more_imports/mod1.ts | 17 + .../run/_005_more_imports/print_hello.ts | 3 + .../run/_005_more_imports/subdir2/mod2.ts | 9 + .../run/_006_url_imports/006_url_imports.ts | 3 + .../_006_url_imports/006_url_imports.ts.out | 2 + .../specs/run/_006_url_imports/__test__.jsonc | 4 + .../specs/run/_006_url_imports/print_hello.ts | 3 + .../run/_006_url_imports/subdir2/mod2.ts | 9 + .../run => specs/run/_012_async}/012_async.ts | 0 .../run/_012_async}/012_async.ts.out | 0 tests/specs/run/_012_async/__test__.jsonc | 4 + .../_013_dynamic_import/013_dynamic_import.ts | 15 + .../013_dynamic_import.ts.out | 0 .../run/_013_dynamic_import/__test__.jsonc | 4 + tests/specs/run/_013_dynamic_import/mod1.ts | 17 + .../run/_013_dynamic_import/print_hello.ts | 3 + .../run/_013_dynamic_import/subdir2/mod2.ts | 9 + .../014_duplicate_import.ts | 9 + .../014_duplicate_import.ts.out | 0 .../run/_014_duplicate_import/__test__.jsonc | 4 + .../_014_duplicate_import/auto_print_hello.ts | 2 + .../015_duplicate_parallel_import.js | 2 +- .../015_duplicate_parallel_import.js.out | 0 .../__test__.jsonc | 4 + .../_015_duplicate_parallel_import/mod1.ts | 17 + .../print_hello.ts | 3 + .../subdir2/mod2.ts | 9 + .../_016_double_await}/016_double_await.ts | 0 .../016_double_await.ts.out | 0 .../run/_016_double_await/__test__.jsonc | 4 + .../017_import_redirect.ts | 4 + .../017_import_redirect.ts.out | 0 .../run/_017_import_redirect/__test__.jsonc | 4 + .../017_import_redirect.ts | 4 + .../017_import_redirect.ts.out} | 0 .../_017_import_redirect_check/__test__.jsonc | 4 + .../017_import_redirect.ts | 4 + .../017_import_redirect_info.out | 0 .../_017_import_redirect_info/__test__.jsonc | 4 + .../017_import_redirect.ts | 4 + .../017_import_redirect.ts.out} | 0 .../__test__.jsonc | 4 + .../run/_018_async_catch}/018_async_catch.ts | 0 .../_018_async_catch}/018_async_catch.ts.out | 0 .../specs/run/_018_async_catch/__test__.jsonc | 4 + .../run/_019_media_types/019_media_types.ts | 24 + .../_019_media_types}/019_media_types.ts.out | 0 .../specs/run/_019_media_types/__test__.jsonc | 4 + .../run/_020_json_modules/020_json_modules.ts | 2 + .../020_json_modules.ts.out | 2 +- .../run/_020_json_modules/__test__.jsonc | 5 + tests/specs/run/_020_json_modules/config.json | 6 + .../run/_021_mjs_modules/021_mjs_modules.ts | 2 + .../_021_mjs_modules}/021_mjs_modules.ts.out | 0 .../specs/run/_021_mjs_modules/__test__.jsonc | 4 + tests/specs/run/_021_mjs_modules/mod5.mjs | 1 + .../025_reload_js_type_error.js | 0 .../025_reload_js_type_error.js.out | 0 .../_025_reload_js_type_error/__test__.jsonc | 4 + .../027_redirect_typescript.ts | 0 .../027_redirect_typescript.ts.out | 0 .../_027_redirect_typescript/__test__.jsonc | 4 + .../027_redirect_typescript.ts | 2 + .../027_redirect_typescript.ts.out | 1 + .../__test__.jsonc | 4 + .../subdir/redirects/redirect1.ts | 1 + .../subdir/redirects/redirect4.ts | 2 + .../vendor/manifest.json | 9 + .../run => specs/run/_028_args}/028_args.ts | 0 .../run/_028_args}/028_args.ts.out | 0 tests/specs/run/_028_args/__test__.jsonc | 4 + .../_033_import_map_data_uri/__test__.jsonc | 4 + .../_033_import_map_data_uri/lodash/lodash.ts | 1 + .../lodash/other_file.ts | 1 + .../_033_import_map_data_uri}/test_data.ts | 0 .../test_data.ts.out | 0 .../033_import_map_remote.out | 0 .../run/_033_import_map_remote/__test__.jsonc | 4 + .../import_map_remote.json | 10 + .../_033_import_map_remote/lodash/lodash.ts | 1 + .../lodash/other_file.ts | 1 + .../_033_import_map_remote/moment/moment.ts | 1 + .../moment/other_file.ts | 1 + .../run/_033_import_map_remote/print_hello.ts | 3 + .../run/_033_import_map_remote/test_remote.ts | 5 + tests/specs/run/_033_import_map_remote/vue.ts | 1 + .../033_import_map_remote.out | 5 + .../__test__.jsonc | 4 + .../import_map_remote.json | 10 + .../lodash/lodash.ts | 1 + .../lodash/other_file.ts | 1 + .../moment/moment.ts | 1 + .../moment/other_file.ts | 1 + .../print_hello.ts | 3 + .../test_remote.ts | 5 + .../_033_import_map_vendor_dir_remote/vue.ts | 1 + .../_035_cached_only_flag/019_media_types.ts | 24 + .../035_cached_only_flag.out | 1 + .../run/_035_cached_only_flag/__test__.jsonc | 5 + .../run/_038_checkjs}/038_checkjs.js | 0 .../run/_038_checkjs}/038_checkjs.js.out | 0 tests/specs/run/_038_checkjs/__test__.jsonc | 6 + .../run/_038_checkjs/checkjs.tsconfig.json | 5 + .../042_dyn_import_evalcontext.ts | 2 +- .../042_dyn_import_evalcontext.ts.out | 0 .../__test__.jsonc | 4 + .../run/_042_dyn_import_evalcontext/mod4.js | 1 + .../run/_044_bad_resource/044_bad_resource.ts | 3 + .../044_bad_resource.ts.out | 0 .../run/_044_bad_resource/__test__.jsonc | 5 + .../run/_046_tsx}/046_jsx_test.tsx | 0 .../run/_046_tsx}/046_jsx_test.tsx.out | 0 tests/specs/run/_046_tsx/__test__.jsonc | 4 + .../run/_047_jsx}/047_jsx_test.jsx | 0 .../run/_047_jsx}/047_jsx_test.jsx.out | 0 tests/specs/run/_047_jsx/__test__.jsonc | 4 + .../048_media_types_jsx.ts | 32 + .../048_media_types_jsx.ts.out | 0 .../run/_048_media_types_jsx/__test__.jsonc | 4 + .../_052_no_remote_flag/019_media_types.ts | 24 + .../052_no_remote_flag.out | 2 +- .../run/_052_no_remote_flag/__test__.jsonc | 5 + .../058_tasks_microtasks_close.ts | 0 .../058_tasks_microtasks_close.ts.out | 0 .../__test__.jsonc | 4 + .../059_fs_relative_path_perm.ts | 0 .../059_fs_relative_path_perm.ts.out | 0 .../_059_fs_relative_path_perm/__test__.jsonc | 5 + .../063_permissions_revoke.ts | 0 .../063_permissions_revoke.ts.out | 0 .../_063_permissions_revoke/__test__.jsonc | 4 + .../063_permissions_revoke.ts.out | 3 + .../063_permissions_revoke_sync.ts | 0 .../__test__.jsonc | 4 + .../064_permissions_revoke_global.ts | 0 .../064_permissions_revoke_global.ts.out | 0 .../__test__.jsonc | 4 + .../064_permissions_revoke_global.ts.out | 3 + .../064_permissions_revoke_global_sync.ts | 0 .../__test__.jsonc | 4 + .../065_permissions_revoke_net.ts | 0 .../065_permissions_revoke_net.ts.out | 0 .../__test__.jsonc | 4 + .../run/_070_location}/070_location.ts | 0 .../run/_070_location}/070_location.ts.out | 0 tests/specs/run/_070_location/__test__.jsonc | 4 + .../071_location_unset.ts | 0 .../071_location_unset.ts.out | 0 .../run/_071_location_unset/__test__.jsonc | 4 + .../072_location_relative_fetch.ts | 0 .../072_location_relative_fetch.ts.out | 0 .../__test__.jsonc | 4 + .../fetch/hello.txt | 1 + .../_075_import_local_query_hash/001_hello.js | 1 + .../_075_import_local_query_hash/002_hello.ts | 1 + .../075_import_local_query_hash.ts | 0 .../075_import_local_query_hash.ts.out | 0 .../__test__.jsonc | 4 + .../run/_077_fetch_empty}/077_fetch_empty.ts | 0 .../_077_fetch_empty}/077_fetch_empty.ts.out | 0 .../specs/run/_077_fetch_empty/__test__.jsonc | 5 + .../078_unload_on_exit.ts | 0 .../078_unload_on_exit.ts.out | 0 .../run/_078_unload_on_exit/__test__.jsonc | 5 + .../079_location_authentication.ts | 0 .../079_location_authentication.ts.out | 0 .../__test__.jsonc | 4 + .../081_location_relative_fetch_redirect.ts | 0 ...81_location_relative_fetch_redirect.ts.out | 0 .../__test__.jsonc | 4 + .../082_prepare_stack_trace_throw.js | 0 .../082_prepare_stack_trace_throw.js.out | 0 .../__test__.jsonc | 5 + .../088_dynamic_import_already_evaluating.ts | 0 ...8_dynamic_import_already_evaluating.ts.out | 0 .../088_dynamic_import_target.ts | 3 + .../__test__.jsonc | 4 + .../091_use_define_for_class_fields.ts | 0 .../091_use_define_for_class_fields.ts.out | 0 .../__test__.jsonc | 5 + .../specs/run/aggregate_error/__test__.jsonc | 5 + .../run/aggregate_error}/aggregate_error.out | 0 .../run/aggregate_error}/aggregate_error.ts | 0 tests/specs/run/async_error/__test__.jsonc | 5 + .../run/async_error}/async_error.ts | 0 .../run/async_error}/async_error.ts.out | 0 .../run/beforeunload_event/__test__.jsonc | 4 + .../run/beforeunload_event}/before_unload.js | 0 .../beforeunload_event}/before_unload.js.out | 0 .../run/blob_gc_finalization/__test__.jsonc | 5 + .../blob_gc_finalization.js | 0 .../blob_gc_finalization.js.out | 0 tests/specs/run/byte_order_mark/001_hello.js | 1 + .../specs/run/byte_order_mark/__test__.jsonc | 4 + .../run/byte_order_mark}/byte_order_mark.out | 0 .../run/byte_order_mark}/byte_order_mark.ts | 2 +- .../run/check_js_points_to_ts/__test__.jsonc | 5 + .../check_js_points_to_ts/bar.ts | 0 .../check_js_points_to_ts/foo.d.ts | 0 .../check_js_points_to_ts/foo.js | 0 .../check_js_points_to_ts/test.js | 0 .../check_js_points_to_ts/test.js.out | 0 .../checkjs.tsconfig.json | 5 + tests/specs/run/check_remote/__test__.jsonc | 5 + .../specs/run/check_remote/no_check_remote.ts | 3 + .../no_check_remote.ts.disabled.out | 2 +- tests/specs/run/check_remote/type_error.ts | 1 + .../classic_workers_event_loop/__test__.jsonc | 4 + .../classic_workers_event_loop.js | 0 .../classic_workers_event_loop.js.out | 0 .../colors_without_global_this/__test__.jsonc | 4 + .../colors_without_globalThis.js | 0 tests/specs/run/complex_error/__test__.jsonc | 5 + .../run/complex_error}/complex_error.ts | 0 .../run/complex_error}/complex_error.ts.out | 0 tests/specs/run/config/__test__.jsonc | 4 + .../run => specs/run/config}/config/main.out | 0 .../run => specs/run/config}/config/main.ts | 0 .../run/config}/config/tsconfig.json | 0 .../__test__.jsonc | 4 + .../frontend_work.ts | 0 .../__test__.jsonc | 4 + .../auto_discovery_log.out | 0 .../deno.jsonc | 0 .../frontend_work.ts | 4 + .../run/config_json_import/__test__.jsonc | 4 + .../config_json_import/config_json_import.ts | 2 + .../config_json_import.ts.out | 0 .../run/config_json_import/deno-jsx.json | 6 + .../__test__.jsonc | 4 + .../server_side_work.ts | 0 tests/specs/run/config_types/__test__.jsonc | 4 + .../run/config_types/config_types/deno.lock | 6 + .../run/config_types}/config_types/main.out | 0 .../run/config_types}/config_types/main.ts | 0 .../config_types/remote.tsconfig.json | 0 .../config_types}/config_types/tsconfig.json | 0 .../run/config_types/config_types/types.d.ts | 2 + .../run/config_types_remote/__test__.jsonc | 4 + .../config_types/deno.lock | 6 + .../config_types/main.out} | 0 .../config_types_remote/config_types/main.ts | 1 + .../config_types/remote.tsconfig.json | 7 + .../config_types/tsconfig.json | 7 + .../config_types/types.d.ts | 2 + .../run/custom_inspect_url/__test__.jsonc | 4 + .../custom_inspect_url}/custom_inspect_url.js | 0 .../custom_inspect_url.js.out | 0 .../decorators_tc39_proposal/__test__.jsonc | 4 + .../decorators/experimental/deno.json | 0 .../decorators/experimental/no_check/main.out | 0 .../decorators/experimental/no_check/main.ts | 0 .../decorators/experimental/runtime/main.out | 0 .../decorators/experimental/runtime/main.ts | 0 .../decorators/experimental/ts/main.out | 0 .../decorators/experimental/ts/main.ts | 0 .../decorators/tc39_proposal/main.out | 0 .../decorators/tc39_proposal/main.ts | 0 .../run/deno_exit_tampering/__test__.jsonc | 5 + .../deno_exit_tampering.ts | 0 .../deny_all_permission_args/__test__.jsonc | 4 + .../deny_all_permission_args.js | 0 .../deny_all_permission_args.out | 0 .../deny_some_permission_args/__test__.jsonc | 4 + .../deny_some_permission_args.js | 0 .../deny_some_permission_args.out | 0 .../dom_exception_formatting/__test__.jsonc | 5 + .../dom_exception_formatting.ts | 0 .../dom_exception_formatting.ts.out | 0 .../__test__.jsonc | 4 + .../error_001.ts | 0 .../dynamic_import_already_rejected/main.out | 0 .../dynamic_import_already_rejected/main.ts | 0 .../dynamic_import_async_error/__test__.jsonc | 4 + .../delayed_error.ts | 0 .../dynamic_import_async_error/main.out | 0 .../dynamic_import_async_error/main.ts | 0 .../__test__.jsonc | 4 + .../main.out | 0 .../main.ts | 0 .../mod.ts | 0 .../dynamic_import_conditional/__test__.jsonc | 4 + .../dynamic_import_conditional.js | 0 .../dynamic_import_conditional.js.out | 0 .../__test__.jsonc | 5 + .../permissions_blob_local.ts | 6 + .../permissions_blob_local.ts.out | 5 + .../__test__.jsonc | 5 + .../permissions_blob_remote.ts | 3 + .../permissions_blob_remote.ts.out | 5 + .../__test__.jsonc | 5 + .../permissions_data_local.ts | 5 + .../permissions_data_local.ts.out | 5 + .../__test__.jsonc | 5 + .../permissions_data_remote.ts | 3 + .../permissions_data_remote.ts.out | 5 + .../__test__.jsonc | 5 + .../permissions_remote_remote.ts | 3 + .../permissions_remote_remote.ts.out | 5 + .../static_remote.ts | 2 + .../__test__.jsonc | 4 + .../empty_1.ts} | 0 .../empty_2.ts} | 0 .../static_analysis_no_permissions.ts | 13 + .../static_analysis_no_permissions.ts.out | 2 + .../__test__.jsonc | 5 + .../dynamic_import_syntax_error.js | 0 .../dynamic_import_syntax_error.js.out | 0 .../dynamic_import_syntax_error_import.js | 5 + .../specs/run/empty_typescript/__test__.jsonc | 4 + .../run/empty_typescript/empty.ts} | 0 tests/specs/run/error_001/__test__.jsonc | 5 + tests/specs/run/error_001/error_001.ts | 9 + .../run/error_001}/error_001.ts.out | 0 tests/specs/run/error_002/__test__.jsonc | 5 + tests/specs/run/error_002/error_002.ts | 7 + .../run/error_002}/error_002.ts.out | 2 +- tests/specs/run/error_002/mod1.ts | 17 + tests/specs/run/error_002/print_hello.ts | 3 + tests/specs/run/error_002/subdir2/mod2.ts | 9 + .../run/error_003_typescript/__test__.jsonc | 5 + .../error_003_typescript.ts | 0 .../error_003_typescript.ts.out | 0 .../run/error_003_typescript2/__test__.jsonc | 5 + .../error_003_typescript.ts | 20 + .../error_003_typescript.ts.out | 7 + .../error_004_missing_module/__test__.jsonc | 5 + .../error_004_missing_module.ts | 0 .../error_004_missing_module.ts.out | 0 .../__test__.jsonc | 5 + .../error_005_missing_dynamic_import.ts | 0 .../error_005_missing_dynamic_import.ts.out | 0 .../__test__.jsonc | 5 + .../error_006_import_ext_failure.ts | 0 .../error_006_import_ext_failure.ts.out | 0 tests/specs/run/error_007_any/__test__.jsonc | 5 + .../run/error_007_any}/error_007_any.ts | 0 .../run/error_007_any}/error_007_any.ts.out | 0 .../run/error_008_checkjs/__test__.jsonc | 5 + .../error_008_checkjs}/error_008_checkjs.js | 0 .../error_008_checkjs.js.out | 0 .../error_009_extensions_error/__test__.jsonc | 5 + .../error_009_extensions_error.js | 0 .../error_009_extensions_error.js.out | 0 .../__test__.jsonc | 5 + .../error_011_bad_module_specifier.ts | 0 .../error_011_bad_module_specifier.ts.out | 0 .../__test__.jsonc | 5 + .../error_012_bad_dynamic_import_specifier.ts | 0 ...or_012_bad_dynamic_import_specifier.ts.out | 0 .../__test__.jsonc | 4 + .../error_014_catch_dynamic_import_error.js | 6 +- ...rror_014_catch_dynamic_import_error.js.out | 6 +- .../indirect_import_error.js | 1 + .../indirect_throws.js | 1 + .../throws.js | 6 + .../__test__.jsonc | 5 + .../error_015_dynamic_import_permissions.js | 3 + .../error_015_dynamic_import_permissions.out | 2 +- .../mod4.js | 1 + .../__test__.jsonc | 5 + .../error_017_hide_long_source_ts.ts | 0 .../error_017_hide_long_source_ts.ts.out | 0 .../__test__.jsonc | 5 + .../error_018_hide_long_source_js.js | 0 .../error_018_hide_long_source_js.js.out | 0 .../error_019_stack_function/__test__.jsonc | 5 + .../error_019_stack_function.ts | 0 .../error_019_stack_function.ts.out | 0 .../__test__.jsonc | 5 + .../error_020_stack_constructor.ts | 0 .../error_020_stack_constructor.ts.out | 0 .../run/error_021_stack_method/__test__.jsonc | 5 + .../error_021_stack_method.ts | 0 .../error_021_stack_method.ts.out | 0 .../__test__.jsonc | 5 + .../error_022_stack_custom_error.ts | 0 .../error_022_stack_custom_error.ts.out | 0 .../run/error_023_stack_async/__test__.jsonc | 5 + .../error_023_stack_async.ts | 0 .../error_023_stack_async.ts.out | 0 .../__test__.jsonc | 5 + .../error_024_stack_promise_all.ts | 0 .../error_024_stack_promise_all.ts.out | 0 .../run/error_025_tab_indent/__test__.jsonc | 5 + .../error_025_tab_indent | 0 .../error_025_tab_indent.out | 0 tests/specs/run/error_cause/__test__.jsonc | 5 + .../run/error_cause}/error_cause.ts | 0 .../run/error_cause}/error_cause.ts.out | 0 .../run/error_cause_recursive/__test__.jsonc | 5 + .../error_cause_recursive.ts | 0 .../error_cause_recursive.ts.out | 0 .../__test__.jsonc | 5 + .../error_cause_recursive_aggregate.ts | 0 .../error_cause_recursive_aggregate.ts.out | 0 .../error_cause_recursive_tail/__test__.jsonc | 5 + .../error_cause_recursive_tail.ts | 0 .../error_cause_recursive_tail.ts.out | 0 .../specs/run/error_for_await/__test__.jsonc | 5 + .../run/error_for_await}/error_for_await.ts | 0 .../error_for_await}/error_for_await.ts.out | 0 .../__test__.jsonc | 5 + .../error_import_map_unable_to_load.out | 0 .../import_maps/test_data.ts | 1 + .../import_maps/test_data.ts.out | 1 + .../__test__.jsonc | 5 + .../error_missing_module_named_import.ts | 0 .../error_missing_module_named_import.ts.out | 0 .../run/error_name_non_string/__test__.jsonc | 5 + .../error_name_non_string.js | 0 .../error_name_non_string.js.out | 0 tests/specs/run/error_no_check/__test__.jsonc | 5 + .../run/error_no_check/error_no_check.ts | 1 + .../run/error_no_check/error_no_check.ts.out | 2 + .../specs/run/error_no_check/type_and_code.ts | 7 + tests/specs/run/error_syntax/__test__.jsonc | 5 + .../run/error_syntax}/error_syntax.js | 0 .../run/error_syntax}/error_syntax.js.out | 0 .../__test__.jsonc | 5 + .../error_syntax_empty_trailing_line.mjs | 0 .../error_syntax_empty_trailing_line.mjs.out | 0 .../run/error_type_definitions/__test__.jsonc | 5 + .../error_type_definitions.ts | 5 + .../error_type_definitions.ts.out | 0 .../type_definitions/bar.d.ts | 7 + .../type_definitions/bar.js | 5 + .../type_definitions/fizz.d.ts | 2 + .../type_definitions/fizz.js | 1 + .../type_definitions/foo.d.ts | 2 + .../type_definitions/foo.js | 1 + .../type_definitions/qat.ts | 1 + .../run/error_with_errors_prop/__test__.jsonc | 5 + .../error_with_errors_prop.js | 0 .../error_with_errors_prop.js.out | 0 .../run/es_private_fields/__test__.jsonc | 4 + .../es_private_fields}/es_private_fields.js | 0 .../es_private_fields.js.out | 0 .../__test__.jsonc | 4 + .../eval_context_throw_dom_exception.js | 0 .../eval_context_throw_dom_exception.js.out | 0 .../run/event_listener_error/__test__.jsonc | 5 + .../event_listener_error.ts | 0 .../event_listener_error.ts.out | 0 .../__test__.jsonc | 4 + .../event_listener_error_handled.ts | 0 .../event_listener_error_handled.ts.out | 0 .../__test__.jsonc | 5 + .../event_listener_error_immediate_exit.ts | 0 ...event_listener_error_immediate_exit.ts.out | 0 .../__test__.jsonc | 5 + .../event_listener_error_immediate_exit.ts | 12 + ...nt_listener_error_immediate_exit_worker.ts | 0 ...istener_error_immediate_exit_worker.ts.out | 0 tests/specs/run/exit_error42/__test__.jsonc | 5 + .../run/exit_error42}/exit_error42.ts | 0 .../run/exit_error42}/exit_error42.ts.out | 0 .../__test__.jsonc | 4 + .../explicit_resource_management/main.out | 0 .../explicit_resource_management/main.ts | 0 .../__test__.jsonc | 5 + .../ts_with_js_extension.js | 5 + .../ts_with_js_extension.out | 2 + .../fetch_async_error_stack/__test__.jsonc | 5 + .../fetch_async_error_stack.ts | 0 .../fetch_async_error_stack.ts.out | 0 .../__test__.jsonc | 5 + .../fetch_response_finalization.js | 0 .../fetch_response_finalization.js.out | 0 .../run/finalization_registry/__test__.jsonc | 4 + .../finalization_registry.js | 0 .../finalization_registry.js.out | 0 .../fix_dynamic_import_errors/__test__.jsonc | 4 + .../specs/run/fix_dynamic_import_errors/b.js | 2 + .../specs/run/fix_dynamic_import_errors/c.js | 2 + .../fix_dynamic_import_errors.js | 4 +- .../fix_dynamic_import_errors.js.out | 0 .../run/fix_emittable_skipped/__test__.jsonc | 4 + .../run/fix_emittable_skipped/emittable.d.ts | 1 + .../fix_emittable_skipped.js | 7 + .../fix_emittable_skipped.ts.out | 0 .../run/fix_emittable_skipped/polyfill.ts | 8 + .../specs/run/fix_js_import_js/__test__.jsonc | 4 + .../run/fix_js_import_js/fix_js_import_js.ts | 3 + .../fix_js_import_js}/fix_js_import_js.ts.out | 0 tests/specs/run/fix_js_import_js/mod4.js | 1 + tests/specs/run/fix_js_import_js/mod6.js | 1 + tests/specs/run/fix_js_imports/__test__.jsonc | 4 + tests/specs/run/fix_js_imports/amd_like.js | 3 + .../run/fix_js_imports/fix_js_imports.ts | 3 + .../run/fix_js_imports}/fix_js_imports.ts.out | 0 .../run/fix_tsc_file_exists/__test__.jsonc | 4 + .../fix_tsc_file_exists.out | 0 tests/specs/run/fix_tsc_file_exists/tsc/a.js | 2 + tests/specs/run/fix_tsc_file_exists/tsc/d.ts | 3 + .../fix_tsc_file_exists/tsc/node_modules/b.js | 2 + .../fix_tsc_file_exists/tsc/node_modules/c.js | 1 + .../specs/run/fix_tsc_file_exists/tsc/test.js | 4 + .../fix_worker_dispatchevent/__test__.jsonc | 4 + .../fix_worker_dispatchevent.ts | 0 .../fix_worker_dispatchevent.ts.out | 0 .../__test__.jsonc | 4 + .../followup_dyn_import_resolves/main.ts | 0 .../followup_dyn_import_resolves/main.ts.out | 0 .../followup_dyn_import_resolves/sub1.ts | 2 + .../followup_dyn_import_resolves/sub2.ts | 1 + tests/specs/run/heapstats/__test__.jsonc | 4 + .../run => specs/run/heapstats}/heapstats.js | 0 .../run/heapstats}/heapstats.js.out | 0 tests/specs/run/https_import/RootCA.pem | 19 + tests/specs/run/https_import/__test__.jsonc | 4 + tests/specs/run/https_import/https_import.ts | 3 + .../run/https_import/https_import.ts.out} | 0 tests/specs/run/https_import/print_hello.ts | 3 + tests/specs/run/if_main/__test__.jsonc | 4 + .../run => specs/run/if_main}/if_main.ts | 0 tests/specs/run/if_main/if_main.ts.out | 1 + .../__test__.jsonc | 5 + .../import_attributes_dynamic_error/data.json | 6 + .../dynamic_error.out | 4 + .../dynamic_error.ts | 3 + .../__test__.jsonc | 4 + .../data.json | 6 + .../dynamic_import.out | 2 + .../dynamic_import.ts | 3 + .../__test__.jsonc | 5 + .../import_attributes_static_error/data.json | 6 + .../static_error.out | 3 + .../static_error.ts | 3 + .../__test__.jsonc | 4 + .../import_attributes_static_export/data.json | 6 + .../static_export.out | 1 + .../static_export.ts | 3 + .../static_reexport.ts | 1 + .../__test__.jsonc | 4 + .../import_attributes_static_import/data.json | 6 + .../static_import.out | 2 + .../static_import.ts | 5 + .../__test__.jsonc | 5 + .../import_attributes_type_check/data.json | 6 + .../type_check.out | 12 + .../type_check.ts | 6 + .../specs/run/import_blob_url/__test__.jsonc | 4 + .../run/import_blob_url}/import_blob_url.ts | 0 .../import_blob_url}/import_blob_url.ts.out | 0 .../__test__.jsonc | 5 + .../import_blob_url_error_stack.ts | 0 .../import_blob_url_error_stack.ts.out | 0 .../__test__.jsonc | 5 + .../import_blob_url_import_relative.ts | 0 .../import_blob_url_import_relative.ts.out | 0 .../import_blob_url_imports/__test__.jsonc | 4 + .../import_blob_url_imports.ts | 0 .../import_blob_url_imports.ts.out} | 0 .../run/import_blob_url_jsx/__test__.jsonc | 4 + .../import_blob_url_jsx.ts | 0 .../import_blob_url_jsx.ts.out | 0 .../run/import_compression/__test__.jsonc | 4 + .../import_compression/brotli | 2 + .../import_compression/gziped | Bin 0 -> 39 bytes .../import_compression/main.out | 0 .../import_compression/main.ts | 0 .../specs/run/import_data_url/__test__.jsonc | 4 + .../run/import_data_url}/import_data_url.ts | 0 .../import_data_url}/import_data_url.ts.out | 0 .../__test__.jsonc | 5 + .../import_data_url_error_stack.ts | 0 .../import_data_url_error_stack.ts.out | 0 .../__test__.jsonc | 5 + .../import_data_url_import_relative.ts | 0 .../import_data_url_import_relative.ts.out | 0 .../import_data_url_imports/__test__.jsonc | 4 + .../import_data_url_imports.ts | 0 .../import_data_url_imports.ts.out} | 0 .../run/import_data_url_jsx/__test__.jsonc | 4 + .../import_data_url_jsx.ts | 0 .../import_data_url_jsx.ts.out | 0 .../import_dynamic_data_url/__test__.jsonc | 4 + .../import_dynamic_data_url.ts | 0 .../import_dynamic_data_url.ts.out | 0 .../run/import_extensionless/__test__.jsonc | 4 + .../import_extensionless.ts | 0 .../import_extensionless.ts.out | 1 + .../run/import_file_with_colon/__test__.jsonc | 4 + .../import_file_with_colon.ts | 0 .../import_file_with_colon.ts.out | 0 tests/specs/run/import_type/__test__.jsonc | 4 + tests/specs/run/import_type/export_types.ts | 11 + tests/specs/run/import_type/import_type.ts | 5 + .../run/import_type}/import_type.ts.out | 0 .../run/import_type_no_check/__test__.jsonc | 4 + .../run/import_type_no_check/export_types.ts | 11 + .../run/import_type_no_check/import_type.ts | 5 + .../import_type_no_check/import_type.ts.out | 1 + .../run/inline_js_source_map_2/__test__.jsonc | 5 + .../inline_js_source_map_2.js | 2 +- .../inline_js_source_map_2.js.out | 0 .../__test__.jsonc | 5 + ...ne_js_source_map_2_with_inline_contents.js | 2 +- ...s_source_map_2_with_inline_contents.js.out | 0 .../__test__.jsonc | 5 + ..._js_source_map_with_contents_from_graph.js | 2 +- ...source_map_with_contents_from_graph.js.out | 0 tests/specs/run/issue_13562/__test__.jsonc | 4 + tests/specs/run/issue_13562/issue13562.ts | 3 + tests/specs/run/issue_13562/issue13562.ts.out | 1 + tests/specs/run/issue_13562/mod1.ts | 17 + tests/specs/run/issue_13562/print_hello.ts | 3 + .../run/issue_13562/subdir2/dynamic_import.ts | 4 + tests/specs/run/issue_13562/subdir2/mod2.ts | 9 + .../specs/run/js_import_detect/__test__.jsonc | 5 + .../run/js_import_detect}/js_import_detect.ts | 0 .../js_import_detect}/js_import_detect.ts.out | 0 .../run/js_root_with_ts_check/__test__.jsonc | 5 + .../js_root_with_ts_check.js | 0 .../js_root_with_ts_check.js.out | 0 .../run/js_without_extension/__test__.jsonc | 5 + .../js_without_extension/js_without_extension | 3 + .../js_without_extension.out | 1 + .../run/jsx_import_from_ts/__test__.jsonc | 4 + .../jsx_import_from_ts.App.jsx | 11 + .../jsx_import_from_ts}/jsx_import_from_ts.ts | 0 .../jsx_import_from_ts.ts.out | 0 .../jsx_import_source_error/__test__.jsonc | 5 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx_import_source_error/jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../run/jsx_import_source_error/jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx_import_source_error.out | 0 .../jsx_import_source_no_pragma.tsx | 7 + .../__test__.jsonc | 4 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx_import_source_import_map.out | 2 + .../jsx_import_source_no_pragma.tsx | 7 + .../__test__.jsonc | 4 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx_import_source_import_map_dev.out | 2 + .../jsx_import_source_no_pragma.tsx | 7 + .../__test__.jsonc | 4 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx_import_source_import_map.out | 2 + .../jsx_import_source_no_pragma.tsx | 7 + .../__test__.jsonc | 4 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../jsx_import_source_no_pragma/jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx_import_source.out | 0 .../jsx_import_source_no_pragma.tsx | 7 + .../__test__.jsonc | 4 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx_import_source_dev.out | 0 .../jsx_import_source_no_pragma.tsx | 7 + .../__test__.jsonc | 4 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx_import_source.out | 2 + .../jsx_import_source_no_pragma.tsx | 7 + .../jsx_import_source_pragma/__test__.jsonc | 4 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../jsx_import_source_pragma/jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx_import_source.out | 2 + .../jsx_import_source_pragma.tsx | 0 .../__test__.jsonc | 4 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx_import_source_import_map.out | 2 + .../jsx_import_source_pragma_import_map.tsx | 0 .../__test__.jsonc | 4 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx_import_source_import_map_dev.out | 2 + .../jsx_import_source_pragma_import_map.tsx | 9 + .../__test__.jsonc | 4 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx_import_source_import_map.out | 2 + .../jsx_import_source_pragma_import_map.tsx | 9 + .../__test__.jsonc | 4 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx_import_source.out | 2 + .../jsx_import_source_pragma.tsx | 9 + .../__test__.jsonc | 4 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx_import_source.out | 2 + .../jsx_import_source_pragma.tsx | 9 + .../__test__.jsonc | 4 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx_import_source.out | 2 + .../jsx_import_source_pragma.tsx | 9 + .../__test__.jsonc | 4 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx/#jsx-runtime_62ac8.js | 11 + .../jsx/vendor/manifest.json | 9 + .../jsx_import_source.out | 2 + .../jsx_import_source_pragma.tsx | 9 + .../__test__.jsonc | 4 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx_import_source_dev.out | 2 + .../jsx_import_source_pragma.tsx | 9 + .../__test__.jsonc | 4 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx_precompile/no_pragma.out | 2 +- .../jsx_precompile/no_pragma.tsx | 0 .../jsx_precompile/skip.out | 0 .../jsx_precompile/skip.tsx | 0 .../__test__.jsonc | 4 + .../jsx/deno-jsx-error.jsonc | 6 + .../jsx/deno-jsx-import-map.jsonc | 6 + .../jsx/deno-jsx-precompile-skip.jsonc | 7 + .../jsx/deno-jsx-precompile.jsonc | 6 + .../jsx/deno-jsx.json | 6 + .../jsx/deno-jsx.jsonc | 6 + .../jsx/deno-jsxdev-import-map.jsonc | 6 + .../jsx/deno-jsxdev.jsonc | 6 + .../jsx/deno.lock | 6 + .../jsx/import-map-scoped.json | 8 + .../jsx/import-map.json | 7 + .../jsx/jsx-dev-runtime/index.ts | 12 + .../jsx/jsx-precompile/index.ts | 23 + .../jsx/jsx-runtime/index.ts | 12 + .../jsx_precompile/no_pragma.out | 3 + .../jsx_precompile/no_pragma.tsx | 3 + .../jsx_precompile/skip.out | 3 + .../jsx_precompile/skip.tsx | 9 + .../run/lock_check_ok/003_relative_import.ts | 3 + .../lock_check_ok/003_relative_import.ts.out | 1 + tests/specs/run/lock_check_ok/__test__.jsonc | 4 + .../run/lock_check_ok/lock_check_ok.json | 4 + tests/specs/run/lock_check_ok/print_hello.ts | 3 + .../run/lock_check_ok2/019_media_types.ts | 24 + .../run/lock_check_ok2/019_media_types.ts.out | 1 + tests/specs/run/lock_check_ok2/__test__.jsonc | 4 + .../run/lock_check_ok2}/lock_check_ok2.json | 0 .../lock_v2_check_ok/003_relative_import.ts | 3 + .../003_relative_import.ts.out | 1 + .../specs/run/lock_v2_check_ok/__test__.jsonc | 4 + .../lock_v2_check_ok/lock_v2_check_ok.json | 7 + .../specs/run/lock_v2_check_ok/print_hello.ts | 3 + .../run/lock_v2_check_ok2/019_media_types.ts | 24 + .../lock_v2_check_ok2/019_media_types.ts.out | 1 + .../run/lock_v2_check_ok2/__test__.jsonc | 4 + .../lock_v2_check_ok2}/lock_v2_check_ok2.json | 0 .../long_data_url_formatting/__test__.jsonc | 5 + .../long_data_url_formatting.ts | 0 .../long_data_url_formatting.ts.out | 0 tests/specs/run/main_module/__test__.jsonc | 4 + .../run/main_module}/main_module/main.out | 0 .../run/main_module}/main_module/main.ts | 0 .../run/main_module}/main_module/other.ts | 0 tests/specs/run/mts_dmts_mjs/__test__.jsonc | 4 + tests/specs/run/mts_dmts_mjs/import.mts | 4 + tests/specs/run/mts_dmts_mjs/mod.mjs | 1 + .../run/mts_dmts_mjs}/mts_dmts_mjs.out | 0 tests/specs/run/mts_dmts_mjs/types.d.mts | 1 + .../run/mts_dmts_mjs_no_check/__test__.jsonc | 4 + .../run/mts_dmts_mjs_no_check/import.mts | 4 + tests/specs/run/mts_dmts_mjs_no_check/mod.mjs | 1 + .../mts_dmts_mjs_no_check/mts_dmts_mjs.out | 1 + .../run/mts_dmts_mjs_no_check/types.d.mts | 1 + tests/specs/run/nested_error/__test__.jsonc | 5 + .../run/nested_error}/nested_error/main.ts | 0 .../nested_error}/nested_error/main.ts.out | 0 tests/specs/run/no_check/006_url_imports.ts | 3 + .../specs/run/no_check/006_url_imports.ts.out | 2 + tests/specs/run/no_check/__test__.jsonc | 4 + tests/specs/run/no_check/mod2.ts | 1 + tests/specs/run/no_check/print_hello.ts | 3 + .../run/no_check_decorators/__test__.jsonc | 4 + .../decorators/experimental/deno.json | 5 + .../decorators/experimental/no_check/main.out | 3 + .../decorators/experimental/no_check/main.ts | 21 + .../decorators/experimental/runtime/main.out | 7 + .../decorators/experimental/runtime/main.ts | 42 + .../decorators/experimental/ts/main.out | 3 + .../decorators/experimental/ts/main.ts | 14 + .../decorators/tc39_proposal/main.out | 3 + .../decorators/tc39_proposal/main.ts | 21 + .../__test__.jsonc | 5 + .../frontend_work.ts | 4 + .../no_auto_discovery.out | 2 +- tests/specs/run/no_lock_flag/__test__.jsonc | 5 + .../run/no_lock_flag}/no_lock_flag/deno.json | 0 .../run/no_lock_flag}/no_lock_flag/deno.lock | 0 .../run/no_lock_flag}/no_lock_flag/main.out | 0 .../run/no_lock_flag}/no_lock_flag/main.ts | 0 tests/specs/run/no_prompt_flag/__test__.jsonc | 4 + tests/specs/run/no_prompt_flag/no_prompt.ts | 10 + .../run/node_env_var_allowlist/__test__.jsonc | 5 + .../node_env_var_allowlist.ts | 0 .../node_env_var_allowlist.ts.out | 0 tests/specs/run/onload/__test__.jsonc | 4 + tests/specs/run/onload/deno.json | 4 + .../run/onload}/onload/imported.ts | 0 .../run => specs/run/onload}/onload/main.out | 0 .../run => specs/run/onload}/onload/main.ts | 0 .../run/onload}/onload/nest_imported.ts | 0 .../__test__.jsonc | 5 + .../op_exit_op_set_exit_code_in_worker.ts | 0 .../op_exit_op_set_exit_code_worker.js | 4 + .../__test__.jsonc | 5 + .../deno.json | 5 + .../main.out | 5 + .../main.ts | 6 + tests/specs/run/permission_args/001_hello.js | 1 + .../specs/run/permission_args/__test__.jsonc | 4 + .../run/permission_args}/permission_args.out | 0 .../run/permission_args_quiet/001_hello.js | 1 + .../permission_args_quiet/001_hello.js.out | 1 + .../run/permission_args_quiet/__test__.jsonc | 4 + .../run/private_field_presence/__test__.jsonc | 4 + .../private_field_presence.ts | 0 .../private_field_presence.ts.out | 0 .../__test__.jsonc | 4 + .../private_field_presence.ts | 20 + .../private_field_presence.ts.out | 2 + tests/specs/run/proto_exploit/__test__.jsonc | 4 + .../run/proto_exploit}/proto_exploit.js | 0 .../run/proto_exploit}/proto_exploit.js.out | 0 .../run/queue_microtask_error/__test__.jsonc | 5 + .../queue_microtask_error.ts | 0 .../queue_microtask_error.ts.out | 0 .../__test__.jsonc | 4 + .../queue_microtask_error_handled.ts | 0 .../queue_microtask_error_handled.ts.out | 0 .../specs/run/reference_types/__test__.jsonc | 4 + .../run/reference_types}/reference_types.ts | 0 .../reference_types/reference_types.ts.out} | 0 .../run/reference_types_error/__test__.jsonc | 5 + .../checkjs.tsconfig.json | 5 + .../reference_types_error.js | 0 .../reference_types_error.js.out | 0 .../__test__.jsonc | 4 + .../reference_types_error.js | 2 + .../__test__.jsonc | 5 + .../checkjs.tsconfig.json | 5 + .../reference_types_error.js | 2 + .../reference_types_error.js.out | 2 + .../references_types_remote/__test__.jsonc | 4 + .../reference_types_remote.ts | 0 .../reference_types_remote.ts.out | 1 + .../run/rejection_handled/__test__.jsonc | 4 + .../rejection_handled}/rejection_handled.out | 0 .../rejection_handled}/rejection_handled.ts | 0 tests/specs/run/replace_self/__test__.jsonc | 4 + .../run/replace_self}/replace_self.js | 0 .../run/replace_self}/replace_self.js.out | 0 tests/specs/run/report_error/__test__.jsonc | 5 + .../run/report_error}/report_error.ts | 0 .../run/report_error}/report_error.ts.out | 0 .../__test__.jsonc | 5 + .../report_error_end_of_program.ts | 0 .../report_error_end_of_program.ts.out | 0 .../run/report_error_handled/__test__.jsonc | 4 + .../report_error_handled.ts | 0 .../report_error_handled.ts.out | 0 .../run/runtime_decorators/__test__.jsonc | 4 + .../decorators/experimental/deno.json | 5 + .../decorators/experimental/no_check/main.out | 3 + .../decorators/experimental/no_check/main.ts | 21 + .../decorators/experimental/runtime/main.out | 7 + .../decorators/experimental/runtime/main.ts | 42 + .../decorators/experimental/ts/main.out | 3 + .../decorators/experimental/ts/main.ts | 14 + .../decorators/tc39_proposal/main.out | 3 + .../decorators/tc39_proposal/main.ts | 21 + tests/specs/run/seed_random/__test__.jsonc | 4 + .../run/seed_random}/seed_random.js | 0 .../run/seed_random}/seed_random.js.out | 0 .../specs/run/set_exit_code_0/__test__.jsonc | 5 + .../run/set_exit_code_0}/set_exit_code_0.ts | 0 .../specs/run/set_exit_code_1/__test__.jsonc | 5 + .../run/set_exit_code_1}/set_exit_code_1.ts | 0 .../specs/run/set_exit_code_2/__test__.jsonc | 5 + .../run/set_exit_code_2}/set_exit_code_2.ts | 0 .../run/set_timeout_error/__test__.jsonc | 5 + .../set_timeout_error}/set_timeout_error.ts | 0 .../set_timeout_error.ts.out | 0 .../set_timeout_error_handled/__test__.jsonc | 4 + .../set_timeout_error_handled.ts | 0 .../set_timeout_error_handled.ts.out | 0 tests/specs/run/shebang_swc/__test__.jsonc | 4 + .../run => specs/run/shebang_swc}/shebang.ts | 0 .../run/shebang_swc}/shebang.ts.out | 0 tests/specs/run/shebang_swc/shebang2.ts | 3 + tests/specs/run/shebang_tsc/__test__.jsonc | 4 + tests/specs/run/shebang_tsc/shebang.ts | 5 + .../run/shebang_tsc/shebang.ts.out} | 0 tests/specs/run/shebang_tsc/shebang2.ts | 3 + .../__test__.jsonc | 5 + .../json_with_shebang.json | 4 + .../json_with_shebang.ts | 3 + .../json_with_shebang.ts.out | 1 + .../__test__.jsonc | 5 + .../json_with_shebang.json | 4 + .../json_with_shebang.ts | 3 + .../json_with_shebang.ts.out | 1 + .../single_compile_with_reload/__test__.jsonc | 4 + .../run/single_compile_with_reload/mod1.ts | 17 + .../single_compile_with_reload/print_hello.ts | 3 + .../single_compile_with_reload.ts | 0 .../single_compile_with_reload.ts.out | 0 .../single_compile_with_reload_dyn.ts | 11 + .../single_compile_with_reload_worker.ts | 3 + .../subdir2/dynamic_import.ts | 4 + .../subdir2/mod2.ts | 9 + .../run/spawn_stdout_inherit/__test__.jsonc | 4 + .../spawn_stdout_inherit.ts | 0 .../spawn_stdout_inherit.ts.out | 0 tests/specs/run/stdin_read_all/__test__.jsonc | 5 + .../run/stdin_read_all}/stdin_read_all.out | 0 .../run/stdin_read_all}/stdin_read_all.ts | 0 .../specs/run/stdout_write_all/__test__.jsonc | 4 + .../stdout_write_all}/stdout_write_all.out | 0 .../run/stdout_write_all}/stdout_write_all.ts | 0 .../stdout_write_sync_async/__test__.jsonc | 4 + .../stdout_write_sync_async.out | 0 .../stdout_write_sync_async.ts | 0 .../specs/run/swc_syntax_error/__test__.jsonc | 5 + .../run/swc_syntax_error}/swc_syntax_error.ts | 0 .../swc_syntax_error}/swc_syntax_error.ts.out | 0 .../__test__.jsonc | 4 + .../test_and_bench_in_run.js | 0 tests/specs/run/tls_connecttls/RootCA.pem | 19 + tests/specs/run/tls_connecttls/__test__.jsonc | 4 + tests/specs/run/tls_connecttls/deno.json | 4 + tests/specs/run/tls_connecttls/localhost.crt | 21 + tests/specs/run/tls_connecttls/localhost.key | 28 + tests/specs/run/tls_connecttls/textproto.ts | 170 ++ .../run => specs/run/tls_connecttls}/tls.out | 0 .../run/tls_connecttls}/tls_connecttls.js | 4 +- tests/specs/run/tls_starttls/RootCA.pem | 19 + tests/specs/run/tls_starttls/__test__.jsonc | 4 + tests/specs/run/tls_starttls/deno.json | 4 + tests/specs/run/tls_starttls/localhost.crt | 21 + tests/specs/run/tls_starttls/localhost.key | 28 + tests/specs/run/tls_starttls/textproto.ts | 170 ++ tests/specs/run/tls_starttls/tls.out | 1 + .../run/tls_starttls}/tls_starttls.js | 4 +- .../specs/run/top_level_await/__test__.jsonc | 4 + tests/specs/run/top_level_await/hello.txt | 1 + .../top_level_await/circular.js | 0 .../top_level_await/circular.out | 0 .../top_level_await/top_level_await/loop.js | 20 + .../top_level_await}/top_level_await/loop.out | 0 .../top_level_await/nested.out | 0 .../top_level_await/nested/a.js | 0 .../top_level_await/nested/b.js | 0 .../top_level_await/nested/main.js | 0 .../top_level_await}/top_level_await/order.js | 0 .../top_level_await/order.out | 0 .../top_level_await/top_level_await/tla/a.js | 3 + .../top_level_await/top_level_await/tla/b.js | 7 + .../top_level_await/top_level_await/tla/c.js | 3 + .../top_level_await/top_level_await/tla/d.js | 8 + .../top_level_await/tla/order.js | 1 + .../top_level_await/tla/parent.js | 9 + .../top_level_await/top_level_await/tla2/a.js | 5 + .../top_level_await/top_level_await/tla2/b.js | 5 + .../top_level_await/top_level_await/tla3/b.js | 7 + .../top_level_await/tla3/timeout_loop.js | 23 + .../top_level_await/top_level_await.js | 3 + .../top_level_await/top_level_await.out | 0 .../top_level_await/top_level_await.ts | 0 .../top_level_await/top_level_for_await.js | 0 .../top_level_await/top_level_for_await.out | 0 .../top_level_await/top_level_for_await.ts | 0 .../top_level_await/unresolved.js | 0 .../top_level_await/unresolved.out | 0 .../top_level_await_circular/__test__.jsonc | 5 + .../top_level_await/circular.js | 8 + .../top_level_await/circular.out | 10 + .../top_level_await/loop.js | 20 + .../top_level_await/loop.out | 5 + .../top_level_await/nested.out | 5 + .../top_level_await/nested/a.js | 3 + .../top_level_await/nested/b.js | 1 + .../top_level_await/nested/main.js | 3 + .../top_level_await/order.js | 21 + .../top_level_await/order.out | 2 + .../top_level_await/tla/a.js | 3 + .../top_level_await/tla/b.js | 7 + .../top_level_await/tla/c.js | 3 + .../top_level_await/tla/d.js | 8 + .../top_level_await/tla/order.js | 1 + .../top_level_await/tla/parent.js | 9 + .../top_level_await/tla2/a.js | 5 + .../top_level_await/tla2/b.js | 5 + .../top_level_await/tla3/b.js | 7 + .../top_level_await/tla3/timeout_loop.js | 23 + .../top_level_await/top_level_await.js | 0 .../top_level_await/top_level_await.out | 3 + .../top_level_await/top_level_await.ts | 3 + .../top_level_await/top_level_for_await.js | 10 + .../top_level_await/top_level_for_await.out | 3 + .../top_level_await/top_level_for_await.ts | 10 + .../top_level_await/unresolved.js | 1 + .../top_level_await/unresolved.out | 4 + .../run/top_level_await_loop/__test__.jsonc | 4 + .../top_level_await/circular.js | 8 + .../top_level_await/circular.out | 10 + .../top_level_await/loop.js | 20 + .../top_level_await/loop.out | 5 + .../top_level_await/nested.out | 5 + .../top_level_await/nested/a.js | 3 + .../top_level_await/nested/b.js | 1 + .../top_level_await/nested/main.js | 3 + .../top_level_await/order.js | 21 + .../top_level_await/order.out | 2 + .../top_level_await/tla/a.js | 3 + .../top_level_await/tla/b.js | 7 + .../top_level_await/tla/c.js | 3 + .../top_level_await/tla/d.js | 8 + .../top_level_await/tla/order.js | 1 + .../top_level_await/tla/parent.js | 9 + .../top_level_await/tla2/a.js | 5 + .../top_level_await/tla2/b.js | 5 + .../top_level_await/tla3/b.js | 7 + .../top_level_await/tla3/timeout_loop.js | 23 + .../top_level_await/top_level_await.js | 3 + .../top_level_await/top_level_await.out | 3 + .../top_level_await/top_level_await.ts | 3 + .../top_level_await/top_level_for_await.js | 10 + .../top_level_await/top_level_for_await.out | 3 + .../top_level_await/top_level_for_await.ts | 10 + .../top_level_await/unresolved.js | 1 + .../top_level_await/unresolved.out | 4 + .../run/top_level_await_nested/__test__.jsonc | 4 + .../top_level_await/circular.js | 8 + .../top_level_await/circular.out | 10 + .../top_level_await/loop.js | 0 .../top_level_await/loop.out | 5 + .../top_level_await/nested.out | 5 + .../top_level_await/nested/a.js | 3 + .../top_level_await/nested/b.js | 1 + .../top_level_await/nested/main.js | 3 + .../top_level_await/order.js | 21 + .../top_level_await/order.out | 2 + .../top_level_await/tla/a.js | 3 + .../top_level_await/tla/b.js | 7 + .../top_level_await/tla/c.js | 3 + .../top_level_await/tla/d.js | 8 + .../top_level_await/tla/order.js | 1 + .../top_level_await/tla/parent.js | 9 + .../top_level_await/tla2/a.js | 5 + .../top_level_await/tla2/b.js | 5 + .../top_level_await/tla3/b.js | 7 + .../top_level_await/tla3/timeout_loop.js | 23 + .../top_level_await/top_level_await.js | 3 + .../top_level_await/top_level_await.out | 3 + .../top_level_await/top_level_await.ts | 3 + .../top_level_await/top_level_for_await.js | 10 + .../top_level_await/top_level_for_await.out | 3 + .../top_level_await/top_level_for_await.ts | 10 + .../top_level_await/unresolved.js | 1 + .../top_level_await/unresolved.out | 4 + .../run/top_level_await_order/__test__.jsonc | 4 + .../top_level_await/circular.js | 8 + .../top_level_await/circular.out | 10 + .../top_level_await/loop.js | 20 + .../top_level_await/loop.out | 5 + .../top_level_await/nested.out | 5 + .../top_level_await/nested/a.js | 3 + .../top_level_await/nested/b.js | 1 + .../top_level_await/nested/main.js | 3 + .../top_level_await/order.js | 21 + .../top_level_await/order.out | 2 + .../top_level_await/tla/a.js | 3 + .../top_level_await/tla/b.js | 7 + .../top_level_await/tla/c.js | 3 + .../top_level_await/tla/d.js | 8 + .../top_level_await/tla/order.js | 1 + .../top_level_await/tla/parent.js | 9 + .../top_level_await/tla2/a.js | 5 + .../top_level_await/tla2/b.js | 5 + .../top_level_await/tla3/b.js | 7 + .../top_level_await/tla3/timeout_loop.js | 23 + .../top_level_await/top_level_await.js | 3 + .../top_level_await/top_level_await.out | 3 + .../top_level_await/top_level_await.ts | 3 + .../top_level_await/top_level_for_await.js | 10 + .../top_level_await/top_level_for_await.out | 3 + .../top_level_await/top_level_for_await.ts | 10 + .../top_level_await/unresolved.js | 1 + .../top_level_await/unresolved.out | 4 + .../run/top_level_await_ts/__test__.jsonc | 4 + tests/specs/run/top_level_await_ts/hello.txt | 1 + .../top_level_await/circular.js | 8 + .../top_level_await/circular.out | 10 + .../top_level_await/loop.js | 20 + .../top_level_await/loop.out | 5 + .../top_level_await/nested.out | 5 + .../top_level_await/nested/a.js | 3 + .../top_level_await/nested/b.js | 1 + .../top_level_await/nested/main.js | 3 + .../top_level_await/order.js | 21 + .../top_level_await/order.out | 2 + .../top_level_await/tla/a.js | 3 + .../top_level_await/tla/b.js | 7 + .../top_level_await/tla/c.js | 3 + .../top_level_await/tla/d.js | 8 + .../top_level_await/tla/order.js | 1 + .../top_level_await/tla/parent.js | 9 + .../top_level_await/tla2/a.js | 5 + .../top_level_await/tla2/b.js | 5 + .../top_level_await/tla3/b.js | 7 + .../top_level_await/tla3/timeout_loop.js | 23 + .../top_level_await/top_level_await.js | 3 + .../top_level_await/top_level_await.out | 3 + .../top_level_await/top_level_await.ts | 3 + .../top_level_await/top_level_for_await.js | 10 + .../top_level_await/top_level_for_await.out | 3 + .../top_level_await/top_level_for_await.ts | 10 + .../top_level_await/unresolved.js | 1 + .../top_level_await/unresolved.out | 4 + .../top_level_await_unresolved/__test__.jsonc | 5 + .../top_level_await/circular.js | 8 + .../top_level_await/circular.out | 10 + .../top_level_await/loop.js | 20 + .../top_level_await/loop.out | 5 + .../top_level_await/nested.out | 5 + .../top_level_await/nested/a.js | 3 + .../top_level_await/nested/b.js | 1 + .../top_level_await/nested/main.js | 3 + .../top_level_await/order.js | 21 + .../top_level_await/order.out | 2 + .../top_level_await/tla/a.js | 3 + .../top_level_await/tla/b.js | 7 + .../top_level_await/tla/c.js | 3 + .../top_level_await/tla/d.js | 8 + .../top_level_await/tla/order.js | 1 + .../top_level_await/tla/parent.js | 9 + .../top_level_await/tla2/a.js | 5 + .../top_level_await/tla2/b.js | 5 + .../top_level_await/tla3/b.js | 7 + .../top_level_await/tla3/timeout_loop.js | 23 + .../top_level_await/top_level_await.js | 3 + .../top_level_await/top_level_await.out | 3 + .../top_level_await/top_level_await.ts | 3 + .../top_level_await/top_level_for_await.js | 10 + .../top_level_await/top_level_for_await.out | 3 + .../top_level_await/top_level_for_await.ts | 10 + .../top_level_await/unresolved.js | 1 + .../top_level_await/unresolved.out | 4 + .../run/top_level_for_await/__test__.jsonc | 4 + .../top_level_await/circular.js | 8 + .../top_level_await/circular.out | 10 + .../top_level_await/loop.js | 20 + .../top_level_await/loop.out | 5 + .../top_level_await/nested.out | 5 + .../top_level_await/nested/a.js | 3 + .../top_level_await/nested/b.js | 1 + .../top_level_await/nested/main.js | 3 + .../top_level_await/order.js | 21 + .../top_level_await/order.out | 2 + .../top_level_await/tla/a.js | 3 + .../top_level_await/tla/b.js | 7 + .../top_level_await/tla/c.js | 3 + .../top_level_await/tla/d.js | 8 + .../top_level_await/tla/order.js | 1 + .../top_level_await/tla/parent.js | 9 + .../top_level_await/tla2/a.js | 5 + .../top_level_await/tla2/b.js | 5 + .../top_level_await/tla3/b.js | 7 + .../top_level_await/tla3/timeout_loop.js | 23 + .../top_level_await/top_level_await.js | 3 + .../top_level_await/top_level_await.out | 3 + .../top_level_await/top_level_await.ts | 3 + .../top_level_await/top_level_for_await.js | 10 + .../top_level_await/top_level_for_await.out | 3 + .../top_level_await/top_level_for_await.ts | 10 + .../top_level_await/unresolved.js | 1 + .../top_level_await/unresolved.out | 4 + .../run/top_level_for_await_ts/__test__.jsonc | 4 + .../top_level_await/circular.js | 8 + .../top_level_await/circular.out | 10 + .../top_level_await/loop.js | 20 + .../top_level_await/loop.out | 5 + .../top_level_await/nested.out | 5 + .../top_level_await/nested/a.js | 3 + .../top_level_await/nested/b.js | 1 + .../top_level_await/nested/main.js | 3 + .../top_level_await/order.js | 21 + .../top_level_await/order.out | 2 + .../top_level_await/tla/a.js | 3 + .../top_level_await/tla/b.js | 7 + .../top_level_await/tla/c.js | 3 + .../top_level_await/tla/d.js | 8 + .../top_level_await/tla/order.js | 1 + .../top_level_await/tla/parent.js | 9 + .../top_level_await/tla2/a.js | 5 + .../top_level_await/tla2/b.js | 5 + .../top_level_await/tla3/b.js | 7 + .../top_level_await/tla3/timeout_loop.js | 23 + .../top_level_await/top_level_await.js | 3 + .../top_level_await/top_level_await.out | 3 + .../top_level_await/top_level_await.ts | 3 + .../top_level_await/top_level_for_await.js | 10 + .../top_level_await/top_level_for_await.out | 3 + .../top_level_await/top_level_for_await.ts | 10 + .../top_level_await/unresolved.js | 1 + .../top_level_await/unresolved.out | 4 + tests/specs/run/ts_decorators/__test__.jsonc | 4 + .../decorators/experimental/deno.json | 5 + .../decorators/experimental/no_check/main.out | 3 + .../decorators/experimental/no_check/main.ts | 21 + .../decorators/experimental/runtime/main.out | 7 + .../decorators/experimental/runtime/main.ts | 42 + .../decorators/experimental/ts/main.out | 3 + .../decorators/experimental/ts/main.ts | 14 + .../decorators/tc39_proposal/main.out | 3 + .../decorators/tc39_proposal/main.ts | 21 + .../run/ts_import_from_js/005_more_imports.ts | 11 + .../run/ts_import_from_js/__test__.jsonc | 4 + tests/specs/run/ts_import_from_js/mod1.ts | 17 + tests/specs/run/ts_import_from_js/mod2.ts | 1 + .../run/ts_import_from_js/print_hello.ts | 3 + .../subdir2/dynamic_import.ts | 4 + .../run/ts_import_from_js/subdir2/mod2.ts | 9 + .../ts_import_from_js/deps.js | 0 .../ts_import_from_js/main.js | 0 .../ts_import_from_js/main.out | 0 .../specs/run/ts_type_imports/__test__.jsonc | 5 + .../run/ts_type_imports}/ts_type_imports.ts | 0 .../ts_type_imports}/ts_type_imports.ts.out | 0 .../ts_type_imports/ts_type_imports_foo.ts | 1 + .../run/ts_type_only_import/__test__.jsonc | 4 + .../ts_type_only_import.d.ts | 3 + .../ts_type_only_import.ts | 0 .../ts_type_only_import.ts.out | 0 .../run/ts_without_extension/__test__.jsonc | 5 + .../ts_without_extension/ts_without_extension | 3 + .../ts_without_extension.out | 2 + tests/specs/run/tsx_imports/046_jsx_test.tsx | 14 + tests/specs/run/tsx_imports/__test__.jsonc | 4 + .../tsx_imports}/tsx_imports/Component.tsx | 0 .../tsx_imports}/tsx_imports/tsx_imports.ts | 0 .../tsx_imports/tsx_imports.ts.out | 0 .../specs/run/type_definitions/__test__.jsonc | 4 + .../run/type_definitions}/type_definitions.ts | 6 +- .../type_definitions}/type_definitions.ts.out | 0 .../type_definitions/bar.d.ts | 7 + .../type_definitions/type_definitions/bar.js | 5 + .../type_definitions/fizz.d.ts | 2 + .../type_definitions/type_definitions/fizz.js | 1 + .../type_definitions/foo.d.ts | 2 + .../type_definitions/type_definitions/foo.js | 1 + .../type_definitions/type_definitions/qat.ts | 1 + .../__test__.jsonc | 5 + .../export_type_def.ts | 2 + .../type_definitions/bar.d.ts | 7 + .../type_definitions/bar.js | 5 + .../type_definitions/fizz.d.ts | 2 + .../type_definitions/fizz.js | 1 + .../type_definitions/foo.d.ts | 2 + .../type_definitions/foo.js | 1 + .../type_definitions/qat.ts | 1 + .../type_definitions_for_export.ts | 0 .../type_definitions_for_export.ts.out | 0 .../run/type_directives_01/__test__.jsonc | 4 + .../type_directives_01}/type_directives_01.ts | 0 .../type_directives_01.ts.out | 0 .../run/type_directives_02/__test__.jsonc | 4 + .../type_directives_02/type_directives_02.ts | 3 + .../type_directives_02.ts.out | 3 + .../type_directives_02/type_reference.d.ts | 1 + .../run/type_directives_02/type_reference.js | 3 + .../type_headers_deno_types/__test__.jsonc | 4 + .../type_headers_deno_types.ts | 0 .../type_headers_deno_types.ts.out | 0 .../run/unbuffered_stderr/__test__.jsonc | 4 + .../unbuffered_stderr}/unbuffered_stderr.ts | 0 .../unbuffered_stderr.ts.out | 0 .../run/unbuffered_stdout/__test__.jsonc | 4 + .../unbuffered_stdout}/unbuffered_stdout.ts | 0 .../unbuffered_stdout.ts.out | 0 .../run/unhandled_rejection/__test__.jsonc | 4 + .../unhandled_rejection.ts | 0 .../unhandled_rejection.ts.out | 9 + .../__test__.jsonc | 5 + .../import.ts | 0 .../main.ts | 0 .../main.ts.out | 0 .../__test__.jsonc | 4 + .../import.ts | 0 .../main.ts | 0 .../main.ts.out | 0 .../__test__.jsonc | 4 + .../unhandled_rejection_sync_error.ts | 0 .../unhandled_rejection_sync_error.ts.out | 6 + tests/specs/run/unsafe_proto/__test__.jsonc | 5 + .../run/unsafe_proto}/unsafe_proto/main.js | 0 .../run/unsafe_proto}/unsafe_proto/main.out | 0 .../main_with_unsafe_proto_flag.out | 0 .../run/unsafe_proto}/unsafe_proto/worker.js | 0 .../run/unsafe_proto_flag/__test__.jsonc | 5 + .../unsafe_proto_flag/unsafe_proto/main.js | 5 + .../unsafe_proto_flag/unsafe_proto/main.out | 2 + .../main_with_unsafe_proto_flag.out | 2 + .../unsafe_proto_flag/unsafe_proto/worker.js | 2 + .../__test__.jsonc | 4 + .../unstable_broadcast_channel.disabled.out | 0 .../unstable_broadcast_channel.js | 0 .../__test__.jsonc | 4 + .../unstable_broadcast_channel.enabled.out | 0 .../unstable_broadcast_channel.js | 10 + .../run/unstable_cron_disabled/__test__.jsonc | 4 + .../unstable_cron.disabled.out | 0 .../unstable_cron_disabled}/unstable_cron.js | 0 .../run/unstable_cron_enabled/__test__.jsonc | 4 + .../unstable_cron.enabled.out | 0 .../unstable_cron_enabled/unstable_cron.js | 10 + .../run/unstable_kv_disabled/__test__.jsonc | 4 + .../unstable_kv.disabled.out | 0 .../run/unstable_kv_disabled}/unstable_kv.js | 0 .../run/unstable_kv_enabled/__test__.jsonc | 4 + .../unstable_kv.enabled.out | 0 .../run/unstable_kv_enabled/unstable_kv.js | 14 + .../run/unstable_net_disabled/__test__.jsonc | 4 + .../unstable_net.disabled.out | 0 .../unstable_net_disabled}/unstable_net.js | 0 .../run/unstable_net_enabled/__test__.jsonc | 4 + .../unstable_net.enabled.out | 0 .../run/unstable_net_enabled/unstable_net.js | 11 + .../specs/run/unstable_worker/__test__.jsonc | 4 + .../run/unstable_worker}/unstable_worker.ts | 2 +- .../unstable_worker}/unstable_worker.ts.out | 0 .../run/unstable_worker/worker_unstable.ts | 5 + .../__test__.jsonc | 5 + .../unstable_worker_options.disabled.out | 0 .../unstable_worker_options.js | 0 .../__test__.jsonc | 4 + .../unstable_worker_options.enabled.out | 0 .../unstable_worker_options.js | 19 + .../__test__.jsonc | 5 + .../unsupported_dynamic_import_scheme.out | 0 .../specs/run/v8_flags_env_run/__test__.jsonc | 7 + .../run/v8_flags_env_run}/v8_flags.js | 0 .../run/v8_flags_env_run}/v8_flags.js.out | 0 tests/specs/run/v8_flags_run/__test__.jsonc | 4 + tests/specs/run/v8_flags_run/v8_flags.js | 1 + tests/specs/run/v8_flags_run/v8_flags.js.out | 1 + .../run/v8_flags_unrecognized/__test__.jsonc | 5 + .../v8_flags_unrecognized.out | 0 tests/specs/run/v8_help/__test__.jsonc | 4 + .../run => specs/run/v8_help}/v8_help.out | 0 tests/specs/run/wasm/__test__.jsonc | 4 + .../{testdata/run => specs/run/wasm}/wasm.ts | 0 tests/specs/run/wasm/wasm.ts.out | 1 + tests/specs/run/wasm_async/__test__.jsonc | 4 + .../run/wasm_async}/wasm_async.js | 0 .../run/wasm_async}/wasm_async.out | 0 tests/specs/run/wasm_shared/__test__.jsonc | 4 + tests/specs/run/wasm_shared/wasm_shared.out | 0 .../run/wasm_shared}/wasm_shared.ts | 0 .../wasm_streaming_panic_test/__test__.jsonc | 5 + .../wasm_streaming_panic_test.js | 0 .../wasm_streaming_panic_test.js.out | 0 .../specs/run/wasm_unreachable/__test__.jsonc | 5 + .../run/wasm_unreachable/unreachable.wasm | Bin 0 -> 42 bytes .../run/wasm_unreachable}/wasm_unreachable.js | 2 +- .../wasm_unreachable}/wasm_unreachable.out | 0 tests/specs/run/wasm_url/__test__.jsonc | 5 + .../run => specs/run/wasm_url}/wasm_url.js | 0 .../run => specs/run/wasm_url}/wasm_url.out | 0 tests/specs/run/weakref/__test__.jsonc | 4 + .../run => specs/run/weakref}/weakref.ts | 0 .../run => specs/run/weakref}/weakref.ts.out | 0 .../webstorage_serialization/__test__.jsonc | 4 + .../webstorage/config_a.jsonc | 3 + .../webstorage/config_b.jsonc | 3 + .../webstorage/fixture.ts | 2 + .../webstorage/logger.ts | 1 + .../webstorage/serialization.ts | 0 .../webstorage/serialization.ts.out | 0 .../webstorage/setter.ts | 1 + .../__test__.jsonc | 4 + .../close_in_wasm_reactions.js | 21 + .../worker_close_in_wasm_reactions.js | 2 +- .../worker_close_in_wasm_reactions.js.out | 0 .../run/worker_close_nested/__test__.jsonc | 4 + .../worker_close_nested/close_nested_child.js | 8 + .../close_nested_parent.js | 13 + .../worker_close_nested.js | 2 +- .../worker_close_nested.js.out | 0 .../run/worker_close_race/__test__.jsonc | 4 + .../worker_close_race/close_race_worker.js | 6 + .../worker_close_race}/worker_close_race.js | 2 +- .../worker_close_race.js.out | 0 .../worker_drop_handle_race/__test__.jsonc | 5 + .../drop_handle_race.js | 3 + .../worker_drop_handle_race.js | 2 +- .../worker_drop_handle_race.js.out | 2 +- .../__test__.jsonc | 4 + .../worker_drop_handle_race_terminate.js | 0 .../worker_drop_handle_race_terminate.js.out | 0 .../worker_event_handler_test/__test__.jsonc | 4 + .../worker_event_handler_test.js | 2 +- .../worker_event_handler_test.js.out | 0 .../worker_event_handlers.js | 26 + .../__test__.jsonc | 4 + .../message_before_close.js | 4 + .../worker_message_before_close.js | 2 +- .../worker_message_before_close.js.out | 0 tests/testdata/run/014_duplicate_import.ts | 9 - tests/testdata/run/020_json_modules.ts | 2 - tests/testdata/run/021_mjs_modules.ts | 2 - tests/testdata/run/035_cached_only_flag.out | 1 - tests/testdata/run/044_bad_resource.ts | 3 - tests/testdata/run/config_json_import.ts | 2 - tests/testdata/run/error_002.ts | 7 - .../error_015_dynamic_import_permissions.js | 3 - tests/testdata/run/error_no_check.ts | 1 - tests/testdata/run/error_no_check.ts.out | 2 - tests/testdata/run/error_type_definitions.ts | 5 - tests/testdata/run/fix_emittable_skipped.js | 7 - tests/testdata/run/fix_js_import_js.ts | 3 - tests/testdata/run/fix_js_imports.ts | 3 - tests/testdata/run/import_type.ts | 5 - tests/testdata/run/issue13562.ts | 3 - tests/testdata/run/lock_check_ok.json | 4 - tests/testdata/run/lock_v2_check_ok.json | 7 - tests/testdata/run/type_directives_02.ts | 3 - tests/testdata/run/type_directives_02.ts.out | 3 - tests/testdata/run/unhandled_rejection.ts.out | 9 - .../run/unhandled_rejection_sync_error.ts.out | 6 - .../run/with_package_json/with_stop/main.out | 5 - tools/lint.js | 2 +- 1656 files changed, 7496 insertions(+), 1936 deletions(-) create mode 100644 tests/specs/run/_001_hello/001_hello.js rename tests/{testdata/run => specs/run/_001_hello}/001_hello.js.out (100%) create mode 100644 tests/specs/run/_001_hello/__test__.jsonc create mode 100644 tests/specs/run/_002_hello/002_hello.ts rename tests/{testdata/run => specs/run/_002_hello}/002_hello.ts.out (100%) create mode 100644 tests/specs/run/_002_hello/__test__.jsonc create mode 100644 tests/specs/run/_003_relative_import/003_relative_import.ts rename tests/{testdata/run => specs/run/_003_relative_import}/003_relative_import.ts.out (100%) create mode 100644 tests/specs/run/_003_relative_import/__test__.jsonc create mode 100644 tests/specs/run/_003_relative_import/print_hello.ts rename tests/{testdata/run => specs/run/_004_set_timeout}/004_set_timeout.ts (100%) rename tests/{testdata/run => specs/run/_004_set_timeout}/004_set_timeout.ts.out (100%) create mode 100644 tests/specs/run/_004_set_timeout/__test__.jsonc rename tests/{testdata/run => specs/run/_005_more_imports}/005_more_imports.ts (65%) rename tests/{testdata/run => specs/run/_005_more_imports}/005_more_imports.ts.out (100%) create mode 100644 tests/specs/run/_005_more_imports/__test__.jsonc create mode 100644 tests/specs/run/_005_more_imports/mod1.ts create mode 100644 tests/specs/run/_005_more_imports/print_hello.ts create mode 100644 tests/specs/run/_005_more_imports/subdir2/mod2.ts create mode 100644 tests/specs/run/_006_url_imports/006_url_imports.ts create mode 100644 tests/specs/run/_006_url_imports/006_url_imports.ts.out create mode 100644 tests/specs/run/_006_url_imports/__test__.jsonc create mode 100644 tests/specs/run/_006_url_imports/print_hello.ts create mode 100644 tests/specs/run/_006_url_imports/subdir2/mod2.ts rename tests/{testdata/run => specs/run/_012_async}/012_async.ts (100%) rename tests/{testdata/run => specs/run/_012_async}/012_async.ts.out (100%) create mode 100644 tests/specs/run/_012_async/__test__.jsonc create mode 100644 tests/specs/run/_013_dynamic_import/013_dynamic_import.ts rename tests/{testdata/run => specs/run/_013_dynamic_import}/013_dynamic_import.ts.out (100%) create mode 100644 tests/specs/run/_013_dynamic_import/__test__.jsonc create mode 100644 tests/specs/run/_013_dynamic_import/mod1.ts create mode 100644 tests/specs/run/_013_dynamic_import/print_hello.ts create mode 100644 tests/specs/run/_013_dynamic_import/subdir2/mod2.ts create mode 100644 tests/specs/run/_014_duplicate_import/014_duplicate_import.ts rename tests/{testdata/run => specs/run/_014_duplicate_import}/014_duplicate_import.ts.out (100%) create mode 100644 tests/specs/run/_014_duplicate_import/__test__.jsonc create mode 100644 tests/specs/run/_014_duplicate_import/auto_print_hello.ts rename tests/{testdata/run => specs/run/_015_duplicate_parallel_import}/015_duplicate_parallel_import.js (91%) rename tests/{testdata/run => specs/run/_015_duplicate_parallel_import}/015_duplicate_parallel_import.js.out (100%) create mode 100644 tests/specs/run/_015_duplicate_parallel_import/__test__.jsonc create mode 100644 tests/specs/run/_015_duplicate_parallel_import/mod1.ts create mode 100644 tests/specs/run/_015_duplicate_parallel_import/print_hello.ts create mode 100644 tests/specs/run/_015_duplicate_parallel_import/subdir2/mod2.ts rename tests/{testdata/run => specs/run/_016_double_await}/016_double_await.ts (100%) rename tests/{testdata/run => specs/run/_016_double_await}/016_double_await.ts.out (100%) create mode 100644 tests/specs/run/_016_double_await/__test__.jsonc create mode 100644 tests/specs/run/_017_import_redirect/017_import_redirect.ts rename tests/{testdata/run => specs/run/_017_import_redirect}/017_import_redirect.ts.out (100%) create mode 100644 tests/specs/run/_017_import_redirect/__test__.jsonc create mode 100644 tests/specs/run/_017_import_redirect_check/017_import_redirect.ts rename tests/{testdata/run/https_import.ts.out => specs/run/_017_import_redirect_check/017_import_redirect.ts.out} (100%) create mode 100644 tests/specs/run/_017_import_redirect_check/__test__.jsonc create mode 100644 tests/specs/run/_017_import_redirect_info/017_import_redirect.ts rename tests/{testdata/run => specs/run/_017_import_redirect_info}/017_import_redirect_info.out (100%) create mode 100644 tests/specs/run/_017_import_redirect_info/__test__.jsonc create mode 100644 tests/specs/run/_017_import_redirect_vendor_dir/017_import_redirect.ts rename tests/{testdata/run/import_blob_url_imports.ts.out => specs/run/_017_import_redirect_vendor_dir/017_import_redirect.ts.out} (100%) create mode 100644 tests/specs/run/_017_import_redirect_vendor_dir/__test__.jsonc rename tests/{testdata/run => specs/run/_018_async_catch}/018_async_catch.ts (100%) rename tests/{testdata/run => specs/run/_018_async_catch}/018_async_catch.ts.out (100%) create mode 100644 tests/specs/run/_018_async_catch/__test__.jsonc create mode 100644 tests/specs/run/_019_media_types/019_media_types.ts rename tests/{testdata/run => specs/run/_019_media_types}/019_media_types.ts.out (100%) create mode 100644 tests/specs/run/_019_media_types/__test__.jsonc create mode 100644 tests/specs/run/_020_json_modules/020_json_modules.ts rename tests/{testdata/run => specs/run/_020_json_modules}/020_json_modules.ts.out (80%) create mode 100644 tests/specs/run/_020_json_modules/__test__.jsonc create mode 100644 tests/specs/run/_020_json_modules/config.json create mode 100644 tests/specs/run/_021_mjs_modules/021_mjs_modules.ts rename tests/{testdata/run => specs/run/_021_mjs_modules}/021_mjs_modules.ts.out (100%) create mode 100644 tests/specs/run/_021_mjs_modules/__test__.jsonc create mode 100644 tests/specs/run/_021_mjs_modules/mod5.mjs rename tests/{testdata/run => specs/run/_025_reload_js_type_error}/025_reload_js_type_error.js (100%) rename tests/{testdata/run => specs/run/_025_reload_js_type_error}/025_reload_js_type_error.js.out (100%) create mode 100644 tests/specs/run/_025_reload_js_type_error/__test__.jsonc rename tests/{testdata/run => specs/run/_027_redirect_typescript}/027_redirect_typescript.ts (100%) rename tests/{testdata/run => specs/run/_027_redirect_typescript}/027_redirect_typescript.ts.out (100%) create mode 100644 tests/specs/run/_027_redirect_typescript/__test__.jsonc create mode 100644 tests/specs/run/_027_redirect_typescript_vendor_dir/027_redirect_typescript.ts create mode 100644 tests/specs/run/_027_redirect_typescript_vendor_dir/027_redirect_typescript.ts.out create mode 100644 tests/specs/run/_027_redirect_typescript_vendor_dir/__test__.jsonc create mode 100644 tests/specs/run/_027_redirect_typescript_vendor_dir/vendor/http_localhost_4545/subdir/redirects/redirect1.ts create mode 100644 tests/specs/run/_027_redirect_typescript_vendor_dir/vendor/http_localhost_4545/subdir/redirects/redirect4.ts create mode 100644 tests/specs/run/_027_redirect_typescript_vendor_dir/vendor/manifest.json rename tests/{testdata/run => specs/run/_028_args}/028_args.ts (100%) rename tests/{testdata/run => specs/run/_028_args}/028_args.ts.out (100%) create mode 100644 tests/specs/run/_028_args/__test__.jsonc create mode 100644 tests/specs/run/_033_import_map_data_uri/__test__.jsonc create mode 100644 tests/specs/run/_033_import_map_data_uri/lodash/lodash.ts create mode 100644 tests/specs/run/_033_import_map_data_uri/lodash/other_file.ts rename tests/{testdata/run/import_maps => specs/run/_033_import_map_data_uri}/test_data.ts (100%) rename tests/{testdata/run/import_maps => specs/run/_033_import_map_data_uri}/test_data.ts.out (100%) rename tests/{testdata/run => specs/run/_033_import_map_remote}/033_import_map_remote.out (100%) create mode 100644 tests/specs/run/_033_import_map_remote/__test__.jsonc create mode 100644 tests/specs/run/_033_import_map_remote/import_map_remote.json create mode 100644 tests/specs/run/_033_import_map_remote/lodash/lodash.ts create mode 100644 tests/specs/run/_033_import_map_remote/lodash/other_file.ts create mode 100644 tests/specs/run/_033_import_map_remote/moment/moment.ts create mode 100644 tests/specs/run/_033_import_map_remote/moment/other_file.ts create mode 100644 tests/specs/run/_033_import_map_remote/print_hello.ts create mode 100644 tests/specs/run/_033_import_map_remote/test_remote.ts create mode 100644 tests/specs/run/_033_import_map_remote/vue.ts create mode 100644 tests/specs/run/_033_import_map_vendor_dir_remote/033_import_map_remote.out create mode 100644 tests/specs/run/_033_import_map_vendor_dir_remote/__test__.jsonc create mode 100644 tests/specs/run/_033_import_map_vendor_dir_remote/import_map_remote.json create mode 100644 tests/specs/run/_033_import_map_vendor_dir_remote/lodash/lodash.ts create mode 100644 tests/specs/run/_033_import_map_vendor_dir_remote/lodash/other_file.ts create mode 100644 tests/specs/run/_033_import_map_vendor_dir_remote/moment/moment.ts create mode 100644 tests/specs/run/_033_import_map_vendor_dir_remote/moment/other_file.ts create mode 100644 tests/specs/run/_033_import_map_vendor_dir_remote/print_hello.ts create mode 100644 tests/specs/run/_033_import_map_vendor_dir_remote/test_remote.ts create mode 100644 tests/specs/run/_033_import_map_vendor_dir_remote/vue.ts create mode 100644 tests/specs/run/_035_cached_only_flag/019_media_types.ts create mode 100644 tests/specs/run/_035_cached_only_flag/035_cached_only_flag.out create mode 100644 tests/specs/run/_035_cached_only_flag/__test__.jsonc rename tests/{testdata/run => specs/run/_038_checkjs}/038_checkjs.js (100%) rename tests/{testdata/run => specs/run/_038_checkjs}/038_checkjs.js.out (100%) create mode 100644 tests/specs/run/_038_checkjs/__test__.jsonc create mode 100644 tests/specs/run/_038_checkjs/checkjs.tsconfig.json rename tests/{testdata/run => specs/run/_042_dyn_import_evalcontext}/042_dyn_import_evalcontext.ts (63%) rename tests/{testdata/run => specs/run/_042_dyn_import_evalcontext}/042_dyn_import_evalcontext.ts.out (100%) create mode 100644 tests/specs/run/_042_dyn_import_evalcontext/__test__.jsonc create mode 100644 tests/specs/run/_042_dyn_import_evalcontext/mod4.js create mode 100644 tests/specs/run/_044_bad_resource/044_bad_resource.ts rename tests/{testdata/run => specs/run/_044_bad_resource}/044_bad_resource.ts.out (100%) create mode 100644 tests/specs/run/_044_bad_resource/__test__.jsonc rename tests/{testdata/run => specs/run/_046_tsx}/046_jsx_test.tsx (100%) rename tests/{testdata/run => specs/run/_046_tsx}/046_jsx_test.tsx.out (100%) create mode 100644 tests/specs/run/_046_tsx/__test__.jsonc rename tests/{testdata/run => specs/run/_047_jsx}/047_jsx_test.jsx (100%) rename tests/{testdata/run => specs/run/_047_jsx}/047_jsx_test.jsx.out (100%) create mode 100644 tests/specs/run/_047_jsx/__test__.jsonc create mode 100644 tests/specs/run/_048_media_types_jsx/048_media_types_jsx.ts rename tests/{testdata/run => specs/run/_048_media_types_jsx}/048_media_types_jsx.ts.out (100%) create mode 100644 tests/specs/run/_048_media_types_jsx/__test__.jsonc create mode 100644 tests/specs/run/_052_no_remote_flag/019_media_types.ts rename tests/{testdata/run => specs/run/_052_no_remote_flag}/052_no_remote_flag.out (53%) create mode 100644 tests/specs/run/_052_no_remote_flag/__test__.jsonc rename tests/{testdata/run => specs/run/_058_tasks_microtasks_close}/058_tasks_microtasks_close.ts (100%) rename tests/{testdata/run => specs/run/_058_tasks_microtasks_close}/058_tasks_microtasks_close.ts.out (100%) create mode 100644 tests/specs/run/_058_tasks_microtasks_close/__test__.jsonc rename tests/{testdata/run => specs/run/_059_fs_relative_path_perm}/059_fs_relative_path_perm.ts (100%) rename tests/{testdata/run => specs/run/_059_fs_relative_path_perm}/059_fs_relative_path_perm.ts.out (100%) create mode 100644 tests/specs/run/_059_fs_relative_path_perm/__test__.jsonc rename tests/{testdata/run => specs/run/_063_permissions_revoke}/063_permissions_revoke.ts (100%) rename tests/{testdata/run => specs/run/_063_permissions_revoke}/063_permissions_revoke.ts.out (100%) create mode 100644 tests/specs/run/_063_permissions_revoke/__test__.jsonc create mode 100644 tests/specs/run/_063_permissions_revoke_sync/063_permissions_revoke.ts.out rename tests/{testdata/run => specs/run/_063_permissions_revoke_sync}/063_permissions_revoke_sync.ts (100%) create mode 100644 tests/specs/run/_063_permissions_revoke_sync/__test__.jsonc rename tests/{testdata/run => specs/run/_064_permissions_revoke_global}/064_permissions_revoke_global.ts (100%) rename tests/{testdata/run => specs/run/_064_permissions_revoke_global}/064_permissions_revoke_global.ts.out (100%) create mode 100644 tests/specs/run/_064_permissions_revoke_global/__test__.jsonc create mode 100644 tests/specs/run/_064_permissions_revoke_global_sync/064_permissions_revoke_global.ts.out rename tests/{testdata/run => specs/run/_064_permissions_revoke_global_sync}/064_permissions_revoke_global_sync.ts (100%) create mode 100644 tests/specs/run/_064_permissions_revoke_global_sync/__test__.jsonc rename tests/{testdata/run => specs/run/_065_permissions_revoke_net}/065_permissions_revoke_net.ts (100%) rename tests/{testdata/run => specs/run/_065_permissions_revoke_net}/065_permissions_revoke_net.ts.out (100%) create mode 100644 tests/specs/run/_065_permissions_revoke_net/__test__.jsonc rename tests/{testdata/run => specs/run/_070_location}/070_location.ts (100%) rename tests/{testdata/run => specs/run/_070_location}/070_location.ts.out (100%) create mode 100644 tests/specs/run/_070_location/__test__.jsonc rename tests/{testdata/run => specs/run/_071_location_unset}/071_location_unset.ts (100%) rename tests/{testdata/run => specs/run/_071_location_unset}/071_location_unset.ts.out (100%) create mode 100644 tests/specs/run/_071_location_unset/__test__.jsonc rename tests/{testdata/run => specs/run/_072_location_relative_fetch}/072_location_relative_fetch.ts (100%) rename tests/{testdata/run => specs/run/_072_location_relative_fetch}/072_location_relative_fetch.ts.out (100%) create mode 100644 tests/specs/run/_072_location_relative_fetch/__test__.jsonc create mode 100644 tests/specs/run/_072_location_relative_fetch/fetch/hello.txt create mode 100644 tests/specs/run/_075_import_local_query_hash/001_hello.js create mode 100644 tests/specs/run/_075_import_local_query_hash/002_hello.ts rename tests/{testdata/run => specs/run/_075_import_local_query_hash}/075_import_local_query_hash.ts (100%) rename tests/{testdata/run => specs/run/_075_import_local_query_hash}/075_import_local_query_hash.ts.out (100%) create mode 100644 tests/specs/run/_075_import_local_query_hash/__test__.jsonc rename tests/{testdata/run => specs/run/_077_fetch_empty}/077_fetch_empty.ts (100%) rename tests/{testdata/run => specs/run/_077_fetch_empty}/077_fetch_empty.ts.out (100%) create mode 100644 tests/specs/run/_077_fetch_empty/__test__.jsonc rename tests/{testdata/run => specs/run/_078_unload_on_exit}/078_unload_on_exit.ts (100%) rename tests/{testdata/run => specs/run/_078_unload_on_exit}/078_unload_on_exit.ts.out (100%) create mode 100644 tests/specs/run/_078_unload_on_exit/__test__.jsonc rename tests/{testdata/run => specs/run/_079_location_authentication}/079_location_authentication.ts (100%) rename tests/{testdata/run => specs/run/_079_location_authentication}/079_location_authentication.ts.out (100%) create mode 100644 tests/specs/run/_079_location_authentication/__test__.jsonc rename tests/{testdata/run => specs/run/_081_location_relative_fetch_redirect}/081_location_relative_fetch_redirect.ts (100%) rename tests/{testdata/run => specs/run/_081_location_relative_fetch_redirect}/081_location_relative_fetch_redirect.ts.out (100%) create mode 100644 tests/specs/run/_081_location_relative_fetch_redirect/__test__.jsonc rename tests/{testdata/run => specs/run/_082_prepare_stack_trace_throw}/082_prepare_stack_trace_throw.js (100%) rename tests/{testdata/run => specs/run/_082_prepare_stack_trace_throw}/082_prepare_stack_trace_throw.js.out (100%) create mode 100644 tests/specs/run/_082_prepare_stack_trace_throw/__test__.jsonc rename tests/{testdata/run => specs/run/_088_dynamic_import_already_evaluating}/088_dynamic_import_already_evaluating.ts (100%) rename tests/{testdata/run => specs/run/_088_dynamic_import_already_evaluating}/088_dynamic_import_already_evaluating.ts.out (100%) create mode 100644 tests/specs/run/_088_dynamic_import_already_evaluating/088_dynamic_import_target.ts create mode 100644 tests/specs/run/_088_dynamic_import_already_evaluating/__test__.jsonc rename tests/{testdata/run => specs/run/_091_use_define_for_class_fields}/091_use_define_for_class_fields.ts (100%) rename tests/{testdata/run => specs/run/_091_use_define_for_class_fields}/091_use_define_for_class_fields.ts.out (100%) create mode 100644 tests/specs/run/_091_use_define_for_class_fields/__test__.jsonc create mode 100644 tests/specs/run/aggregate_error/__test__.jsonc rename tests/{testdata/run => specs/run/aggregate_error}/aggregate_error.out (100%) rename tests/{testdata/run => specs/run/aggregate_error}/aggregate_error.ts (100%) create mode 100644 tests/specs/run/async_error/__test__.jsonc rename tests/{testdata/run => specs/run/async_error}/async_error.ts (100%) rename tests/{testdata/run => specs/run/async_error}/async_error.ts.out (100%) create mode 100644 tests/specs/run/beforeunload_event/__test__.jsonc rename tests/{testdata/run => specs/run/beforeunload_event}/before_unload.js (100%) rename tests/{testdata/run => specs/run/beforeunload_event}/before_unload.js.out (100%) create mode 100644 tests/specs/run/blob_gc_finalization/__test__.jsonc rename tests/{testdata/run => specs/run/blob_gc_finalization}/blob_gc_finalization.js (100%) rename tests/{testdata/run => specs/run/blob_gc_finalization}/blob_gc_finalization.js.out (100%) create mode 100644 tests/specs/run/byte_order_mark/001_hello.js create mode 100644 tests/specs/run/byte_order_mark/__test__.jsonc rename tests/{testdata/run => specs/run/byte_order_mark}/byte_order_mark.out (100%) rename tests/{testdata/run => specs/run/byte_order_mark}/byte_order_mark.ts (86%) create mode 100644 tests/specs/run/check_js_points_to_ts/__test__.jsonc rename tests/{testdata/run => specs/run/check_js_points_to_ts}/check_js_points_to_ts/bar.ts (100%) rename tests/{testdata/run => specs/run/check_js_points_to_ts}/check_js_points_to_ts/foo.d.ts (100%) rename tests/{testdata/run => specs/run/check_js_points_to_ts}/check_js_points_to_ts/foo.js (100%) rename tests/{testdata/run => specs/run/check_js_points_to_ts}/check_js_points_to_ts/test.js (100%) rename tests/{testdata/run => specs/run/check_js_points_to_ts}/check_js_points_to_ts/test.js.out (100%) create mode 100644 tests/specs/run/check_js_points_to_ts/checkjs.tsconfig.json create mode 100644 tests/specs/run/check_remote/__test__.jsonc create mode 100644 tests/specs/run/check_remote/no_check_remote.ts rename tests/{testdata/run => specs/run/check_remote}/no_check_remote.ts.disabled.out (66%) create mode 100644 tests/specs/run/check_remote/type_error.ts create mode 100644 tests/specs/run/classic_workers_event_loop/__test__.jsonc rename tests/{testdata/run => specs/run/classic_workers_event_loop}/classic_workers_event_loop.js (100%) rename tests/{testdata/run => specs/run/classic_workers_event_loop}/classic_workers_event_loop.js.out (100%) create mode 100644 tests/specs/run/colors_without_global_this/__test__.jsonc rename tests/{testdata/run => specs/run/colors_without_global_this}/colors_without_globalThis.js (100%) create mode 100644 tests/specs/run/complex_error/__test__.jsonc rename tests/{testdata/run => specs/run/complex_error}/complex_error.ts (100%) rename tests/{testdata/run => specs/run/complex_error}/complex_error.ts.out (100%) create mode 100644 tests/specs/run/config/__test__.jsonc rename tests/{testdata/run => specs/run/config}/config/main.out (100%) rename tests/{testdata/run => specs/run/config}/config/main.ts (100%) rename tests/{testdata/run => specs/run/config}/config/tsconfig.json (100%) create mode 100644 tests/specs/run/config_auto_discovered_for_local_script/__test__.jsonc rename tests/{testdata/run/with_config => specs/run/config_auto_discovered_for_local_script}/frontend_work.ts (100%) create mode 100644 tests/specs/run/config_auto_discovered_for_local_script_log/__test__.jsonc rename tests/{testdata/run/with_config => specs/run/config_auto_discovered_for_local_script_log}/auto_discovery_log.out (100%) rename tests/{testdata/run/with_config => specs/run/config_auto_discovered_for_local_script_log}/deno.jsonc (100%) create mode 100644 tests/specs/run/config_auto_discovered_for_local_script_log/frontend_work.ts create mode 100644 tests/specs/run/config_json_import/__test__.jsonc create mode 100644 tests/specs/run/config_json_import/config_json_import.ts rename tests/{testdata/run => specs/run/config_json_import}/config_json_import.ts.out (100%) create mode 100644 tests/specs/run/config_json_import/deno-jsx.json create mode 100644 tests/specs/run/config_not_auto_discovered_for_remote_script/__test__.jsonc rename tests/{testdata/run/with_config => specs/run/config_not_auto_discovered_for_remote_script}/server_side_work.ts (100%) create mode 100644 tests/specs/run/config_types/__test__.jsonc create mode 100644 tests/specs/run/config_types/config_types/deno.lock rename tests/{testdata/run => specs/run/config_types}/config_types/main.out (100%) rename tests/{testdata/run => specs/run/config_types}/config_types/main.ts (100%) rename tests/{testdata/run => specs/run/config_types}/config_types/remote.tsconfig.json (100%) rename tests/{testdata/run => specs/run/config_types}/config_types/tsconfig.json (100%) create mode 100644 tests/specs/run/config_types/config_types/types.d.ts create mode 100644 tests/specs/run/config_types_remote/__test__.jsonc create mode 100644 tests/specs/run/config_types_remote/config_types/deno.lock rename tests/{testdata/run/reference_types.ts.out => specs/run/config_types_remote/config_types/main.out} (100%) create mode 100644 tests/specs/run/config_types_remote/config_types/main.ts create mode 100644 tests/specs/run/config_types_remote/config_types/remote.tsconfig.json create mode 100644 tests/specs/run/config_types_remote/config_types/tsconfig.json create mode 100644 tests/specs/run/config_types_remote/config_types/types.d.ts create mode 100644 tests/specs/run/custom_inspect_url/__test__.jsonc rename tests/{testdata/run => specs/run/custom_inspect_url}/custom_inspect_url.js (100%) rename tests/{testdata/run => specs/run/custom_inspect_url}/custom_inspect_url.js.out (100%) create mode 100644 tests/specs/run/decorators_tc39_proposal/__test__.jsonc rename tests/{testdata/run => specs/run/decorators_tc39_proposal}/decorators/experimental/deno.json (100%) rename tests/{testdata/run => specs/run/decorators_tc39_proposal}/decorators/experimental/no_check/main.out (100%) rename tests/{testdata/run => specs/run/decorators_tc39_proposal}/decorators/experimental/no_check/main.ts (100%) rename tests/{testdata/run => specs/run/decorators_tc39_proposal}/decorators/experimental/runtime/main.out (100%) rename tests/{testdata/run => specs/run/decorators_tc39_proposal}/decorators/experimental/runtime/main.ts (100%) rename tests/{testdata/run => specs/run/decorators_tc39_proposal}/decorators/experimental/ts/main.out (100%) rename tests/{testdata/run => specs/run/decorators_tc39_proposal}/decorators/experimental/ts/main.ts (100%) rename tests/{testdata/run => specs/run/decorators_tc39_proposal}/decorators/tc39_proposal/main.out (100%) rename tests/{testdata/run => specs/run/decorators_tc39_proposal}/decorators/tc39_proposal/main.ts (100%) create mode 100644 tests/specs/run/deno_exit_tampering/__test__.jsonc rename tests/{testdata/run => specs/run/deno_exit_tampering}/deno_exit_tampering.ts (100%) create mode 100644 tests/specs/run/deny_all_permission_args/__test__.jsonc rename tests/{testdata/run => specs/run/deny_all_permission_args}/deny_all_permission_args.js (100%) rename tests/{testdata/run => specs/run/deny_all_permission_args}/deny_all_permission_args.out (100%) create mode 100644 tests/specs/run/deny_some_permission_args/__test__.jsonc rename tests/{testdata/run => specs/run/deny_some_permission_args}/deny_some_permission_args.js (100%) rename tests/{testdata/run => specs/run/deny_some_permission_args}/deny_some_permission_args.out (100%) create mode 100644 tests/specs/run/dom_exception_formatting/__test__.jsonc rename tests/{testdata/run => specs/run/dom_exception_formatting}/dom_exception_formatting.ts (100%) rename tests/{testdata/run => specs/run/dom_exception_formatting}/dom_exception_formatting.ts.out (100%) create mode 100644 tests/specs/run/dynamic_import_already_rejected/__test__.jsonc rename tests/{testdata/run => specs/run/dynamic_import_already_rejected}/dynamic_import_already_rejected/error_001.ts (100%) rename tests/{testdata/run => specs/run/dynamic_import_already_rejected}/dynamic_import_already_rejected/main.out (100%) rename tests/{testdata/run => specs/run/dynamic_import_already_rejected}/dynamic_import_already_rejected/main.ts (100%) create mode 100644 tests/specs/run/dynamic_import_async_error/__test__.jsonc rename tests/{testdata/run => specs/run/dynamic_import_async_error}/dynamic_import_async_error/delayed_error.ts (100%) rename tests/{testdata/run => specs/run/dynamic_import_async_error}/dynamic_import_async_error/main.out (100%) rename tests/{testdata/run => specs/run/dynamic_import_async_error}/dynamic_import_async_error/main.ts (100%) create mode 100644 tests/specs/run/dynamic_import_concurrent_non_statically_analyzable/__test__.jsonc rename tests/{testdata/run => specs/run/dynamic_import_concurrent_non_statically_analyzable}/dynamic_import_concurrent_non_statically_analyzable/main.out (100%) rename tests/{testdata/run => specs/run/dynamic_import_concurrent_non_statically_analyzable}/dynamic_import_concurrent_non_statically_analyzable/main.ts (100%) rename tests/{testdata/run => specs/run/dynamic_import_concurrent_non_statically_analyzable}/dynamic_import_concurrent_non_statically_analyzable/mod.ts (100%) create mode 100644 tests/specs/run/dynamic_import_conditional/__test__.jsonc rename tests/{testdata/run => specs/run/dynamic_import_conditional}/dynamic_import_conditional.js (100%) rename tests/{testdata/run => specs/run/dynamic_import_conditional}/dynamic_import_conditional.js.out (100%) create mode 100644 tests/specs/run/dynamic_import_permissions_blob_local/__test__.jsonc create mode 100644 tests/specs/run/dynamic_import_permissions_blob_local/permissions_blob_local.ts create mode 100644 tests/specs/run/dynamic_import_permissions_blob_local/permissions_blob_local.ts.out create mode 100644 tests/specs/run/dynamic_import_permissions_blob_remote/__test__.jsonc create mode 100644 tests/specs/run/dynamic_import_permissions_blob_remote/permissions_blob_remote.ts create mode 100644 tests/specs/run/dynamic_import_permissions_blob_remote/permissions_blob_remote.ts.out create mode 100644 tests/specs/run/dynamic_import_permissions_data_local/__test__.jsonc create mode 100644 tests/specs/run/dynamic_import_permissions_data_local/permissions_data_local.ts create mode 100644 tests/specs/run/dynamic_import_permissions_data_local/permissions_data_local.ts.out create mode 100644 tests/specs/run/dynamic_import_permissions_data_remote/__test__.jsonc create mode 100644 tests/specs/run/dynamic_import_permissions_data_remote/permissions_data_remote.ts create mode 100644 tests/specs/run/dynamic_import_permissions_data_remote/permissions_data_remote.ts.out create mode 100644 tests/specs/run/dynamic_import_permissions_remote_remote/__test__.jsonc create mode 100644 tests/specs/run/dynamic_import_permissions_remote_remote/permissions_remote_remote.ts create mode 100644 tests/specs/run/dynamic_import_permissions_remote_remote/permissions_remote_remote.ts.out create mode 100644 tests/specs/run/dynamic_import_permissions_remote_remote/static_remote.ts create mode 100644 tests/specs/run/dynamic_import_static_analysis_no_permissions/__test__.jsonc rename tests/{testdata/run/empty.ts => specs/run/dynamic_import_static_analysis_no_permissions/empty_1.ts} (100%) rename tests/{testdata/run/wasm_shared.out => specs/run/dynamic_import_static_analysis_no_permissions/empty_2.ts} (100%) create mode 100644 tests/specs/run/dynamic_import_static_analysis_no_permissions/static_analysis_no_permissions.ts create mode 100644 tests/specs/run/dynamic_import_static_analysis_no_permissions/static_analysis_no_permissions.ts.out create mode 100644 tests/specs/run/dynamic_import_syntax_error/__test__.jsonc rename tests/{testdata/run => specs/run/dynamic_import_syntax_error}/dynamic_import_syntax_error.js (100%) rename tests/{testdata/run => specs/run/dynamic_import_syntax_error}/dynamic_import_syntax_error.js.out (100%) create mode 100644 tests/specs/run/dynamic_import_syntax_error/dynamic_import_syntax_error_import.js create mode 100644 tests/specs/run/empty_typescript/__test__.jsonc rename tests/{testdata/run/worker_close_race.js.out => specs/run/empty_typescript/empty.ts} (100%) create mode 100644 tests/specs/run/error_001/__test__.jsonc create mode 100644 tests/specs/run/error_001/error_001.ts rename tests/{testdata/run => specs/run/error_001}/error_001.ts.out (100%) create mode 100644 tests/specs/run/error_002/__test__.jsonc create mode 100644 tests/specs/run/error_002/error_002.ts rename tests/{testdata/run => specs/run/error_002}/error_002.ts.out (78%) create mode 100644 tests/specs/run/error_002/mod1.ts create mode 100644 tests/specs/run/error_002/print_hello.ts create mode 100644 tests/specs/run/error_002/subdir2/mod2.ts create mode 100644 tests/specs/run/error_003_typescript/__test__.jsonc rename tests/{testdata/run => specs/run/error_003_typescript}/error_003_typescript.ts (100%) rename tests/{testdata/run => specs/run/error_003_typescript}/error_003_typescript.ts.out (100%) create mode 100644 tests/specs/run/error_003_typescript2/__test__.jsonc create mode 100644 tests/specs/run/error_003_typescript2/error_003_typescript.ts create mode 100644 tests/specs/run/error_003_typescript2/error_003_typescript.ts.out create mode 100644 tests/specs/run/error_004_missing_module/__test__.jsonc rename tests/{testdata/run => specs/run/error_004_missing_module}/error_004_missing_module.ts (100%) rename tests/{testdata/run => specs/run/error_004_missing_module}/error_004_missing_module.ts.out (100%) create mode 100644 tests/specs/run/error_005_missing_dynamic_import/__test__.jsonc rename tests/{testdata/run => specs/run/error_005_missing_dynamic_import}/error_005_missing_dynamic_import.ts (100%) rename tests/{testdata/run => specs/run/error_005_missing_dynamic_import}/error_005_missing_dynamic_import.ts.out (100%) create mode 100644 tests/specs/run/error_006_import_ext_failure/__test__.jsonc rename tests/{testdata/run => specs/run/error_006_import_ext_failure}/error_006_import_ext_failure.ts (100%) rename tests/{testdata/run => specs/run/error_006_import_ext_failure}/error_006_import_ext_failure.ts.out (100%) create mode 100644 tests/specs/run/error_007_any/__test__.jsonc rename tests/{testdata/run => specs/run/error_007_any}/error_007_any.ts (100%) rename tests/{testdata/run => specs/run/error_007_any}/error_007_any.ts.out (100%) create mode 100644 tests/specs/run/error_008_checkjs/__test__.jsonc rename tests/{testdata/run => specs/run/error_008_checkjs}/error_008_checkjs.js (100%) rename tests/{testdata/run => specs/run/error_008_checkjs}/error_008_checkjs.js.out (100%) create mode 100644 tests/specs/run/error_009_extensions_error/__test__.jsonc rename tests/{testdata/run => specs/run/error_009_extensions_error}/error_009_extensions_error.js (100%) rename tests/{testdata/run => specs/run/error_009_extensions_error}/error_009_extensions_error.js.out (100%) create mode 100644 tests/specs/run/error_011_bad_module_specifier/__test__.jsonc rename tests/{testdata/run => specs/run/error_011_bad_module_specifier}/error_011_bad_module_specifier.ts (100%) rename tests/{testdata/run => specs/run/error_011_bad_module_specifier}/error_011_bad_module_specifier.ts.out (100%) create mode 100644 tests/specs/run/error_012_bad_dynamic_import_specifier/__test__.jsonc rename tests/{testdata/run => specs/run/error_012_bad_dynamic_import_specifier}/error_012_bad_dynamic_import_specifier.ts (100%) rename tests/{testdata/run => specs/run/error_012_bad_dynamic_import_specifier}/error_012_bad_dynamic_import_specifier.ts.out (100%) create mode 100644 tests/specs/run/error_014_catch_dynamic_import_error/__test__.jsonc rename tests/{testdata/run => specs/run/error_014_catch_dynamic_import_error}/error_014_catch_dynamic_import_error.js (79%) rename tests/{testdata/run => specs/run/error_014_catch_dynamic_import_error}/error_014_catch_dynamic_import_error.js.out (83%) create mode 100644 tests/specs/run/error_014_catch_dynamic_import_error/indirect_import_error.js create mode 100644 tests/specs/run/error_014_catch_dynamic_import_error/indirect_throws.js create mode 100644 tests/specs/run/error_014_catch_dynamic_import_error/throws.js create mode 100644 tests/specs/run/error_015_dynamic_import_permissions/__test__.jsonc create mode 100644 tests/specs/run/error_015_dynamic_import_permissions/error_015_dynamic_import_permissions.js rename tests/{testdata/run => specs/run/error_015_dynamic_import_permissions}/error_015_dynamic_import_permissions.out (77%) create mode 100644 tests/specs/run/error_015_dynamic_import_permissions/mod4.js create mode 100644 tests/specs/run/error_017_hide_long_source_ts/__test__.jsonc rename tests/{testdata/run => specs/run/error_017_hide_long_source_ts}/error_017_hide_long_source_ts.ts (100%) rename tests/{testdata/run => specs/run/error_017_hide_long_source_ts}/error_017_hide_long_source_ts.ts.out (100%) create mode 100644 tests/specs/run/error_018_hide_long_source_js/__test__.jsonc rename tests/{testdata/run => specs/run/error_018_hide_long_source_js}/error_018_hide_long_source_js.js (100%) rename tests/{testdata/run => specs/run/error_018_hide_long_source_js}/error_018_hide_long_source_js.js.out (100%) create mode 100644 tests/specs/run/error_019_stack_function/__test__.jsonc rename tests/{testdata/run => specs/run/error_019_stack_function}/error_019_stack_function.ts (100%) rename tests/{testdata/run => specs/run/error_019_stack_function}/error_019_stack_function.ts.out (100%) create mode 100644 tests/specs/run/error_020_stack_constructor/__test__.jsonc rename tests/{testdata/run => specs/run/error_020_stack_constructor}/error_020_stack_constructor.ts (100%) rename tests/{testdata/run => specs/run/error_020_stack_constructor}/error_020_stack_constructor.ts.out (100%) create mode 100644 tests/specs/run/error_021_stack_method/__test__.jsonc rename tests/{testdata/run => specs/run/error_021_stack_method}/error_021_stack_method.ts (100%) rename tests/{testdata/run => specs/run/error_021_stack_method}/error_021_stack_method.ts.out (100%) create mode 100644 tests/specs/run/error_022_stack_custom_error/__test__.jsonc rename tests/{testdata/run => specs/run/error_022_stack_custom_error}/error_022_stack_custom_error.ts (100%) rename tests/{testdata/run => specs/run/error_022_stack_custom_error}/error_022_stack_custom_error.ts.out (100%) create mode 100644 tests/specs/run/error_023_stack_async/__test__.jsonc rename tests/{testdata/run => specs/run/error_023_stack_async}/error_023_stack_async.ts (100%) rename tests/{testdata/run => specs/run/error_023_stack_async}/error_023_stack_async.ts.out (100%) create mode 100644 tests/specs/run/error_024_stack_promise_all/__test__.jsonc rename tests/{testdata/run => specs/run/error_024_stack_promise_all}/error_024_stack_promise_all.ts (100%) rename tests/{testdata/run => specs/run/error_024_stack_promise_all}/error_024_stack_promise_all.ts.out (100%) create mode 100644 tests/specs/run/error_025_tab_indent/__test__.jsonc rename tests/{testdata/run => specs/run/error_025_tab_indent}/error_025_tab_indent (100%) rename tests/{testdata/run => specs/run/error_025_tab_indent}/error_025_tab_indent.out (100%) create mode 100644 tests/specs/run/error_cause/__test__.jsonc rename tests/{testdata/run => specs/run/error_cause}/error_cause.ts (100%) rename tests/{testdata/run => specs/run/error_cause}/error_cause.ts.out (100%) create mode 100644 tests/specs/run/error_cause_recursive/__test__.jsonc rename tests/{testdata/run => specs/run/error_cause_recursive}/error_cause_recursive.ts (100%) rename tests/{testdata/run => specs/run/error_cause_recursive}/error_cause_recursive.ts.out (100%) create mode 100644 tests/specs/run/error_cause_recursive_aggregate/__test__.jsonc rename tests/{testdata => specs/run/error_cause_recursive_aggregate}/error_cause_recursive_aggregate.ts (100%) rename tests/{testdata => specs/run/error_cause_recursive_aggregate}/error_cause_recursive_aggregate.ts.out (100%) create mode 100644 tests/specs/run/error_cause_recursive_tail/__test__.jsonc rename tests/{testdata => specs/run/error_cause_recursive_tail}/error_cause_recursive_tail.ts (100%) rename tests/{testdata => specs/run/error_cause_recursive_tail}/error_cause_recursive_tail.ts.out (100%) create mode 100644 tests/specs/run/error_for_await/__test__.jsonc rename tests/{testdata/run => specs/run/error_for_await}/error_for_await.ts (100%) rename tests/{testdata/run => specs/run/error_for_await}/error_for_await.ts.out (100%) create mode 100644 tests/specs/run/error_import_map_unable_to_load/__test__.jsonc rename tests/{testdata/run => specs/run/error_import_map_unable_to_load}/error_import_map_unable_to_load.out (100%) create mode 100644 tests/specs/run/error_import_map_unable_to_load/import_maps/test_data.ts create mode 100644 tests/specs/run/error_import_map_unable_to_load/import_maps/test_data.ts.out create mode 100644 tests/specs/run/error_missing_module_named_import/__test__.jsonc rename tests/{testdata/run => specs/run/error_missing_module_named_import}/error_missing_module_named_import.ts (100%) rename tests/{testdata/run => specs/run/error_missing_module_named_import}/error_missing_module_named_import.ts.out (100%) create mode 100644 tests/specs/run/error_name_non_string/__test__.jsonc rename tests/{testdata/run => specs/run/error_name_non_string}/error_name_non_string.js (100%) rename tests/{testdata/run => specs/run/error_name_non_string}/error_name_non_string.js.out (100%) create mode 100644 tests/specs/run/error_no_check/__test__.jsonc create mode 100644 tests/specs/run/error_no_check/error_no_check.ts create mode 100644 tests/specs/run/error_no_check/error_no_check.ts.out create mode 100644 tests/specs/run/error_no_check/type_and_code.ts create mode 100644 tests/specs/run/error_syntax/__test__.jsonc rename tests/{testdata/run => specs/run/error_syntax}/error_syntax.js (100%) rename tests/{testdata/run => specs/run/error_syntax}/error_syntax.js.out (100%) create mode 100644 tests/specs/run/error_syntax_empty_trailing_line/__test__.jsonc rename tests/{testdata/run => specs/run/error_syntax_empty_trailing_line}/error_syntax_empty_trailing_line.mjs (100%) rename tests/{testdata/run => specs/run/error_syntax_empty_trailing_line}/error_syntax_empty_trailing_line.mjs.out (100%) create mode 100644 tests/specs/run/error_type_definitions/__test__.jsonc create mode 100644 tests/specs/run/error_type_definitions/error_type_definitions.ts rename tests/{testdata/run => specs/run/error_type_definitions}/error_type_definitions.ts.out (100%) create mode 100644 tests/specs/run/error_type_definitions/type_definitions/bar.d.ts create mode 100644 tests/specs/run/error_type_definitions/type_definitions/bar.js create mode 100644 tests/specs/run/error_type_definitions/type_definitions/fizz.d.ts create mode 100644 tests/specs/run/error_type_definitions/type_definitions/fizz.js create mode 100644 tests/specs/run/error_type_definitions/type_definitions/foo.d.ts create mode 100644 tests/specs/run/error_type_definitions/type_definitions/foo.js create mode 100644 tests/specs/run/error_type_definitions/type_definitions/qat.ts create mode 100644 tests/specs/run/error_with_errors_prop/__test__.jsonc rename tests/{testdata/run => specs/run/error_with_errors_prop}/error_with_errors_prop.js (100%) rename tests/{testdata/run => specs/run/error_with_errors_prop}/error_with_errors_prop.js.out (100%) create mode 100644 tests/specs/run/es_private_fields/__test__.jsonc rename tests/{testdata/run => specs/run/es_private_fields}/es_private_fields.js (100%) rename tests/{testdata/run => specs/run/es_private_fields}/es_private_fields.js.out (100%) create mode 100644 tests/specs/run/eval_context_throw_dom_exception/__test__.jsonc rename tests/{testdata/run => specs/run/eval_context_throw_dom_exception}/eval_context_throw_dom_exception.js (100%) rename tests/{testdata/run => specs/run/eval_context_throw_dom_exception}/eval_context_throw_dom_exception.js.out (100%) create mode 100644 tests/specs/run/event_listener_error/__test__.jsonc rename tests/{testdata/run => specs/run/event_listener_error}/event_listener_error.ts (100%) rename tests/{testdata/run => specs/run/event_listener_error}/event_listener_error.ts.out (100%) create mode 100644 tests/specs/run/event_listener_error_handled/__test__.jsonc rename tests/{testdata/run => specs/run/event_listener_error_handled}/event_listener_error_handled.ts (100%) rename tests/{testdata/run => specs/run/event_listener_error_handled}/event_listener_error_handled.ts.out (100%) create mode 100644 tests/specs/run/event_listener_error_immediate_exit/__test__.jsonc rename tests/{testdata/run => specs/run/event_listener_error_immediate_exit}/event_listener_error_immediate_exit.ts (100%) rename tests/{testdata/run => specs/run/event_listener_error_immediate_exit}/event_listener_error_immediate_exit.ts.out (100%) create mode 100644 tests/specs/run/event_listener_error_immediate_exit_worker/__test__.jsonc create mode 100644 tests/specs/run/event_listener_error_immediate_exit_worker/event_listener_error_immediate_exit.ts rename tests/{testdata/run => specs/run/event_listener_error_immediate_exit_worker}/event_listener_error_immediate_exit_worker.ts (100%) rename tests/{testdata/run => specs/run/event_listener_error_immediate_exit_worker}/event_listener_error_immediate_exit_worker.ts.out (100%) create mode 100644 tests/specs/run/exit_error42/__test__.jsonc rename tests/{testdata/run => specs/run/exit_error42}/exit_error42.ts (100%) rename tests/{testdata/run => specs/run/exit_error42}/exit_error42.ts.out (100%) create mode 100644 tests/specs/run/explicit_resource_management/__test__.jsonc rename tests/{testdata/run => specs/run/explicit_resource_management}/explicit_resource_management/main.out (100%) rename tests/{testdata/run => specs/run/explicit_resource_management}/explicit_resource_management/main.ts (100%) create mode 100644 tests/specs/run/ext_flag_takes_precedence_over_extension/__test__.jsonc create mode 100644 tests/specs/run/ext_flag_takes_precedence_over_extension/ts_with_js_extension.js create mode 100644 tests/specs/run/ext_flag_takes_precedence_over_extension/ts_with_js_extension.out create mode 100644 tests/specs/run/fetch_async_error_stack/__test__.jsonc rename tests/{testdata/run => specs/run/fetch_async_error_stack}/fetch_async_error_stack.ts (100%) rename tests/{testdata/run => specs/run/fetch_async_error_stack}/fetch_async_error_stack.ts.out (100%) create mode 100644 tests/specs/run/fetch_response_finalization/__test__.jsonc rename tests/{testdata/run => specs/run/fetch_response_finalization}/fetch_response_finalization.js (100%) rename tests/{testdata/run => specs/run/fetch_response_finalization}/fetch_response_finalization.js.out (100%) create mode 100644 tests/specs/run/finalization_registry/__test__.jsonc rename tests/{testdata/run => specs/run/finalization_registry}/finalization_registry.js (100%) rename tests/{testdata/run => specs/run/finalization_registry}/finalization_registry.js.out (100%) create mode 100644 tests/specs/run/fix_dynamic_import_errors/__test__.jsonc create mode 100644 tests/specs/run/fix_dynamic_import_errors/b.js create mode 100644 tests/specs/run/fix_dynamic_import_errors/c.js rename tests/{testdata/run => specs/run/fix_dynamic_import_errors}/fix_dynamic_import_errors.js (52%) rename tests/{testdata/run => specs/run/fix_dynamic_import_errors}/fix_dynamic_import_errors.js.out (100%) create mode 100644 tests/specs/run/fix_emittable_skipped/__test__.jsonc create mode 100644 tests/specs/run/fix_emittable_skipped/emittable.d.ts create mode 100644 tests/specs/run/fix_emittable_skipped/fix_emittable_skipped.js rename tests/{testdata/run => specs/run/fix_emittable_skipped}/fix_emittable_skipped.ts.out (100%) create mode 100644 tests/specs/run/fix_emittable_skipped/polyfill.ts create mode 100644 tests/specs/run/fix_js_import_js/__test__.jsonc create mode 100644 tests/specs/run/fix_js_import_js/fix_js_import_js.ts rename tests/{testdata/run => specs/run/fix_js_import_js}/fix_js_import_js.ts.out (100%) create mode 100644 tests/specs/run/fix_js_import_js/mod4.js create mode 100644 tests/specs/run/fix_js_import_js/mod6.js create mode 100644 tests/specs/run/fix_js_imports/__test__.jsonc create mode 100644 tests/specs/run/fix_js_imports/amd_like.js create mode 100644 tests/specs/run/fix_js_imports/fix_js_imports.ts rename tests/{testdata/run => specs/run/fix_js_imports}/fix_js_imports.ts.out (100%) create mode 100644 tests/specs/run/fix_tsc_file_exists/__test__.jsonc rename tests/{testdata/run => specs/run/fix_tsc_file_exists}/fix_tsc_file_exists.out (100%) create mode 100644 tests/specs/run/fix_tsc_file_exists/tsc/a.js create mode 100644 tests/specs/run/fix_tsc_file_exists/tsc/d.ts create mode 100644 tests/specs/run/fix_tsc_file_exists/tsc/node_modules/b.js create mode 100644 tests/specs/run/fix_tsc_file_exists/tsc/node_modules/c.js create mode 100644 tests/specs/run/fix_tsc_file_exists/tsc/test.js create mode 100644 tests/specs/run/fix_worker_dispatchevent/__test__.jsonc rename tests/{testdata/run => specs/run/fix_worker_dispatchevent}/fix_worker_dispatchevent.ts (100%) rename tests/{testdata/run => specs/run/fix_worker_dispatchevent}/fix_worker_dispatchevent.ts.out (100%) create mode 100644 tests/specs/run/followup_dyn_import_resolved/__test__.jsonc rename tests/{testdata/run => specs/run/followup_dyn_import_resolved}/followup_dyn_import_resolves/main.ts (100%) rename tests/{testdata/run => specs/run/followup_dyn_import_resolved}/followup_dyn_import_resolves/main.ts.out (100%) create mode 100644 tests/specs/run/followup_dyn_import_resolved/followup_dyn_import_resolves/sub1.ts create mode 100644 tests/specs/run/followup_dyn_import_resolved/followup_dyn_import_resolves/sub2.ts create mode 100644 tests/specs/run/heapstats/__test__.jsonc rename tests/{testdata/run => specs/run/heapstats}/heapstats.js (100%) rename tests/{testdata/run => specs/run/heapstats}/heapstats.js.out (100%) create mode 100644 tests/specs/run/https_import/RootCA.pem create mode 100644 tests/specs/run/https_import/__test__.jsonc create mode 100644 tests/specs/run/https_import/https_import.ts rename tests/{testdata/run/import_data_url_imports.ts.out => specs/run/https_import/https_import.ts.out} (100%) create mode 100644 tests/specs/run/https_import/print_hello.ts create mode 100644 tests/specs/run/if_main/__test__.jsonc rename tests/{testdata/run => specs/run/if_main}/if_main.ts (100%) create mode 100644 tests/specs/run/if_main/if_main.ts.out create mode 100644 tests/specs/run/import_attributes_dynamic_error/__test__.jsonc create mode 100644 tests/specs/run/import_attributes_dynamic_error/data.json create mode 100644 tests/specs/run/import_attributes_dynamic_error/dynamic_error.out create mode 100644 tests/specs/run/import_attributes_dynamic_error/dynamic_error.ts create mode 100644 tests/specs/run/import_attributes_dynamic_import/__test__.jsonc create mode 100644 tests/specs/run/import_attributes_dynamic_import/data.json create mode 100644 tests/specs/run/import_attributes_dynamic_import/dynamic_import.out create mode 100644 tests/specs/run/import_attributes_dynamic_import/dynamic_import.ts create mode 100644 tests/specs/run/import_attributes_static_error/__test__.jsonc create mode 100644 tests/specs/run/import_attributes_static_error/data.json create mode 100644 tests/specs/run/import_attributes_static_error/static_error.out create mode 100644 tests/specs/run/import_attributes_static_error/static_error.ts create mode 100644 tests/specs/run/import_attributes_static_export/__test__.jsonc create mode 100644 tests/specs/run/import_attributes_static_export/data.json create mode 100644 tests/specs/run/import_attributes_static_export/static_export.out create mode 100644 tests/specs/run/import_attributes_static_export/static_export.ts create mode 100644 tests/specs/run/import_attributes_static_export/static_reexport.ts create mode 100644 tests/specs/run/import_attributes_static_import/__test__.jsonc create mode 100644 tests/specs/run/import_attributes_static_import/data.json create mode 100644 tests/specs/run/import_attributes_static_import/static_import.out create mode 100644 tests/specs/run/import_attributes_static_import/static_import.ts create mode 100644 tests/specs/run/import_attributes_type_check/__test__.jsonc create mode 100644 tests/specs/run/import_attributes_type_check/data.json create mode 100644 tests/specs/run/import_attributes_type_check/type_check.out create mode 100644 tests/specs/run/import_attributes_type_check/type_check.ts create mode 100644 tests/specs/run/import_blob_url/__test__.jsonc rename tests/{testdata/run => specs/run/import_blob_url}/import_blob_url.ts (100%) rename tests/{testdata/run => specs/run/import_blob_url}/import_blob_url.ts.out (100%) create mode 100644 tests/specs/run/import_blob_url_error_stack/__test__.jsonc rename tests/{testdata/run => specs/run/import_blob_url_error_stack}/import_blob_url_error_stack.ts (100%) rename tests/{testdata/run => specs/run/import_blob_url_error_stack}/import_blob_url_error_stack.ts.out (100%) create mode 100644 tests/specs/run/import_blob_url_import_relative/__test__.jsonc rename tests/{testdata/run => specs/run/import_blob_url_import_relative}/import_blob_url_import_relative.ts (100%) rename tests/{testdata/run => specs/run/import_blob_url_import_relative}/import_blob_url_import_relative.ts.out (100%) create mode 100644 tests/specs/run/import_blob_url_imports/__test__.jsonc rename tests/{testdata/run => specs/run/import_blob_url_imports}/import_blob_url_imports.ts (100%) rename tests/{testdata/run/import_extensionless.ts.out => specs/run/import_blob_url_imports/import_blob_url_imports.ts.out} (100%) create mode 100644 tests/specs/run/import_blob_url_jsx/__test__.jsonc rename tests/{testdata/run => specs/run/import_blob_url_jsx}/import_blob_url_jsx.ts (100%) rename tests/{testdata/run => specs/run/import_blob_url_jsx}/import_blob_url_jsx.ts.out (100%) create mode 100644 tests/specs/run/import_compression/__test__.jsonc create mode 100644 tests/specs/run/import_compression/import_compression/brotli create mode 100644 tests/specs/run/import_compression/import_compression/gziped rename tests/{testdata/run => specs/run/import_compression}/import_compression/main.out (100%) rename tests/{testdata/run => specs/run/import_compression}/import_compression/main.ts (100%) create mode 100644 tests/specs/run/import_data_url/__test__.jsonc rename tests/{testdata/run => specs/run/import_data_url}/import_data_url.ts (100%) rename tests/{testdata/run => specs/run/import_data_url}/import_data_url.ts.out (100%) create mode 100644 tests/specs/run/import_data_url_error_stack/__test__.jsonc rename tests/{testdata/run => specs/run/import_data_url_error_stack}/import_data_url_error_stack.ts (100%) rename tests/{testdata/run => specs/run/import_data_url_error_stack}/import_data_url_error_stack.ts.out (100%) create mode 100644 tests/specs/run/import_data_url_import_relative/__test__.jsonc rename tests/{testdata/run => specs/run/import_data_url_import_relative}/import_data_url_import_relative.ts (100%) rename tests/{testdata/run => specs/run/import_data_url_import_relative}/import_data_url_import_relative.ts.out (100%) create mode 100644 tests/specs/run/import_data_url_imports/__test__.jsonc rename tests/{testdata/run => specs/run/import_data_url_imports}/import_data_url_imports.ts (100%) rename tests/{testdata/run/issue13562.ts.out => specs/run/import_data_url_imports/import_data_url_imports.ts.out} (100%) create mode 100644 tests/specs/run/import_data_url_jsx/__test__.jsonc rename tests/{testdata/run => specs/run/import_data_url_jsx}/import_data_url_jsx.ts (100%) rename tests/{testdata/run => specs/run/import_data_url_jsx}/import_data_url_jsx.ts.out (100%) create mode 100644 tests/specs/run/import_dynamic_data_url/__test__.jsonc rename tests/{testdata/run => specs/run/import_dynamic_data_url}/import_dynamic_data_url.ts (100%) rename tests/{testdata/run => specs/run/import_dynamic_data_url}/import_dynamic_data_url.ts.out (100%) create mode 100644 tests/specs/run/import_extensionless/__test__.jsonc rename tests/{testdata/run => specs/run/import_extensionless}/import_extensionless.ts (100%) create mode 100644 tests/specs/run/import_extensionless/import_extensionless.ts.out create mode 100644 tests/specs/run/import_file_with_colon/__test__.jsonc rename tests/{testdata/run => specs/run/import_file_with_colon}/import_file_with_colon.ts (100%) rename tests/{testdata/run => specs/run/import_file_with_colon}/import_file_with_colon.ts.out (100%) create mode 100644 tests/specs/run/import_type/__test__.jsonc create mode 100644 tests/specs/run/import_type/export_types.ts create mode 100644 tests/specs/run/import_type/import_type.ts rename tests/{testdata/run => specs/run/import_type}/import_type.ts.out (100%) create mode 100644 tests/specs/run/import_type_no_check/__test__.jsonc create mode 100644 tests/specs/run/import_type_no_check/export_types.ts create mode 100644 tests/specs/run/import_type_no_check/import_type.ts create mode 100644 tests/specs/run/import_type_no_check/import_type.ts.out create mode 100644 tests/specs/run/inline_js_source_map_2/__test__.jsonc rename tests/{testdata/run => specs/run/inline_js_source_map_2}/inline_js_source_map_2.js (84%) rename tests/{testdata/run => specs/run/inline_js_source_map_2}/inline_js_source_map_2.js.out (100%) create mode 100644 tests/specs/run/inline_js_source_map_2_with_inline_contents/__test__.jsonc rename tests/{testdata/run => specs/run/inline_js_source_map_2_with_inline_contents}/inline_js_source_map_2_with_inline_contents.js (93%) rename tests/{testdata/run => specs/run/inline_js_source_map_2_with_inline_contents}/inline_js_source_map_2_with_inline_contents.js.out (100%) create mode 100644 tests/specs/run/inline_js_source_map_with_contents_from_graph/__test__.jsonc rename tests/{testdata/run => specs/run/inline_js_source_map_with_contents_from_graph}/inline_js_source_map_with_contents_from_graph.js (86%) rename tests/{testdata/run => specs/run/inline_js_source_map_with_contents_from_graph}/inline_js_source_map_with_contents_from_graph.js.out (100%) create mode 100644 tests/specs/run/issue_13562/__test__.jsonc create mode 100644 tests/specs/run/issue_13562/issue13562.ts create mode 100644 tests/specs/run/issue_13562/issue13562.ts.out create mode 100644 tests/specs/run/issue_13562/mod1.ts create mode 100644 tests/specs/run/issue_13562/print_hello.ts create mode 100644 tests/specs/run/issue_13562/subdir2/dynamic_import.ts create mode 100644 tests/specs/run/issue_13562/subdir2/mod2.ts create mode 100644 tests/specs/run/js_import_detect/__test__.jsonc rename tests/{testdata/run => specs/run/js_import_detect}/js_import_detect.ts (100%) rename tests/{testdata/run => specs/run/js_import_detect}/js_import_detect.ts.out (100%) create mode 100644 tests/specs/run/js_root_with_ts_check/__test__.jsonc rename tests/{testdata/run => specs/run/js_root_with_ts_check}/js_root_with_ts_check.js (100%) rename tests/{testdata/run => specs/run/js_root_with_ts_check}/js_root_with_ts_check.js.out (100%) create mode 100644 tests/specs/run/js_without_extension/__test__.jsonc create mode 100644 tests/specs/run/js_without_extension/js_without_extension create mode 100644 tests/specs/run/js_without_extension/js_without_extension.out create mode 100644 tests/specs/run/jsx_import_from_ts/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_from_ts/jsx_import_from_ts.App.jsx rename tests/{testdata/run => specs/run/jsx_import_from_ts}/jsx_import_from_ts.ts (100%) rename tests/{testdata/run => specs/run/jsx_import_from_ts}/jsx_import_from_ts.ts.out (100%) create mode 100644 tests/specs/run/jsx_import_source_error/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_error/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_error/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_error/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_error/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_error/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_error/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_error/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_error/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_error/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_error/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_error/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_error/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_error/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_error/jsx/jsx-runtime/index.ts rename tests/{testdata/run => specs/run/jsx_import_source_error}/jsx_import_source_error.out (100%) create mode 100644 tests/specs/run/jsx_import_source_error/jsx_import_source_no_pragma.tsx create mode 100644 tests/specs/run/jsx_import_source_import_map/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_import_map/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_import_map/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_import_map/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_import_map/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_import_map/jsx/jsx-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_import_map/jsx_import_source_import_map.out create mode 100644 tests/specs/run/jsx_import_source_import_map/jsx_import_source_no_pragma.tsx create mode 100644 tests/specs/run/jsx_import_source_import_map_dev/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map_dev/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_import_map_dev/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_import_map_dev/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_import_map_dev/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_import_map_dev/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_import_map_dev/jsx/jsx-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_import_map_dev/jsx_import_source_import_map_dev.out create mode 100644 tests/specs/run/jsx_import_source_import_map_dev/jsx_import_source_no_pragma.tsx create mode 100644 tests/specs/run/jsx_import_source_import_map_no_check/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_import_map_no_check/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_import_map_no_check/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_import_map_no_check/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_import_map_no_check/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_import_map_no_check/jsx/jsx-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_import_map_no_check/jsx_import_source_import_map.out create mode 100644 tests/specs/run/jsx_import_source_import_map_no_check/jsx_import_source_no_pragma.tsx create mode 100644 tests/specs/run/jsx_import_source_no_pragma/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_no_pragma/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_no_pragma/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_no_pragma/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_no_pragma/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_no_pragma/jsx/jsx-runtime/index.ts rename tests/{testdata/run => specs/run/jsx_import_source_no_pragma}/jsx_import_source.out (100%) create mode 100644 tests/specs/run/jsx_import_source_no_pragma/jsx_import_source_no_pragma.tsx create mode 100644 tests/specs/run/jsx_import_source_no_pragma_dev/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_no_pragma_dev/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_no_pragma_dev/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_no_pragma_dev/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_no_pragma_dev/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_no_pragma_dev/jsx/jsx-runtime/index.ts rename tests/{testdata/run => specs/run/jsx_import_source_no_pragma_dev}/jsx_import_source_dev.out (100%) create mode 100644 tests/specs/run/jsx_import_source_no_pragma_dev/jsx_import_source_no_pragma.tsx create mode 100644 tests/specs/run/jsx_import_source_no_pragma_no_check/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/jsx-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_no_pragma_no_check/jsx_import_source.out create mode 100644 tests/specs/run/jsx_import_source_no_pragma_no_check/jsx_import_source_no_pragma.tsx create mode 100644 tests/specs/run/jsx_import_source_pragma/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_pragma/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_pragma/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_pragma/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma/jsx/jsx-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma/jsx_import_source.out rename tests/{testdata/run => specs/run/jsx_import_source_pragma}/jsx_import_source_pragma.tsx (100%) create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map/jsx/jsx-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map/jsx_import_source_import_map.out rename tests/{testdata/run => specs/run/jsx_import_source_pragma_import_map}/jsx_import_source_pragma_import_map.tsx (100%) create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_dev/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/jsx-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx_import_source_import_map_dev.out create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx_import_source_pragma_import_map.tsx create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_no_check/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/jsx-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx_import_source_import_map.out create mode 100644 tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx_import_source_pragma_import_map.tsx create mode 100644 tests/specs/run/jsx_import_source_pragma_no_check/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_pragma_no_check/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_pragma_no_check/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_pragma_no_check/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_no_check/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_no_check/jsx/jsx-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_no_check/jsx_import_source.out create mode 100644 tests/specs/run/jsx_import_source_pragma_no_check/jsx_import_source_pragma.tsx create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config/jsx/jsx-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config/jsx_import_source.out create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config/jsx_import_source_pragma.tsx create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_no_check/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/jsx-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx_import_source.out create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx_import_source_pragma.tsx create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/jsx-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/vendor/http_localhost_4545/jsx/#jsx-runtime_62ac8.js create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/vendor/manifest.json create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx_import_source.out create mode 100644 tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx_import_source_pragma.tsx create mode 100644 tests/specs/run/jsx_import_source_pragma_with_dev_config/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/jsx-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx_import_source_dev.out create mode 100644 tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx_import_source_pragma.tsx create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map/jsx/jsx-runtime/index.ts rename tests/{testdata/run => specs/run/jsx_import_source_precompile_import_map}/jsx_precompile/no_pragma.out (67%) rename tests/{testdata/run => specs/run/jsx_import_source_precompile_import_map}/jsx_precompile/no_pragma.tsx (100%) rename tests/{testdata/run => specs/run/jsx_import_source_precompile_import_map}/jsx_precompile/skip.out (100%) rename tests/{testdata/run => specs/run/jsx_import_source_precompile_import_map}/jsx_precompile/skip.tsx (100%) create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/__test__.jsonc create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx-error.jsonc create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx-precompile-skip.jsonc create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx-precompile.jsonc create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx.json create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx.jsonc create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsxdev-import-map.jsonc create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsxdev.jsonc create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno.lock create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/import-map-scoped.json create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/import-map.json create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/jsx-dev-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/jsx-precompile/index.ts create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/jsx-runtime/index.ts create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx_precompile/no_pragma.out create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx_precompile/no_pragma.tsx create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx_precompile/skip.out create mode 100644 tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx_precompile/skip.tsx create mode 100644 tests/specs/run/lock_check_ok/003_relative_import.ts create mode 100644 tests/specs/run/lock_check_ok/003_relative_import.ts.out create mode 100644 tests/specs/run/lock_check_ok/__test__.jsonc create mode 100644 tests/specs/run/lock_check_ok/lock_check_ok.json create mode 100644 tests/specs/run/lock_check_ok/print_hello.ts create mode 100644 tests/specs/run/lock_check_ok2/019_media_types.ts create mode 100644 tests/specs/run/lock_check_ok2/019_media_types.ts.out create mode 100644 tests/specs/run/lock_check_ok2/__test__.jsonc rename tests/{testdata/run => specs/run/lock_check_ok2}/lock_check_ok2.json (100%) create mode 100644 tests/specs/run/lock_v2_check_ok/003_relative_import.ts create mode 100644 tests/specs/run/lock_v2_check_ok/003_relative_import.ts.out create mode 100644 tests/specs/run/lock_v2_check_ok/__test__.jsonc create mode 100644 tests/specs/run/lock_v2_check_ok/lock_v2_check_ok.json create mode 100644 tests/specs/run/lock_v2_check_ok/print_hello.ts create mode 100644 tests/specs/run/lock_v2_check_ok2/019_media_types.ts create mode 100644 tests/specs/run/lock_v2_check_ok2/019_media_types.ts.out create mode 100644 tests/specs/run/lock_v2_check_ok2/__test__.jsonc rename tests/{testdata/run => specs/run/lock_v2_check_ok2}/lock_v2_check_ok2.json (100%) create mode 100644 tests/specs/run/long_data_url_formatting/__test__.jsonc rename tests/{testdata/run => specs/run/long_data_url_formatting}/long_data_url_formatting.ts (100%) rename tests/{testdata/run => specs/run/long_data_url_formatting}/long_data_url_formatting.ts.out (100%) create mode 100644 tests/specs/run/main_module/__test__.jsonc rename tests/{testdata/run => specs/run/main_module}/main_module/main.out (100%) rename tests/{testdata/run => specs/run/main_module}/main_module/main.ts (100%) rename tests/{testdata/run => specs/run/main_module}/main_module/other.ts (100%) create mode 100644 tests/specs/run/mts_dmts_mjs/__test__.jsonc create mode 100644 tests/specs/run/mts_dmts_mjs/import.mts create mode 100644 tests/specs/run/mts_dmts_mjs/mod.mjs rename tests/{testdata/run => specs/run/mts_dmts_mjs}/mts_dmts_mjs.out (100%) create mode 100644 tests/specs/run/mts_dmts_mjs/types.d.mts create mode 100644 tests/specs/run/mts_dmts_mjs_no_check/__test__.jsonc create mode 100644 tests/specs/run/mts_dmts_mjs_no_check/import.mts create mode 100644 tests/specs/run/mts_dmts_mjs_no_check/mod.mjs create mode 100644 tests/specs/run/mts_dmts_mjs_no_check/mts_dmts_mjs.out create mode 100644 tests/specs/run/mts_dmts_mjs_no_check/types.d.mts create mode 100644 tests/specs/run/nested_error/__test__.jsonc rename tests/{testdata/run => specs/run/nested_error}/nested_error/main.ts (100%) rename tests/{testdata/run => specs/run/nested_error}/nested_error/main.ts.out (100%) create mode 100644 tests/specs/run/no_check/006_url_imports.ts create mode 100644 tests/specs/run/no_check/006_url_imports.ts.out create mode 100644 tests/specs/run/no_check/__test__.jsonc create mode 100644 tests/specs/run/no_check/mod2.ts create mode 100644 tests/specs/run/no_check/print_hello.ts create mode 100644 tests/specs/run/no_check_decorators/__test__.jsonc create mode 100644 tests/specs/run/no_check_decorators/decorators/experimental/deno.json create mode 100644 tests/specs/run/no_check_decorators/decorators/experimental/no_check/main.out create mode 100644 tests/specs/run/no_check_decorators/decorators/experimental/no_check/main.ts create mode 100644 tests/specs/run/no_check_decorators/decorators/experimental/runtime/main.out create mode 100644 tests/specs/run/no_check_decorators/decorators/experimental/runtime/main.ts create mode 100644 tests/specs/run/no_check_decorators/decorators/experimental/ts/main.out create mode 100644 tests/specs/run/no_check_decorators/decorators/experimental/ts/main.ts create mode 100644 tests/specs/run/no_check_decorators/decorators/tc39_proposal/main.out create mode 100644 tests/specs/run/no_check_decorators/decorators/tc39_proposal/main.ts create mode 100644 tests/specs/run/no_config_auto_discovery_for_local_script/__test__.jsonc create mode 100644 tests/specs/run/no_config_auto_discovery_for_local_script/frontend_work.ts rename tests/{testdata/run/with_config => specs/run/no_config_auto_discovery_for_local_script}/no_auto_discovery.out (78%) create mode 100644 tests/specs/run/no_lock_flag/__test__.jsonc rename tests/{testdata/run => specs/run/no_lock_flag}/no_lock_flag/deno.json (100%) rename tests/{testdata/run => specs/run/no_lock_flag}/no_lock_flag/deno.lock (100%) rename tests/{testdata/run => specs/run/no_lock_flag}/no_lock_flag/main.out (100%) rename tests/{testdata/run => specs/run/no_lock_flag}/no_lock_flag/main.ts (100%) create mode 100644 tests/specs/run/no_prompt_flag/__test__.jsonc create mode 100644 tests/specs/run/no_prompt_flag/no_prompt.ts create mode 100644 tests/specs/run/node_env_var_allowlist/__test__.jsonc rename tests/{testdata/run => specs/run/node_env_var_allowlist}/node_env_var_allowlist.ts (100%) rename tests/{testdata/run => specs/run/node_env_var_allowlist}/node_env_var_allowlist.ts.out (100%) create mode 100644 tests/specs/run/onload/__test__.jsonc create mode 100644 tests/specs/run/onload/deno.json rename tests/{testdata/run => specs/run/onload}/onload/imported.ts (100%) rename tests/{testdata/run => specs/run/onload}/onload/main.out (100%) rename tests/{testdata/run => specs/run/onload}/onload/main.ts (100%) rename tests/{testdata/run => specs/run/onload}/onload/nest_imported.ts (100%) create mode 100644 tests/specs/run/op_exit_op_set_exit_code_in_worker/__test__.jsonc rename tests/{testdata/run => specs/run/op_exit_op_set_exit_code_in_worker}/op_exit_op_set_exit_code_in_worker.ts (100%) create mode 100644 tests/specs/run/op_exit_op_set_exit_code_in_worker/op_exit_op_set_exit_code_worker.js create mode 100644 tests/specs/run/package_json_auto_discovered_for_local_script_arg_with_stop/__test__.jsonc create mode 100644 tests/specs/run/package_json_auto_discovered_for_local_script_arg_with_stop/deno.json create mode 100644 tests/specs/run/package_json_auto_discovered_for_local_script_arg_with_stop/main.out create mode 100644 tests/specs/run/package_json_auto_discovered_for_local_script_arg_with_stop/main.ts create mode 100644 tests/specs/run/permission_args/001_hello.js create mode 100644 tests/specs/run/permission_args/__test__.jsonc rename tests/{testdata/run => specs/run/permission_args}/permission_args.out (100%) create mode 100644 tests/specs/run/permission_args_quiet/001_hello.js create mode 100644 tests/specs/run/permission_args_quiet/001_hello.js.out create mode 100644 tests/specs/run/permission_args_quiet/__test__.jsonc create mode 100644 tests/specs/run/private_field_presence/__test__.jsonc rename tests/{testdata/run => specs/run/private_field_presence}/private_field_presence.ts (100%) rename tests/{testdata/run => specs/run/private_field_presence}/private_field_presence.ts.out (100%) create mode 100644 tests/specs/run/private_field_presence_no_check/__test__.jsonc create mode 100644 tests/specs/run/private_field_presence_no_check/private_field_presence.ts create mode 100644 tests/specs/run/private_field_presence_no_check/private_field_presence.ts.out create mode 100644 tests/specs/run/proto_exploit/__test__.jsonc rename tests/{testdata/run => specs/run/proto_exploit}/proto_exploit.js (100%) rename tests/{testdata/run => specs/run/proto_exploit}/proto_exploit.js.out (100%) create mode 100644 tests/specs/run/queue_microtask_error/__test__.jsonc rename tests/{testdata/run => specs/run/queue_microtask_error}/queue_microtask_error.ts (100%) rename tests/{testdata/run => specs/run/queue_microtask_error}/queue_microtask_error.ts.out (100%) create mode 100644 tests/specs/run/queue_microtask_error_handled/__test__.jsonc rename tests/{testdata/run => specs/run/queue_microtask_error_handled}/queue_microtask_error_handled.ts (100%) rename tests/{testdata/run => specs/run/queue_microtask_error_handled}/queue_microtask_error_handled.ts.out (100%) create mode 100644 tests/specs/run/reference_types/__test__.jsonc rename tests/{testdata/run => specs/run/reference_types}/reference_types.ts (100%) rename tests/{testdata/run/reference_types_remote.ts.out => specs/run/reference_types/reference_types.ts.out} (100%) create mode 100644 tests/specs/run/reference_types_error/__test__.jsonc create mode 100644 tests/specs/run/reference_types_error/checkjs.tsconfig.json rename tests/{testdata/run => specs/run/reference_types_error}/reference_types_error.js (100%) rename tests/{testdata/run => specs/run/reference_types_error}/reference_types_error.js.out (100%) create mode 100644 tests/specs/run/reference_types_error_no_check/__test__.jsonc create mode 100644 tests/specs/run/reference_types_error_no_check/reference_types_error.js create mode 100644 tests/specs/run/reference_types_error_vendor_dir/__test__.jsonc create mode 100644 tests/specs/run/reference_types_error_vendor_dir/checkjs.tsconfig.json create mode 100644 tests/specs/run/reference_types_error_vendor_dir/reference_types_error.js create mode 100644 tests/specs/run/reference_types_error_vendor_dir/reference_types_error.js.out create mode 100644 tests/specs/run/references_types_remote/__test__.jsonc rename tests/{testdata/run => specs/run/references_types_remote}/reference_types_remote.ts (100%) create mode 100644 tests/specs/run/references_types_remote/reference_types_remote.ts.out create mode 100644 tests/specs/run/rejection_handled/__test__.jsonc rename tests/{testdata/run => specs/run/rejection_handled}/rejection_handled.out (100%) rename tests/{testdata/run => specs/run/rejection_handled}/rejection_handled.ts (100%) create mode 100644 tests/specs/run/replace_self/__test__.jsonc rename tests/{testdata/run => specs/run/replace_self}/replace_self.js (100%) rename tests/{testdata/run => specs/run/replace_self}/replace_self.js.out (100%) create mode 100644 tests/specs/run/report_error/__test__.jsonc rename tests/{testdata/run => specs/run/report_error}/report_error.ts (100%) rename tests/{testdata/run => specs/run/report_error}/report_error.ts.out (100%) create mode 100644 tests/specs/run/report_error_end_of_program/__test__.jsonc rename tests/{testdata/run => specs/run/report_error_end_of_program}/report_error_end_of_program.ts (100%) rename tests/{testdata/run => specs/run/report_error_end_of_program}/report_error_end_of_program.ts.out (100%) create mode 100644 tests/specs/run/report_error_handled/__test__.jsonc rename tests/{testdata/run => specs/run/report_error_handled}/report_error_handled.ts (100%) rename tests/{testdata/run => specs/run/report_error_handled}/report_error_handled.ts.out (100%) create mode 100644 tests/specs/run/runtime_decorators/__test__.jsonc create mode 100644 tests/specs/run/runtime_decorators/decorators/experimental/deno.json create mode 100644 tests/specs/run/runtime_decorators/decorators/experimental/no_check/main.out create mode 100644 tests/specs/run/runtime_decorators/decorators/experimental/no_check/main.ts create mode 100644 tests/specs/run/runtime_decorators/decorators/experimental/runtime/main.out create mode 100644 tests/specs/run/runtime_decorators/decorators/experimental/runtime/main.ts create mode 100644 tests/specs/run/runtime_decorators/decorators/experimental/ts/main.out create mode 100644 tests/specs/run/runtime_decorators/decorators/experimental/ts/main.ts create mode 100644 tests/specs/run/runtime_decorators/decorators/tc39_proposal/main.out create mode 100644 tests/specs/run/runtime_decorators/decorators/tc39_proposal/main.ts create mode 100644 tests/specs/run/seed_random/__test__.jsonc rename tests/{testdata/run => specs/run/seed_random}/seed_random.js (100%) rename tests/{testdata/run => specs/run/seed_random}/seed_random.js.out (100%) create mode 100644 tests/specs/run/set_exit_code_0/__test__.jsonc rename tests/{testdata/run => specs/run/set_exit_code_0}/set_exit_code_0.ts (100%) create mode 100644 tests/specs/run/set_exit_code_1/__test__.jsonc rename tests/{testdata/run => specs/run/set_exit_code_1}/set_exit_code_1.ts (100%) create mode 100644 tests/specs/run/set_exit_code_2/__test__.jsonc rename tests/{testdata/run => specs/run/set_exit_code_2}/set_exit_code_2.ts (100%) create mode 100644 tests/specs/run/set_timeout_error/__test__.jsonc rename tests/{testdata/run => specs/run/set_timeout_error}/set_timeout_error.ts (100%) rename tests/{testdata/run => specs/run/set_timeout_error}/set_timeout_error.ts.out (100%) create mode 100644 tests/specs/run/set_timeout_error_handled/__test__.jsonc rename tests/{testdata/run => specs/run/set_timeout_error_handled}/set_timeout_error_handled.ts (100%) rename tests/{testdata/run => specs/run/set_timeout_error_handled}/set_timeout_error_handled.ts.out (100%) create mode 100644 tests/specs/run/shebang_swc/__test__.jsonc rename tests/{testdata/run => specs/run/shebang_swc}/shebang.ts (100%) rename tests/{testdata/run => specs/run/shebang_swc}/shebang.ts.out (100%) create mode 100644 tests/specs/run/shebang_swc/shebang2.ts create mode 100644 tests/specs/run/shebang_tsc/__test__.jsonc create mode 100644 tests/specs/run/shebang_tsc/shebang.ts rename tests/{testdata/run/wasm.ts.out => specs/run/shebang_tsc/shebang.ts.out} (100%) create mode 100644 tests/specs/run/shebang_tsc/shebang2.ts create mode 100644 tests/specs/run/shebang_with_json_imports_swc/__test__.jsonc create mode 100644 tests/specs/run/shebang_with_json_imports_swc/json_with_shebang.json create mode 100644 tests/specs/run/shebang_with_json_imports_swc/json_with_shebang.ts create mode 100644 tests/specs/run/shebang_with_json_imports_swc/json_with_shebang.ts.out create mode 100644 tests/specs/run/shebang_with_json_imports_tsc/__test__.jsonc create mode 100644 tests/specs/run/shebang_with_json_imports_tsc/json_with_shebang.json create mode 100644 tests/specs/run/shebang_with_json_imports_tsc/json_with_shebang.ts create mode 100644 tests/specs/run/shebang_with_json_imports_tsc/json_with_shebang.ts.out create mode 100644 tests/specs/run/single_compile_with_reload/__test__.jsonc create mode 100644 tests/specs/run/single_compile_with_reload/mod1.ts create mode 100644 tests/specs/run/single_compile_with_reload/print_hello.ts rename tests/{testdata/run => specs/run/single_compile_with_reload}/single_compile_with_reload.ts (100%) rename tests/{testdata/run => specs/run/single_compile_with_reload}/single_compile_with_reload.ts.out (100%) create mode 100644 tests/specs/run/single_compile_with_reload/single_compile_with_reload_dyn.ts create mode 100644 tests/specs/run/single_compile_with_reload/single_compile_with_reload_worker.ts create mode 100644 tests/specs/run/single_compile_with_reload/subdir2/dynamic_import.ts create mode 100644 tests/specs/run/single_compile_with_reload/subdir2/mod2.ts create mode 100644 tests/specs/run/spawn_stdout_inherit/__test__.jsonc rename tests/{testdata/run => specs/run/spawn_stdout_inherit}/spawn_stdout_inherit.ts (100%) rename tests/{testdata/run => specs/run/spawn_stdout_inherit}/spawn_stdout_inherit.ts.out (100%) create mode 100644 tests/specs/run/stdin_read_all/__test__.jsonc rename tests/{testdata/run => specs/run/stdin_read_all}/stdin_read_all.out (100%) rename tests/{testdata/run => specs/run/stdin_read_all}/stdin_read_all.ts (100%) create mode 100644 tests/specs/run/stdout_write_all/__test__.jsonc rename tests/{testdata/run => specs/run/stdout_write_all}/stdout_write_all.out (100%) rename tests/{testdata/run => specs/run/stdout_write_all}/stdout_write_all.ts (100%) create mode 100644 tests/specs/run/stdout_write_sync_async/__test__.jsonc rename tests/{testdata/run => specs/run/stdout_write_sync_async}/stdout_write_sync_async.out (100%) rename tests/{testdata/run => specs/run/stdout_write_sync_async}/stdout_write_sync_async.ts (100%) create mode 100644 tests/specs/run/swc_syntax_error/__test__.jsonc rename tests/{testdata/run => specs/run/swc_syntax_error}/swc_syntax_error.ts (100%) rename tests/{testdata/run => specs/run/swc_syntax_error}/swc_syntax_error.ts.out (100%) create mode 100644 tests/specs/run/test_and_bench_are_noops_in_run/__test__.jsonc rename tests/{testdata/run => specs/run/test_and_bench_are_noops_in_run}/test_and_bench_in_run.js (100%) create mode 100644 tests/specs/run/tls_connecttls/RootCA.pem create mode 100644 tests/specs/run/tls_connecttls/__test__.jsonc create mode 100644 tests/specs/run/tls_connecttls/deno.json create mode 100644 tests/specs/run/tls_connecttls/localhost.crt create mode 100644 tests/specs/run/tls_connecttls/localhost.key create mode 100644 tests/specs/run/tls_connecttls/textproto.ts rename tests/{testdata/run => specs/run/tls_connecttls}/tls.out (100%) rename tests/{testdata/run => specs/run/tls_connecttls}/tls_connecttls.js (94%) create mode 100644 tests/specs/run/tls_starttls/RootCA.pem create mode 100644 tests/specs/run/tls_starttls/__test__.jsonc create mode 100644 tests/specs/run/tls_starttls/deno.json create mode 100644 tests/specs/run/tls_starttls/localhost.crt create mode 100644 tests/specs/run/tls_starttls/localhost.key create mode 100644 tests/specs/run/tls_starttls/textproto.ts create mode 100644 tests/specs/run/tls_starttls/tls.out rename tests/{testdata/run => specs/run/tls_starttls}/tls_starttls.js (94%) create mode 100644 tests/specs/run/top_level_await/__test__.jsonc create mode 100644 tests/specs/run/top_level_await/hello.txt rename tests/{testdata/run => specs/run/top_level_await}/top_level_await/circular.js (100%) rename tests/{testdata/run => specs/run/top_level_await}/top_level_await/circular.out (100%) create mode 100644 tests/specs/run/top_level_await/top_level_await/loop.js rename tests/{testdata/run => specs/run/top_level_await}/top_level_await/loop.out (100%) rename tests/{testdata/run => specs/run/top_level_await}/top_level_await/nested.out (100%) rename tests/{testdata/run => specs/run/top_level_await}/top_level_await/nested/a.js (100%) rename tests/{testdata/run => specs/run/top_level_await}/top_level_await/nested/b.js (100%) rename tests/{testdata/run => specs/run/top_level_await}/top_level_await/nested/main.js (100%) rename tests/{testdata/run => specs/run/top_level_await}/top_level_await/order.js (100%) rename tests/{testdata/run => specs/run/top_level_await}/top_level_await/order.out (100%) create mode 100644 tests/specs/run/top_level_await/top_level_await/tla/a.js create mode 100644 tests/specs/run/top_level_await/top_level_await/tla/b.js create mode 100644 tests/specs/run/top_level_await/top_level_await/tla/c.js create mode 100644 tests/specs/run/top_level_await/top_level_await/tla/d.js create mode 100644 tests/specs/run/top_level_await/top_level_await/tla/order.js create mode 100644 tests/specs/run/top_level_await/top_level_await/tla/parent.js create mode 100644 tests/specs/run/top_level_await/top_level_await/tla2/a.js create mode 100644 tests/specs/run/top_level_await/top_level_await/tla2/b.js create mode 100644 tests/specs/run/top_level_await/top_level_await/tla3/b.js create mode 100644 tests/specs/run/top_level_await/top_level_await/tla3/timeout_loop.js create mode 100644 tests/specs/run/top_level_await/top_level_await/top_level_await.js rename tests/{testdata/run => specs/run/top_level_await}/top_level_await/top_level_await.out (100%) rename tests/{testdata/run => specs/run/top_level_await}/top_level_await/top_level_await.ts (100%) rename tests/{testdata/run => specs/run/top_level_await}/top_level_await/top_level_for_await.js (100%) rename tests/{testdata/run => specs/run/top_level_await}/top_level_await/top_level_for_await.out (100%) rename tests/{testdata/run => specs/run/top_level_await}/top_level_await/top_level_for_await.ts (100%) rename tests/{testdata/run => specs/run/top_level_await}/top_level_await/unresolved.js (100%) rename tests/{testdata/run => specs/run/top_level_await}/top_level_await/unresolved.out (100%) create mode 100644 tests/specs/run/top_level_await_circular/__test__.jsonc create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/circular.js create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/circular.out create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/loop.js create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/loop.out create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/nested.out create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/nested/a.js create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/nested/b.js create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/nested/main.js create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/order.js create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/order.out create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/tla/a.js create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/tla/b.js create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/tla/c.js create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/tla/d.js create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/tla/order.js create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/tla/parent.js create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/tla2/a.js create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/tla2/b.js create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/tla3/b.js create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/tla3/timeout_loop.js rename tests/{testdata/run => specs/run/top_level_await_circular}/top_level_await/top_level_await.js (100%) create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/top_level_await.out create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/top_level_await.ts create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/top_level_for_await.js create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/top_level_for_await.out create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/top_level_for_await.ts create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/unresolved.js create mode 100644 tests/specs/run/top_level_await_circular/top_level_await/unresolved.out create mode 100644 tests/specs/run/top_level_await_loop/__test__.jsonc create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/circular.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/circular.out create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/loop.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/loop.out create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/nested.out create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/nested/a.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/nested/b.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/nested/main.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/order.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/order.out create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/tla/a.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/tla/b.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/tla/c.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/tla/d.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/tla/order.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/tla/parent.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/tla2/a.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/tla2/b.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/tla3/b.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/tla3/timeout_loop.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/top_level_await.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/top_level_await.out create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/top_level_await.ts create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/top_level_for_await.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/top_level_for_await.out create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/top_level_for_await.ts create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/unresolved.js create mode 100644 tests/specs/run/top_level_await_loop/top_level_await/unresolved.out create mode 100644 tests/specs/run/top_level_await_nested/__test__.jsonc create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/circular.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/circular.out rename tests/{testdata/run => specs/run/top_level_await_nested}/top_level_await/loop.js (100%) create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/loop.out create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/nested.out create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/nested/a.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/nested/b.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/nested/main.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/order.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/order.out create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/tla/a.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/tla/b.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/tla/c.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/tla/d.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/tla/order.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/tla/parent.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/tla2/a.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/tla2/b.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/tla3/b.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/tla3/timeout_loop.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/top_level_await.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/top_level_await.out create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/top_level_await.ts create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/top_level_for_await.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/top_level_for_await.out create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/top_level_for_await.ts create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/unresolved.js create mode 100644 tests/specs/run/top_level_await_nested/top_level_await/unresolved.out create mode 100644 tests/specs/run/top_level_await_order/__test__.jsonc create mode 100644 tests/specs/run/top_level_await_order/top_level_await/circular.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/circular.out create mode 100644 tests/specs/run/top_level_await_order/top_level_await/loop.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/loop.out create mode 100644 tests/specs/run/top_level_await_order/top_level_await/nested.out create mode 100644 tests/specs/run/top_level_await_order/top_level_await/nested/a.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/nested/b.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/nested/main.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/order.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/order.out create mode 100644 tests/specs/run/top_level_await_order/top_level_await/tla/a.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/tla/b.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/tla/c.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/tla/d.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/tla/order.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/tla/parent.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/tla2/a.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/tla2/b.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/tla3/b.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/tla3/timeout_loop.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/top_level_await.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/top_level_await.out create mode 100644 tests/specs/run/top_level_await_order/top_level_await/top_level_await.ts create mode 100644 tests/specs/run/top_level_await_order/top_level_await/top_level_for_await.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/top_level_for_await.out create mode 100644 tests/specs/run/top_level_await_order/top_level_await/top_level_for_await.ts create mode 100644 tests/specs/run/top_level_await_order/top_level_await/unresolved.js create mode 100644 tests/specs/run/top_level_await_order/top_level_await/unresolved.out create mode 100644 tests/specs/run/top_level_await_ts/__test__.jsonc create mode 100644 tests/specs/run/top_level_await_ts/hello.txt create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/circular.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/circular.out create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/loop.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/loop.out create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/nested.out create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/nested/a.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/nested/b.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/nested/main.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/order.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/order.out create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/tla/a.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/tla/b.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/tla/c.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/tla/d.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/tla/order.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/tla/parent.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/tla2/a.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/tla2/b.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/tla3/b.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/tla3/timeout_loop.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/top_level_await.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/top_level_await.out create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/top_level_await.ts create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/top_level_for_await.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/top_level_for_await.out create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/top_level_for_await.ts create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/unresolved.js create mode 100644 tests/specs/run/top_level_await_ts/top_level_await/unresolved.out create mode 100644 tests/specs/run/top_level_await_unresolved/__test__.jsonc create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/circular.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/circular.out create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/loop.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/loop.out create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/nested.out create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/nested/a.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/nested/b.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/nested/main.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/order.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/order.out create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/tla/a.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/tla/b.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/tla/c.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/tla/d.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/tla/order.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/tla/parent.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/tla2/a.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/tla2/b.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/tla3/b.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/tla3/timeout_loop.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/top_level_await.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/top_level_await.out create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/top_level_await.ts create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/top_level_for_await.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/top_level_for_await.out create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/top_level_for_await.ts create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/unresolved.js create mode 100644 tests/specs/run/top_level_await_unresolved/top_level_await/unresolved.out create mode 100644 tests/specs/run/top_level_for_await/__test__.jsonc create mode 100644 tests/specs/run/top_level_for_await/top_level_await/circular.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/circular.out create mode 100644 tests/specs/run/top_level_for_await/top_level_await/loop.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/loop.out create mode 100644 tests/specs/run/top_level_for_await/top_level_await/nested.out create mode 100644 tests/specs/run/top_level_for_await/top_level_await/nested/a.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/nested/b.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/nested/main.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/order.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/order.out create mode 100644 tests/specs/run/top_level_for_await/top_level_await/tla/a.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/tla/b.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/tla/c.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/tla/d.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/tla/order.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/tla/parent.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/tla2/a.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/tla2/b.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/tla3/b.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/tla3/timeout_loop.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/top_level_await.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/top_level_await.out create mode 100644 tests/specs/run/top_level_for_await/top_level_await/top_level_await.ts create mode 100644 tests/specs/run/top_level_for_await/top_level_await/top_level_for_await.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/top_level_for_await.out create mode 100644 tests/specs/run/top_level_for_await/top_level_await/top_level_for_await.ts create mode 100644 tests/specs/run/top_level_for_await/top_level_await/unresolved.js create mode 100644 tests/specs/run/top_level_for_await/top_level_await/unresolved.out create mode 100644 tests/specs/run/top_level_for_await_ts/__test__.jsonc create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/circular.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/circular.out create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/loop.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/loop.out create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/nested.out create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/nested/a.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/nested/b.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/nested/main.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/order.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/order.out create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/tla/a.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/tla/b.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/tla/c.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/tla/d.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/tla/order.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/tla/parent.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/tla2/a.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/tla2/b.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/tla3/b.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/tla3/timeout_loop.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/top_level_await.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/top_level_await.out create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/top_level_await.ts create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/top_level_for_await.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/top_level_for_await.out create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/top_level_for_await.ts create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/unresolved.js create mode 100644 tests/specs/run/top_level_for_await_ts/top_level_await/unresolved.out create mode 100644 tests/specs/run/ts_decorators/__test__.jsonc create mode 100644 tests/specs/run/ts_decorators/decorators/experimental/deno.json create mode 100644 tests/specs/run/ts_decorators/decorators/experimental/no_check/main.out create mode 100644 tests/specs/run/ts_decorators/decorators/experimental/no_check/main.ts create mode 100644 tests/specs/run/ts_decorators/decorators/experimental/runtime/main.out create mode 100644 tests/specs/run/ts_decorators/decorators/experimental/runtime/main.ts create mode 100644 tests/specs/run/ts_decorators/decorators/experimental/ts/main.out create mode 100644 tests/specs/run/ts_decorators/decorators/experimental/ts/main.ts create mode 100644 tests/specs/run/ts_decorators/decorators/tc39_proposal/main.out create mode 100644 tests/specs/run/ts_decorators/decorators/tc39_proposal/main.ts create mode 100644 tests/specs/run/ts_import_from_js/005_more_imports.ts create mode 100644 tests/specs/run/ts_import_from_js/__test__.jsonc create mode 100644 tests/specs/run/ts_import_from_js/mod1.ts create mode 100644 tests/specs/run/ts_import_from_js/mod2.ts create mode 100644 tests/specs/run/ts_import_from_js/print_hello.ts create mode 100644 tests/specs/run/ts_import_from_js/subdir2/dynamic_import.ts create mode 100644 tests/specs/run/ts_import_from_js/subdir2/mod2.ts rename tests/{testdata/run => specs/run/ts_import_from_js}/ts_import_from_js/deps.js (100%) rename tests/{testdata/run => specs/run/ts_import_from_js}/ts_import_from_js/main.js (100%) rename tests/{testdata/run => specs/run/ts_import_from_js}/ts_import_from_js/main.out (100%) create mode 100644 tests/specs/run/ts_type_imports/__test__.jsonc rename tests/{testdata/run => specs/run/ts_type_imports}/ts_type_imports.ts (100%) rename tests/{testdata/run => specs/run/ts_type_imports}/ts_type_imports.ts.out (100%) create mode 100644 tests/specs/run/ts_type_imports/ts_type_imports_foo.ts create mode 100644 tests/specs/run/ts_type_only_import/__test__.jsonc create mode 100644 tests/specs/run/ts_type_only_import/ts_type_only_import.d.ts rename tests/{testdata/run => specs/run/ts_type_only_import}/ts_type_only_import.ts (100%) rename tests/{testdata/run => specs/run/ts_type_only_import}/ts_type_only_import.ts.out (100%) create mode 100644 tests/specs/run/ts_without_extension/__test__.jsonc create mode 100644 tests/specs/run/ts_without_extension/ts_without_extension create mode 100644 tests/specs/run/ts_without_extension/ts_without_extension.out create mode 100644 tests/specs/run/tsx_imports/046_jsx_test.tsx create mode 100644 tests/specs/run/tsx_imports/__test__.jsonc rename tests/{testdata/run => specs/run/tsx_imports}/tsx_imports/Component.tsx (100%) rename tests/{testdata/run => specs/run/tsx_imports}/tsx_imports/tsx_imports.ts (100%) rename tests/{testdata/run => specs/run/tsx_imports}/tsx_imports/tsx_imports.ts.out (100%) create mode 100644 tests/specs/run/type_definitions/__test__.jsonc rename tests/{testdata/run => specs/run/type_definitions}/type_definitions.ts (56%) rename tests/{testdata/run => specs/run/type_definitions}/type_definitions.ts.out (100%) create mode 100644 tests/specs/run/type_definitions/type_definitions/bar.d.ts create mode 100644 tests/specs/run/type_definitions/type_definitions/bar.js create mode 100644 tests/specs/run/type_definitions/type_definitions/fizz.d.ts create mode 100644 tests/specs/run/type_definitions/type_definitions/fizz.js create mode 100644 tests/specs/run/type_definitions/type_definitions/foo.d.ts create mode 100644 tests/specs/run/type_definitions/type_definitions/foo.js create mode 100644 tests/specs/run/type_definitions/type_definitions/qat.ts create mode 100644 tests/specs/run/type_definitions_for_export/__test__.jsonc create mode 100644 tests/specs/run/type_definitions_for_export/export_type_def.ts create mode 100644 tests/specs/run/type_definitions_for_export/type_definitions/bar.d.ts create mode 100644 tests/specs/run/type_definitions_for_export/type_definitions/bar.js create mode 100644 tests/specs/run/type_definitions_for_export/type_definitions/fizz.d.ts create mode 100644 tests/specs/run/type_definitions_for_export/type_definitions/fizz.js create mode 100644 tests/specs/run/type_definitions_for_export/type_definitions/foo.d.ts create mode 100644 tests/specs/run/type_definitions_for_export/type_definitions/foo.js create mode 100644 tests/specs/run/type_definitions_for_export/type_definitions/qat.ts rename tests/{testdata/run => specs/run/type_definitions_for_export}/type_definitions_for_export.ts (100%) rename tests/{testdata/run => specs/run/type_definitions_for_export}/type_definitions_for_export.ts.out (100%) create mode 100644 tests/specs/run/type_directives_01/__test__.jsonc rename tests/{testdata/run => specs/run/type_directives_01}/type_directives_01.ts (100%) rename tests/{testdata/run => specs/run/type_directives_01}/type_directives_01.ts.out (100%) create mode 100644 tests/specs/run/type_directives_02/__test__.jsonc create mode 100644 tests/specs/run/type_directives_02/type_directives_02.ts create mode 100644 tests/specs/run/type_directives_02/type_directives_02.ts.out create mode 100644 tests/specs/run/type_directives_02/type_reference.d.ts create mode 100644 tests/specs/run/type_directives_02/type_reference.js create mode 100644 tests/specs/run/type_headers_deno_types/__test__.jsonc rename tests/{testdata/run => specs/run/type_headers_deno_types}/type_headers_deno_types.ts (100%) rename tests/{testdata/run => specs/run/type_headers_deno_types}/type_headers_deno_types.ts.out (100%) create mode 100644 tests/specs/run/unbuffered_stderr/__test__.jsonc rename tests/{testdata/run => specs/run/unbuffered_stderr}/unbuffered_stderr.ts (100%) rename tests/{testdata/run => specs/run/unbuffered_stderr}/unbuffered_stderr.ts.out (100%) create mode 100644 tests/specs/run/unbuffered_stdout/__test__.jsonc rename tests/{testdata/run => specs/run/unbuffered_stdout}/unbuffered_stdout.ts (100%) rename tests/{testdata/run => specs/run/unbuffered_stdout}/unbuffered_stdout.ts.out (100%) create mode 100644 tests/specs/run/unhandled_rejection/__test__.jsonc rename tests/{testdata/run => specs/run/unhandled_rejection}/unhandled_rejection.ts (100%) create mode 100644 tests/specs/run/unhandled_rejection/unhandled_rejection.ts.out create mode 100644 tests/specs/run/unhandled_rejection_dynamic_import/__test__.jsonc rename tests/{testdata/run => specs/run/unhandled_rejection_dynamic_import}/unhandled_rejection_dynamic_import/import.ts (100%) rename tests/{testdata/run => specs/run/unhandled_rejection_dynamic_import}/unhandled_rejection_dynamic_import/main.ts (100%) rename tests/{testdata/run => specs/run/unhandled_rejection_dynamic_import}/unhandled_rejection_dynamic_import/main.ts.out (100%) create mode 100644 tests/specs/run/unhandled_rejection_dynamic_import2/__test__.jsonc rename tests/{testdata/run => specs/run/unhandled_rejection_dynamic_import2}/unhandled_rejection_dynamic_import2/import.ts (100%) rename tests/{testdata/run => specs/run/unhandled_rejection_dynamic_import2}/unhandled_rejection_dynamic_import2/main.ts (100%) rename tests/{testdata/run => specs/run/unhandled_rejection_dynamic_import2}/unhandled_rejection_dynamic_import2/main.ts.out (100%) create mode 100644 tests/specs/run/unhandled_rejection_sync_error/__test__.jsonc rename tests/{testdata/run => specs/run/unhandled_rejection_sync_error}/unhandled_rejection_sync_error.ts (100%) create mode 100644 tests/specs/run/unhandled_rejection_sync_error/unhandled_rejection_sync_error.ts.out create mode 100644 tests/specs/run/unsafe_proto/__test__.jsonc rename tests/{testdata/run => specs/run/unsafe_proto}/unsafe_proto/main.js (100%) rename tests/{testdata/run => specs/run/unsafe_proto}/unsafe_proto/main.out (100%) rename tests/{testdata/run => specs/run/unsafe_proto}/unsafe_proto/main_with_unsafe_proto_flag.out (100%) rename tests/{testdata/run => specs/run/unsafe_proto}/unsafe_proto/worker.js (100%) create mode 100644 tests/specs/run/unsafe_proto_flag/__test__.jsonc create mode 100644 tests/specs/run/unsafe_proto_flag/unsafe_proto/main.js create mode 100644 tests/specs/run/unsafe_proto_flag/unsafe_proto/main.out create mode 100644 tests/specs/run/unsafe_proto_flag/unsafe_proto/main_with_unsafe_proto_flag.out create mode 100644 tests/specs/run/unsafe_proto_flag/unsafe_proto/worker.js create mode 100644 tests/specs/run/unstable_broadcast_channel_disabled/__test__.jsonc rename tests/{testdata/run => specs/run/unstable_broadcast_channel_disabled}/unstable_broadcast_channel.disabled.out (100%) rename tests/{testdata/run => specs/run/unstable_broadcast_channel_disabled}/unstable_broadcast_channel.js (100%) create mode 100644 tests/specs/run/unstable_broadcast_channel_enabled/__test__.jsonc rename tests/{testdata/run => specs/run/unstable_broadcast_channel_enabled}/unstable_broadcast_channel.enabled.out (100%) create mode 100644 tests/specs/run/unstable_broadcast_channel_enabled/unstable_broadcast_channel.js create mode 100644 tests/specs/run/unstable_cron_disabled/__test__.jsonc rename tests/{testdata/run => specs/run/unstable_cron_disabled}/unstable_cron.disabled.out (100%) rename tests/{testdata/run => specs/run/unstable_cron_disabled}/unstable_cron.js (100%) create mode 100644 tests/specs/run/unstable_cron_enabled/__test__.jsonc rename tests/{testdata/run => specs/run/unstable_cron_enabled}/unstable_cron.enabled.out (100%) create mode 100644 tests/specs/run/unstable_cron_enabled/unstable_cron.js create mode 100644 tests/specs/run/unstable_kv_disabled/__test__.jsonc rename tests/{testdata/run => specs/run/unstable_kv_disabled}/unstable_kv.disabled.out (100%) rename tests/{testdata/run => specs/run/unstable_kv_disabled}/unstable_kv.js (100%) create mode 100644 tests/specs/run/unstable_kv_enabled/__test__.jsonc rename tests/{testdata/run => specs/run/unstable_kv_enabled}/unstable_kv.enabled.out (100%) create mode 100644 tests/specs/run/unstable_kv_enabled/unstable_kv.js create mode 100644 tests/specs/run/unstable_net_disabled/__test__.jsonc rename tests/{testdata/run => specs/run/unstable_net_disabled}/unstable_net.disabled.out (100%) rename tests/{testdata/run => specs/run/unstable_net_disabled}/unstable_net.js (100%) create mode 100644 tests/specs/run/unstable_net_enabled/__test__.jsonc rename tests/{testdata/run => specs/run/unstable_net_enabled}/unstable_net.enabled.out (100%) create mode 100644 tests/specs/run/unstable_net_enabled/unstable_net.js create mode 100644 tests/specs/run/unstable_worker/__test__.jsonc rename tests/{testdata/run => specs/run/unstable_worker}/unstable_worker.ts (62%) rename tests/{testdata/run => specs/run/unstable_worker}/unstable_worker.ts.out (100%) create mode 100644 tests/specs/run/unstable_worker/worker_unstable.ts create mode 100644 tests/specs/run/unstable_worker_options_disabled/__test__.jsonc rename tests/{testdata/run => specs/run/unstable_worker_options_disabled}/unstable_worker_options.disabled.out (100%) rename tests/{testdata/run => specs/run/unstable_worker_options_disabled}/unstable_worker_options.js (100%) create mode 100644 tests/specs/run/unstable_worker_options_enabled/__test__.jsonc rename tests/{testdata/run => specs/run/unstable_worker_options_enabled}/unstable_worker_options.enabled.out (100%) create mode 100644 tests/specs/run/unstable_worker_options_enabled/unstable_worker_options.js create mode 100644 tests/specs/run/unsupported_dynamic_import_scheme/__test__.jsonc rename tests/{testdata/run => specs/run/unsupported_dynamic_import_scheme}/unsupported_dynamic_import_scheme.out (100%) create mode 100644 tests/specs/run/v8_flags_env_run/__test__.jsonc rename tests/{testdata/run => specs/run/v8_flags_env_run}/v8_flags.js (100%) rename tests/{testdata/run => specs/run/v8_flags_env_run}/v8_flags.js.out (100%) create mode 100644 tests/specs/run/v8_flags_run/__test__.jsonc create mode 100644 tests/specs/run/v8_flags_run/v8_flags.js create mode 100644 tests/specs/run/v8_flags_run/v8_flags.js.out create mode 100644 tests/specs/run/v8_flags_unrecognized/__test__.jsonc rename tests/{testdata/run => specs/run/v8_flags_unrecognized}/v8_flags_unrecognized.out (100%) create mode 100644 tests/specs/run/v8_help/__test__.jsonc rename tests/{testdata/run => specs/run/v8_help}/v8_help.out (100%) create mode 100644 tests/specs/run/wasm/__test__.jsonc rename tests/{testdata/run => specs/run/wasm}/wasm.ts (100%) create mode 100644 tests/specs/run/wasm/wasm.ts.out create mode 100644 tests/specs/run/wasm_async/__test__.jsonc rename tests/{testdata/run => specs/run/wasm_async}/wasm_async.js (100%) rename tests/{testdata/run => specs/run/wasm_async}/wasm_async.out (100%) create mode 100644 tests/specs/run/wasm_shared/__test__.jsonc create mode 100644 tests/specs/run/wasm_shared/wasm_shared.out rename tests/{testdata/run => specs/run/wasm_shared}/wasm_shared.ts (100%) create mode 100644 tests/specs/run/wasm_streaming_panic_test/__test__.jsonc rename tests/{testdata/run => specs/run/wasm_streaming_panic_test}/wasm_streaming_panic_test.js (100%) rename tests/{testdata/run => specs/run/wasm_streaming_panic_test}/wasm_streaming_panic_test.js.out (100%) create mode 100644 tests/specs/run/wasm_unreachable/__test__.jsonc create mode 100644 tests/specs/run/wasm_unreachable/unreachable.wasm rename tests/{testdata/run => specs/run/wasm_unreachable}/wasm_unreachable.js (82%) rename tests/{testdata/run => specs/run/wasm_unreachable}/wasm_unreachable.out (100%) create mode 100644 tests/specs/run/wasm_url/__test__.jsonc rename tests/{testdata/run => specs/run/wasm_url}/wasm_url.js (100%) rename tests/{testdata/run => specs/run/wasm_url}/wasm_url.out (100%) create mode 100644 tests/specs/run/weakref/__test__.jsonc rename tests/{testdata/run => specs/run/weakref}/weakref.ts (100%) rename tests/{testdata/run => specs/run/weakref}/weakref.ts.out (100%) create mode 100644 tests/specs/run/webstorage_serialization/__test__.jsonc create mode 100644 tests/specs/run/webstorage_serialization/webstorage/config_a.jsonc create mode 100644 tests/specs/run/webstorage_serialization/webstorage/config_b.jsonc create mode 100644 tests/specs/run/webstorage_serialization/webstorage/fixture.ts create mode 100644 tests/specs/run/webstorage_serialization/webstorage/logger.ts rename tests/{testdata/run => specs/run/webstorage_serialization}/webstorage/serialization.ts (100%) rename tests/{testdata/run => specs/run/webstorage_serialization}/webstorage/serialization.ts.out (100%) create mode 100644 tests/specs/run/webstorage_serialization/webstorage/setter.ts create mode 100644 tests/specs/run/worker_close_in_wasm_reactions/__test__.jsonc create mode 100644 tests/specs/run/worker_close_in_wasm_reactions/close_in_wasm_reactions.js rename tests/{testdata/run => specs/run/worker_close_in_wasm_reactions}/worker_close_in_wasm_reactions.js (80%) rename tests/{testdata/run => specs/run/worker_close_in_wasm_reactions}/worker_close_in_wasm_reactions.js.out (100%) create mode 100644 tests/specs/run/worker_close_nested/__test__.jsonc create mode 100644 tests/specs/run/worker_close_nested/close_nested_child.js create mode 100644 tests/specs/run/worker_close_nested/close_nested_parent.js rename tests/{testdata/run => specs/run/worker_close_nested}/worker_close_nested.js (89%) rename tests/{testdata/run => specs/run/worker_close_nested}/worker_close_nested.js.out (100%) create mode 100644 tests/specs/run/worker_close_race/__test__.jsonc create mode 100644 tests/specs/run/worker_close_race/close_race_worker.js rename tests/{testdata/run => specs/run/worker_close_race}/worker_close_race.js (85%) create mode 100644 tests/specs/run/worker_close_race/worker_close_race.js.out create mode 100644 tests/specs/run/worker_drop_handle_race/__test__.jsonc create mode 100644 tests/specs/run/worker_drop_handle_race/drop_handle_race.js rename tests/{testdata/run => specs/run/worker_drop_handle_race}/worker_drop_handle_race.js (88%) rename tests/{testdata/run => specs/run/worker_drop_handle_race}/worker_drop_handle_race.js.out (79%) create mode 100644 tests/specs/run/worker_drop_handle_race_terminate/__test__.jsonc rename tests/{testdata/run => specs/run/worker_drop_handle_race_terminate}/worker_drop_handle_race_terminate.js (100%) rename tests/{testdata/run => specs/run/worker_drop_handle_race_terminate}/worker_drop_handle_race_terminate.js.out (100%) create mode 100644 tests/specs/run/worker_event_handler_test/__test__.jsonc rename tests/{testdata/run => specs/run/worker_event_handler_test}/worker_event_handler_test.js (51%) rename tests/{testdata/run => specs/run/worker_event_handler_test}/worker_event_handler_test.js.out (100%) create mode 100644 tests/specs/run/worker_event_handler_test/worker_event_handlers.js create mode 100644 tests/specs/run/worker_message_before_close/__test__.jsonc create mode 100644 tests/specs/run/worker_message_before_close/message_before_close.js rename tests/{testdata/run => specs/run/worker_message_before_close}/worker_message_before_close.js (89%) rename tests/{testdata/run => specs/run/worker_message_before_close}/worker_message_before_close.js.out (100%) delete mode 100644 tests/testdata/run/014_duplicate_import.ts delete mode 100644 tests/testdata/run/020_json_modules.ts delete mode 100644 tests/testdata/run/021_mjs_modules.ts delete mode 100644 tests/testdata/run/035_cached_only_flag.out delete mode 100644 tests/testdata/run/044_bad_resource.ts delete mode 100644 tests/testdata/run/config_json_import.ts delete mode 100644 tests/testdata/run/error_002.ts delete mode 100644 tests/testdata/run/error_015_dynamic_import_permissions.js delete mode 100644 tests/testdata/run/error_no_check.ts delete mode 100644 tests/testdata/run/error_no_check.ts.out delete mode 100644 tests/testdata/run/error_type_definitions.ts delete mode 100644 tests/testdata/run/fix_emittable_skipped.js delete mode 100644 tests/testdata/run/fix_js_import_js.ts delete mode 100644 tests/testdata/run/fix_js_imports.ts delete mode 100644 tests/testdata/run/import_type.ts delete mode 100644 tests/testdata/run/issue13562.ts delete mode 100644 tests/testdata/run/lock_check_ok.json delete mode 100644 tests/testdata/run/lock_v2_check_ok.json delete mode 100644 tests/testdata/run/type_directives_02.ts delete mode 100644 tests/testdata/run/type_directives_02.ts.out delete mode 100644 tests/testdata/run/unhandled_rejection.ts.out delete mode 100644 tests/testdata/run/unhandled_rejection_sync_error.ts.out delete mode 100644 tests/testdata/run/with_package_json/with_stop/main.out diff --git a/.dprint.json b/.dprint.json index 489a61e571..3b2376f786 100644 --- a/.dprint.json +++ b/.dprint.json @@ -65,7 +65,11 @@ "tests/wpt/runner/expectation.json", "tests/wpt/runner/manifest.json", "tests/wpt/suite", - "third_party" + "third_party", + "tests/specs/run/shebang_with_json_imports_tsc", + "tests/specs/run/shebang_with_json_imports_swc", + "tests/specs/run/ext_flag_takes_precedence_over_extension", + "tests/specs/run/error_syntax_empty_trailing_line/error_syntax_empty_trailing_line.mjs" ], "plugins": [ "https://plugins.dprint.dev/typescript-0.93.2.wasm", diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index a07dd56c83..686fbabcf6 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -24,272 +24,12 @@ use trust_dns_client::serialize::txt::Lexer; use trust_dns_client::serialize::txt::Parser; use util::assert_contains; use util::assert_not_contains; -use util::env_vars_for_npm_tests; use util::PathRef; use util::TestContext; use util::TestContextBuilder; const CODE_CACHE_DB_FILE_NAME: &str = "v8_code_cache_v2"; -itest!(stdout_write_all { - args: "run --quiet run/stdout_write_all.ts", - output: "run/stdout_write_all.out", -}); - -itest!(stdin_read_all { - args: "run --quiet run/stdin_read_all.ts", - output: "run/stdin_read_all.out", - input: Some("01234567890123456789012345678901234567890123456789"), -}); - -itest!(stdout_write_sync_async { - args: "run --quiet run/stdout_write_sync_async.ts", - output: "run/stdout_write_sync_async.out", -}); - -itest!(_001_hello { - args: "run --reload run/001_hello.js", - output: "run/001_hello.js.out", -}); - -itest!(_002_hello { - args: "run --quiet --reload run/002_hello.ts", - output: "run/002_hello.ts.out", -}); - -itest!(_003_relative_import { - args: "run --quiet --reload run/003_relative_import.ts", - output: "run/003_relative_import.ts.out", -}); - -itest!(_004_set_timeout { - args: "run --quiet --reload run/004_set_timeout.ts", - output: "run/004_set_timeout.ts.out", -}); - -itest!(_005_more_imports { - args: "run --quiet --reload run/005_more_imports.ts", - output: "run/005_more_imports.ts.out", -}); - -itest!(_006_url_imports { - args: "run --quiet --reload --allow-import run/006_url_imports.ts", - output: "run/006_url_imports.ts.out", - http_server: true, -}); - -itest!(_012_async { - args: "run --quiet --reload run/012_async.ts", - output: "run/012_async.ts.out", -}); - -itest!(_013_dynamic_import { - args: "run --quiet --reload --allow-read run/013_dynamic_import.ts", - output: "run/013_dynamic_import.ts.out", -}); - -itest!(_014_duplicate_import { - args: "run --quiet --reload --allow-read run/014_duplicate_import.ts ", - output: "run/014_duplicate_import.ts.out", -}); - -itest!(_015_duplicate_parallel_import { - args: - "run --quiet --reload --allow-read run/015_duplicate_parallel_import.js", - output: "run/015_duplicate_parallel_import.js.out", -}); - -itest!(_016_double_await { - args: "run --quiet --allow-read --reload run/016_double_await.ts", - output: "run/016_double_await.ts.out", -}); - -itest!(_017_import_redirect { - args: "run --quiet --allow-import --reload run/017_import_redirect.ts", - output: "run/017_import_redirect.ts.out", -}); - -itest!(_017_import_redirect_check { - args: - "run --quiet --allow-import --reload --check run/017_import_redirect.ts", - output: "run/017_import_redirect.ts.out", -}); - -itest!(_017_import_redirect_vendor_dir { - args: - "run --quiet --allow-import --reload --vendor --check $TESTDATA/run/017_import_redirect.ts", - output: "run/017_import_redirect.ts.out", - temp_cwd: true, -}); - -itest!(_017_import_redirect_info { - args: "info --quiet --allow-import --reload run/017_import_redirect.ts", - output: "run/017_import_redirect_info.out", -}); - -itest!(_018_async_catch { - args: "run --quiet --reload run/018_async_catch.ts", - output: "run/018_async_catch.ts.out", -}); - -itest!(_019_media_types { - args: "run --reload --allow-import run/019_media_types.ts", - output: "run/019_media_types.ts.out", - http_server: true, -}); - -itest!(_020_json_modules { - args: "run --reload run/020_json_modules.ts", - output: "run/020_json_modules.ts.out", - exit_code: 1, -}); - -itest!(_021_mjs_modules { - args: "run --quiet --reload run/021_mjs_modules.ts", - output: "run/021_mjs_modules.ts.out", -}); - -itest!(_025_reload_js_type_error { - args: "run --quiet --reload run/025_reload_js_type_error.js", - output: "run/025_reload_js_type_error.js.out", -}); - -itest!(_027_redirect_typescript { - args: "run --quiet --reload --allow-import run/027_redirect_typescript.ts", - output: "run/027_redirect_typescript.ts.out", - http_server: true, -}); - -itest!(_027_redirect_typescript_vendor_dir { - args: - "run --quiet --reload --vendor --allow-import $TESTDATA/run/027_redirect_typescript.ts", - output: "run/027_redirect_typescript.ts.out", - http_server: true, - temp_cwd: true, -}); - -itest!(_028_args { - args: - "run --quiet --reload run/028_args.ts --arg1 val1 --arg2=val2 -- arg3 arg4", - output: "run/028_args.ts.out", -}); - -itest!(_033_import_map_remote { - args: - "run --quiet --reload --allow-import --import-map=http://127.0.0.1:4545/import_maps/import_map_remote.json import_maps/test_remote.ts", - output: "run/033_import_map_remote.out", - http_server: true, -}); - -itest!(_033_import_map_vendor_dir_remote { - args: - "run --quiet --reload --allow-import --import-map=http://127.0.0.1:4545/import_maps/import_map_remote.json --vendor $TESTDATA/import_maps/test_remote.ts", - output: "run/033_import_map_remote.out", - http_server: true, - temp_cwd: true, -}); - -itest!(_033_import_map_data_uri { - args: - "run --quiet --reload --allow-import --import-map=data:application/json;charset=utf-8;base64,ewogICJpbXBvcnRzIjogewogICAgInRlc3Rfc2VydmVyLyI6ICJodHRwOi8vbG9jYWxob3N0OjQ1NDUvIgogIH0KfQ== run/import_maps/test_data.ts", - output: "run/import_maps/test_data.ts.out", - http_server: true, -}); - -itest!(onload { - args: "run --quiet --reload --config ../config/deno.json run/onload/main.ts", - output: "run/onload/main.out", -}); - -itest!(_035_cached_only_flag { - args: "run --reload --check --allow-import --cached-only http://127.0.0.1:4545/run/019_media_types.ts", - output: "run/035_cached_only_flag.out", - exit_code: 1, - http_server: true, -}); - -itest!(_038_checkjs { - // checking if JS file is run through TS compiler - args: - "run --reload --config run/checkjs.tsconfig.json --check run/038_checkjs.js", - exit_code: 1, - output: "run/038_checkjs.js.out", -}); - -itest!(_042_dyn_import_evalcontext { - args: "run --quiet --allow-read --reload run/042_dyn_import_evalcontext.ts", - output: "run/042_dyn_import_evalcontext.ts.out", -}); - -itest!(_044_bad_resource { - args: "run --quiet --reload --allow-read run/044_bad_resource.ts", - output: "run/044_bad_resource.ts.out", - exit_code: 1, -}); - -itest!(_046_tsx { - args: "run --quiet --reload run/046_jsx_test.tsx", - output: "run/046_jsx_test.tsx.out", -}); - -itest!(_047_jsx { - args: "run --quiet --reload run/047_jsx_test.jsx", - output: "run/047_jsx_test.jsx.out", -}); - -itest!(_048_media_types_jsx { - args: "run --reload --allow-import run/048_media_types_jsx.ts", - output: "run/048_media_types_jsx.ts.out", - http_server: true, -}); - -itest!(_052_no_remote_flag { - args: - "run --reload --check --allow-import --no-remote http://127.0.0.1:4545/run/019_media_types.ts", - output: "run/052_no_remote_flag.out", - exit_code: 1, - http_server: true, -}); - -itest!(_058_tasks_microtasks_close { - args: "run --quiet run/058_tasks_microtasks_close.ts", - output: "run/058_tasks_microtasks_close.ts.out", -}); - -itest!(_059_fs_relative_path_perm { - args: "run run/059_fs_relative_path_perm.ts", - output: "run/059_fs_relative_path_perm.ts.out", - exit_code: 1, -}); - -itest!(_070_location { - args: "run --location https://foo/bar?baz#bat run/070_location.ts", - output: "run/070_location.ts.out", -}); - -itest!(_071_location_unset { - args: "run run/071_location_unset.ts", - output: "run/071_location_unset.ts.out", -}); - -itest!(_072_location_relative_fetch { - args: "run --location http://127.0.0.1:4545/ --allow-net run/072_location_relative_fetch.ts", - output: "run/072_location_relative_fetch.ts.out", - http_server: true, -}); - -// tests the beforeunload event -itest!(beforeunload_event { - args: "run run/before_unload.js", - output: "run/before_unload.js.out", -}); - -// tests the serialization of webstorage (both localStorage and sessionStorage) -itest!(webstorage_serialization { - args: "run run/webstorage/serialization.ts", - output: "run/webstorage/serialization.ts.out", -}); - // tests to ensure that when `--location` is set, all code shares the same // localStorage cache based on the origin of the location URL. #[test] @@ -394,41 +134,6 @@ fn webstorage_main_module() { .assert_matches_text("Storage { hello: \"deno\", length: 1 }\n"); } -itest!(_075_import_local_query_hash { - args: "run run/075_import_local_query_hash.ts", - output: "run/075_import_local_query_hash.ts.out", -}); - -itest!(_077_fetch_empty { - args: "run -A run/077_fetch_empty.ts", - output: "run/077_fetch_empty.ts.out", - exit_code: 1, -}); - -itest!(_078_unload_on_exit { - args: "run run/078_unload_on_exit.ts", - output: "run/078_unload_on_exit.ts.out", - exit_code: 1, -}); - -itest!(_079_location_authentication { - args: - "run --location https://foo:bar@baz/qux run/079_location_authentication.ts", - output: "run/079_location_authentication.ts.out", -}); - -itest!(_081_location_relative_fetch_redirect { - args: "run --location http://127.0.0.1:4546/ --allow-net run/081_location_relative_fetch_redirect.ts", - output: "run/081_location_relative_fetch_redirect.ts.out", - http_server: true, - }); - -itest!(_082_prepare_stack_trace_throw { - args: "run run/082_prepare_stack_trace_throw.js", - output: "run/082_prepare_stack_trace_throw.js.out", - exit_code: 1, -}); - #[test] fn _083_legacy_external_source_map() { let _g = util::http_server(); @@ -457,27 +162,6 @@ fn _083_legacy_external_source_map() { assert_eq!(out, ""); } -itest!(dynamic_import_async_error { - args: "run --allow-read run/dynamic_import_async_error/main.ts", - output: "run/dynamic_import_async_error/main.out", -}); - -itest!(dynamic_import_already_rejected { - args: "run --allow-read run/dynamic_import_already_rejected/main.ts", - output: "run/dynamic_import_already_rejected/main.out", -}); - -itest!(dynamic_import_concurrent_non_statically_analyzable { - args: "run --allow-import --allow-read --allow-net --quiet run/dynamic_import_concurrent_non_statically_analyzable/main.ts", - output: "run/dynamic_import_concurrent_non_statically_analyzable/main.out", - http_server: true, -}); - -itest!(_088_dynamic_import_already_evaluating { - args: "run --allow-read run/088_dynamic_import_already_evaluating.ts", - output: "run/088_dynamic_import_already_evaluating.ts.out", -}); - itest!(_089_run_allow_list { args: "run --allow-run=curl run/089_run_allow_list.ts", envs: vec![ @@ -713,16 +397,6 @@ fn permission_request_long() { }); } -itest!(deny_all_permission_args { - args: "run --deny-env --deny-read --deny-write --deny-ffi --deny-run --deny-sys --deny-net run/deny_all_permission_args.js", - output: "run/deny_all_permission_args.out", -}); - -itest!(deny_some_permission_args { - args: "run --allow-env --deny-env=FOO --allow-read --deny-read=/foo --allow-write --deny-write=/foo --allow-ffi --deny-ffi=/foo --allow-run --deny-run=foo --allow-sys --deny-sys=hostname --allow-net --deny-net=127.0.0.1 run/deny_some_permission_args.js", - output: "run/deny_some_permission_args.out", -}); - #[test] fn permissions_cache() { TestContext::default() @@ -755,52 +429,6 @@ itest!(env_file_missing { output: "run/env_file_missing.out", }); -itest!(_091_use_define_for_class_fields { - args: "run --check run/091_use_define_for_class_fields.ts", - output: "run/091_use_define_for_class_fields.ts.out", - exit_code: 1, -}); - -itest!(js_import_detect { - args: "run --quiet --reload run/js_import_detect.ts", - output: "run/js_import_detect.ts.out", - exit_code: 0, -}); - -itest!(blob_gc_finalization { - args: "run run/blob_gc_finalization.js", - output: "run/blob_gc_finalization.js.out", - exit_code: 0, -}); - -itest!(fetch_response_finalization { - args: - "run --v8-flags=--expose-gc --allow-net run/fetch_response_finalization.js", - output: "run/fetch_response_finalization.js.out", - http_server: true, - exit_code: 0, -}); - -itest!(import_type { - args: "run --reload run/import_type.ts", - output: "run/import_type.ts.out", -}); - -itest!(import_type_no_check { - args: "run --reload --no-check run/import_type.ts", - output: "run/import_type.ts.out", -}); - -itest!(private_field_presence { - args: "run --reload run/private_field_presence.ts", - output: "run/private_field_presence.ts.out", -}); - -itest!(private_field_presence_no_check { - args: "run --reload --no-check run/private_field_presence.ts", - output: "run/private_field_presence.ts.out", -}); - itest!(lock_write_fetch { args: "run --quiet --allow-import --allow-read --allow-write --allow-env --allow-run run/lock_write_fetch/main.ts", @@ -809,33 +437,6 @@ itest!(lock_write_fetch { exit_code: 0, }); -itest!(lock_check_ok { - args: - "run --quiet --allow-import --lock=run/lock_check_ok.json http://127.0.0.1:4545/run/003_relative_import.ts", - output: "run/003_relative_import.ts.out", - http_server: true, -}); - -itest!(lock_check_ok2 { - args: - "run --allow-import --lock=run/lock_check_ok2.json run/019_media_types.ts", - output: "run/019_media_types.ts.out", - http_server: true, -}); - -itest!(lock_v2_check_ok { - args: - "run --allow-import --quiet --lock=run/lock_v2_check_ok.json http://127.0.0.1:4545/run/003_relative_import.ts", - output: "run/003_relative_import.ts.out", - http_server: true, -}); - -itest!(lock_v2_check_ok2 { - args: "run --allow-import --lock=run/lock_v2_check_ok2.json run/019_media_types.ts", - output: "run/019_media_types.ts.out", - http_server: true, -}); - #[test] fn lock_redirects() { let context = TestContextBuilder::new() @@ -1234,141 +835,12 @@ fn get_lockfile_npm_package_integrity( .to_string() } -itest!(mts_dmts_mjs { - args: "run subdir/import.mts", - output: "run/mts_dmts_mjs.out", -}); - -itest!(mts_dmts_mjs_no_check { - args: "run --no-check subdir/import.mts", - output: "run/mts_dmts_mjs.out", -}); - -itest!(async_error { - exit_code: 1, - args: "run --reload run/async_error.ts", - output: "run/async_error.ts.out", -}); - -itest!(config { - args: - "run --reload --config run/config/tsconfig.json --check run/config/main.ts", - output: "run/config/main.out", -}); - -itest!(config_types { - args: - "run --reload --quiet --check=all --config run/config_types/tsconfig.json run/config_types/main.ts", - output: "run/config_types/main.out", -}); - -itest!(config_types_remote { - http_server: true, - args: "run --allow-import --reload --quiet --check=all --config run/config_types/remote.tsconfig.json run/config_types/main.ts", - output: "run/config_types/main.out", -}); - -itest!(empty_typescript { - args: "run --reload --check run/empty.ts", - output_str: Some("Check file:[WILDCARD]/run/empty.ts\n"), -}); - -itest!(error_001 { - args: "run --reload run/error_001.ts", - exit_code: 1, - output: "run/error_001.ts.out", -}); - -itest!(error_002 { - args: "run --reload run/error_002.ts", - exit_code: 1, - output: "run/error_002.ts.out", -}); - -itest!(error_003_typescript { - args: "run --reload --check run/error_003_typescript.ts", - exit_code: 1, - output: "run/error_003_typescript.ts.out", -}); - -// Supposing that we've already attempted to run error_003_typescript.ts -// we want to make sure that JS wasn't emitted. Running again without reload flag -// should result in the same output. -// https://github.com/denoland/deno/issues/2436 -itest!(error_003_typescript2 { - args: "run --check run/error_003_typescript.ts", - exit_code: 1, - output: "run/error_003_typescript.ts.out", -}); - -itest!(error_004_missing_module { - args: "run --reload run/error_004_missing_module.ts", - exit_code: 1, - output: "run/error_004_missing_module.ts.out", -}); - -itest!(error_005_missing_dynamic_import { - args: - "run --reload --allow-read --quiet run/error_005_missing_dynamic_import.ts", - exit_code: 1, - output: "run/error_005_missing_dynamic_import.ts.out", -}); - -itest!(error_006_import_ext_failure { - args: "run --reload run/error_006_import_ext_failure.ts", - exit_code: 1, - output: "run/error_006_import_ext_failure.ts.out", -}); - -itest!(error_007_any { - args: "run --reload run/error_007_any.ts", - exit_code: 1, - output: "run/error_007_any.ts.out", -}); - -itest!(error_008_checkjs { - args: "run --reload run/error_008_checkjs.js", - exit_code: 1, - output: "run/error_008_checkjs.js.out", -}); - -itest!(error_009_extensions_error { - args: "run run/error_009_extensions_error.js", - output: "run/error_009_extensions_error.js.out", - exit_code: 1, -}); - -itest!(error_011_bad_module_specifier { - args: "run --reload run/error_011_bad_module_specifier.ts", - exit_code: 1, - output: "run/error_011_bad_module_specifier.ts.out", -}); - -itest!(error_012_bad_dynamic_import_specifier { - args: "run --reload --check run/error_012_bad_dynamic_import_specifier.ts", - exit_code: 1, - output: "run/error_012_bad_dynamic_import_specifier.ts.out", -}); - itest!(error_013_missing_script { args: "run --reload missing_file_name", exit_code: 1, output: "run/error_013_missing_script.out", }); -itest!(error_014_catch_dynamic_import_error { - args: - "run --reload --allow-read run/error_014_catch_dynamic_import_error.js", - output: "run/error_014_catch_dynamic_import_error.js.out", -}); - -itest!(error_015_dynamic_import_permissions { - args: "run --reload --quiet run/error_015_dynamic_import_permissions.js", - output: "run/error_015_dynamic_import_permissions.out", - exit_code: 1, - http_server: true, -}); - // We have an allow-import flag but not allow-read, it should still result in error. itest!(error_016_dynamic_import_permissions2 { args: @@ -1378,60 +850,6 @@ itest!(error_016_dynamic_import_permissions2 { http_server: true, }); -itest!(error_017_hide_long_source_ts { - args: "run --reload --check run/error_017_hide_long_source_ts.ts", - output: "run/error_017_hide_long_source_ts.ts.out", - exit_code: 1, -}); - -itest!(error_018_hide_long_source_js { - args: "run run/error_018_hide_long_source_js.js", - output: "run/error_018_hide_long_source_js.js.out", - exit_code: 1, -}); - -itest!(error_019_stack_function { - args: "run run/error_019_stack_function.ts", - output: "run/error_019_stack_function.ts.out", - exit_code: 1, -}); - -itest!(error_020_stack_constructor { - args: "run run/error_020_stack_constructor.ts", - output: "run/error_020_stack_constructor.ts.out", - exit_code: 1, -}); - -itest!(error_021_stack_method { - args: "run run/error_021_stack_method.ts", - output: "run/error_021_stack_method.ts.out", - exit_code: 1, -}); - -itest!(error_022_stack_custom_error { - args: "run run/error_022_stack_custom_error.ts", - output: "run/error_022_stack_custom_error.ts.out", - exit_code: 1, -}); - -itest!(error_023_stack_async { - args: "run run/error_023_stack_async.ts", - output: "run/error_023_stack_async.ts.out", - exit_code: 1, -}); - -itest!(error_024_stack_promise_all { - args: "run run/error_024_stack_promise_all.ts", - output: "run/error_024_stack_promise_all.ts.out", - exit_code: 1, -}); - -itest!(error_025_tab_indent { - args: "run run/error_025_tab_indent", - output: "run/error_025_tab_indent.out", - exit_code: 1, -}); - itest!(error_026_remote_import_error { args: "run --allow-import run/error_026_remote_import_error.ts", output: "run/error_026_remote_import_error.ts.out", @@ -1439,42 +857,6 @@ itest!(error_026_remote_import_error { http_server: true, }); -itest!(error_for_await { - args: "run --reload --check run/error_for_await.ts", - output: "run/error_for_await.ts.out", - exit_code: 1, -}); - -itest!(error_missing_module_named_import { - args: "run --reload run/error_missing_module_named_import.ts", - output: "run/error_missing_module_named_import.ts.out", - exit_code: 1, -}); - -itest!(error_no_check { - args: "run --reload --no-check run/error_no_check.ts", - output: "run/error_no_check.ts.out", - exit_code: 1, -}); - -itest!(error_syntax { - args: "run --reload run/error_syntax.js", - exit_code: 1, - output: "run/error_syntax.js.out", -}); - -itest!(error_syntax_empty_trailing_line { - args: "run --reload run/error_syntax_empty_trailing_line.mjs", - exit_code: 1, - output: "run/error_syntax_empty_trailing_line.mjs.out", -}); - -itest!(error_type_definitions { - args: "run --reload --check run/error_type_definitions.ts", - exit_code: 1, - output: "run/error_type_definitions.ts.out", -}); - itest!(error_local_static_import_from_remote_ts { args: "run --allow-import --reload http://localhost:4545/run/error_local_static_import_from_remote.ts", exit_code: 1, @@ -1489,138 +871,18 @@ itest!(error_local_static_import_from_remote_js { output: "run/error_local_static_import_from_remote.js.out", }); -itest!(exit_error42 { - exit_code: 42, - args: "run --quiet --reload run/exit_error42.ts", - output: "run/exit_error42.ts.out", -}); - -itest!(set_exit_code_0 { - args: "run --no-check run/set_exit_code_0.ts", - output_str: Some(""), - exit_code: 0, -}); - -itest!(set_exit_code_1 { - args: "run --no-check run/set_exit_code_1.ts", - output_str: Some(""), - exit_code: 42, -}); - -itest!(set_exit_code_2 { - args: "run --no-check run/set_exit_code_2.ts", - output_str: Some(""), - exit_code: 42, -}); - -itest!(op_exit_op_set_exit_code_in_worker { - args: "run --no-check --allow-read run/op_exit_op_set_exit_code_in_worker.ts", - exit_code: 21, - output_str: Some(""), -}); - -itest!(deno_exit_tampering { - args: "run --no-check run/deno_exit_tampering.ts", - output_str: Some(""), - exit_code: 42, -}); - -itest!(heapstats { - args: "run --quiet --v8-flags=--expose-gc run/heapstats.js", - output: "run/heapstats.js.out", -}); - -itest!(finalization_registry { - args: "run --quiet --v8-flags=--expose-gc run/finalization_registry.js", - output: "run/finalization_registry.js.out", -}); - -itest!(https_import { - args: "run --allow-import --quiet --reload --cert tls/RootCA.pem run/https_import.ts", - output: "run/https_import.ts.out", - http_server: true, -}); - -itest!(if_main { - args: "run --quiet --reload run/if_main.ts", - output: "run/if_main.ts.out", -}); - itest!(import_meta { args: "run --allow-import --quiet --reload --import-map=run/import_meta/importmap.json run/import_meta/main.ts", output: "run/import_meta/main.out", http_server: true, }); -itest!(main_module { - args: "run --quiet --reload run/main_module/main.ts", - output: "run/main_module/main.out", -}); - -itest!(no_check { - args: "run --allow-import --quiet --reload --no-check run/006_url_imports.ts", - output: "run/006_url_imports.ts.out", - http_server: true, -}); - -itest!(no_check_decorators { - args: "run --quiet --reload --no-check run/decorators/experimental/no_check/main.ts", - output: "run/decorators/experimental/no_check/main.out", -}); - -itest!(decorators_tc39_proposal { - args: "run --quiet --reload --check run/decorators/tc39_proposal/main.ts", - output: "run/decorators/tc39_proposal/main.out", -}); - -itest!(check_remote { - args: - "run --quiet --allow-import --reload --check=all run/no_check_remote.ts", - output: "run/no_check_remote.ts.disabled.out", - exit_code: 1, - http_server: true, -}); - itest!(no_check_remote { args: "run --allow-import --quiet --reload --no-check=remote run/no_check_remote.ts", output: "run/no_check_remote.ts.enabled.out", http_server: true, }); -itest!(runtime_decorators { - args: "run --quiet --reload --no-check run/decorators/experimental/runtime/main.ts", - output: "run/decorators/experimental/runtime/main.out", -}); - -itest!(seed_random { - args: "run --seed=100 run/seed_random.js", - output: "run/seed_random.js.out", -}); - -itest!(type_definitions { - args: "run --reload run/type_definitions.ts", - output: "run/type_definitions.ts.out", -}); - -itest!(type_definitions_for_export { - args: "run --reload --check run/type_definitions_for_export.ts", - output: "run/type_definitions_for_export.ts.out", - exit_code: 1, -}); - -itest!(type_directives_01 { - args: - "run --allow-import --reload --check=all -L debug run/type_directives_01.ts", - output: "run/type_directives_01.ts.out", - http_server: true, -}); - -itest!(type_directives_02 { - args: - "run --allow-import --reload --check=all -L debug run/type_directives_02.ts", - output: "run/type_directives_02.ts.out", -}); - #[test] fn type_directives_js_main() { let context = TestContext::default(); @@ -1642,216 +904,6 @@ itest!(type_directives_redirect { http_server: true, }); -itest!(type_headers_deno_types { - args: "run --allow-import --reload --check run/type_headers_deno_types.ts", - output: "run/type_headers_deno_types.ts.out", - http_server: true, -}); - -itest!(ts_type_imports { - args: "run --reload --check run/ts_type_imports.ts", - output: "run/ts_type_imports.ts.out", - exit_code: 1, -}); - -itest!(ts_decorators { - args: "run --reload --check run/decorators/experimental/ts/main.ts", - output: "run/decorators/experimental/ts/main.out", -}); - -itest!(ts_type_only_import { - args: "run --reload --check run/ts_type_only_import.ts", - output: "run/ts_type_only_import.ts.out", -}); - -itest!(swc_syntax_error { - args: "run --reload --check run/swc_syntax_error.ts", - output: "run/swc_syntax_error.ts.out", - exit_code: 1, -}); - -itest!(unbuffered_stderr { - args: "run --reload run/unbuffered_stderr.ts", - output: "run/unbuffered_stderr.ts.out", -}); - -itest!(unbuffered_stdout { - args: "run --quiet --reload run/unbuffered_stdout.ts", - output: "run/unbuffered_stdout.ts.out", -}); - -itest!(v8_flags_run { - args: "run --v8-flags=--expose-gc run/v8_flags.js", - output: "run/v8_flags.js.out", -}); - -itest!(v8_flags_env_run { - envs: vec![("DENO_V8_FLAGS".to_string(), "--expose-gc".to_string())], - args: "run run/v8_flags.js", - output: "run/v8_flags.js.out", -}); - -itest!(v8_flags_unrecognized { - args: "repl --v8-flags=--foo,bar,--trace-gc,-baz", - output: "run/v8_flags_unrecognized.out", - exit_code: 1, -}); - -itest!(v8_help { - args: "repl --v8-flags=--help", - output: "run/v8_help.out", -}); - -itest!(unsupported_dynamic_import_scheme { - args: "eval import('xxx:')", - output: "run/unsupported_dynamic_import_scheme.out", - exit_code: 1, -}); - -itest!(wasm { - args: "run --quiet run/wasm.ts", - output: "run/wasm.ts.out", -}); - -itest!(wasm_shared { - args: "run --quiet run/wasm_shared.ts", - output: "run/wasm_shared.out", -}); - -itest!(wasm_async { - args: "run run/wasm_async.js", - output: "run/wasm_async.out", -}); - -itest!(wasm_unreachable { - args: "run --allow-read run/wasm_unreachable.js", - output: "run/wasm_unreachable.out", - exit_code: 1, -}); - -itest!(wasm_url { - args: "run --quiet --allow-net=localhost:4545 run/wasm_url.js", - output: "run/wasm_url.out", - exit_code: 1, - http_server: true, -}); - -itest!(weakref { - args: "run --quiet --reload run/weakref.ts", - output: "run/weakref.ts.out", -}); - -itest!(top_level_await_order { - args: "run --allow-read run/top_level_await/order.js", - output: "run/top_level_await/order.out", -}); - -itest!(top_level_await_loop { - args: "run --allow-read run/top_level_await/loop.js", - output: "run/top_level_await/loop.out", -}); - -itest!(top_level_await_circular { - args: "run --allow-read run/top_level_await/circular.js", - output: "run/top_level_await/circular.out", - exit_code: 1, -}); - -// Regression test for https://github.com/denoland/deno/issues/11238. -itest!(top_level_await_nested { - args: "run --allow-read run/top_level_await/nested/main.js", - output: "run/top_level_await/nested.out", -}); - -itest!(top_level_await_unresolved { - args: "run run/top_level_await/unresolved.js", - output: "run/top_level_await/unresolved.out", - exit_code: 1, -}); - -itest!(top_level_await { - args: "run --allow-read run/top_level_await/top_level_await.js", - output: "run/top_level_await/top_level_await.out", -}); - -itest!(top_level_await_ts { - args: "run --quiet --allow-read run/top_level_await/top_level_await.ts", - output: "run/top_level_await/top_level_await.out", -}); - -itest!(top_level_for_await { - args: "run --quiet run/top_level_await/top_level_for_await.js", - output: "run/top_level_await/top_level_for_await.out", -}); - -itest!(top_level_for_await_ts { - args: "run --quiet run/top_level_await/top_level_for_await.ts", - output: "run/top_level_await/top_level_for_await.out", -}); - -itest!(unstable_worker { - args: "run --reload --quiet --allow-read run/unstable_worker.ts", - output: "run/unstable_worker.ts.out", -}); - -itest!(unstable_worker_options_disabled { - args: "run --quiet --reload --allow-read run/unstable_worker_options.js", - output: "run/unstable_worker_options.disabled.out", - exit_code: 70, -}); - -itest!(unstable_worker_options_enabled { - args: "run --quiet --reload --allow-read --unstable-worker-options run/unstable_worker_options.js", - output: "run/unstable_worker_options.enabled.out", -}); - -itest!(unstable_broadcast_channel_disabled { - args: "run --quiet --reload --allow-read run/unstable_broadcast_channel.js", - output: "run/unstable_broadcast_channel.disabled.out", -}); - -itest!(unstable_broadcast_channel_enabled { - args: "run --quiet --reload --allow-read --unstable-broadcast-channel run/unstable_broadcast_channel.js", - output: "run/unstable_broadcast_channel.enabled.out", -}); - -itest!(unstable_cron_disabled { - args: "run --quiet --reload --allow-read run/unstable_cron.js", - output: "run/unstable_cron.disabled.out", -}); - -itest!(unstable_cron_enabled { - args: - "run --quiet --reload --allow-read --unstable-cron run/unstable_cron.js", - output: "run/unstable_cron.enabled.out", -}); - -itest!(unstable_net_disabled { - args: "run --quiet --reload --allow-read run/unstable_net.js", - output: "run/unstable_net.disabled.out", -}); - -itest!(unstable_net_enabled { - args: "run --quiet --reload --allow-read --unstable-net run/unstable_net.js", - output: "run/unstable_net.enabled.out", -}); - -itest!(unstable_kv_disabled { - args: "run --quiet --reload --allow-read run/unstable_kv.js", - output: "run/unstable_kv.disabled.out", -}); - -itest!(unstable_kv_enabled { - args: "run --quiet --reload --allow-read --unstable-kv run/unstable_kv.js", - output: "run/unstable_kv.enabled.out", -}); - -itest!(import_compression { - args: "run --allow-import --quiet --reload --allow-net run/import_compression/main.ts", - output: "run/import_compression/main.out", - http_server: true, -}); - itest!(disallow_http_from_https_js { args: "run --allow-import --quiet --reload --cert tls/RootCA.pem https://localhost:5545/run/disallow_http_from_https.js", output: "run/disallow_http_from_https_js.out", @@ -1866,131 +918,6 @@ itest!(disallow_http_from_https_ts { exit_code: 1, }); -itest!(dynamic_import_conditional { - args: "run --quiet --reload run/dynamic_import_conditional.js", - output: "run/dynamic_import_conditional.js.out", -}); - -itest!(tsx_imports { - args: "run --reload --check run/tsx_imports/tsx_imports.ts", - output: "run/tsx_imports/tsx_imports.ts.out", -}); - -itest!(fix_dynamic_import_errors { - args: "run --reload run/fix_dynamic_import_errors.js", - output: "run/fix_dynamic_import_errors.js.out", -}); - -itest!(fix_emittable_skipped { - args: "run --reload run/fix_emittable_skipped.js", - output: "run/fix_emittable_skipped.ts.out", -}); - -itest!(fix_js_import_js { - args: "run --quiet --reload run/fix_js_import_js.ts", - output: "run/fix_js_import_js.ts.out", -}); - -itest!(fix_js_imports { - args: "run --quiet --reload run/fix_js_imports.ts", - output: "run/fix_js_imports.ts.out", -}); - -itest!(fix_tsc_file_exists { - args: "run --quiet --reload tsc/test.js", - output: "run/fix_tsc_file_exists.out", -}); - -itest!(fix_worker_dispatchevent { - args: "run --quiet --reload run/fix_worker_dispatchevent.ts", - output: "run/fix_worker_dispatchevent.ts.out", -}); - -itest!(es_private_fields { - args: "run --quiet --reload run/es_private_fields.js", - output: "run/es_private_fields.js.out", -}); - -itest!(ts_import_from_js { - args: "run --allow-import --quiet --reload run/ts_import_from_js/main.js", - output: "run/ts_import_from_js/main.out", - http_server: true, -}); - -itest!(jsx_import_from_ts { - args: "run --quiet --reload run/jsx_import_from_ts.ts", - output: "run/jsx_import_from_ts.ts.out", -}); - -itest!(jsx_import_source_pragma { - args: "run --reload --allow-import run/jsx_import_source_pragma.tsx", - output: "run/jsx_import_source.out", - http_server: true, -}); - -itest!(jsx_import_source_pragma_with_config { - args: - "run --reload --allow-import --config jsx/deno-jsx.jsonc --no-lock run/jsx_import_source_pragma.tsx", - output: "run/jsx_import_source.out", - http_server: true, -}); - -itest!(jsx_import_source_pragma_with_dev_config { - args: - "run --reload --allow-import --config jsx/deno-jsxdev.jsonc --no-lock run/jsx_import_source_pragma.tsx", - output: "run/jsx_import_source_dev.out", - http_server: true, -}); - -itest!(jsx_import_source_no_pragma { - args: - "run --allow-import --reload --config jsx/deno-jsx.jsonc --no-lock run/jsx_import_source_no_pragma.tsx", - output: "run/jsx_import_source.out", - http_server: true, -}); - -itest!(jsx_import_source_no_pragma_dev { - args: "run --allow-import --reload --config jsx/deno-jsxdev.jsonc --no-lock run/jsx_import_source_no_pragma.tsx", - output: "run/jsx_import_source_dev.out", - http_server: true, -}); - -itest!(jsx_import_source_pragma_import_map { - args: "run --allow-import --reload --import-map jsx/import-map.json run/jsx_import_source_pragma_import_map.tsx", - output: "run/jsx_import_source_import_map.out", - http_server: true, -}); - -itest!(jsx_import_source_pragma_import_map_dev { - args: "run --allow-import --reload --import-map jsx/import-map.json --config jsx/deno-jsxdev-import-map.jsonc run/jsx_import_source_pragma_import_map.tsx", - output: "run/jsx_import_source_import_map_dev.out", - http_server: true, -}); - -itest!(jsx_import_source_precompile_import_map { - args: "run --allow-import --reload --check --import-map jsx/import-map.json --no-lock --config jsx/deno-jsx-precompile.jsonc run/jsx_precompile/no_pragma.tsx", - output: "run/jsx_precompile/no_pragma.out", - http_server: true, -}); - -itest!(jsx_import_source_precompile_import_map_skip_element { - args: "run --allow-import --reload --check --import-map jsx/import-map.json --no-lock --config jsx/deno-jsx-precompile-skip.jsonc run/jsx_precompile/skip.tsx", - output: "run/jsx_precompile/skip.out", - http_server: true, -}); - -itest!(jsx_import_source_import_map { - args: "run --allow-import --reload --import-map jsx/import-map.json --no-lock --config jsx/deno-jsx-import-map.jsonc run/jsx_import_source_no_pragma.tsx", - output: "run/jsx_import_source_import_map.out", - http_server: true, -}); - -itest!(jsx_import_source_import_map_dev { - args: "run --allow-import --reload --import-map jsx/import-map.json --no-lock --config jsx/deno-jsxdev-import-map.jsonc run/jsx_import_source_no_pragma.tsx", - output: "run/jsx_import_source_import_map_dev.out", - http_server: true, -}); - itest!(jsx_import_source_import_map_scoped { args: "run --allow-import --reload --import-map jsx/import-map-scoped.json --no-lock --config jsx/deno-jsx-import-map.jsonc subdir/jsx_import_source_no_pragma.tsx", output: "run/jsx_import_source_import_map.out", @@ -2003,289 +930,12 @@ itest!(jsx_import_source_import_map_scoped_dev { http_server: true, }); -itest!(jsx_import_source_pragma_no_check { - args: - "run --allow-import --reload --no-check run/jsx_import_source_pragma.tsx", - output: "run/jsx_import_source.out", - http_server: true, -}); - -itest!(jsx_import_source_pragma_with_config_no_check { - args: "run --allow-import --reload --config jsx/deno-jsx.jsonc --no-lock --no-check run/jsx_import_source_pragma.tsx", - output: "run/jsx_import_source.out", - http_server: true, -}); - -itest!(jsx_import_source_pragma_with_config_vendor_dir { - args: "run --allow-import --reload --config jsx/deno-jsx.jsonc --no-lock --vendor $TESTDATA/run/jsx_import_source_pragma.tsx", - output: "run/jsx_import_source.out", - http_server: true, - temp_cwd: true, - copy_temp_dir: Some("jsx/"), -}); - -itest!(jsx_import_source_no_pragma_no_check { - args: - "run --allow-import --reload --config jsx/deno-jsx.jsonc --no-lock --no-check run/jsx_import_source_no_pragma.tsx", - output: "run/jsx_import_source.out", - http_server: true, -}); - -itest!(jsx_import_source_pragma_import_map_no_check { - args: "run --allow-import --reload --import-map jsx/import-map.json --no-check run/jsx_import_source_pragma_import_map.tsx", - output: "run/jsx_import_source_import_map.out", - http_server: true, -}); - -itest!(jsx_import_source_import_map_no_check { - args: "run --allow-import --reload --import-map jsx/import-map.json --no-lock --config jsx/deno-jsx-import-map.jsonc --no-check run/jsx_import_source_no_pragma.tsx", - output: "run/jsx_import_source_import_map.out", - http_server: true, -}); - -itest!(jsx_import_source_error { - args: "run --config jsx/deno-jsx-error.jsonc --check run/jsx_import_source_no_pragma.tsx", - output: "run/jsx_import_source_error.out", - exit_code: 1, -}); - -itest!(single_compile_with_reload { - args: "run --reload --allow-read run/single_compile_with_reload.ts", - output: "run/single_compile_with_reload.ts.out", -}); - -itest!(proto_exploit { - args: "run run/proto_exploit.js", - output: "run/proto_exploit.js.out", -}); - -itest!(reference_types { - args: "run --reload --quiet run/reference_types.ts", - output: "run/reference_types.ts.out", -}); - -itest!(references_types_remote { - http_server: true, - args: "run --reload --quiet run/reference_types_remote.ts", - output: "run/reference_types_remote.ts.out", -}); - -itest!(reference_types_error { - args: - "run --config run/checkjs.tsconfig.json --check run/reference_types_error.js", - output: "run/reference_types_error.js.out", - exit_code: 1, -}); - -itest!(reference_types_error_vendor_dir { - args: - "run --config run/checkjs.tsconfig.json --check --vendor $TESTDATA/run/reference_types_error.js", - output: "run/reference_types_error.js.out", - exit_code: 1, -}); - -itest!(reference_types_error_no_check { - args: "run --no-check run/reference_types_error.js", - output_str: Some(""), -}); - -itest!(import_data_url_error_stack { - args: "run --quiet --reload run/import_data_url_error_stack.ts", - output: "run/import_data_url_error_stack.ts.out", - exit_code: 1, -}); - -itest!(import_data_url_import_relative { - args: "run --quiet --reload run/import_data_url_import_relative.ts", - output: "run/import_data_url_import_relative.ts.out", - exit_code: 1, -}); - -itest!(import_data_url_imports { - args: "run --allow-import --quiet --reload run/import_data_url_imports.ts", - output: "run/import_data_url_imports.ts.out", - http_server: true, -}); - -itest!(import_data_url_jsx { - args: "run --quiet --reload run/import_data_url_jsx.ts", - output: "run/import_data_url_jsx.ts.out", -}); - -itest!(import_data_url { - args: "run --quiet --reload run/import_data_url.ts", - output: "run/import_data_url.ts.out", -}); - -itest!(import_dynamic_data_url { - args: "run --quiet --reload run/import_dynamic_data_url.ts", - output: "run/import_dynamic_data_url.ts.out", -}); - -itest!(import_blob_url_error_stack { - args: "run --quiet --reload run/import_blob_url_error_stack.ts", - output: "run/import_blob_url_error_stack.ts.out", - exit_code: 1, -}); - -itest!(import_blob_url_import_relative { - args: "run --quiet --reload run/import_blob_url_import_relative.ts", - output: "run/import_blob_url_import_relative.ts.out", - exit_code: 1, -}); - -itest!(import_blob_url_imports { - args: - "run --allow-import --quiet --reload --allow-net=localhost:4545 run/import_blob_url_imports.ts", - output: "run/import_blob_url_imports.ts.out", - http_server: true, -}); - -itest!(import_blob_url_jsx { - args: "run --quiet --reload run/import_blob_url_jsx.ts", - output: "run/import_blob_url_jsx.ts.out", -}); - -itest!(import_blob_url { - args: "run --quiet --reload run/import_blob_url.ts", - output: "run/import_blob_url.ts.out", -}); - -itest!(import_file_with_colon { - args: "run --allow-import --quiet --reload run/import_file_with_colon.ts", - output: "run/import_file_with_colon.ts.out", - http_server: true, -}); - -itest!(import_extensionless { - args: "run --allow-import --quiet --reload run/import_extensionless.ts", - output: "run/import_extensionless.ts.out", - http_server: true, -}); - -itest!(classic_workers_event_loop { - args: - "run --enable-testing-features-do-not-use run/classic_workers_event_loop.js", - output: "run/classic_workers_event_loop.js.out", -}); - // FIXME(bartlomieju): disabled, because this test is very flaky on CI // itest!(local_sources_not_cached_in_memory { // args: "run --allow-read --allow-write run/no_mem_cache.js", // output: "run/no_mem_cache.js.out", // }); -// This test checks that inline source map data is used. It uses a hand crafted -// source map that maps to a file that exists, but is not loaded into the module -// graph (inline_js_source_map_2.ts) (because there are no direct dependencies). -// Source line is not remapped because no inline source contents are included in -// the sourcemap and the file is not present in the dependency graph. -itest!(inline_js_source_map_2 { - args: "run --quiet run/inline_js_source_map_2.js", - output: "run/inline_js_source_map_2.js.out", - exit_code: 1, -}); - -// This test checks that inline source map data is used. It uses a hand crafted -// source map that maps to a file that exists, but is not loaded into the module -// graph (inline_js_source_map_2.ts) (because there are no direct dependencies). -// Source line remapped using th inline source contents that are included in the -// inline source map. -itest!(inline_js_source_map_2_with_inline_contents { - args: "run --quiet run/inline_js_source_map_2_with_inline_contents.js", - output: "run/inline_js_source_map_2_with_inline_contents.js.out", - exit_code: 1, -}); - -// This test checks that inline source map data is used. It uses a hand crafted -// source map that maps to a file that exists, and is loaded into the module -// graph because of a direct import statement (inline_js_source_map.ts). The -// source map was generated from an earlier version of this file, where the throw -// was not commented out. The source line is remapped using source contents that -// from the module graph. -itest!(inline_js_source_map_with_contents_from_graph { - args: "run --allow-import --quiet run/inline_js_source_map_with_contents_from_graph.js", - output: "run/inline_js_source_map_with_contents_from_graph.js.out", - exit_code: 1, - http_server: true, -}); - -// This test ensures that a descriptive error is shown when we're unable to load -// the import map. Even though this tests only the `run` subcommand, we can be sure -// that the error message is similar for other subcommands as they all use -// `program_state.maybe_import_map` to access the import map underneath. -itest!(error_import_map_unable_to_load { - args: "run --import-map=import_maps/does_not_exist.json import_maps/test.ts", - output: "run/error_import_map_unable_to_load.out", - exit_code: 1, -}); - -// Test that setting `self` in the main thread to some other value doesn't break -// the world. -itest!(replace_self { - args: "run run/replace_self.js", - output: "run/replace_self.js.out", -}); - -itest!(worker_event_handler_test { - args: "run --quiet --reload --allow-read run/worker_event_handler_test.js", - output: "run/worker_event_handler_test.js.out", -}); - -itest!(worker_close_race { - args: "run --quiet --reload --allow-read run/worker_close_race.js", - output: "run/worker_close_race.js.out", -}); - -itest!(worker_drop_handle_race { - args: "run --quiet --reload --allow-read run/worker_drop_handle_race.js", - output: "run/worker_drop_handle_race.js.out", - exit_code: 1, -}); - -itest!(worker_drop_handle_race_terminate { - args: "run run/worker_drop_handle_race_terminate.js", - output: "run/worker_drop_handle_race_terminate.js.out", -}); - -itest!(worker_close_nested { - args: "run --quiet --reload --allow-read run/worker_close_nested.js", - output: "run/worker_close_nested.js.out", -}); - -itest!(worker_message_before_close { - args: "run --quiet --reload --allow-read run/worker_message_before_close.js", - output: "run/worker_message_before_close.js.out", -}); - -itest!(worker_close_in_wasm_reactions { - args: - "run --quiet --reload --allow-read run/worker_close_in_wasm_reactions.js", - output: "run/worker_close_in_wasm_reactions.js.out", -}); - -itest!(shebang_tsc { - args: "run --quiet --check run/shebang.ts", - output: "run/shebang.ts.out", -}); - -itest!(shebang_swc { - args: "run --quiet run/shebang.ts", - output: "run/shebang.ts.out", -}); - -itest!(shebang_with_json_imports_tsc { - args: "run --quiet import_attributes/json_with_shebang.ts", - output: "import_attributes/json_with_shebang.ts.out", - exit_code: 1, -}); - -itest!(shebang_with_json_imports_swc { - args: "run --quiet --no-check import_attributes/json_with_shebang.ts", - output: "import_attributes/json_with_shebang.ts.out", - exit_code: 1, -}); - #[test] fn no_validate_asm() { let output = util::deno_cmd() @@ -2523,7 +1173,6 @@ fn dont_cache_on_check_fail() { mod permissions { use test_util as util; - use test_util::itest; use util::TestContext; #[test] @@ -2973,31 +1622,6 @@ mod permissions { }); } - itest!(_063_permissions_revoke { - args: "run --allow-read=foo,bar run/063_permissions_revoke.ts", - output: "run/063_permissions_revoke.ts.out", - }); - - itest!(_063_permissions_revoke_sync { - args: "run --allow-read=foo,bar run/063_permissions_revoke_sync.ts", - output: "run/063_permissions_revoke.ts.out", - }); - - itest!(_064_permissions_revoke_global { - args: "run --allow-read=foo,bar run/064_permissions_revoke_global.ts", - output: "run/064_permissions_revoke_global.ts.out", - }); - - itest!(_064_permissions_revoke_global_sync { - args: "run --allow-read=foo,bar run/064_permissions_revoke_global_sync.ts", - output: "run/064_permissions_revoke_global.ts.out", - }); - - itest!(_065_permissions_revoke_net { - args: "run --allow-net run/065_permissions_revoke_net.ts", - output: "run/065_permissions_revoke_net.ts.out", - }); - #[test] fn _066_prompt() { TestContext::default() @@ -3033,63 +1657,8 @@ mod permissions { console.expect("The end of test"); }); } - - itest!(dynamic_import_static_analysis_no_permissions { - args: "run --quiet --reload --no-prompt dynamic_import/static_analysis_no_permissions.ts", - output: "dynamic_import/static_analysis_no_permissions.ts.out", - }); - - itest!(dynamic_import_permissions_remote_remote { - args: "run --quiet --reload --allow-import=localhost:4545 dynamic_import/permissions_remote_remote.ts", - output: "dynamic_import/permissions_remote_remote.ts.out", - http_server: true, - exit_code: 1, - }); - - itest!(dynamic_import_permissions_data_remote { - args: "run --quiet --reload --allow-import=localhost:4545 dynamic_import/permissions_data_remote.ts", - output: "dynamic_import/permissions_data_remote.ts.out", - http_server: true, - exit_code: 1, - }); - - itest!(dynamic_import_permissions_blob_remote { - args: "run --quiet --reload --allow-net=localhost:4545 dynamic_import/permissions_blob_remote.ts", - output: "dynamic_import/permissions_blob_remote.ts.out", - http_server: true, - exit_code: 1, - }); - - itest!(dynamic_import_permissions_data_local { - args: "run --quiet --reload --allow-net=localhost:4545 dynamic_import/permissions_data_local.ts", - output: "dynamic_import/permissions_data_local.ts.out", - http_server: true, - exit_code: 1, - }); - - itest!(dynamic_import_permissions_blob_local { - args: "run --quiet --reload --allow-net=localhost:4545 dynamic_import/permissions_blob_local.ts", - output: "dynamic_import/permissions_blob_local.ts.out", - http_server: true, - exit_code: 1, - }); } -itest!(tls_starttls { - args: "run --quiet --reload --allow-net --allow-read --cert tls/RootCA.pem --config ../config/deno.json run/tls_starttls.js", - output: "run/tls.out", -}); - -itest!(tls_connecttls { - args: "run --quiet --reload --allow-net --allow-read --cert tls/RootCA.pem --config ../config/deno.json run/tls_connecttls.js", - output: "run/tls.out", -}); - -itest!(byte_order_mark { - args: "run --no-check run/byte_order_mark.ts", - output: "run/byte_order_mark.out", -}); - #[test] #[cfg(windows)] fn process_stdin_read_unblock() { @@ -3137,24 +1706,6 @@ fn issue9750() { }); } -// Regression test for https://github.com/denoland/deno/issues/11451. -itest!(dom_exception_formatting { - args: "run run/dom_exception_formatting.ts", - output: "run/dom_exception_formatting.ts.out", - exit_code: 1, -}); - -itest!(long_data_url_formatting { - args: "run run/long_data_url_formatting.ts", - output: "run/long_data_url_formatting.ts.out", - exit_code: 1, -}); - -itest!(eval_context_throw_dom_exception { - args: "run run/eval_context_throw_dom_exception.js", - output: "run/eval_context_throw_dom_exception.js.out", -}); - #[test] #[cfg(unix)] fn navigator_language_unix() { @@ -3278,85 +1829,6 @@ fn issue12807() { assert!(status.success()); } -itest!(issue_13562 { - args: "run run/issue13562.ts", - output: "run/issue13562.ts.out", -}); - -itest!(import_attributes_static_import { - args: "run --allow-read import_attributes/static_import.ts", - output: "import_attributes/static_import.out", -}); - -itest!(import_attributes_static_export { - args: "run --allow-read import_attributes/static_export.ts", - output: "import_attributes/static_export.out", -}); - -itest!(import_attributes_static_error { - args: "run --allow-read import_attributes/static_error.ts", - output: "import_attributes/static_error.out", - exit_code: 1, -}); - -itest!(import_attributes_dynamic_import { - args: "run --allow-read --check import_attributes/dynamic_import.ts", - output: "import_attributes/dynamic_import.out", -}); - -itest!(import_attributes_dynamic_error { - args: "run --allow-read import_attributes/dynamic_error.ts", - output: "import_attributes/dynamic_error.out", - exit_code: 1, -}); - -itest!(import_attributes_type_check { - args: "run --allow-read --check import_attributes/type_check.ts", - output: "import_attributes/type_check.out", - exit_code: 1, -}); - -itest!(colors_without_global_this { - args: "run run/colors_without_globalThis.js", - output_str: Some("true\n"), -}); - -itest!(config_auto_discovered_for_local_script { - args: "run --quiet run/with_config/frontend_work.ts", - output_str: Some("ok\n"), -}); - -itest!(config_auto_discovered_for_local_script_log { - args: "run -L debug run/with_config/frontend_work.ts", - output: "run/with_config/auto_discovery_log.out", -}); - -itest!(no_config_auto_discovery_for_local_script { - args: "run --quiet --no-config --check run/with_config/frontend_work.ts", - output: "run/with_config/no_auto_discovery.out", - exit_code: 1, -}); - -itest!(config_not_auto_discovered_for_remote_script { - args: "run --allow-import --quiet http://127.0.0.1:4545/run/with_config/server_side_work.ts", - output_str: Some("ok\n"), - http_server: true, -}); - -// In this case we shouldn't discover `package.json` file, because it's in a -// directory that is above the directory containing `deno.json` file. -itest!( - package_json_auto_discovered_for_local_script_arg_with_stop { - args: "run -L debug with_stop/some/nested/dir/main.ts", - output: "run/with_package_json/with_stop/main.out", - cwd: Some("run/with_package_json/"), - copy_temp_dir: Some("run/with_package_json/"), - envs: env_vars_for_npm_tests(), - http_server: true, - exit_code: 1, - } -); - #[test] fn package_json_no_node_modules_dir_created() { // it should not create a node_modules directory @@ -3395,81 +1867,6 @@ fn node_modules_dir_no_npm_specifiers_no_dir_created() { assert!(!temp_dir.path().join("node_modules").exists()); } -itest!(wasm_streaming_panic_test { - args: "run run/wasm_streaming_panic_test.js", - output: "run/wasm_streaming_panic_test.js.out", - exit_code: 1, -}); - -// Regression test for https://github.com/denoland/deno/issues/13897. -itest!(fetch_async_error_stack { - args: "run --quiet -A run/fetch_async_error_stack.ts", - output: "run/fetch_async_error_stack.ts.out", - exit_code: 1, -}); - -itest!(event_listener_error { - args: "run --quiet run/event_listener_error.ts", - output: "run/event_listener_error.ts.out", - exit_code: 1, -}); - -itest!(event_listener_error_handled { - args: "run --quiet run/event_listener_error_handled.ts", - output: "run/event_listener_error_handled.ts.out", -}); - -// https://github.com/denoland/deno/pull/14159#issuecomment-1092285446 -itest!(event_listener_error_immediate_exit { - args: "run --quiet run/event_listener_error_immediate_exit.ts", - output: "run/event_listener_error_immediate_exit.ts.out", - exit_code: 1, -}); - -// https://github.com/denoland/deno/pull/14159#issuecomment-1092285446 -itest!(event_listener_error_immediate_exit_worker { - args: "run --quiet -A run/event_listener_error_immediate_exit_worker.ts", - output: "run/event_listener_error_immediate_exit_worker.ts.out", - exit_code: 1, -}); - -itest!(set_timeout_error { - args: "run --quiet run/set_timeout_error.ts", - output: "run/set_timeout_error.ts.out", - exit_code: 1, -}); - -itest!(set_timeout_error_handled { - args: "run --quiet run/set_timeout_error_handled.ts", - output: "run/set_timeout_error_handled.ts.out", -}); - -itest!(aggregate_error { - args: "run --quiet run/aggregate_error.ts", - output: "run/aggregate_error.out", - exit_code: 1, -}); - -itest!(complex_error { - args: "run --quiet run/complex_error.ts", - output: "run/complex_error.ts.out", - exit_code: 1, -}); - -// Regression test for https://github.com/denoland/deno/issues/16340. -itest!(error_with_errors_prop { - args: "run --quiet run/error_with_errors_prop.js", - output: "run/error_with_errors_prop.js.out", - exit_code: 1, -}); - -// Regression test for https://github.com/denoland/deno/issues/12143. -itest!(js_root_with_ts_check { - args: "run --quiet --check run/js_root_with_ts_check.js", - output: "run/js_root_with_ts_check.js.out", - exit_code: 1, -}); - #[test] fn check_local_then_remote() { let _http_guard = util::http_server(); @@ -3502,18 +1899,6 @@ fn check_local_then_remote() { assert_contains!(stderr, "Type 'string' is not assignable to type 'number'."); } -// Regression test for https://github.com/denoland/deno/issues/15163 -itest!(check_js_points_to_ts { - args: "run --quiet --check --config run/checkjs.tsconfig.json run/check_js_points_to_ts/test.js", - output: "run/check_js_points_to_ts/test.js.out", - exit_code: 1, -}); - -itest!(no_prompt_flag { - args: "run --quiet --no-prompt run/no_prompt.ts", - output_str: Some(""), -}); - #[test] fn permission_request_with_no_prompt() { TestContext::default() @@ -3544,57 +1929,6 @@ fn deno_no_prompt_environment_variable() { assert!(output.status.success()); } -itest!(report_error { - args: "run --quiet run/report_error.ts", - output: "run/report_error.ts.out", - exit_code: 1, -}); - -itest!(report_error_handled { - args: "run --quiet run/report_error_handled.ts", - output: "run/report_error_handled.ts.out", -}); - -// Regression test for https://github.com/denoland/deno/issues/15513. -itest!(report_error_end_of_program { - args: "run --quiet run/report_error_end_of_program.ts", - output: "run/report_error_end_of_program.ts.out", - exit_code: 1, -}); - -itest!(queue_microtask_error { - args: "run --quiet run/queue_microtask_error.ts", - output: "run/queue_microtask_error.ts.out", - exit_code: 1, -}); - -itest!(queue_microtask_error_handled { - args: "run --quiet run/queue_microtask_error_handled.ts", - output: "run/queue_microtask_error_handled.ts.out", -}); - -itest!(spawn_stdout_inherit { - args: "run --quiet -A run/spawn_stdout_inherit.ts", - output: "run/spawn_stdout_inherit.ts.out", -}); - -itest!(error_name_non_string { - args: "run --quiet run/error_name_non_string.js", - output: "run/error_name_non_string.js.out", - exit_code: 1, -}); - -itest!(custom_inspect_url { - args: "run run/custom_inspect_url.js", - output: "run/custom_inspect_url.js.out", -}); - -itest!(config_json_import { - args: "run --quiet -c jsx/deno-jsx.json run/config_json_import.ts", - output: "run/config_json_import.ts.out", - http_server: true, -}); - #[test] fn running_declaration_files() { let context = TestContextBuilder::new().use_temp_cwd().build(); @@ -3613,11 +1947,6 @@ fn running_declaration_files() { } } -itest!(test_and_bench_are_noops_in_run { - args: "run run/test_and_bench_in_run.js", - output_str: Some(""), -}); - #[cfg(not(target_os = "windows"))] itest!(spawn_kill_permissions { args: "run --quiet --allow-run=cat spawn_kill_permissions.ts", @@ -3628,51 +1957,6 @@ itest!(spawn_kill_permissions { output_str: Some(""), }); -itest!(followup_dyn_import_resolved { - args: "run --allow-read run/followup_dyn_import_resolves/main.ts", - output: "run/followup_dyn_import_resolves/main.ts.out", -}); - -itest!(unhandled_rejection { - args: "run --check run/unhandled_rejection.ts", - output: "run/unhandled_rejection.ts.out", -}); - -itest!(unhandled_rejection_sync_error { - args: "run --check run/unhandled_rejection_sync_error.ts", - output: "run/unhandled_rejection_sync_error.ts.out", -}); - -// Regression test for https://github.com/denoland/deno/issues/15661 -itest!(unhandled_rejection_dynamic_import { - args: "run --allow-read run/unhandled_rejection_dynamic_import/main.ts", - output: "run/unhandled_rejection_dynamic_import/main.ts.out", - exit_code: 1, -}); - -// Regression test for https://github.com/denoland/deno/issues/16909 -itest!(unhandled_rejection_dynamic_import2 { - args: "run --allow-read run/unhandled_rejection_dynamic_import2/main.ts", - output: "run/unhandled_rejection_dynamic_import2/main.ts.out", -}); - -itest!(rejection_handled { - args: "run --check run/rejection_handled.ts", - output: "run/rejection_handled.out", -}); - -itest!(nested_error { - args: "run run/nested_error/main.ts", - output: "run/nested_error/main.ts.out", - exit_code: 1, -}); - -itest!(node_env_var_allowlist { - args: "run --no-prompt run/node_env_var_allowlist.ts", - output: "run/node_env_var_allowlist.ts.out", - exit_code: 1, -}); - #[test] fn cache_test() { let _g = util::http_server(); @@ -4212,48 +2496,6 @@ fn broken_stdout_repl() { assert_not_contains!(stderr, "panic"); } -itest!(error_cause { - args: "run run/error_cause.ts", - output: "run/error_cause.ts.out", - exit_code: 1, -}); - -itest!(error_cause_recursive_aggregate { - args: "run error_cause_recursive_aggregate.ts", - output: "error_cause_recursive_aggregate.ts.out", - exit_code: 1, -}); - -itest!(error_cause_recursive_tail { - args: "run error_cause_recursive_tail.ts", - output: "error_cause_recursive_tail.ts.out", - exit_code: 1, -}); - -itest!(error_cause_recursive { - args: "run run/error_cause_recursive.ts", - output: "run/error_cause_recursive.ts.out", - exit_code: 1, -}); - -itest!(js_without_extension { - args: "run --ext js --check file_extensions/js_without_extension", - output: "file_extensions/js_without_extension.out", - exit_code: 0, -}); - -itest!(ts_without_extension { - args: "run --ext ts --check file_extensions/ts_without_extension", - output: "file_extensions/ts_without_extension.out", - exit_code: 0, -}); - -itest!(ext_flag_takes_precedence_over_extension { - args: "run --ext ts --check file_extensions/ts_with_js_extension.js", - output: "file_extensions/ts_with_js_extension.out", - exit_code: 0, -}); - #[tokio::test(flavor = "multi_thread")] async fn websocketstream_ping() { let _g = util::http_server(); @@ -4435,24 +2677,6 @@ async fn websocket_server_idletimeout() { assert_eq!(child.wait().unwrap().code(), Some(123)); } -itest!(no_lock_flag { - args: "run --allow-import --no-lock run/no_lock_flag/main.ts", - output: "run/no_lock_flag/main.out", - http_server: true, - exit_code: 0, -}); - -itest!(permission_args { - args: "run run/001_hello.js --allow-net", - output: "run/permission_args.out", - envs: vec![("NO_COLOR".to_string(), "1".to_string())], -}); - -itest!(permission_args_quiet { - args: "run --quiet run/001_hello.js --allow-net", - output: "run/001_hello.js.out", -}); - // Regression test for https://github.com/denoland/deno/issues/16772 #[test] fn file_fetcher_preserves_permissions() { @@ -4560,12 +2784,6 @@ fn permission_prompt_escapes_ansi_codes_and_control_chars() { } } -itest!(dynamic_import_syntax_error { - args: "run -A run/dynamic_import_syntax_error.js", - output: "run/dynamic_import_syntax_error.js.out", - exit_code: 1, -}); - itest!(extension_import { args: "run run/extension_import.ts", output: "run/extension_import.ts.out", @@ -4679,25 +2897,6 @@ console.log(returnsHi());"#, .assert_exit_code(1); } -itest!(explicit_resource_management { - args: "run --quiet --check run/explicit_resource_management/main.ts", - output: "run/explicit_resource_management/main.out", -}); - -itest!(unsafe_proto { - args: "run -A run/unsafe_proto/main.js", - output: "run/unsafe_proto/main.out", - http_server: false, - exit_code: 0, -}); - -itest!(unsafe_proto_flag { - args: "run -A --unstable-unsafe-proto run/unsafe_proto/main.js", - output: "run/unsafe_proto/main_with_unsafe_proto_flag.out", - http_server: false, - exit_code: 0, -}); - // TODO(bartlomieju): temporary disabled // itest!(warn_on_deprecated_api { // args: "run -A run/warn_on_deprecated_api/main.js", diff --git a/tests/specs/run/_001_hello/001_hello.js b/tests/specs/run/_001_hello/001_hello.js new file mode 100644 index 0000000000..accefceba6 --- /dev/null +++ b/tests/specs/run/_001_hello/001_hello.js @@ -0,0 +1 @@ +console.log("Hello World"); diff --git a/tests/testdata/run/001_hello.js.out b/tests/specs/run/_001_hello/001_hello.js.out similarity index 100% rename from tests/testdata/run/001_hello.js.out rename to tests/specs/run/_001_hello/001_hello.js.out diff --git a/tests/specs/run/_001_hello/__test__.jsonc b/tests/specs/run/_001_hello/__test__.jsonc new file mode 100644 index 0000000000..4fd8126f0c --- /dev/null +++ b/tests/specs/run/_001_hello/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload 001_hello.js", + "output": "001_hello.js.out" +} diff --git a/tests/specs/run/_002_hello/002_hello.ts b/tests/specs/run/_002_hello/002_hello.ts new file mode 100644 index 0000000000..accefceba6 --- /dev/null +++ b/tests/specs/run/_002_hello/002_hello.ts @@ -0,0 +1 @@ +console.log("Hello World"); diff --git a/tests/testdata/run/002_hello.ts.out b/tests/specs/run/_002_hello/002_hello.ts.out similarity index 100% rename from tests/testdata/run/002_hello.ts.out rename to tests/specs/run/_002_hello/002_hello.ts.out diff --git a/tests/specs/run/_002_hello/__test__.jsonc b/tests/specs/run/_002_hello/__test__.jsonc new file mode 100644 index 0000000000..dde74d27cb --- /dev/null +++ b/tests/specs/run/_002_hello/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload 002_hello.ts", + "output": "002_hello.ts.out" +} diff --git a/tests/specs/run/_003_relative_import/003_relative_import.ts b/tests/specs/run/_003_relative_import/003_relative_import.ts new file mode 100644 index 0000000000..d392f4a5d1 --- /dev/null +++ b/tests/specs/run/_003_relative_import/003_relative_import.ts @@ -0,0 +1,3 @@ +import { printHello } from "./print_hello.ts"; + +printHello(); diff --git a/tests/testdata/run/003_relative_import.ts.out b/tests/specs/run/_003_relative_import/003_relative_import.ts.out similarity index 100% rename from tests/testdata/run/003_relative_import.ts.out rename to tests/specs/run/_003_relative_import/003_relative_import.ts.out diff --git a/tests/specs/run/_003_relative_import/__test__.jsonc b/tests/specs/run/_003_relative_import/__test__.jsonc new file mode 100644 index 0000000000..7bed2c00af --- /dev/null +++ b/tests/specs/run/_003_relative_import/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload 003_relative_import.ts", + "output": "003_relative_import.ts.out" +} diff --git a/tests/specs/run/_003_relative_import/print_hello.ts b/tests/specs/run/_003_relative_import/print_hello.ts new file mode 100644 index 0000000000..b9c0ad5275 --- /dev/null +++ b/tests/specs/run/_003_relative_import/print_hello.ts @@ -0,0 +1,3 @@ +export function printHello() { + console.log("Hello"); +} diff --git a/tests/testdata/run/004_set_timeout.ts b/tests/specs/run/_004_set_timeout/004_set_timeout.ts similarity index 100% rename from tests/testdata/run/004_set_timeout.ts rename to tests/specs/run/_004_set_timeout/004_set_timeout.ts diff --git a/tests/testdata/run/004_set_timeout.ts.out b/tests/specs/run/_004_set_timeout/004_set_timeout.ts.out similarity index 100% rename from tests/testdata/run/004_set_timeout.ts.out rename to tests/specs/run/_004_set_timeout/004_set_timeout.ts.out diff --git a/tests/specs/run/_004_set_timeout/__test__.jsonc b/tests/specs/run/_004_set_timeout/__test__.jsonc new file mode 100644 index 0000000000..6904dc0935 --- /dev/null +++ b/tests/specs/run/_004_set_timeout/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload 004_set_timeout.ts", + "output": "004_set_timeout.ts.out" +} diff --git a/tests/testdata/run/005_more_imports.ts b/tests/specs/run/_005_more_imports/005_more_imports.ts similarity index 65% rename from tests/testdata/run/005_more_imports.ts rename to tests/specs/run/_005_more_imports/005_more_imports.ts index 6c96fac64c..c69556be15 100644 --- a/tests/testdata/run/005_more_imports.ts +++ b/tests/specs/run/_005_more_imports/005_more_imports.ts @@ -1,4 +1,4 @@ -import { printHello3, returnsFoo2, returnsHi } from "../subdir/mod1.ts"; +import { printHello3, returnsFoo2, returnsHi } from "./mod1.ts"; printHello3(); diff --git a/tests/testdata/run/005_more_imports.ts.out b/tests/specs/run/_005_more_imports/005_more_imports.ts.out similarity index 100% rename from tests/testdata/run/005_more_imports.ts.out rename to tests/specs/run/_005_more_imports/005_more_imports.ts.out diff --git a/tests/specs/run/_005_more_imports/__test__.jsonc b/tests/specs/run/_005_more_imports/__test__.jsonc new file mode 100644 index 0000000000..159a0265a8 --- /dev/null +++ b/tests/specs/run/_005_more_imports/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload 005_more_imports.ts", + "output": "005_more_imports.ts.out" +} diff --git a/tests/specs/run/_005_more_imports/mod1.ts b/tests/specs/run/_005_more_imports/mod1.ts new file mode 100644 index 0000000000..5e58f432ed --- /dev/null +++ b/tests/specs/run/_005_more_imports/mod1.ts @@ -0,0 +1,17 @@ +import { printHello2, returnsFoo } from "./subdir2/mod2.ts"; + +export function returnsHi(): string { + return "Hi"; +} + +export function returnsFoo2(): string { + return returnsFoo(); +} + +export function printHello3() { + printHello2(); +} + +export function throwsError() { + throw Error("exception from mod1"); +} diff --git a/tests/specs/run/_005_more_imports/print_hello.ts b/tests/specs/run/_005_more_imports/print_hello.ts new file mode 100644 index 0000000000..b9c0ad5275 --- /dev/null +++ b/tests/specs/run/_005_more_imports/print_hello.ts @@ -0,0 +1,3 @@ +export function printHello() { + console.log("Hello"); +} diff --git a/tests/specs/run/_005_more_imports/subdir2/mod2.ts b/tests/specs/run/_005_more_imports/subdir2/mod2.ts new file mode 100644 index 0000000000..9071d0aeb4 --- /dev/null +++ b/tests/specs/run/_005_more_imports/subdir2/mod2.ts @@ -0,0 +1,9 @@ +import { printHello } from "../print_hello.ts"; + +export function returnsFoo(): string { + return "Foo"; +} + +export function printHello2() { + printHello(); +} diff --git a/tests/specs/run/_006_url_imports/006_url_imports.ts b/tests/specs/run/_006_url_imports/006_url_imports.ts new file mode 100644 index 0000000000..4036f27ed8 --- /dev/null +++ b/tests/specs/run/_006_url_imports/006_url_imports.ts @@ -0,0 +1,3 @@ +import { printHello } from "http://localhost:4545/subdir/mod2.ts"; +printHello(); +console.log("success"); diff --git a/tests/specs/run/_006_url_imports/006_url_imports.ts.out b/tests/specs/run/_006_url_imports/006_url_imports.ts.out new file mode 100644 index 0000000000..989ce33e93 --- /dev/null +++ b/tests/specs/run/_006_url_imports/006_url_imports.ts.out @@ -0,0 +1,2 @@ +Hello +success diff --git a/tests/specs/run/_006_url_imports/__test__.jsonc b/tests/specs/run/_006_url_imports/__test__.jsonc new file mode 100644 index 0000000000..50c0379ab9 --- /dev/null +++ b/tests/specs/run/_006_url_imports/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-import 006_url_imports.ts", + "output": "006_url_imports.ts.out" +} diff --git a/tests/specs/run/_006_url_imports/print_hello.ts b/tests/specs/run/_006_url_imports/print_hello.ts new file mode 100644 index 0000000000..b9c0ad5275 --- /dev/null +++ b/tests/specs/run/_006_url_imports/print_hello.ts @@ -0,0 +1,3 @@ +export function printHello() { + console.log("Hello"); +} diff --git a/tests/specs/run/_006_url_imports/subdir2/mod2.ts b/tests/specs/run/_006_url_imports/subdir2/mod2.ts new file mode 100644 index 0000000000..9071d0aeb4 --- /dev/null +++ b/tests/specs/run/_006_url_imports/subdir2/mod2.ts @@ -0,0 +1,9 @@ +import { printHello } from "../print_hello.ts"; + +export function returnsFoo(): string { + return "Foo"; +} + +export function printHello2() { + printHello(); +} diff --git a/tests/testdata/run/012_async.ts b/tests/specs/run/_012_async/012_async.ts similarity index 100% rename from tests/testdata/run/012_async.ts rename to tests/specs/run/_012_async/012_async.ts diff --git a/tests/testdata/run/012_async.ts.out b/tests/specs/run/_012_async/012_async.ts.out similarity index 100% rename from tests/testdata/run/012_async.ts.out rename to tests/specs/run/_012_async/012_async.ts.out diff --git a/tests/specs/run/_012_async/__test__.jsonc b/tests/specs/run/_012_async/__test__.jsonc new file mode 100644 index 0000000000..2778f04847 --- /dev/null +++ b/tests/specs/run/_012_async/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload 012_async.ts", + "output": "012_async.ts.out" +} diff --git a/tests/specs/run/_013_dynamic_import/013_dynamic_import.ts b/tests/specs/run/_013_dynamic_import/013_dynamic_import.ts new file mode 100644 index 0000000000..5e73b6eb79 --- /dev/null +++ b/tests/specs/run/_013_dynamic_import/013_dynamic_import.ts @@ -0,0 +1,15 @@ +(async () => { + const { returnsHi, returnsFoo2, printHello3 } = await import( + "./mod1.ts" + ); + + printHello3(); + + if (returnsHi() !== "Hi") { + throw Error("Unexpected"); + } + + if (returnsFoo2() !== "Foo") { + throw Error("Unexpected"); + } +})(); diff --git a/tests/testdata/run/013_dynamic_import.ts.out b/tests/specs/run/_013_dynamic_import/013_dynamic_import.ts.out similarity index 100% rename from tests/testdata/run/013_dynamic_import.ts.out rename to tests/specs/run/_013_dynamic_import/013_dynamic_import.ts.out diff --git a/tests/specs/run/_013_dynamic_import/__test__.jsonc b/tests/specs/run/_013_dynamic_import/__test__.jsonc new file mode 100644 index 0000000000..8be2c975bd --- /dev/null +++ b/tests/specs/run/_013_dynamic_import/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-read 013_dynamic_import.ts", + "output": "013_dynamic_import.ts.out" +} diff --git a/tests/specs/run/_013_dynamic_import/mod1.ts b/tests/specs/run/_013_dynamic_import/mod1.ts new file mode 100644 index 0000000000..5e58f432ed --- /dev/null +++ b/tests/specs/run/_013_dynamic_import/mod1.ts @@ -0,0 +1,17 @@ +import { printHello2, returnsFoo } from "./subdir2/mod2.ts"; + +export function returnsHi(): string { + return "Hi"; +} + +export function returnsFoo2(): string { + return returnsFoo(); +} + +export function printHello3() { + printHello2(); +} + +export function throwsError() { + throw Error("exception from mod1"); +} diff --git a/tests/specs/run/_013_dynamic_import/print_hello.ts b/tests/specs/run/_013_dynamic_import/print_hello.ts new file mode 100644 index 0000000000..b9c0ad5275 --- /dev/null +++ b/tests/specs/run/_013_dynamic_import/print_hello.ts @@ -0,0 +1,3 @@ +export function printHello() { + console.log("Hello"); +} diff --git a/tests/specs/run/_013_dynamic_import/subdir2/mod2.ts b/tests/specs/run/_013_dynamic_import/subdir2/mod2.ts new file mode 100644 index 0000000000..9071d0aeb4 --- /dev/null +++ b/tests/specs/run/_013_dynamic_import/subdir2/mod2.ts @@ -0,0 +1,9 @@ +import { printHello } from "../print_hello.ts"; + +export function returnsFoo(): string { + return "Foo"; +} + +export function printHello2() { + printHello(); +} diff --git a/tests/specs/run/_014_duplicate_import/014_duplicate_import.ts b/tests/specs/run/_014_duplicate_import/014_duplicate_import.ts new file mode 100644 index 0000000000..b996ca8aef --- /dev/null +++ b/tests/specs/run/_014_duplicate_import/014_duplicate_import.ts @@ -0,0 +1,9 @@ +// with all the imports of the same module, the module should only be +// instantiated once +import "./auto_print_hello.ts"; + +import "./auto_print_hello.ts"; + +(async () => { + await import("./auto_print_hello.ts"); +})(); diff --git a/tests/testdata/run/014_duplicate_import.ts.out b/tests/specs/run/_014_duplicate_import/014_duplicate_import.ts.out similarity index 100% rename from tests/testdata/run/014_duplicate_import.ts.out rename to tests/specs/run/_014_duplicate_import/014_duplicate_import.ts.out diff --git a/tests/specs/run/_014_duplicate_import/__test__.jsonc b/tests/specs/run/_014_duplicate_import/__test__.jsonc new file mode 100644 index 0000000000..7172fc1833 --- /dev/null +++ b/tests/specs/run/_014_duplicate_import/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-read 014_duplicate_import.ts ", + "output": "014_duplicate_import.ts.out" +} diff --git a/tests/specs/run/_014_duplicate_import/auto_print_hello.ts b/tests/specs/run/_014_duplicate_import/auto_print_hello.ts new file mode 100644 index 0000000000..5efa72e03f --- /dev/null +++ b/tests/specs/run/_014_duplicate_import/auto_print_hello.ts @@ -0,0 +1,2 @@ +console.log("hello!"); +export default {}; diff --git a/tests/testdata/run/015_duplicate_parallel_import.js b/tests/specs/run/_015_duplicate_parallel_import/015_duplicate_parallel_import.js similarity index 91% rename from tests/testdata/run/015_duplicate_parallel_import.js rename to tests/specs/run/_015_duplicate_parallel_import/015_duplicate_parallel_import.js index 2fbe2c732e..136d80f462 100644 --- a/tests/testdata/run/015_duplicate_parallel_import.js +++ b/tests/specs/run/_015_duplicate_parallel_import/015_duplicate_parallel_import.js @@ -3,7 +3,7 @@ const promises = new Array(100) .fill(null) - .map(() => import("../subdir/mod1.ts")); + .map(() => import("./mod1.ts")); Promise.all(promises).then((imports) => { const mod = imports.reduce((first, cur) => { diff --git a/tests/testdata/run/015_duplicate_parallel_import.js.out b/tests/specs/run/_015_duplicate_parallel_import/015_duplicate_parallel_import.js.out similarity index 100% rename from tests/testdata/run/015_duplicate_parallel_import.js.out rename to tests/specs/run/_015_duplicate_parallel_import/015_duplicate_parallel_import.js.out diff --git a/tests/specs/run/_015_duplicate_parallel_import/__test__.jsonc b/tests/specs/run/_015_duplicate_parallel_import/__test__.jsonc new file mode 100644 index 0000000000..44fe479e29 --- /dev/null +++ b/tests/specs/run/_015_duplicate_parallel_import/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-read 015_duplicate_parallel_import.js", + "output": "015_duplicate_parallel_import.js.out" +} diff --git a/tests/specs/run/_015_duplicate_parallel_import/mod1.ts b/tests/specs/run/_015_duplicate_parallel_import/mod1.ts new file mode 100644 index 0000000000..5e58f432ed --- /dev/null +++ b/tests/specs/run/_015_duplicate_parallel_import/mod1.ts @@ -0,0 +1,17 @@ +import { printHello2, returnsFoo } from "./subdir2/mod2.ts"; + +export function returnsHi(): string { + return "Hi"; +} + +export function returnsFoo2(): string { + return returnsFoo(); +} + +export function printHello3() { + printHello2(); +} + +export function throwsError() { + throw Error("exception from mod1"); +} diff --git a/tests/specs/run/_015_duplicate_parallel_import/print_hello.ts b/tests/specs/run/_015_duplicate_parallel_import/print_hello.ts new file mode 100644 index 0000000000..b9c0ad5275 --- /dev/null +++ b/tests/specs/run/_015_duplicate_parallel_import/print_hello.ts @@ -0,0 +1,3 @@ +export function printHello() { + console.log("Hello"); +} diff --git a/tests/specs/run/_015_duplicate_parallel_import/subdir2/mod2.ts b/tests/specs/run/_015_duplicate_parallel_import/subdir2/mod2.ts new file mode 100644 index 0000000000..9071d0aeb4 --- /dev/null +++ b/tests/specs/run/_015_duplicate_parallel_import/subdir2/mod2.ts @@ -0,0 +1,9 @@ +import { printHello } from "../print_hello.ts"; + +export function returnsFoo(): string { + return "Foo"; +} + +export function printHello2() { + printHello(); +} diff --git a/tests/testdata/run/016_double_await.ts b/tests/specs/run/_016_double_await/016_double_await.ts similarity index 100% rename from tests/testdata/run/016_double_await.ts rename to tests/specs/run/_016_double_await/016_double_await.ts diff --git a/tests/testdata/run/016_double_await.ts.out b/tests/specs/run/_016_double_await/016_double_await.ts.out similarity index 100% rename from tests/testdata/run/016_double_await.ts.out rename to tests/specs/run/_016_double_await/016_double_await.ts.out diff --git a/tests/specs/run/_016_double_await/__test__.jsonc b/tests/specs/run/_016_double_await/__test__.jsonc new file mode 100644 index 0000000000..9ff2027168 --- /dev/null +++ b/tests/specs/run/_016_double_await/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --allow-read --reload 016_double_await.ts", + "output": "016_double_await.ts.out" +} diff --git a/tests/specs/run/_017_import_redirect/017_import_redirect.ts b/tests/specs/run/_017_import_redirect/017_import_redirect.ts new file mode 100644 index 0000000000..1265dd4edc --- /dev/null +++ b/tests/specs/run/_017_import_redirect/017_import_redirect.ts @@ -0,0 +1,4 @@ +// http -> https redirect would happen: +import { printHello } from "http://gist.githubusercontent.com/ry/f12b2aa3409e6b52645bc346a9e22929/raw/79318f239f51d764384a8bded8d7c6a833610dde/print_hello.ts"; + +printHello(); diff --git a/tests/testdata/run/017_import_redirect.ts.out b/tests/specs/run/_017_import_redirect/017_import_redirect.ts.out similarity index 100% rename from tests/testdata/run/017_import_redirect.ts.out rename to tests/specs/run/_017_import_redirect/017_import_redirect.ts.out diff --git a/tests/specs/run/_017_import_redirect/__test__.jsonc b/tests/specs/run/_017_import_redirect/__test__.jsonc new file mode 100644 index 0000000000..dd5442dcd1 --- /dev/null +++ b/tests/specs/run/_017_import_redirect/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --allow-import --reload --check 017_import_redirect.ts", + "output": "017_import_redirect.ts.out" +} diff --git a/tests/specs/run/_017_import_redirect_check/017_import_redirect.ts b/tests/specs/run/_017_import_redirect_check/017_import_redirect.ts new file mode 100644 index 0000000000..1265dd4edc --- /dev/null +++ b/tests/specs/run/_017_import_redirect_check/017_import_redirect.ts @@ -0,0 +1,4 @@ +// http -> https redirect would happen: +import { printHello } from "http://gist.githubusercontent.com/ry/f12b2aa3409e6b52645bc346a9e22929/raw/79318f239f51d764384a8bded8d7c6a833610dde/print_hello.ts"; + +printHello(); diff --git a/tests/testdata/run/https_import.ts.out b/tests/specs/run/_017_import_redirect_check/017_import_redirect.ts.out similarity index 100% rename from tests/testdata/run/https_import.ts.out rename to tests/specs/run/_017_import_redirect_check/017_import_redirect.ts.out diff --git a/tests/specs/run/_017_import_redirect_check/__test__.jsonc b/tests/specs/run/_017_import_redirect_check/__test__.jsonc new file mode 100644 index 0000000000..dd5442dcd1 --- /dev/null +++ b/tests/specs/run/_017_import_redirect_check/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --allow-import --reload --check 017_import_redirect.ts", + "output": "017_import_redirect.ts.out" +} diff --git a/tests/specs/run/_017_import_redirect_info/017_import_redirect.ts b/tests/specs/run/_017_import_redirect_info/017_import_redirect.ts new file mode 100644 index 0000000000..1265dd4edc --- /dev/null +++ b/tests/specs/run/_017_import_redirect_info/017_import_redirect.ts @@ -0,0 +1,4 @@ +// http -> https redirect would happen: +import { printHello } from "http://gist.githubusercontent.com/ry/f12b2aa3409e6b52645bc346a9e22929/raw/79318f239f51d764384a8bded8d7c6a833610dde/print_hello.ts"; + +printHello(); diff --git a/tests/testdata/run/017_import_redirect_info.out b/tests/specs/run/_017_import_redirect_info/017_import_redirect_info.out similarity index 100% rename from tests/testdata/run/017_import_redirect_info.out rename to tests/specs/run/_017_import_redirect_info/017_import_redirect_info.out diff --git a/tests/specs/run/_017_import_redirect_info/__test__.jsonc b/tests/specs/run/_017_import_redirect_info/__test__.jsonc new file mode 100644 index 0000000000..d23e8dd998 --- /dev/null +++ b/tests/specs/run/_017_import_redirect_info/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "info --quiet --allow-import --reload 017_import_redirect.ts", + "output": "017_import_redirect_info.out" +} diff --git a/tests/specs/run/_017_import_redirect_vendor_dir/017_import_redirect.ts b/tests/specs/run/_017_import_redirect_vendor_dir/017_import_redirect.ts new file mode 100644 index 0000000000..1265dd4edc --- /dev/null +++ b/tests/specs/run/_017_import_redirect_vendor_dir/017_import_redirect.ts @@ -0,0 +1,4 @@ +// http -> https redirect would happen: +import { printHello } from "http://gist.githubusercontent.com/ry/f12b2aa3409e6b52645bc346a9e22929/raw/79318f239f51d764384a8bded8d7c6a833610dde/print_hello.ts"; + +printHello(); diff --git a/tests/testdata/run/import_blob_url_imports.ts.out b/tests/specs/run/_017_import_redirect_vendor_dir/017_import_redirect.ts.out similarity index 100% rename from tests/testdata/run/import_blob_url_imports.ts.out rename to tests/specs/run/_017_import_redirect_vendor_dir/017_import_redirect.ts.out diff --git a/tests/specs/run/_017_import_redirect_vendor_dir/__test__.jsonc b/tests/specs/run/_017_import_redirect_vendor_dir/__test__.jsonc new file mode 100644 index 0000000000..dd5442dcd1 --- /dev/null +++ b/tests/specs/run/_017_import_redirect_vendor_dir/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --allow-import --reload --check 017_import_redirect.ts", + "output": "017_import_redirect.ts.out" +} diff --git a/tests/testdata/run/018_async_catch.ts b/tests/specs/run/_018_async_catch/018_async_catch.ts similarity index 100% rename from tests/testdata/run/018_async_catch.ts rename to tests/specs/run/_018_async_catch/018_async_catch.ts diff --git a/tests/testdata/run/018_async_catch.ts.out b/tests/specs/run/_018_async_catch/018_async_catch.ts.out similarity index 100% rename from tests/testdata/run/018_async_catch.ts.out rename to tests/specs/run/_018_async_catch/018_async_catch.ts.out diff --git a/tests/specs/run/_018_async_catch/__test__.jsonc b/tests/specs/run/_018_async_catch/__test__.jsonc new file mode 100644 index 0000000000..7995c79fdb --- /dev/null +++ b/tests/specs/run/_018_async_catch/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload 018_async_catch.ts", + "output": "018_async_catch.ts.out" +} diff --git a/tests/specs/run/_019_media_types/019_media_types.ts b/tests/specs/run/_019_media_types/019_media_types.ts new file mode 100644 index 0000000000..d985bd2496 --- /dev/null +++ b/tests/specs/run/_019_media_types/019_media_types.ts @@ -0,0 +1,24 @@ +// When run against the test HTTP server, it will serve different media types +// based on the URL containing `.t#.` strings, which exercises the different +// mapping of media types end to end. + +import { loaded as loadedTs1 } from "http://localhost:4545/subdir/mt_text_typescript.t1.ts"; +import { loaded as loadedTs2 } from "http://localhost:4545/subdir/mt_video_vdn.t2.ts"; +import { loaded as loadedTs3 } from "http://localhost:4545/subdir/mt_video_mp2t.t3.ts"; +import { loaded as loadedTs4 } from "http://localhost:4545/subdir/mt_application_x_typescript.t4.ts"; +import { loaded as loadedJs1 } from "http://localhost:4545/subdir/mt_text_javascript.j1.js"; +import { loaded as loadedJs2 } from "http://localhost:4545/subdir/mt_application_ecmascript.j2.js"; +import { loaded as loadedJs3 } from "http://localhost:4545/subdir/mt_text_ecmascript.j3.js"; +import { loaded as loadedJs4 } from "http://localhost:4545/subdir/mt_application_x_javascript.j4.js"; + +console.log( + "success", + loadedTs1, + loadedTs2, + loadedTs3, + loadedTs4, + loadedJs1, + loadedJs2, + loadedJs3, + loadedJs4, +); diff --git a/tests/testdata/run/019_media_types.ts.out b/tests/specs/run/_019_media_types/019_media_types.ts.out similarity index 100% rename from tests/testdata/run/019_media_types.ts.out rename to tests/specs/run/_019_media_types/019_media_types.ts.out diff --git a/tests/specs/run/_019_media_types/__test__.jsonc b/tests/specs/run/_019_media_types/__test__.jsonc new file mode 100644 index 0000000000..b741a0bf22 --- /dev/null +++ b/tests/specs/run/_019_media_types/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --allow-import 019_media_types.ts", + "output": "019_media_types.ts.out" +} diff --git a/tests/specs/run/_020_json_modules/020_json_modules.ts b/tests/specs/run/_020_json_modules/020_json_modules.ts new file mode 100644 index 0000000000..bde024cf86 --- /dev/null +++ b/tests/specs/run/_020_json_modules/020_json_modules.ts @@ -0,0 +1,2 @@ +import config from "./config.json"; +console.log(JSON.stringify(config)); diff --git a/tests/testdata/run/020_json_modules.ts.out b/tests/specs/run/_020_json_modules/020_json_modules.ts.out similarity index 80% rename from tests/testdata/run/020_json_modules.ts.out rename to tests/specs/run/_020_json_modules/020_json_modules.ts.out index 948901724a..8bf0b41465 100644 --- a/tests/testdata/run/020_json_modules.ts.out +++ b/tests/specs/run/_020_json_modules/020_json_modules.ts.out @@ -1,3 +1,3 @@ error: Expected a JavaScript or TypeScript module, but identified a Json module. Consider importing Json modules with an import attribute with the type of "json". - Specifier: [WILDCARD]/subdir/config.json + Specifier: [WILDCARD]/config.json [WILDCARD] \ No newline at end of file diff --git a/tests/specs/run/_020_json_modules/__test__.jsonc b/tests/specs/run/_020_json_modules/__test__.jsonc new file mode 100644 index 0000000000..618616438a --- /dev/null +++ b/tests/specs/run/_020_json_modules/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload 020_json_modules.ts", + "output": "020_json_modules.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/run/_020_json_modules/config.json b/tests/specs/run/_020_json_modules/config.json new file mode 100644 index 0000000000..01c3b5e79a --- /dev/null +++ b/tests/specs/run/_020_json_modules/config.json @@ -0,0 +1,6 @@ +{ + "foo": { + "bar": true, + "baz": ["qat", 1] + } +} diff --git a/tests/specs/run/_021_mjs_modules/021_mjs_modules.ts b/tests/specs/run/_021_mjs_modules/021_mjs_modules.ts new file mode 100644 index 0000000000..326fce3e51 --- /dev/null +++ b/tests/specs/run/_021_mjs_modules/021_mjs_modules.ts @@ -0,0 +1,2 @@ +import { isMod5 } from "./mod5.mjs"; +console.log(isMod5); diff --git a/tests/testdata/run/021_mjs_modules.ts.out b/tests/specs/run/_021_mjs_modules/021_mjs_modules.ts.out similarity index 100% rename from tests/testdata/run/021_mjs_modules.ts.out rename to tests/specs/run/_021_mjs_modules/021_mjs_modules.ts.out diff --git a/tests/specs/run/_021_mjs_modules/__test__.jsonc b/tests/specs/run/_021_mjs_modules/__test__.jsonc new file mode 100644 index 0000000000..f029658862 --- /dev/null +++ b/tests/specs/run/_021_mjs_modules/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload 021_mjs_modules.ts", + "output": "021_mjs_modules.ts.out" +} diff --git a/tests/specs/run/_021_mjs_modules/mod5.mjs b/tests/specs/run/_021_mjs_modules/mod5.mjs new file mode 100644 index 0000000000..f21d8862b1 --- /dev/null +++ b/tests/specs/run/_021_mjs_modules/mod5.mjs @@ -0,0 +1 @@ +export const isMod5 = true; diff --git a/tests/testdata/run/025_reload_js_type_error.js b/tests/specs/run/_025_reload_js_type_error/025_reload_js_type_error.js similarity index 100% rename from tests/testdata/run/025_reload_js_type_error.js rename to tests/specs/run/_025_reload_js_type_error/025_reload_js_type_error.js diff --git a/tests/testdata/run/025_reload_js_type_error.js.out b/tests/specs/run/_025_reload_js_type_error/025_reload_js_type_error.js.out similarity index 100% rename from tests/testdata/run/025_reload_js_type_error.js.out rename to tests/specs/run/_025_reload_js_type_error/025_reload_js_type_error.js.out diff --git a/tests/specs/run/_025_reload_js_type_error/__test__.jsonc b/tests/specs/run/_025_reload_js_type_error/__test__.jsonc new file mode 100644 index 0000000000..ce098f9097 --- /dev/null +++ b/tests/specs/run/_025_reload_js_type_error/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload 025_reload_js_type_error.js", + "output": "025_reload_js_type_error.js.out" +} diff --git a/tests/testdata/run/027_redirect_typescript.ts b/tests/specs/run/_027_redirect_typescript/027_redirect_typescript.ts similarity index 100% rename from tests/testdata/run/027_redirect_typescript.ts rename to tests/specs/run/_027_redirect_typescript/027_redirect_typescript.ts diff --git a/tests/testdata/run/027_redirect_typescript.ts.out b/tests/specs/run/_027_redirect_typescript/027_redirect_typescript.ts.out similarity index 100% rename from tests/testdata/run/027_redirect_typescript.ts.out rename to tests/specs/run/_027_redirect_typescript/027_redirect_typescript.ts.out diff --git a/tests/specs/run/_027_redirect_typescript/__test__.jsonc b/tests/specs/run/_027_redirect_typescript/__test__.jsonc new file mode 100644 index 0000000000..fca55c9f8e --- /dev/null +++ b/tests/specs/run/_027_redirect_typescript/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-import 027_redirect_typescript.ts", + "output": "027_redirect_typescript.ts.out" +} diff --git a/tests/specs/run/_027_redirect_typescript_vendor_dir/027_redirect_typescript.ts b/tests/specs/run/_027_redirect_typescript_vendor_dir/027_redirect_typescript.ts new file mode 100644 index 0000000000..584341975f --- /dev/null +++ b/tests/specs/run/_027_redirect_typescript_vendor_dir/027_redirect_typescript.ts @@ -0,0 +1,2 @@ +import { value } from "http://localhost:4547/redirects/redirect4.ts"; +console.log(value); diff --git a/tests/specs/run/_027_redirect_typescript_vendor_dir/027_redirect_typescript.ts.out b/tests/specs/run/_027_redirect_typescript_vendor_dir/027_redirect_typescript.ts.out new file mode 100644 index 0000000000..480d4e8ca0 --- /dev/null +++ b/tests/specs/run/_027_redirect_typescript_vendor_dir/027_redirect_typescript.ts.out @@ -0,0 +1 @@ +4 imports 1 diff --git a/tests/specs/run/_027_redirect_typescript_vendor_dir/__test__.jsonc b/tests/specs/run/_027_redirect_typescript_vendor_dir/__test__.jsonc new file mode 100644 index 0000000000..f35557907b --- /dev/null +++ b/tests/specs/run/_027_redirect_typescript_vendor_dir/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --vendor --allow-import 027_redirect_typescript.ts", + "output": "027_redirect_typescript.ts.out" +} diff --git a/tests/specs/run/_027_redirect_typescript_vendor_dir/vendor/http_localhost_4545/subdir/redirects/redirect1.ts b/tests/specs/run/_027_redirect_typescript_vendor_dir/vendor/http_localhost_4545/subdir/redirects/redirect1.ts new file mode 100644 index 0000000000..d674be88c3 --- /dev/null +++ b/tests/specs/run/_027_redirect_typescript_vendor_dir/vendor/http_localhost_4545/subdir/redirects/redirect1.ts @@ -0,0 +1 @@ +export const redirect = 1; diff --git a/tests/specs/run/_027_redirect_typescript_vendor_dir/vendor/http_localhost_4545/subdir/redirects/redirect4.ts b/tests/specs/run/_027_redirect_typescript_vendor_dir/vendor/http_localhost_4545/subdir/redirects/redirect4.ts new file mode 100644 index 0000000000..45c65c5eb3 --- /dev/null +++ b/tests/specs/run/_027_redirect_typescript_vendor_dir/vendor/http_localhost_4545/subdir/redirects/redirect4.ts @@ -0,0 +1,2 @@ +import { redirect } from "./redirect1.ts"; +export const value = `4 imports ${redirect}`; diff --git a/tests/specs/run/_027_redirect_typescript_vendor_dir/vendor/manifest.json b/tests/specs/run/_027_redirect_typescript_vendor_dir/vendor/manifest.json new file mode 100644 index 0000000000..49cc42e8cc --- /dev/null +++ b/tests/specs/run/_027_redirect_typescript_vendor_dir/vendor/manifest.json @@ -0,0 +1,9 @@ +{ + "modules": { + "http://localhost:4547/redirects/redirect4.ts": { + "headers": { + "location": "http://localhost:4545/subdir/redirects/redirect4.ts" + } + } + } +} diff --git a/tests/testdata/run/028_args.ts b/tests/specs/run/_028_args/028_args.ts similarity index 100% rename from tests/testdata/run/028_args.ts rename to tests/specs/run/_028_args/028_args.ts diff --git a/tests/testdata/run/028_args.ts.out b/tests/specs/run/_028_args/028_args.ts.out similarity index 100% rename from tests/testdata/run/028_args.ts.out rename to tests/specs/run/_028_args/028_args.ts.out diff --git a/tests/specs/run/_028_args/__test__.jsonc b/tests/specs/run/_028_args/__test__.jsonc new file mode 100644 index 0000000000..6ab81bf21d --- /dev/null +++ b/tests/specs/run/_028_args/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload 028_args.ts --arg1 val1 --arg2=val2 -- arg3 arg4", + "output": "028_args.ts.out" +} diff --git a/tests/specs/run/_033_import_map_data_uri/__test__.jsonc b/tests/specs/run/_033_import_map_data_uri/__test__.jsonc new file mode 100644 index 0000000000..400269c751 --- /dev/null +++ b/tests/specs/run/_033_import_map_data_uri/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-import --import-map=data:application/json;charset=utf-8;base64,ewogICJpbXBvcnRzIjogewogICAgInRlc3Rfc2VydmVyLyI6ICJodHRwOi8vbG9jYWxob3N0OjQ1NDUvIgogIH0KfQ== test_data.ts", + "output": "test_data.ts.out" +} diff --git a/tests/specs/run/_033_import_map_data_uri/lodash/lodash.ts b/tests/specs/run/_033_import_map_data_uri/lodash/lodash.ts new file mode 100644 index 0000000000..2ec04ed3cf --- /dev/null +++ b/tests/specs/run/_033_import_map_data_uri/lodash/lodash.ts @@ -0,0 +1 @@ +console.log("Hello from remapped lodash!"); diff --git a/tests/specs/run/_033_import_map_data_uri/lodash/other_file.ts b/tests/specs/run/_033_import_map_data_uri/lodash/other_file.ts new file mode 100644 index 0000000000..714adae3fb --- /dev/null +++ b/tests/specs/run/_033_import_map_data_uri/lodash/other_file.ts @@ -0,0 +1 @@ +console.log("Hello from remapped lodash dir!"); diff --git a/tests/testdata/run/import_maps/test_data.ts b/tests/specs/run/_033_import_map_data_uri/test_data.ts similarity index 100% rename from tests/testdata/run/import_maps/test_data.ts rename to tests/specs/run/_033_import_map_data_uri/test_data.ts diff --git a/tests/testdata/run/import_maps/test_data.ts.out b/tests/specs/run/_033_import_map_data_uri/test_data.ts.out similarity index 100% rename from tests/testdata/run/import_maps/test_data.ts.out rename to tests/specs/run/_033_import_map_data_uri/test_data.ts.out diff --git a/tests/testdata/run/033_import_map_remote.out b/tests/specs/run/_033_import_map_remote/033_import_map_remote.out similarity index 100% rename from tests/testdata/run/033_import_map_remote.out rename to tests/specs/run/_033_import_map_remote/033_import_map_remote.out diff --git a/tests/specs/run/_033_import_map_remote/__test__.jsonc b/tests/specs/run/_033_import_map_remote/__test__.jsonc new file mode 100644 index 0000000000..20c848d492 --- /dev/null +++ b/tests/specs/run/_033_import_map_remote/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-import --import-map=import_map_remote.json test_remote.ts", + "output": "033_import_map_remote.out" +} diff --git a/tests/specs/run/_033_import_map_remote/import_map_remote.json b/tests/specs/run/_033_import_map_remote/import_map_remote.json new file mode 100644 index 0000000000..190fc4f55a --- /dev/null +++ b/tests/specs/run/_033_import_map_remote/import_map_remote.json @@ -0,0 +1,10 @@ +{ + "imports": { + "moment": "./moment/moment.ts", + "moment/": "./moment/", + "lodash": "./lodash/lodash.ts", + "lodash/": "./lodash/", + "https://www.unpkg.com/vue/dist/vue.runtime.esm.js": "./vue.ts", + "print_hello": "./print_hello.ts" + } +} diff --git a/tests/specs/run/_033_import_map_remote/lodash/lodash.ts b/tests/specs/run/_033_import_map_remote/lodash/lodash.ts new file mode 100644 index 0000000000..2ec04ed3cf --- /dev/null +++ b/tests/specs/run/_033_import_map_remote/lodash/lodash.ts @@ -0,0 +1 @@ +console.log("Hello from remapped lodash!"); diff --git a/tests/specs/run/_033_import_map_remote/lodash/other_file.ts b/tests/specs/run/_033_import_map_remote/lodash/other_file.ts new file mode 100644 index 0000000000..714adae3fb --- /dev/null +++ b/tests/specs/run/_033_import_map_remote/lodash/other_file.ts @@ -0,0 +1 @@ +console.log("Hello from remapped lodash dir!"); diff --git a/tests/specs/run/_033_import_map_remote/moment/moment.ts b/tests/specs/run/_033_import_map_remote/moment/moment.ts new file mode 100644 index 0000000000..2b54a431e7 --- /dev/null +++ b/tests/specs/run/_033_import_map_remote/moment/moment.ts @@ -0,0 +1 @@ +console.log("Hello from remapped moment!"); diff --git a/tests/specs/run/_033_import_map_remote/moment/other_file.ts b/tests/specs/run/_033_import_map_remote/moment/other_file.ts new file mode 100644 index 0000000000..24f3a0226d --- /dev/null +++ b/tests/specs/run/_033_import_map_remote/moment/other_file.ts @@ -0,0 +1 @@ +console.log("Hello from remapped moment dir!"); diff --git a/tests/specs/run/_033_import_map_remote/print_hello.ts b/tests/specs/run/_033_import_map_remote/print_hello.ts new file mode 100644 index 0000000000..7942573905 --- /dev/null +++ b/tests/specs/run/_033_import_map_remote/print_hello.ts @@ -0,0 +1,3 @@ +export function printHello() { + console.log("Hello, world!"); +} diff --git a/tests/specs/run/_033_import_map_remote/test_remote.ts b/tests/specs/run/_033_import_map_remote/test_remote.ts new file mode 100644 index 0000000000..206bdbd5ff --- /dev/null +++ b/tests/specs/run/_033_import_map_remote/test_remote.ts @@ -0,0 +1,5 @@ +import "moment"; +import "moment/other_file.ts"; +import "lodash"; +import "lodash/other_file.ts"; +import "https://www.unpkg.com/vue/dist/vue.runtime.esm.js"; diff --git a/tests/specs/run/_033_import_map_remote/vue.ts b/tests/specs/run/_033_import_map_remote/vue.ts new file mode 100644 index 0000000000..76dbe19179 --- /dev/null +++ b/tests/specs/run/_033_import_map_remote/vue.ts @@ -0,0 +1 @@ +console.log("Hello from remapped Vue!"); diff --git a/tests/specs/run/_033_import_map_vendor_dir_remote/033_import_map_remote.out b/tests/specs/run/_033_import_map_vendor_dir_remote/033_import_map_remote.out new file mode 100644 index 0000000000..804fa0d57e --- /dev/null +++ b/tests/specs/run/_033_import_map_vendor_dir_remote/033_import_map_remote.out @@ -0,0 +1,5 @@ +Hello from remapped moment! +Hello from remapped moment dir! +Hello from remapped lodash! +Hello from remapped lodash dir! +Hello from remapped Vue! diff --git a/tests/specs/run/_033_import_map_vendor_dir_remote/__test__.jsonc b/tests/specs/run/_033_import_map_vendor_dir_remote/__test__.jsonc new file mode 100644 index 0000000000..4eb3a22c50 --- /dev/null +++ b/tests/specs/run/_033_import_map_vendor_dir_remote/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-import --import-map=import_map_remote.json --vendor test_remote.ts", + "output": "033_import_map_remote.out" +} diff --git a/tests/specs/run/_033_import_map_vendor_dir_remote/import_map_remote.json b/tests/specs/run/_033_import_map_vendor_dir_remote/import_map_remote.json new file mode 100644 index 0000000000..190fc4f55a --- /dev/null +++ b/tests/specs/run/_033_import_map_vendor_dir_remote/import_map_remote.json @@ -0,0 +1,10 @@ +{ + "imports": { + "moment": "./moment/moment.ts", + "moment/": "./moment/", + "lodash": "./lodash/lodash.ts", + "lodash/": "./lodash/", + "https://www.unpkg.com/vue/dist/vue.runtime.esm.js": "./vue.ts", + "print_hello": "./print_hello.ts" + } +} diff --git a/tests/specs/run/_033_import_map_vendor_dir_remote/lodash/lodash.ts b/tests/specs/run/_033_import_map_vendor_dir_remote/lodash/lodash.ts new file mode 100644 index 0000000000..2ec04ed3cf --- /dev/null +++ b/tests/specs/run/_033_import_map_vendor_dir_remote/lodash/lodash.ts @@ -0,0 +1 @@ +console.log("Hello from remapped lodash!"); diff --git a/tests/specs/run/_033_import_map_vendor_dir_remote/lodash/other_file.ts b/tests/specs/run/_033_import_map_vendor_dir_remote/lodash/other_file.ts new file mode 100644 index 0000000000..714adae3fb --- /dev/null +++ b/tests/specs/run/_033_import_map_vendor_dir_remote/lodash/other_file.ts @@ -0,0 +1 @@ +console.log("Hello from remapped lodash dir!"); diff --git a/tests/specs/run/_033_import_map_vendor_dir_remote/moment/moment.ts b/tests/specs/run/_033_import_map_vendor_dir_remote/moment/moment.ts new file mode 100644 index 0000000000..2b54a431e7 --- /dev/null +++ b/tests/specs/run/_033_import_map_vendor_dir_remote/moment/moment.ts @@ -0,0 +1 @@ +console.log("Hello from remapped moment!"); diff --git a/tests/specs/run/_033_import_map_vendor_dir_remote/moment/other_file.ts b/tests/specs/run/_033_import_map_vendor_dir_remote/moment/other_file.ts new file mode 100644 index 0000000000..24f3a0226d --- /dev/null +++ b/tests/specs/run/_033_import_map_vendor_dir_remote/moment/other_file.ts @@ -0,0 +1 @@ +console.log("Hello from remapped moment dir!"); diff --git a/tests/specs/run/_033_import_map_vendor_dir_remote/print_hello.ts b/tests/specs/run/_033_import_map_vendor_dir_remote/print_hello.ts new file mode 100644 index 0000000000..7942573905 --- /dev/null +++ b/tests/specs/run/_033_import_map_vendor_dir_remote/print_hello.ts @@ -0,0 +1,3 @@ +export function printHello() { + console.log("Hello, world!"); +} diff --git a/tests/specs/run/_033_import_map_vendor_dir_remote/test_remote.ts b/tests/specs/run/_033_import_map_vendor_dir_remote/test_remote.ts new file mode 100644 index 0000000000..206bdbd5ff --- /dev/null +++ b/tests/specs/run/_033_import_map_vendor_dir_remote/test_remote.ts @@ -0,0 +1,5 @@ +import "moment"; +import "moment/other_file.ts"; +import "lodash"; +import "lodash/other_file.ts"; +import "https://www.unpkg.com/vue/dist/vue.runtime.esm.js"; diff --git a/tests/specs/run/_033_import_map_vendor_dir_remote/vue.ts b/tests/specs/run/_033_import_map_vendor_dir_remote/vue.ts new file mode 100644 index 0000000000..76dbe19179 --- /dev/null +++ b/tests/specs/run/_033_import_map_vendor_dir_remote/vue.ts @@ -0,0 +1 @@ +console.log("Hello from remapped Vue!"); diff --git a/tests/specs/run/_035_cached_only_flag/019_media_types.ts b/tests/specs/run/_035_cached_only_flag/019_media_types.ts new file mode 100644 index 0000000000..d985bd2496 --- /dev/null +++ b/tests/specs/run/_035_cached_only_flag/019_media_types.ts @@ -0,0 +1,24 @@ +// When run against the test HTTP server, it will serve different media types +// based on the URL containing `.t#.` strings, which exercises the different +// mapping of media types end to end. + +import { loaded as loadedTs1 } from "http://localhost:4545/subdir/mt_text_typescript.t1.ts"; +import { loaded as loadedTs2 } from "http://localhost:4545/subdir/mt_video_vdn.t2.ts"; +import { loaded as loadedTs3 } from "http://localhost:4545/subdir/mt_video_mp2t.t3.ts"; +import { loaded as loadedTs4 } from "http://localhost:4545/subdir/mt_application_x_typescript.t4.ts"; +import { loaded as loadedJs1 } from "http://localhost:4545/subdir/mt_text_javascript.j1.js"; +import { loaded as loadedJs2 } from "http://localhost:4545/subdir/mt_application_ecmascript.j2.js"; +import { loaded as loadedJs3 } from "http://localhost:4545/subdir/mt_text_ecmascript.j3.js"; +import { loaded as loadedJs4 } from "http://localhost:4545/subdir/mt_application_x_javascript.j4.js"; + +console.log( + "success", + loadedTs1, + loadedTs2, + loadedTs3, + loadedTs4, + loadedJs1, + loadedJs2, + loadedJs3, + loadedJs4, +); diff --git a/tests/specs/run/_035_cached_only_flag/035_cached_only_flag.out b/tests/specs/run/_035_cached_only_flag/035_cached_only_flag.out new file mode 100644 index 0000000000..aad3f2fbc1 --- /dev/null +++ b/tests/specs/run/_035_cached_only_flag/035_cached_only_flag.out @@ -0,0 +1 @@ +error: Specifier not found in cache: "http://127.0.0.1:4545/019_media_types.ts", --cached-only is specified. diff --git a/tests/specs/run/_035_cached_only_flag/__test__.jsonc b/tests/specs/run/_035_cached_only_flag/__test__.jsonc new file mode 100644 index 0000000000..ac9d01cdd0 --- /dev/null +++ b/tests/specs/run/_035_cached_only_flag/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload --check --allow-import --cached-only http://127.0.0.1:4545/019_media_types.ts", + "output": "035_cached_only_flag.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/038_checkjs.js b/tests/specs/run/_038_checkjs/038_checkjs.js similarity index 100% rename from tests/testdata/run/038_checkjs.js rename to tests/specs/run/_038_checkjs/038_checkjs.js diff --git a/tests/testdata/run/038_checkjs.js.out b/tests/specs/run/_038_checkjs/038_checkjs.js.out similarity index 100% rename from tests/testdata/run/038_checkjs.js.out rename to tests/specs/run/_038_checkjs/038_checkjs.js.out diff --git a/tests/specs/run/_038_checkjs/__test__.jsonc b/tests/specs/run/_038_checkjs/__test__.jsonc new file mode 100644 index 0000000000..6915787d2d --- /dev/null +++ b/tests/specs/run/_038_checkjs/__test__.jsonc @@ -0,0 +1,6 @@ +{ + // checking if JS file is run through TS compiler + "args": "run --reload --config checkjs.tsconfig.json --check 038_checkjs.js", + "exitCode": 1, + "output": "038_checkjs.js.out" +} diff --git a/tests/specs/run/_038_checkjs/checkjs.tsconfig.json b/tests/specs/run/_038_checkjs/checkjs.tsconfig.json new file mode 100644 index 0000000000..08ac60b6cd --- /dev/null +++ b/tests/specs/run/_038_checkjs/checkjs.tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "checkJs": true + } +} diff --git a/tests/testdata/run/042_dyn_import_evalcontext.ts b/tests/specs/run/_042_dyn_import_evalcontext/042_dyn_import_evalcontext.ts similarity index 63% rename from tests/testdata/run/042_dyn_import_evalcontext.ts rename to tests/specs/run/_042_dyn_import_evalcontext/042_dyn_import_evalcontext.ts index 386ae48ec7..f39ae24685 100644 --- a/tests/testdata/run/042_dyn_import_evalcontext.ts +++ b/tests/specs/run/_042_dyn_import_evalcontext/042_dyn_import_evalcontext.ts @@ -1,5 +1,5 @@ // @ts-expect-error "Deno[Deno.internal].core" is not a public interface Deno[Deno.internal].core.evalContext( - "(async () => console.log(await import('./subdir/mod4.js')))()", + "(async () => console.log(await import('./_042_dyn_import_evalcontext/mod4.js')))()", new URL("..", import.meta.url).href, ); diff --git a/tests/testdata/run/042_dyn_import_evalcontext.ts.out b/tests/specs/run/_042_dyn_import_evalcontext/042_dyn_import_evalcontext.ts.out similarity index 100% rename from tests/testdata/run/042_dyn_import_evalcontext.ts.out rename to tests/specs/run/_042_dyn_import_evalcontext/042_dyn_import_evalcontext.ts.out diff --git a/tests/specs/run/_042_dyn_import_evalcontext/__test__.jsonc b/tests/specs/run/_042_dyn_import_evalcontext/__test__.jsonc new file mode 100644 index 0000000000..e3cb0d1844 --- /dev/null +++ b/tests/specs/run/_042_dyn_import_evalcontext/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --allow-read --reload 042_dyn_import_evalcontext.ts", + "output": "042_dyn_import_evalcontext.ts.out" +} diff --git a/tests/specs/run/_042_dyn_import_evalcontext/mod4.js b/tests/specs/run/_042_dyn_import_evalcontext/mod4.js new file mode 100644 index 0000000000..71332dbc42 --- /dev/null +++ b/tests/specs/run/_042_dyn_import_evalcontext/mod4.js @@ -0,0 +1 @@ +export const isMod4 = true; diff --git a/tests/specs/run/_044_bad_resource/044_bad_resource.ts b/tests/specs/run/_044_bad_resource/044_bad_resource.ts new file mode 100644 index 0000000000..c76a11eff9 --- /dev/null +++ b/tests/specs/run/_044_bad_resource/044_bad_resource.ts @@ -0,0 +1,3 @@ +const file = await Deno.open("./044_bad_resource.ts", { read: true }); +file.close(); +await file.seek(10, 0); diff --git a/tests/testdata/run/044_bad_resource.ts.out b/tests/specs/run/_044_bad_resource/044_bad_resource.ts.out similarity index 100% rename from tests/testdata/run/044_bad_resource.ts.out rename to tests/specs/run/_044_bad_resource/044_bad_resource.ts.out diff --git a/tests/specs/run/_044_bad_resource/__test__.jsonc b/tests/specs/run/_044_bad_resource/__test__.jsonc new file mode 100644 index 0000000000..cb7832e74a --- /dev/null +++ b/tests/specs/run/_044_bad_resource/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --reload --allow-read 044_bad_resource.ts", + "output": "044_bad_resource.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/046_jsx_test.tsx b/tests/specs/run/_046_tsx/046_jsx_test.tsx similarity index 100% rename from tests/testdata/run/046_jsx_test.tsx rename to tests/specs/run/_046_tsx/046_jsx_test.tsx diff --git a/tests/testdata/run/046_jsx_test.tsx.out b/tests/specs/run/_046_tsx/046_jsx_test.tsx.out similarity index 100% rename from tests/testdata/run/046_jsx_test.tsx.out rename to tests/specs/run/_046_tsx/046_jsx_test.tsx.out diff --git a/tests/specs/run/_046_tsx/__test__.jsonc b/tests/specs/run/_046_tsx/__test__.jsonc new file mode 100644 index 0000000000..28a48ececc --- /dev/null +++ b/tests/specs/run/_046_tsx/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload 046_jsx_test.tsx", + "output": "046_jsx_test.tsx.out" +} diff --git a/tests/testdata/run/047_jsx_test.jsx b/tests/specs/run/_047_jsx/047_jsx_test.jsx similarity index 100% rename from tests/testdata/run/047_jsx_test.jsx rename to tests/specs/run/_047_jsx/047_jsx_test.jsx diff --git a/tests/testdata/run/047_jsx_test.jsx.out b/tests/specs/run/_047_jsx/047_jsx_test.jsx.out similarity index 100% rename from tests/testdata/run/047_jsx_test.jsx.out rename to tests/specs/run/_047_jsx/047_jsx_test.jsx.out diff --git a/tests/specs/run/_047_jsx/__test__.jsonc b/tests/specs/run/_047_jsx/__test__.jsonc new file mode 100644 index 0000000000..bb89db0177 --- /dev/null +++ b/tests/specs/run/_047_jsx/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload 047_jsx_test.jsx", + "output": "047_jsx_test.jsx.out" +} diff --git a/tests/specs/run/_048_media_types_jsx/048_media_types_jsx.ts b/tests/specs/run/_048_media_types_jsx/048_media_types_jsx.ts new file mode 100644 index 0000000000..8dcd0ad687 --- /dev/null +++ b/tests/specs/run/_048_media_types_jsx/048_media_types_jsx.ts @@ -0,0 +1,32 @@ +// When run against the test HTTP server, it will serve different media types +// based on the URL containing `.t#.` strings, which exercises the different +// mapping of media types end to end. +import { loaded as loadedTsx1 } from "http://localhost:4545/subdir/mt_text_typescript_tsx.t1.tsx"; +import { loaded as loadedTsx2 } from "http://localhost:4545/subdir/mt_video_vdn_tsx.t2.tsx"; +import { loaded as loadedTsx3 } from "http://localhost:4545/subdir/mt_video_mp2t_tsx.t3.tsx"; +import { loaded as loadedTsx4 } from "http://localhost:4545/subdir/mt_application_x_typescript_tsx.t4.tsx"; +import { loaded as loadedJsx1 } from "http://localhost:4545/subdir/mt_text_javascript_jsx.j1.jsx"; +import { loaded as loadedJsx2 } from "http://localhost:4545/subdir/mt_application_ecmascript_jsx.j2.jsx"; +import { loaded as loadedJsx3 } from "http://localhost:4545/subdir/mt_text_ecmascript_jsx.j3.jsx"; +import { loaded as loadedJsx4 } from "http://localhost:4545/subdir/mt_application_x_javascript_jsx.j4.jsx"; + +declare global { + namespace JSX { + interface IntrinsicElements { + // deno-lint-ignore no-explicit-any + [elemName: string]: any; + } + } +} + +console.log( + "success", + loadedTsx1, + loadedTsx2, + loadedTsx3, + loadedTsx4, + loadedJsx1, + loadedJsx2, + loadedJsx3, + loadedJsx4, +); diff --git a/tests/testdata/run/048_media_types_jsx.ts.out b/tests/specs/run/_048_media_types_jsx/048_media_types_jsx.ts.out similarity index 100% rename from tests/testdata/run/048_media_types_jsx.ts.out rename to tests/specs/run/_048_media_types_jsx/048_media_types_jsx.ts.out diff --git a/tests/specs/run/_048_media_types_jsx/__test__.jsonc b/tests/specs/run/_048_media_types_jsx/__test__.jsonc new file mode 100644 index 0000000000..0dec930b09 --- /dev/null +++ b/tests/specs/run/_048_media_types_jsx/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --allow-import 048_media_types_jsx.ts", + "output": "048_media_types_jsx.ts.out" +} diff --git a/tests/specs/run/_052_no_remote_flag/019_media_types.ts b/tests/specs/run/_052_no_remote_flag/019_media_types.ts new file mode 100644 index 0000000000..d985bd2496 --- /dev/null +++ b/tests/specs/run/_052_no_remote_flag/019_media_types.ts @@ -0,0 +1,24 @@ +// When run against the test HTTP server, it will serve different media types +// based on the URL containing `.t#.` strings, which exercises the different +// mapping of media types end to end. + +import { loaded as loadedTs1 } from "http://localhost:4545/subdir/mt_text_typescript.t1.ts"; +import { loaded as loadedTs2 } from "http://localhost:4545/subdir/mt_video_vdn.t2.ts"; +import { loaded as loadedTs3 } from "http://localhost:4545/subdir/mt_video_mp2t.t3.ts"; +import { loaded as loadedTs4 } from "http://localhost:4545/subdir/mt_application_x_typescript.t4.ts"; +import { loaded as loadedJs1 } from "http://localhost:4545/subdir/mt_text_javascript.j1.js"; +import { loaded as loadedJs2 } from "http://localhost:4545/subdir/mt_application_ecmascript.j2.js"; +import { loaded as loadedJs3 } from "http://localhost:4545/subdir/mt_text_ecmascript.j3.js"; +import { loaded as loadedJs4 } from "http://localhost:4545/subdir/mt_application_x_javascript.j4.js"; + +console.log( + "success", + loadedTs1, + loadedTs2, + loadedTs3, + loadedTs4, + loadedJs1, + loadedJs2, + loadedJs3, + loadedJs4, +); diff --git a/tests/testdata/run/052_no_remote_flag.out b/tests/specs/run/_052_no_remote_flag/052_no_remote_flag.out similarity index 53% rename from tests/testdata/run/052_no_remote_flag.out rename to tests/specs/run/_052_no_remote_flag/052_no_remote_flag.out index 2f5950ee89..c1f9f4e131 100644 --- a/tests/testdata/run/052_no_remote_flag.out +++ b/tests/specs/run/_052_no_remote_flag/052_no_remote_flag.out @@ -1 +1 @@ -error: A remote specifier was requested: "http://127.0.0.1:4545/run/019_media_types.ts", but --no-remote is specified. +error: A remote specifier was requested: "http://127.0.0.1:4545/019_media_types.ts", but --no-remote is specified. diff --git a/tests/specs/run/_052_no_remote_flag/__test__.jsonc b/tests/specs/run/_052_no_remote_flag/__test__.jsonc new file mode 100644 index 0000000000..c8ac477c66 --- /dev/null +++ b/tests/specs/run/_052_no_remote_flag/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload --check --allow-import --no-remote http://127.0.0.1:4545/019_media_types.ts", + "output": "052_no_remote_flag.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/058_tasks_microtasks_close.ts b/tests/specs/run/_058_tasks_microtasks_close/058_tasks_microtasks_close.ts similarity index 100% rename from tests/testdata/run/058_tasks_microtasks_close.ts rename to tests/specs/run/_058_tasks_microtasks_close/058_tasks_microtasks_close.ts diff --git a/tests/testdata/run/058_tasks_microtasks_close.ts.out b/tests/specs/run/_058_tasks_microtasks_close/058_tasks_microtasks_close.ts.out similarity index 100% rename from tests/testdata/run/058_tasks_microtasks_close.ts.out rename to tests/specs/run/_058_tasks_microtasks_close/058_tasks_microtasks_close.ts.out diff --git a/tests/specs/run/_058_tasks_microtasks_close/__test__.jsonc b/tests/specs/run/_058_tasks_microtasks_close/__test__.jsonc new file mode 100644 index 0000000000..9eec8f53cb --- /dev/null +++ b/tests/specs/run/_058_tasks_microtasks_close/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet 058_tasks_microtasks_close.ts", + "output": "058_tasks_microtasks_close.ts.out" +} diff --git a/tests/testdata/run/059_fs_relative_path_perm.ts b/tests/specs/run/_059_fs_relative_path_perm/059_fs_relative_path_perm.ts similarity index 100% rename from tests/testdata/run/059_fs_relative_path_perm.ts rename to tests/specs/run/_059_fs_relative_path_perm/059_fs_relative_path_perm.ts diff --git a/tests/testdata/run/059_fs_relative_path_perm.ts.out b/tests/specs/run/_059_fs_relative_path_perm/059_fs_relative_path_perm.ts.out similarity index 100% rename from tests/testdata/run/059_fs_relative_path_perm.ts.out rename to tests/specs/run/_059_fs_relative_path_perm/059_fs_relative_path_perm.ts.out diff --git a/tests/specs/run/_059_fs_relative_path_perm/__test__.jsonc b/tests/specs/run/_059_fs_relative_path_perm/__test__.jsonc new file mode 100644 index 0000000000..04a7b8aa4f --- /dev/null +++ b/tests/specs/run/_059_fs_relative_path_perm/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run 059_fs_relative_path_perm.ts", + "output": "059_fs_relative_path_perm.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/063_permissions_revoke.ts b/tests/specs/run/_063_permissions_revoke/063_permissions_revoke.ts similarity index 100% rename from tests/testdata/run/063_permissions_revoke.ts rename to tests/specs/run/_063_permissions_revoke/063_permissions_revoke.ts diff --git a/tests/testdata/run/063_permissions_revoke.ts.out b/tests/specs/run/_063_permissions_revoke/063_permissions_revoke.ts.out similarity index 100% rename from tests/testdata/run/063_permissions_revoke.ts.out rename to tests/specs/run/_063_permissions_revoke/063_permissions_revoke.ts.out diff --git a/tests/specs/run/_063_permissions_revoke/__test__.jsonc b/tests/specs/run/_063_permissions_revoke/__test__.jsonc new file mode 100644 index 0000000000..1dd5ed747f --- /dev/null +++ b/tests/specs/run/_063_permissions_revoke/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read=foo,bar 063_permissions_revoke.ts", + "output": "063_permissions_revoke.ts.out" +} diff --git a/tests/specs/run/_063_permissions_revoke_sync/063_permissions_revoke.ts.out b/tests/specs/run/_063_permissions_revoke_sync/063_permissions_revoke.ts.out new file mode 100644 index 0000000000..bbd64c557b --- /dev/null +++ b/tests/specs/run/_063_permissions_revoke_sync/063_permissions_revoke.ts.out @@ -0,0 +1,3 @@ +[WILDCARD]PermissionStatus { state: "prompt", onchange: null } +PermissionStatus { state: "granted", onchange: null } +PermissionStatus { state: "prompt", onchange: null } diff --git a/tests/testdata/run/063_permissions_revoke_sync.ts b/tests/specs/run/_063_permissions_revoke_sync/063_permissions_revoke_sync.ts similarity index 100% rename from tests/testdata/run/063_permissions_revoke_sync.ts rename to tests/specs/run/_063_permissions_revoke_sync/063_permissions_revoke_sync.ts diff --git a/tests/specs/run/_063_permissions_revoke_sync/__test__.jsonc b/tests/specs/run/_063_permissions_revoke_sync/__test__.jsonc new file mode 100644 index 0000000000..8dd9384e3d --- /dev/null +++ b/tests/specs/run/_063_permissions_revoke_sync/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read=foo,bar 063_permissions_revoke_sync.ts", + "output": "063_permissions_revoke.ts.out" +} diff --git a/tests/testdata/run/064_permissions_revoke_global.ts b/tests/specs/run/_064_permissions_revoke_global/064_permissions_revoke_global.ts similarity index 100% rename from tests/testdata/run/064_permissions_revoke_global.ts rename to tests/specs/run/_064_permissions_revoke_global/064_permissions_revoke_global.ts diff --git a/tests/testdata/run/064_permissions_revoke_global.ts.out b/tests/specs/run/_064_permissions_revoke_global/064_permissions_revoke_global.ts.out similarity index 100% rename from tests/testdata/run/064_permissions_revoke_global.ts.out rename to tests/specs/run/_064_permissions_revoke_global/064_permissions_revoke_global.ts.out diff --git a/tests/specs/run/_064_permissions_revoke_global/__test__.jsonc b/tests/specs/run/_064_permissions_revoke_global/__test__.jsonc new file mode 100644 index 0000000000..929e48ee8d --- /dev/null +++ b/tests/specs/run/_064_permissions_revoke_global/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read=foo,bar 064_permissions_revoke_global.ts", + "output": "064_permissions_revoke_global.ts.out" +} diff --git a/tests/specs/run/_064_permissions_revoke_global_sync/064_permissions_revoke_global.ts.out b/tests/specs/run/_064_permissions_revoke_global_sync/064_permissions_revoke_global.ts.out new file mode 100644 index 0000000000..f7e389a76b --- /dev/null +++ b/tests/specs/run/_064_permissions_revoke_global_sync/064_permissions_revoke_global.ts.out @@ -0,0 +1,3 @@ +[WILDCARD]PermissionStatus { state: "prompt", onchange: null } +PermissionStatus { state: "prompt", onchange: null } +PermissionStatus { state: "prompt", onchange: null } diff --git a/tests/testdata/run/064_permissions_revoke_global_sync.ts b/tests/specs/run/_064_permissions_revoke_global_sync/064_permissions_revoke_global_sync.ts similarity index 100% rename from tests/testdata/run/064_permissions_revoke_global_sync.ts rename to tests/specs/run/_064_permissions_revoke_global_sync/064_permissions_revoke_global_sync.ts diff --git a/tests/specs/run/_064_permissions_revoke_global_sync/__test__.jsonc b/tests/specs/run/_064_permissions_revoke_global_sync/__test__.jsonc new file mode 100644 index 0000000000..8d6f8079d3 --- /dev/null +++ b/tests/specs/run/_064_permissions_revoke_global_sync/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read=foo,bar 064_permissions_revoke_global_sync.ts", + "output": "064_permissions_revoke_global.ts.out" +} diff --git a/tests/testdata/run/065_permissions_revoke_net.ts b/tests/specs/run/_065_permissions_revoke_net/065_permissions_revoke_net.ts similarity index 100% rename from tests/testdata/run/065_permissions_revoke_net.ts rename to tests/specs/run/_065_permissions_revoke_net/065_permissions_revoke_net.ts diff --git a/tests/testdata/run/065_permissions_revoke_net.ts.out b/tests/specs/run/_065_permissions_revoke_net/065_permissions_revoke_net.ts.out similarity index 100% rename from tests/testdata/run/065_permissions_revoke_net.ts.out rename to tests/specs/run/_065_permissions_revoke_net/065_permissions_revoke_net.ts.out diff --git a/tests/specs/run/_065_permissions_revoke_net/__test__.jsonc b/tests/specs/run/_065_permissions_revoke_net/__test__.jsonc new file mode 100644 index 0000000000..ab66835fdb --- /dev/null +++ b/tests/specs/run/_065_permissions_revoke_net/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-net 065_permissions_revoke_net.ts", + "output": "065_permissions_revoke_net.ts.out" +} diff --git a/tests/testdata/run/070_location.ts b/tests/specs/run/_070_location/070_location.ts similarity index 100% rename from tests/testdata/run/070_location.ts rename to tests/specs/run/_070_location/070_location.ts diff --git a/tests/testdata/run/070_location.ts.out b/tests/specs/run/_070_location/070_location.ts.out similarity index 100% rename from tests/testdata/run/070_location.ts.out rename to tests/specs/run/_070_location/070_location.ts.out diff --git a/tests/specs/run/_070_location/__test__.jsonc b/tests/specs/run/_070_location/__test__.jsonc new file mode 100644 index 0000000000..ad92752ea0 --- /dev/null +++ b/tests/specs/run/_070_location/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --location https://foo/bar?baz#bat 070_location.ts", + "output": "070_location.ts.out" +} diff --git a/tests/testdata/run/071_location_unset.ts b/tests/specs/run/_071_location_unset/071_location_unset.ts similarity index 100% rename from tests/testdata/run/071_location_unset.ts rename to tests/specs/run/_071_location_unset/071_location_unset.ts diff --git a/tests/testdata/run/071_location_unset.ts.out b/tests/specs/run/_071_location_unset/071_location_unset.ts.out similarity index 100% rename from tests/testdata/run/071_location_unset.ts.out rename to tests/specs/run/_071_location_unset/071_location_unset.ts.out diff --git a/tests/specs/run/_071_location_unset/__test__.jsonc b/tests/specs/run/_071_location_unset/__test__.jsonc new file mode 100644 index 0000000000..946755cf5a --- /dev/null +++ b/tests/specs/run/_071_location_unset/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run 071_location_unset.ts", + "output": "071_location_unset.ts.out" +} diff --git a/tests/testdata/run/072_location_relative_fetch.ts b/tests/specs/run/_072_location_relative_fetch/072_location_relative_fetch.ts similarity index 100% rename from tests/testdata/run/072_location_relative_fetch.ts rename to tests/specs/run/_072_location_relative_fetch/072_location_relative_fetch.ts diff --git a/tests/testdata/run/072_location_relative_fetch.ts.out b/tests/specs/run/_072_location_relative_fetch/072_location_relative_fetch.ts.out similarity index 100% rename from tests/testdata/run/072_location_relative_fetch.ts.out rename to tests/specs/run/_072_location_relative_fetch/072_location_relative_fetch.ts.out diff --git a/tests/specs/run/_072_location_relative_fetch/__test__.jsonc b/tests/specs/run/_072_location_relative_fetch/__test__.jsonc new file mode 100644 index 0000000000..e6e9e48996 --- /dev/null +++ b/tests/specs/run/_072_location_relative_fetch/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --location http://127.0.0.1:4545/ --allow-net 072_location_relative_fetch.ts", + "output": "072_location_relative_fetch.ts.out" +} diff --git a/tests/specs/run/_072_location_relative_fetch/fetch/hello.txt b/tests/specs/run/_072_location_relative_fetch/fetch/hello.txt new file mode 100644 index 0000000000..af5626b4a1 --- /dev/null +++ b/tests/specs/run/_072_location_relative_fetch/fetch/hello.txt @@ -0,0 +1 @@ +Hello, world! diff --git a/tests/specs/run/_075_import_local_query_hash/001_hello.js b/tests/specs/run/_075_import_local_query_hash/001_hello.js new file mode 100644 index 0000000000..accefceba6 --- /dev/null +++ b/tests/specs/run/_075_import_local_query_hash/001_hello.js @@ -0,0 +1 @@ +console.log("Hello World"); diff --git a/tests/specs/run/_075_import_local_query_hash/002_hello.ts b/tests/specs/run/_075_import_local_query_hash/002_hello.ts new file mode 100644 index 0000000000..accefceba6 --- /dev/null +++ b/tests/specs/run/_075_import_local_query_hash/002_hello.ts @@ -0,0 +1 @@ +console.log("Hello World"); diff --git a/tests/testdata/run/075_import_local_query_hash.ts b/tests/specs/run/_075_import_local_query_hash/075_import_local_query_hash.ts similarity index 100% rename from tests/testdata/run/075_import_local_query_hash.ts rename to tests/specs/run/_075_import_local_query_hash/075_import_local_query_hash.ts diff --git a/tests/testdata/run/075_import_local_query_hash.ts.out b/tests/specs/run/_075_import_local_query_hash/075_import_local_query_hash.ts.out similarity index 100% rename from tests/testdata/run/075_import_local_query_hash.ts.out rename to tests/specs/run/_075_import_local_query_hash/075_import_local_query_hash.ts.out diff --git a/tests/specs/run/_075_import_local_query_hash/__test__.jsonc b/tests/specs/run/_075_import_local_query_hash/__test__.jsonc new file mode 100644 index 0000000000..521cd3ea8a --- /dev/null +++ b/tests/specs/run/_075_import_local_query_hash/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run 075_import_local_query_hash.ts", + "output": "075_import_local_query_hash.ts.out" +} diff --git a/tests/testdata/run/077_fetch_empty.ts b/tests/specs/run/_077_fetch_empty/077_fetch_empty.ts similarity index 100% rename from tests/testdata/run/077_fetch_empty.ts rename to tests/specs/run/_077_fetch_empty/077_fetch_empty.ts diff --git a/tests/testdata/run/077_fetch_empty.ts.out b/tests/specs/run/_077_fetch_empty/077_fetch_empty.ts.out similarity index 100% rename from tests/testdata/run/077_fetch_empty.ts.out rename to tests/specs/run/_077_fetch_empty/077_fetch_empty.ts.out diff --git a/tests/specs/run/_077_fetch_empty/__test__.jsonc b/tests/specs/run/_077_fetch_empty/__test__.jsonc new file mode 100644 index 0000000000..654b109380 --- /dev/null +++ b/tests/specs/run/_077_fetch_empty/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run -A 077_fetch_empty.ts", + "output": "077_fetch_empty.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/078_unload_on_exit.ts b/tests/specs/run/_078_unload_on_exit/078_unload_on_exit.ts similarity index 100% rename from tests/testdata/run/078_unload_on_exit.ts rename to tests/specs/run/_078_unload_on_exit/078_unload_on_exit.ts diff --git a/tests/testdata/run/078_unload_on_exit.ts.out b/tests/specs/run/_078_unload_on_exit/078_unload_on_exit.ts.out similarity index 100% rename from tests/testdata/run/078_unload_on_exit.ts.out rename to tests/specs/run/_078_unload_on_exit/078_unload_on_exit.ts.out diff --git a/tests/specs/run/_078_unload_on_exit/__test__.jsonc b/tests/specs/run/_078_unload_on_exit/__test__.jsonc new file mode 100644 index 0000000000..4091b7dc99 --- /dev/null +++ b/tests/specs/run/_078_unload_on_exit/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run 078_unload_on_exit.ts", + "output": "078_unload_on_exit.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/079_location_authentication.ts b/tests/specs/run/_079_location_authentication/079_location_authentication.ts similarity index 100% rename from tests/testdata/run/079_location_authentication.ts rename to tests/specs/run/_079_location_authentication/079_location_authentication.ts diff --git a/tests/testdata/run/079_location_authentication.ts.out b/tests/specs/run/_079_location_authentication/079_location_authentication.ts.out similarity index 100% rename from tests/testdata/run/079_location_authentication.ts.out rename to tests/specs/run/_079_location_authentication/079_location_authentication.ts.out diff --git a/tests/specs/run/_079_location_authentication/__test__.jsonc b/tests/specs/run/_079_location_authentication/__test__.jsonc new file mode 100644 index 0000000000..30ba279490 --- /dev/null +++ b/tests/specs/run/_079_location_authentication/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --location https://foo:bar@baz/qux 079_location_authentication.ts", + "output": "079_location_authentication.ts.out" +} diff --git a/tests/testdata/run/081_location_relative_fetch_redirect.ts b/tests/specs/run/_081_location_relative_fetch_redirect/081_location_relative_fetch_redirect.ts similarity index 100% rename from tests/testdata/run/081_location_relative_fetch_redirect.ts rename to tests/specs/run/_081_location_relative_fetch_redirect/081_location_relative_fetch_redirect.ts diff --git a/tests/testdata/run/081_location_relative_fetch_redirect.ts.out b/tests/specs/run/_081_location_relative_fetch_redirect/081_location_relative_fetch_redirect.ts.out similarity index 100% rename from tests/testdata/run/081_location_relative_fetch_redirect.ts.out rename to tests/specs/run/_081_location_relative_fetch_redirect/081_location_relative_fetch_redirect.ts.out diff --git a/tests/specs/run/_081_location_relative_fetch_redirect/__test__.jsonc b/tests/specs/run/_081_location_relative_fetch_redirect/__test__.jsonc new file mode 100644 index 0000000000..6756bf6d1f --- /dev/null +++ b/tests/specs/run/_081_location_relative_fetch_redirect/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --location http://127.0.0.1:4546/ --allow-net 081_location_relative_fetch_redirect.ts", + "output": "081_location_relative_fetch_redirect.ts.out" +} diff --git a/tests/testdata/run/082_prepare_stack_trace_throw.js b/tests/specs/run/_082_prepare_stack_trace_throw/082_prepare_stack_trace_throw.js similarity index 100% rename from tests/testdata/run/082_prepare_stack_trace_throw.js rename to tests/specs/run/_082_prepare_stack_trace_throw/082_prepare_stack_trace_throw.js diff --git a/tests/testdata/run/082_prepare_stack_trace_throw.js.out b/tests/specs/run/_082_prepare_stack_trace_throw/082_prepare_stack_trace_throw.js.out similarity index 100% rename from tests/testdata/run/082_prepare_stack_trace_throw.js.out rename to tests/specs/run/_082_prepare_stack_trace_throw/082_prepare_stack_trace_throw.js.out diff --git a/tests/specs/run/_082_prepare_stack_trace_throw/__test__.jsonc b/tests/specs/run/_082_prepare_stack_trace_throw/__test__.jsonc new file mode 100644 index 0000000000..41b27e3bdd --- /dev/null +++ b/tests/specs/run/_082_prepare_stack_trace_throw/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run 082_prepare_stack_trace_throw.js", + "output": "082_prepare_stack_trace_throw.js.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/088_dynamic_import_already_evaluating.ts b/tests/specs/run/_088_dynamic_import_already_evaluating/088_dynamic_import_already_evaluating.ts similarity index 100% rename from tests/testdata/run/088_dynamic_import_already_evaluating.ts rename to tests/specs/run/_088_dynamic_import_already_evaluating/088_dynamic_import_already_evaluating.ts diff --git a/tests/testdata/run/088_dynamic_import_already_evaluating.ts.out b/tests/specs/run/_088_dynamic_import_already_evaluating/088_dynamic_import_already_evaluating.ts.out similarity index 100% rename from tests/testdata/run/088_dynamic_import_already_evaluating.ts.out rename to tests/specs/run/_088_dynamic_import_already_evaluating/088_dynamic_import_already_evaluating.ts.out diff --git a/tests/specs/run/_088_dynamic_import_already_evaluating/088_dynamic_import_target.ts b/tests/specs/run/_088_dynamic_import_already_evaluating/088_dynamic_import_target.ts new file mode 100644 index 0000000000..226f1851a6 --- /dev/null +++ b/tests/specs/run/_088_dynamic_import_already_evaluating/088_dynamic_import_target.ts @@ -0,0 +1,3 @@ +console.log(1); +await new Promise((r) => setTimeout(r, 100)); +console.log(2); diff --git a/tests/specs/run/_088_dynamic_import_already_evaluating/__test__.jsonc b/tests/specs/run/_088_dynamic_import_already_evaluating/__test__.jsonc new file mode 100644 index 0000000000..4ce912bf86 --- /dev/null +++ b/tests/specs/run/_088_dynamic_import_already_evaluating/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read 088_dynamic_import_already_evaluating.ts", + "output": "088_dynamic_import_already_evaluating.ts.out" +} diff --git a/tests/testdata/run/091_use_define_for_class_fields.ts b/tests/specs/run/_091_use_define_for_class_fields/091_use_define_for_class_fields.ts similarity index 100% rename from tests/testdata/run/091_use_define_for_class_fields.ts rename to tests/specs/run/_091_use_define_for_class_fields/091_use_define_for_class_fields.ts diff --git a/tests/testdata/run/091_use_define_for_class_fields.ts.out b/tests/specs/run/_091_use_define_for_class_fields/091_use_define_for_class_fields.ts.out similarity index 100% rename from tests/testdata/run/091_use_define_for_class_fields.ts.out rename to tests/specs/run/_091_use_define_for_class_fields/091_use_define_for_class_fields.ts.out diff --git a/tests/specs/run/_091_use_define_for_class_fields/__test__.jsonc b/tests/specs/run/_091_use_define_for_class_fields/__test__.jsonc new file mode 100644 index 0000000000..100db44aa8 --- /dev/null +++ b/tests/specs/run/_091_use_define_for_class_fields/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --check 091_use_define_for_class_fields.ts", + "output": "091_use_define_for_class_fields.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/run/aggregate_error/__test__.jsonc b/tests/specs/run/aggregate_error/__test__.jsonc new file mode 100644 index 0000000000..e9bd82481c --- /dev/null +++ b/tests/specs/run/aggregate_error/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet aggregate_error.ts", + "output": "aggregate_error.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/aggregate_error.out b/tests/specs/run/aggregate_error/aggregate_error.out similarity index 100% rename from tests/testdata/run/aggregate_error.out rename to tests/specs/run/aggregate_error/aggregate_error.out diff --git a/tests/testdata/run/aggregate_error.ts b/tests/specs/run/aggregate_error/aggregate_error.ts similarity index 100% rename from tests/testdata/run/aggregate_error.ts rename to tests/specs/run/aggregate_error/aggregate_error.ts diff --git a/tests/specs/run/async_error/__test__.jsonc b/tests/specs/run/async_error/__test__.jsonc new file mode 100644 index 0000000000..86c31adac7 --- /dev/null +++ b/tests/specs/run/async_error/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload async_error.ts", + "output": "async_error.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/async_error.ts b/tests/specs/run/async_error/async_error.ts similarity index 100% rename from tests/testdata/run/async_error.ts rename to tests/specs/run/async_error/async_error.ts diff --git a/tests/testdata/run/async_error.ts.out b/tests/specs/run/async_error/async_error.ts.out similarity index 100% rename from tests/testdata/run/async_error.ts.out rename to tests/specs/run/async_error/async_error.ts.out diff --git a/tests/specs/run/beforeunload_event/__test__.jsonc b/tests/specs/run/beforeunload_event/__test__.jsonc new file mode 100644 index 0000000000..01c7e70077 --- /dev/null +++ b/tests/specs/run/beforeunload_event/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run before_unload.js", + "output": "before_unload.js.out" +} diff --git a/tests/testdata/run/before_unload.js b/tests/specs/run/beforeunload_event/before_unload.js similarity index 100% rename from tests/testdata/run/before_unload.js rename to tests/specs/run/beforeunload_event/before_unload.js diff --git a/tests/testdata/run/before_unload.js.out b/tests/specs/run/beforeunload_event/before_unload.js.out similarity index 100% rename from tests/testdata/run/before_unload.js.out rename to tests/specs/run/beforeunload_event/before_unload.js.out diff --git a/tests/specs/run/blob_gc_finalization/__test__.jsonc b/tests/specs/run/blob_gc_finalization/__test__.jsonc new file mode 100644 index 0000000000..20a8128fce --- /dev/null +++ b/tests/specs/run/blob_gc_finalization/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run blob_gc_finalization.js", + "output": "blob_gc_finalization.js.out", + "exitCode": 0 +} diff --git a/tests/testdata/run/blob_gc_finalization.js b/tests/specs/run/blob_gc_finalization/blob_gc_finalization.js similarity index 100% rename from tests/testdata/run/blob_gc_finalization.js rename to tests/specs/run/blob_gc_finalization/blob_gc_finalization.js diff --git a/tests/testdata/run/blob_gc_finalization.js.out b/tests/specs/run/blob_gc_finalization/blob_gc_finalization.js.out similarity index 100% rename from tests/testdata/run/blob_gc_finalization.js.out rename to tests/specs/run/blob_gc_finalization/blob_gc_finalization.js.out diff --git a/tests/specs/run/byte_order_mark/001_hello.js b/tests/specs/run/byte_order_mark/001_hello.js new file mode 100644 index 0000000000..accefceba6 --- /dev/null +++ b/tests/specs/run/byte_order_mark/001_hello.js @@ -0,0 +1 @@ +console.log("Hello World"); diff --git a/tests/specs/run/byte_order_mark/__test__.jsonc b/tests/specs/run/byte_order_mark/__test__.jsonc new file mode 100644 index 0000000000..f47cb7d025 --- /dev/null +++ b/tests/specs/run/byte_order_mark/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --no-check byte_order_mark.ts", + "output": "byte_order_mark.out" +} diff --git a/tests/testdata/run/byte_order_mark.out b/tests/specs/run/byte_order_mark/byte_order_mark.out similarity index 100% rename from tests/testdata/run/byte_order_mark.out rename to tests/specs/run/byte_order_mark/byte_order_mark.out diff --git a/tests/testdata/run/byte_order_mark.ts b/tests/specs/run/byte_order_mark/byte_order_mark.ts similarity index 86% rename from tests/testdata/run/byte_order_mark.ts rename to tests/specs/run/byte_order_mark/byte_order_mark.ts index 40eb23c1d0..71da3e1e9c 100644 --- a/tests/testdata/run/byte_order_mark.ts +++ b/tests/specs/run/byte_order_mark/byte_order_mark.ts @@ -1,4 +1,4 @@ -import "./001_hello.js"; +import "./001_hello.js"; // Note this file starts with special byte order mark // it's important that this file is a .ts typescript file which is passed to // deno through `--no-check` mode. diff --git a/tests/specs/run/check_js_points_to_ts/__test__.jsonc b/tests/specs/run/check_js_points_to_ts/__test__.jsonc new file mode 100644 index 0000000000..a63b9e5a46 --- /dev/null +++ b/tests/specs/run/check_js_points_to_ts/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --check --config checkjs.tsconfig.json check_js_points_to_ts/test.js", + "output": "check_js_points_to_ts/test.js.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/check_js_points_to_ts/bar.ts b/tests/specs/run/check_js_points_to_ts/check_js_points_to_ts/bar.ts similarity index 100% rename from tests/testdata/run/check_js_points_to_ts/bar.ts rename to tests/specs/run/check_js_points_to_ts/check_js_points_to_ts/bar.ts diff --git a/tests/testdata/run/check_js_points_to_ts/foo.d.ts b/tests/specs/run/check_js_points_to_ts/check_js_points_to_ts/foo.d.ts similarity index 100% rename from tests/testdata/run/check_js_points_to_ts/foo.d.ts rename to tests/specs/run/check_js_points_to_ts/check_js_points_to_ts/foo.d.ts diff --git a/tests/testdata/run/check_js_points_to_ts/foo.js b/tests/specs/run/check_js_points_to_ts/check_js_points_to_ts/foo.js similarity index 100% rename from tests/testdata/run/check_js_points_to_ts/foo.js rename to tests/specs/run/check_js_points_to_ts/check_js_points_to_ts/foo.js diff --git a/tests/testdata/run/check_js_points_to_ts/test.js b/tests/specs/run/check_js_points_to_ts/check_js_points_to_ts/test.js similarity index 100% rename from tests/testdata/run/check_js_points_to_ts/test.js rename to tests/specs/run/check_js_points_to_ts/check_js_points_to_ts/test.js diff --git a/tests/testdata/run/check_js_points_to_ts/test.js.out b/tests/specs/run/check_js_points_to_ts/check_js_points_to_ts/test.js.out similarity index 100% rename from tests/testdata/run/check_js_points_to_ts/test.js.out rename to tests/specs/run/check_js_points_to_ts/check_js_points_to_ts/test.js.out diff --git a/tests/specs/run/check_js_points_to_ts/checkjs.tsconfig.json b/tests/specs/run/check_js_points_to_ts/checkjs.tsconfig.json new file mode 100644 index 0000000000..08ac60b6cd --- /dev/null +++ b/tests/specs/run/check_js_points_to_ts/checkjs.tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "checkJs": true + } +} diff --git a/tests/specs/run/check_remote/__test__.jsonc b/tests/specs/run/check_remote/__test__.jsonc new file mode 100644 index 0000000000..6543e61b3f --- /dev/null +++ b/tests/specs/run/check_remote/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --allow-import --reload --check=all no_check_remote.ts", + "output": "no_check_remote.ts.disabled.out", + "exitCode": 1 +} diff --git a/tests/specs/run/check_remote/no_check_remote.ts b/tests/specs/run/check_remote/no_check_remote.ts new file mode 100644 index 0000000000..f42dadf8a7 --- /dev/null +++ b/tests/specs/run/check_remote/no_check_remote.ts @@ -0,0 +1,3 @@ +import * as a from "./type_error.ts"; + +console.log(a.a); diff --git a/tests/testdata/run/no_check_remote.ts.disabled.out b/tests/specs/run/check_remote/no_check_remote.ts.disabled.out similarity index 66% rename from tests/testdata/run/no_check_remote.ts.disabled.out rename to tests/specs/run/check_remote/no_check_remote.ts.disabled.out index 3442646348..06c046072d 100644 --- a/tests/testdata/run/no_check_remote.ts.disabled.out +++ b/tests/specs/run/check_remote/no_check_remote.ts.disabled.out @@ -1,4 +1,4 @@ error: TS2322 [ERROR]: Type '12' is not assignable to type '"a"'. export const a: "a" = 12; ^ - at http://localhost:4545/subdir/type_error.ts:1:14 + at [WILDCARD]/type_error.ts:1:14 diff --git a/tests/specs/run/check_remote/type_error.ts b/tests/specs/run/check_remote/type_error.ts new file mode 100644 index 0000000000..cc3c1d29d8 --- /dev/null +++ b/tests/specs/run/check_remote/type_error.ts @@ -0,0 +1 @@ +export const a: "a" = 12; diff --git a/tests/specs/run/classic_workers_event_loop/__test__.jsonc b/tests/specs/run/classic_workers_event_loop/__test__.jsonc new file mode 100644 index 0000000000..44ea36bdc0 --- /dev/null +++ b/tests/specs/run/classic_workers_event_loop/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --enable-testing-features-do-not-use classic_workers_event_loop.js", + "output": "classic_workers_event_loop.js.out" +} diff --git a/tests/testdata/run/classic_workers_event_loop.js b/tests/specs/run/classic_workers_event_loop/classic_workers_event_loop.js similarity index 100% rename from tests/testdata/run/classic_workers_event_loop.js rename to tests/specs/run/classic_workers_event_loop/classic_workers_event_loop.js diff --git a/tests/testdata/run/classic_workers_event_loop.js.out b/tests/specs/run/classic_workers_event_loop/classic_workers_event_loop.js.out similarity index 100% rename from tests/testdata/run/classic_workers_event_loop.js.out rename to tests/specs/run/classic_workers_event_loop/classic_workers_event_loop.js.out diff --git a/tests/specs/run/colors_without_global_this/__test__.jsonc b/tests/specs/run/colors_without_global_this/__test__.jsonc new file mode 100644 index 0000000000..1d2f1c1cfe --- /dev/null +++ b/tests/specs/run/colors_without_global_this/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run colors_without_globalThis.js", + "output": "true\n" +} diff --git a/tests/testdata/run/colors_without_globalThis.js b/tests/specs/run/colors_without_global_this/colors_without_globalThis.js similarity index 100% rename from tests/testdata/run/colors_without_globalThis.js rename to tests/specs/run/colors_without_global_this/colors_without_globalThis.js diff --git a/tests/specs/run/complex_error/__test__.jsonc b/tests/specs/run/complex_error/__test__.jsonc new file mode 100644 index 0000000000..2f7274be49 --- /dev/null +++ b/tests/specs/run/complex_error/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet complex_error.ts", + "output": "complex_error.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/complex_error.ts b/tests/specs/run/complex_error/complex_error.ts similarity index 100% rename from tests/testdata/run/complex_error.ts rename to tests/specs/run/complex_error/complex_error.ts diff --git a/tests/testdata/run/complex_error.ts.out b/tests/specs/run/complex_error/complex_error.ts.out similarity index 100% rename from tests/testdata/run/complex_error.ts.out rename to tests/specs/run/complex_error/complex_error.ts.out diff --git a/tests/specs/run/config/__test__.jsonc b/tests/specs/run/config/__test__.jsonc new file mode 100644 index 0000000000..59d3ae5fcc --- /dev/null +++ b/tests/specs/run/config/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --config config/tsconfig.json --check config/main.ts", + "output": "config/main.out" +} diff --git a/tests/testdata/run/config/main.out b/tests/specs/run/config/config/main.out similarity index 100% rename from tests/testdata/run/config/main.out rename to tests/specs/run/config/config/main.out diff --git a/tests/testdata/run/config/main.ts b/tests/specs/run/config/config/main.ts similarity index 100% rename from tests/testdata/run/config/main.ts rename to tests/specs/run/config/config/main.ts diff --git a/tests/testdata/run/config/tsconfig.json b/tests/specs/run/config/config/tsconfig.json similarity index 100% rename from tests/testdata/run/config/tsconfig.json rename to tests/specs/run/config/config/tsconfig.json diff --git a/tests/specs/run/config_auto_discovered_for_local_script/__test__.jsonc b/tests/specs/run/config_auto_discovered_for_local_script/__test__.jsonc new file mode 100644 index 0000000000..bd2a77ab1a --- /dev/null +++ b/tests/specs/run/config_auto_discovered_for_local_script/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet frontend_work.ts", + "output": "ok\n" +} diff --git a/tests/testdata/run/with_config/frontend_work.ts b/tests/specs/run/config_auto_discovered_for_local_script/frontend_work.ts similarity index 100% rename from tests/testdata/run/with_config/frontend_work.ts rename to tests/specs/run/config_auto_discovered_for_local_script/frontend_work.ts diff --git a/tests/specs/run/config_auto_discovered_for_local_script_log/__test__.jsonc b/tests/specs/run/config_auto_discovered_for_local_script_log/__test__.jsonc new file mode 100644 index 0000000000..5182cc9589 --- /dev/null +++ b/tests/specs/run/config_auto_discovered_for_local_script_log/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run -L debug frontend_work.ts", + "output": "auto_discovery_log.out" +} diff --git a/tests/testdata/run/with_config/auto_discovery_log.out b/tests/specs/run/config_auto_discovered_for_local_script_log/auto_discovery_log.out similarity index 100% rename from tests/testdata/run/with_config/auto_discovery_log.out rename to tests/specs/run/config_auto_discovered_for_local_script_log/auto_discovery_log.out diff --git a/tests/testdata/run/with_config/deno.jsonc b/tests/specs/run/config_auto_discovered_for_local_script_log/deno.jsonc similarity index 100% rename from tests/testdata/run/with_config/deno.jsonc rename to tests/specs/run/config_auto_discovered_for_local_script_log/deno.jsonc diff --git a/tests/specs/run/config_auto_discovered_for_local_script_log/frontend_work.ts b/tests/specs/run/config_auto_discovered_for_local_script_log/frontend_work.ts new file mode 100644 index 0000000000..783af44e4c --- /dev/null +++ b/tests/specs/run/config_auto_discovered_for_local_script_log/frontend_work.ts @@ -0,0 +1,4 @@ +function _main() { + console.log(document); +} +console.log("ok"); diff --git a/tests/specs/run/config_json_import/__test__.jsonc b/tests/specs/run/config_json_import/__test__.jsonc new file mode 100644 index 0000000000..6ef632ff8d --- /dev/null +++ b/tests/specs/run/config_json_import/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet -c deno-jsx.json config_json_import.ts", + "output": "config_json_import.ts.out" +} diff --git a/tests/specs/run/config_json_import/config_json_import.ts b/tests/specs/run/config_json_import/config_json_import.ts new file mode 100644 index 0000000000..4a772fac3f --- /dev/null +++ b/tests/specs/run/config_json_import/config_json_import.ts @@ -0,0 +1,2 @@ +import config from "./deno-jsx.json" with { type: "json" }; +console.log(config); diff --git a/tests/testdata/run/config_json_import.ts.out b/tests/specs/run/config_json_import/config_json_import.ts.out similarity index 100% rename from tests/testdata/run/config_json_import.ts.out rename to tests/specs/run/config_json_import/config_json_import.ts.out diff --git a/tests/specs/run/config_json_import/deno-jsx.json b/tests/specs/run/config_json_import/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/config_json_import/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/config_not_auto_discovered_for_remote_script/__test__.jsonc b/tests/specs/run/config_not_auto_discovered_for_remote_script/__test__.jsonc new file mode 100644 index 0000000000..e6ccc02aca --- /dev/null +++ b/tests/specs/run/config_not_auto_discovered_for_remote_script/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --quiet server_side_work.ts", + "output": "ok\n" +} diff --git a/tests/testdata/run/with_config/server_side_work.ts b/tests/specs/run/config_not_auto_discovered_for_remote_script/server_side_work.ts similarity index 100% rename from tests/testdata/run/with_config/server_side_work.ts rename to tests/specs/run/config_not_auto_discovered_for_remote_script/server_side_work.ts diff --git a/tests/specs/run/config_types/__test__.jsonc b/tests/specs/run/config_types/__test__.jsonc new file mode 100644 index 0000000000..d803915c73 --- /dev/null +++ b/tests/specs/run/config_types/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --quiet --check=all --config config_types/tsconfig.json config_types/main.ts", + "output": "config_types/main.out" +} diff --git a/tests/specs/run/config_types/config_types/deno.lock b/tests/specs/run/config_types/config_types/deno.lock new file mode 100644 index 0000000000..157bd98a2e --- /dev/null +++ b/tests/specs/run/config_types/config_types/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/run/config_types/types.d.ts": "741c39165e37de0c12acc5c081841f4362487e3f17dc4cad7017b70af72c4605" + } +} diff --git a/tests/testdata/run/config_types/main.out b/tests/specs/run/config_types/config_types/main.out similarity index 100% rename from tests/testdata/run/config_types/main.out rename to tests/specs/run/config_types/config_types/main.out diff --git a/tests/testdata/run/config_types/main.ts b/tests/specs/run/config_types/config_types/main.ts similarity index 100% rename from tests/testdata/run/config_types/main.ts rename to tests/specs/run/config_types/config_types/main.ts diff --git a/tests/testdata/run/config_types/remote.tsconfig.json b/tests/specs/run/config_types/config_types/remote.tsconfig.json similarity index 100% rename from tests/testdata/run/config_types/remote.tsconfig.json rename to tests/specs/run/config_types/config_types/remote.tsconfig.json diff --git a/tests/testdata/run/config_types/tsconfig.json b/tests/specs/run/config_types/config_types/tsconfig.json similarity index 100% rename from tests/testdata/run/config_types/tsconfig.json rename to tests/specs/run/config_types/config_types/tsconfig.json diff --git a/tests/specs/run/config_types/config_types/types.d.ts b/tests/specs/run/config_types/config_types/types.d.ts new file mode 100644 index 0000000000..536a6d0a69 --- /dev/null +++ b/tests/specs/run/config_types/config_types/types.d.ts @@ -0,0 +1,2 @@ +// deno-lint-ignore-file no-var +declare var a: string; diff --git a/tests/specs/run/config_types_remote/__test__.jsonc b/tests/specs/run/config_types_remote/__test__.jsonc new file mode 100644 index 0000000000..87457ace21 --- /dev/null +++ b/tests/specs/run/config_types_remote/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --quiet --check=all --config config_types/remote.tsconfig.json config_types/main.ts", + "output": "config_types/main.out" +} diff --git a/tests/specs/run/config_types_remote/config_types/deno.lock b/tests/specs/run/config_types_remote/config_types/deno.lock new file mode 100644 index 0000000000..157bd98a2e --- /dev/null +++ b/tests/specs/run/config_types_remote/config_types/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/run/config_types/types.d.ts": "741c39165e37de0c12acc5c081841f4362487e3f17dc4cad7017b70af72c4605" + } +} diff --git a/tests/testdata/run/reference_types.ts.out b/tests/specs/run/config_types_remote/config_types/main.out similarity index 100% rename from tests/testdata/run/reference_types.ts.out rename to tests/specs/run/config_types_remote/config_types/main.out diff --git a/tests/specs/run/config_types_remote/config_types/main.ts b/tests/specs/run/config_types_remote/config_types/main.ts new file mode 100644 index 0000000000..f1a8d65831 --- /dev/null +++ b/tests/specs/run/config_types_remote/config_types/main.ts @@ -0,0 +1 @@ +console.log(globalThis.a); diff --git a/tests/specs/run/config_types_remote/config_types/remote.tsconfig.json b/tests/specs/run/config_types_remote/config_types/remote.tsconfig.json new file mode 100644 index 0000000000..255ff5def0 --- /dev/null +++ b/tests/specs/run/config_types_remote/config_types/remote.tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "types": [ + "http://localhost:4545/run/config_types/types.d.ts" + ] + } +} diff --git a/tests/specs/run/config_types_remote/config_types/tsconfig.json b/tests/specs/run/config_types_remote/config_types/tsconfig.json new file mode 100644 index 0000000000..85f1549e0d --- /dev/null +++ b/tests/specs/run/config_types_remote/config_types/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "types": [ + "./types.d.ts" + ] + } +} diff --git a/tests/specs/run/config_types_remote/config_types/types.d.ts b/tests/specs/run/config_types_remote/config_types/types.d.ts new file mode 100644 index 0000000000..536a6d0a69 --- /dev/null +++ b/tests/specs/run/config_types_remote/config_types/types.d.ts @@ -0,0 +1,2 @@ +// deno-lint-ignore-file no-var +declare var a: string; diff --git a/tests/specs/run/custom_inspect_url/__test__.jsonc b/tests/specs/run/custom_inspect_url/__test__.jsonc new file mode 100644 index 0000000000..1c1c2b9c47 --- /dev/null +++ b/tests/specs/run/custom_inspect_url/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run custom_inspect_url.js", + "output": "custom_inspect_url.js.out" +} diff --git a/tests/testdata/run/custom_inspect_url.js b/tests/specs/run/custom_inspect_url/custom_inspect_url.js similarity index 100% rename from tests/testdata/run/custom_inspect_url.js rename to tests/specs/run/custom_inspect_url/custom_inspect_url.js diff --git a/tests/testdata/run/custom_inspect_url.js.out b/tests/specs/run/custom_inspect_url/custom_inspect_url.js.out similarity index 100% rename from tests/testdata/run/custom_inspect_url.js.out rename to tests/specs/run/custom_inspect_url/custom_inspect_url.js.out diff --git a/tests/specs/run/decorators_tc39_proposal/__test__.jsonc b/tests/specs/run/decorators_tc39_proposal/__test__.jsonc new file mode 100644 index 0000000000..8e529695d9 --- /dev/null +++ b/tests/specs/run/decorators_tc39_proposal/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --check decorators/tc39_proposal/main.ts", + "output": "decorators/tc39_proposal/main.out" +} diff --git a/tests/testdata/run/decorators/experimental/deno.json b/tests/specs/run/decorators_tc39_proposal/decorators/experimental/deno.json similarity index 100% rename from tests/testdata/run/decorators/experimental/deno.json rename to tests/specs/run/decorators_tc39_proposal/decorators/experimental/deno.json diff --git a/tests/testdata/run/decorators/experimental/no_check/main.out b/tests/specs/run/decorators_tc39_proposal/decorators/experimental/no_check/main.out similarity index 100% rename from tests/testdata/run/decorators/experimental/no_check/main.out rename to tests/specs/run/decorators_tc39_proposal/decorators/experimental/no_check/main.out diff --git a/tests/testdata/run/decorators/experimental/no_check/main.ts b/tests/specs/run/decorators_tc39_proposal/decorators/experimental/no_check/main.ts similarity index 100% rename from tests/testdata/run/decorators/experimental/no_check/main.ts rename to tests/specs/run/decorators_tc39_proposal/decorators/experimental/no_check/main.ts diff --git a/tests/testdata/run/decorators/experimental/runtime/main.out b/tests/specs/run/decorators_tc39_proposal/decorators/experimental/runtime/main.out similarity index 100% rename from tests/testdata/run/decorators/experimental/runtime/main.out rename to tests/specs/run/decorators_tc39_proposal/decorators/experimental/runtime/main.out diff --git a/tests/testdata/run/decorators/experimental/runtime/main.ts b/tests/specs/run/decorators_tc39_proposal/decorators/experimental/runtime/main.ts similarity index 100% rename from tests/testdata/run/decorators/experimental/runtime/main.ts rename to tests/specs/run/decorators_tc39_proposal/decorators/experimental/runtime/main.ts diff --git a/tests/testdata/run/decorators/experimental/ts/main.out b/tests/specs/run/decorators_tc39_proposal/decorators/experimental/ts/main.out similarity index 100% rename from tests/testdata/run/decorators/experimental/ts/main.out rename to tests/specs/run/decorators_tc39_proposal/decorators/experimental/ts/main.out diff --git a/tests/testdata/run/decorators/experimental/ts/main.ts b/tests/specs/run/decorators_tc39_proposal/decorators/experimental/ts/main.ts similarity index 100% rename from tests/testdata/run/decorators/experimental/ts/main.ts rename to tests/specs/run/decorators_tc39_proposal/decorators/experimental/ts/main.ts diff --git a/tests/testdata/run/decorators/tc39_proposal/main.out b/tests/specs/run/decorators_tc39_proposal/decorators/tc39_proposal/main.out similarity index 100% rename from tests/testdata/run/decorators/tc39_proposal/main.out rename to tests/specs/run/decorators_tc39_proposal/decorators/tc39_proposal/main.out diff --git a/tests/testdata/run/decorators/tc39_proposal/main.ts b/tests/specs/run/decorators_tc39_proposal/decorators/tc39_proposal/main.ts similarity index 100% rename from tests/testdata/run/decorators/tc39_proposal/main.ts rename to tests/specs/run/decorators_tc39_proposal/decorators/tc39_proposal/main.ts diff --git a/tests/specs/run/deno_exit_tampering/__test__.jsonc b/tests/specs/run/deno_exit_tampering/__test__.jsonc new file mode 100644 index 0000000000..1666fbacb3 --- /dev/null +++ b/tests/specs/run/deno_exit_tampering/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --no-check deno_exit_tampering.ts", + "output": "", + "exitCode": 42 +} diff --git a/tests/testdata/run/deno_exit_tampering.ts b/tests/specs/run/deno_exit_tampering/deno_exit_tampering.ts similarity index 100% rename from tests/testdata/run/deno_exit_tampering.ts rename to tests/specs/run/deno_exit_tampering/deno_exit_tampering.ts diff --git a/tests/specs/run/deny_all_permission_args/__test__.jsonc b/tests/specs/run/deny_all_permission_args/__test__.jsonc new file mode 100644 index 0000000000..1d6b286822 --- /dev/null +++ b/tests/specs/run/deny_all_permission_args/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --deny-env --deny-read --deny-write --deny-ffi --deny-run --deny-sys --deny-net deny_all_permission_args.js", + "output": "deny_all_permission_args.out" +} diff --git a/tests/testdata/run/deny_all_permission_args.js b/tests/specs/run/deny_all_permission_args/deny_all_permission_args.js similarity index 100% rename from tests/testdata/run/deny_all_permission_args.js rename to tests/specs/run/deny_all_permission_args/deny_all_permission_args.js diff --git a/tests/testdata/run/deny_all_permission_args.out b/tests/specs/run/deny_all_permission_args/deny_all_permission_args.out similarity index 100% rename from tests/testdata/run/deny_all_permission_args.out rename to tests/specs/run/deny_all_permission_args/deny_all_permission_args.out diff --git a/tests/specs/run/deny_some_permission_args/__test__.jsonc b/tests/specs/run/deny_some_permission_args/__test__.jsonc new file mode 100644 index 0000000000..a55ee57e48 --- /dev/null +++ b/tests/specs/run/deny_some_permission_args/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-env --deny-env=FOO --allow-read --deny-read=/foo --allow-write --deny-write=/foo --allow-ffi --deny-ffi=/foo --allow-run --deny-run=foo --allow-sys --deny-sys=hostname --allow-net --deny-net=127.0.0.1 deny_some_permission_args.js", + "output": "deny_some_permission_args.out" +} diff --git a/tests/testdata/run/deny_some_permission_args.js b/tests/specs/run/deny_some_permission_args/deny_some_permission_args.js similarity index 100% rename from tests/testdata/run/deny_some_permission_args.js rename to tests/specs/run/deny_some_permission_args/deny_some_permission_args.js diff --git a/tests/testdata/run/deny_some_permission_args.out b/tests/specs/run/deny_some_permission_args/deny_some_permission_args.out similarity index 100% rename from tests/testdata/run/deny_some_permission_args.out rename to tests/specs/run/deny_some_permission_args/deny_some_permission_args.out diff --git a/tests/specs/run/dom_exception_formatting/__test__.jsonc b/tests/specs/run/dom_exception_formatting/__test__.jsonc new file mode 100644 index 0000000000..5b1505b57b --- /dev/null +++ b/tests/specs/run/dom_exception_formatting/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run dom_exception_formatting.ts", + "output": "dom_exception_formatting.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/dom_exception_formatting.ts b/tests/specs/run/dom_exception_formatting/dom_exception_formatting.ts similarity index 100% rename from tests/testdata/run/dom_exception_formatting.ts rename to tests/specs/run/dom_exception_formatting/dom_exception_formatting.ts diff --git a/tests/testdata/run/dom_exception_formatting.ts.out b/tests/specs/run/dom_exception_formatting/dom_exception_formatting.ts.out similarity index 100% rename from tests/testdata/run/dom_exception_formatting.ts.out rename to tests/specs/run/dom_exception_formatting/dom_exception_formatting.ts.out diff --git a/tests/specs/run/dynamic_import_already_rejected/__test__.jsonc b/tests/specs/run/dynamic_import_already_rejected/__test__.jsonc new file mode 100644 index 0000000000..0cd1201309 --- /dev/null +++ b/tests/specs/run/dynamic_import_already_rejected/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read dynamic_import_already_rejected/main.ts", + "output": "dynamic_import_already_rejected/main.out" +} diff --git a/tests/testdata/run/dynamic_import_already_rejected/error_001.ts b/tests/specs/run/dynamic_import_already_rejected/dynamic_import_already_rejected/error_001.ts similarity index 100% rename from tests/testdata/run/dynamic_import_already_rejected/error_001.ts rename to tests/specs/run/dynamic_import_already_rejected/dynamic_import_already_rejected/error_001.ts diff --git a/tests/testdata/run/dynamic_import_already_rejected/main.out b/tests/specs/run/dynamic_import_already_rejected/dynamic_import_already_rejected/main.out similarity index 100% rename from tests/testdata/run/dynamic_import_already_rejected/main.out rename to tests/specs/run/dynamic_import_already_rejected/dynamic_import_already_rejected/main.out diff --git a/tests/testdata/run/dynamic_import_already_rejected/main.ts b/tests/specs/run/dynamic_import_already_rejected/dynamic_import_already_rejected/main.ts similarity index 100% rename from tests/testdata/run/dynamic_import_already_rejected/main.ts rename to tests/specs/run/dynamic_import_already_rejected/dynamic_import_already_rejected/main.ts diff --git a/tests/specs/run/dynamic_import_async_error/__test__.jsonc b/tests/specs/run/dynamic_import_async_error/__test__.jsonc new file mode 100644 index 0000000000..9824c34508 --- /dev/null +++ b/tests/specs/run/dynamic_import_async_error/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read dynamic_import_async_error/main.ts", + "output": "dynamic_import_async_error/main.out" +} diff --git a/tests/testdata/run/dynamic_import_async_error/delayed_error.ts b/tests/specs/run/dynamic_import_async_error/dynamic_import_async_error/delayed_error.ts similarity index 100% rename from tests/testdata/run/dynamic_import_async_error/delayed_error.ts rename to tests/specs/run/dynamic_import_async_error/dynamic_import_async_error/delayed_error.ts diff --git a/tests/testdata/run/dynamic_import_async_error/main.out b/tests/specs/run/dynamic_import_async_error/dynamic_import_async_error/main.out similarity index 100% rename from tests/testdata/run/dynamic_import_async_error/main.out rename to tests/specs/run/dynamic_import_async_error/dynamic_import_async_error/main.out diff --git a/tests/testdata/run/dynamic_import_async_error/main.ts b/tests/specs/run/dynamic_import_async_error/dynamic_import_async_error/main.ts similarity index 100% rename from tests/testdata/run/dynamic_import_async_error/main.ts rename to tests/specs/run/dynamic_import_async_error/dynamic_import_async_error/main.ts diff --git a/tests/specs/run/dynamic_import_concurrent_non_statically_analyzable/__test__.jsonc b/tests/specs/run/dynamic_import_concurrent_non_statically_analyzable/__test__.jsonc new file mode 100644 index 0000000000..c4c30ca5d4 --- /dev/null +++ b/tests/specs/run/dynamic_import_concurrent_non_statically_analyzable/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --allow-read --allow-net --quiet dynamic_import_concurrent_non_statically_analyzable/main.ts", + "output": "dynamic_import_concurrent_non_statically_analyzable/main.out" +} diff --git a/tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/main.out b/tests/specs/run/dynamic_import_concurrent_non_statically_analyzable/dynamic_import_concurrent_non_statically_analyzable/main.out similarity index 100% rename from tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/main.out rename to tests/specs/run/dynamic_import_concurrent_non_statically_analyzable/dynamic_import_concurrent_non_statically_analyzable/main.out diff --git a/tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/main.ts b/tests/specs/run/dynamic_import_concurrent_non_statically_analyzable/dynamic_import_concurrent_non_statically_analyzable/main.ts similarity index 100% rename from tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/main.ts rename to tests/specs/run/dynamic_import_concurrent_non_statically_analyzable/dynamic_import_concurrent_non_statically_analyzable/main.ts diff --git a/tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/mod.ts b/tests/specs/run/dynamic_import_concurrent_non_statically_analyzable/dynamic_import_concurrent_non_statically_analyzable/mod.ts similarity index 100% rename from tests/testdata/run/dynamic_import_concurrent_non_statically_analyzable/mod.ts rename to tests/specs/run/dynamic_import_concurrent_non_statically_analyzable/dynamic_import_concurrent_non_statically_analyzable/mod.ts diff --git a/tests/specs/run/dynamic_import_conditional/__test__.jsonc b/tests/specs/run/dynamic_import_conditional/__test__.jsonc new file mode 100644 index 0000000000..8adff3a16d --- /dev/null +++ b/tests/specs/run/dynamic_import_conditional/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload dynamic_import_conditional.js", + "output": "dynamic_import_conditional.js.out" +} diff --git a/tests/testdata/run/dynamic_import_conditional.js b/tests/specs/run/dynamic_import_conditional/dynamic_import_conditional.js similarity index 100% rename from tests/testdata/run/dynamic_import_conditional.js rename to tests/specs/run/dynamic_import_conditional/dynamic_import_conditional.js diff --git a/tests/testdata/run/dynamic_import_conditional.js.out b/tests/specs/run/dynamic_import_conditional/dynamic_import_conditional.js.out similarity index 100% rename from tests/testdata/run/dynamic_import_conditional.js.out rename to tests/specs/run/dynamic_import_conditional/dynamic_import_conditional.js.out diff --git a/tests/specs/run/dynamic_import_permissions_blob_local/__test__.jsonc b/tests/specs/run/dynamic_import_permissions_blob_local/__test__.jsonc new file mode 100644 index 0000000000..27a747b3a5 --- /dev/null +++ b/tests/specs/run/dynamic_import_permissions_blob_local/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --reload --allow-net=localhost:4545 permissions_blob_local.ts", + "output": "permissions_blob_local.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/run/dynamic_import_permissions_blob_local/permissions_blob_local.ts b/tests/specs/run/dynamic_import_permissions_blob_local/permissions_blob_local.ts new file mode 100644 index 0000000000..865c1777a9 --- /dev/null +++ b/tests/specs/run/dynamic_import_permissions_blob_local/permissions_blob_local.ts @@ -0,0 +1,6 @@ +// This file doesn't really exist, but it doesn't matter, a "NotCapable" error should be thrown. +const code = `import "file:///${ + Deno.build.os == "windows" ? "C:/" : "" +}local_file.ts";`; +const blob = new Blob([code]); +await import(URL.createObjectURL(blob)); diff --git a/tests/specs/run/dynamic_import_permissions_blob_local/permissions_blob_local.ts.out b/tests/specs/run/dynamic_import_permissions_blob_local/permissions_blob_local.ts.out new file mode 100644 index 0000000000..b7b246ba2b --- /dev/null +++ b/tests/specs/run/dynamic_import_permissions_blob_local/permissions_blob_local.ts.out @@ -0,0 +1,5 @@ +error: Uncaught (in promise) TypeError: Requires read access to "[WILDCARD]local_file.ts", run again with the --allow-read flag + at blob:null/[WILDCARD]:1:8 +await import(URL.createObjectURL(blob)); +^ + at async file://[WILDCARD]/permissions_blob_local.ts:6:1 diff --git a/tests/specs/run/dynamic_import_permissions_blob_remote/__test__.jsonc b/tests/specs/run/dynamic_import_permissions_blob_remote/__test__.jsonc new file mode 100644 index 0000000000..f9d66b6b38 --- /dev/null +++ b/tests/specs/run/dynamic_import_permissions_blob_remote/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --reload --allow-net=localhost:4545 permissions_blob_remote.ts", + "output": "permissions_blob_remote.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/run/dynamic_import_permissions_blob_remote/permissions_blob_remote.ts b/tests/specs/run/dynamic_import_permissions_blob_remote/permissions_blob_remote.ts new file mode 100644 index 0000000000..569b1f84c5 --- /dev/null +++ b/tests/specs/run/dynamic_import_permissions_blob_remote/permissions_blob_remote.ts @@ -0,0 +1,3 @@ +const code = `import "https://example.com/some/file.ts";`; +const blob = new Blob([code]); +await import(URL.createObjectURL(blob)); diff --git a/tests/specs/run/dynamic_import_permissions_blob_remote/permissions_blob_remote.ts.out b/tests/specs/run/dynamic_import_permissions_blob_remote/permissions_blob_remote.ts.out new file mode 100644 index 0000000000..287cf99985 --- /dev/null +++ b/tests/specs/run/dynamic_import_permissions_blob_remote/permissions_blob_remote.ts.out @@ -0,0 +1,5 @@ +error: Uncaught (in promise) TypeError: Requires import access to "example.com:443", run again with the --allow-import flag + at blob:null/[WILDCARD]:1:8 +await import(URL.createObjectURL(blob)); +^ + at async file:///[WILDCARD]/permissions_blob_remote.ts:3:1 diff --git a/tests/specs/run/dynamic_import_permissions_data_local/__test__.jsonc b/tests/specs/run/dynamic_import_permissions_data_local/__test__.jsonc new file mode 100644 index 0000000000..8f118d8be3 --- /dev/null +++ b/tests/specs/run/dynamic_import_permissions_data_local/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --reload --allow-net=localhost:4545 permissions_data_local.ts", + "output": "permissions_data_local.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/run/dynamic_import_permissions_data_local/permissions_data_local.ts b/tests/specs/run/dynamic_import_permissions_data_local/permissions_data_local.ts new file mode 100644 index 0000000000..01bff7d7a2 --- /dev/null +++ b/tests/specs/run/dynamic_import_permissions_data_local/permissions_data_local.ts @@ -0,0 +1,5 @@ +// This file doesn't really exist, but it doesn't matter, a "NotCapable" error should be thrown. +const code = `import "file:///${ + Deno.build.os == "windows" ? "C:/" : "" +}local_file.ts";`; +await import(`data:application/javascript;base64,${btoa(code)}`); diff --git a/tests/specs/run/dynamic_import_permissions_data_local/permissions_data_local.ts.out b/tests/specs/run/dynamic_import_permissions_data_local/permissions_data_local.ts.out new file mode 100644 index 0000000000..bf8c1948e6 --- /dev/null +++ b/tests/specs/run/dynamic_import_permissions_data_local/permissions_data_local.ts.out @@ -0,0 +1,5 @@ +error: Uncaught (in promise) TypeError: Requires read access to "[WILDCARD]local_file.ts", run again with the --allow-read flag + at data:application/javascript;base64,[WILDCARD]:1:8 +await import(`data:application/javascript;base64,${btoa(code)}`); +^ + at async file:///[WILDCARD]/permissions_data_local.ts:5:1 diff --git a/tests/specs/run/dynamic_import_permissions_data_remote/__test__.jsonc b/tests/specs/run/dynamic_import_permissions_data_remote/__test__.jsonc new file mode 100644 index 0000000000..5b2c0c568f --- /dev/null +++ b/tests/specs/run/dynamic_import_permissions_data_remote/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --reload --allow-import=localhost:4545 permissions_data_remote.ts", + "output": "permissions_data_remote.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/run/dynamic_import_permissions_data_remote/permissions_data_remote.ts b/tests/specs/run/dynamic_import_permissions_data_remote/permissions_data_remote.ts new file mode 100644 index 0000000000..b0a9540c32 --- /dev/null +++ b/tests/specs/run/dynamic_import_permissions_data_remote/permissions_data_remote.ts @@ -0,0 +1,3 @@ +// This file doesn't really exist, but it doesn't matter, a "PermissionsDenied" error should be thrown. +const code = `import "https://example.com/some/file.ts";`; +await import(`data:application/javascript;base64,${btoa(code)}`); diff --git a/tests/specs/run/dynamic_import_permissions_data_remote/permissions_data_remote.ts.out b/tests/specs/run/dynamic_import_permissions_data_remote/permissions_data_remote.ts.out new file mode 100644 index 0000000000..c8de9382a5 --- /dev/null +++ b/tests/specs/run/dynamic_import_permissions_data_remote/permissions_data_remote.ts.out @@ -0,0 +1,5 @@ +error: Uncaught (in promise) TypeError: Requires import access to "example.com:443", run again with the --allow-import flag + at data:application/javascript;base64,aW1wb3J0ICJodHRwczovL2V4YW1wbGUuY29tL3NvbWUvZmlsZS50cyI7:1:8 +await import(`data:application/javascript;base64,${btoa(code)}`); +^ + at async file:///[WILDCARD]/permissions_data_remote.ts:3:1 diff --git a/tests/specs/run/dynamic_import_permissions_remote_remote/__test__.jsonc b/tests/specs/run/dynamic_import_permissions_remote_remote/__test__.jsonc new file mode 100644 index 0000000000..00fd2a6e4c --- /dev/null +++ b/tests/specs/run/dynamic_import_permissions_remote_remote/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --reload --allow-import=localhost:4545 permissions_remote_remote.ts", + "output": "permissions_remote_remote.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/run/dynamic_import_permissions_remote_remote/permissions_remote_remote.ts b/tests/specs/run/dynamic_import_permissions_remote_remote/permissions_remote_remote.ts new file mode 100644 index 0000000000..65a2541910 --- /dev/null +++ b/tests/specs/run/dynamic_import_permissions_remote_remote/permissions_remote_remote.ts @@ -0,0 +1,3 @@ +await import( + "" + "http://localhost:4545/dynamic_import/static_remote.ts" +); diff --git a/tests/specs/run/dynamic_import_permissions_remote_remote/permissions_remote_remote.ts.out b/tests/specs/run/dynamic_import_permissions_remote_remote/permissions_remote_remote.ts.out new file mode 100644 index 0000000000..16fe3bbdd6 --- /dev/null +++ b/tests/specs/run/dynamic_import_permissions_remote_remote/permissions_remote_remote.ts.out @@ -0,0 +1,5 @@ +error: Uncaught (in promise) TypeError: Requires import access to "example.com:443", run again with the --allow-import flag + at http://localhost:4545/dynamic_import/static_remote.ts:2:8 +await import( +^ + at async file:///[WILDCARD]/permissions_remote_remote.ts:1:1 diff --git a/tests/specs/run/dynamic_import_permissions_remote_remote/static_remote.ts b/tests/specs/run/dynamic_import_permissions_remote_remote/static_remote.ts new file mode 100644 index 0000000000..2d6e820fd6 --- /dev/null +++ b/tests/specs/run/dynamic_import_permissions_remote_remote/static_remote.ts @@ -0,0 +1,2 @@ +// This file doesn't really exist, but it doesn't matter, a "PermissionsDenied" error should be thrown. +import "https://example.com/some/file.ts"; diff --git a/tests/specs/run/dynamic_import_static_analysis_no_permissions/__test__.jsonc b/tests/specs/run/dynamic_import_static_analysis_no_permissions/__test__.jsonc new file mode 100644 index 0000000000..9379748691 --- /dev/null +++ b/tests/specs/run/dynamic_import_static_analysis_no_permissions/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --no-prompt static_analysis_no_permissions.ts", + "output": "static_analysis_no_permissions.ts.out" +} diff --git a/tests/testdata/run/empty.ts b/tests/specs/run/dynamic_import_static_analysis_no_permissions/empty_1.ts similarity index 100% rename from tests/testdata/run/empty.ts rename to tests/specs/run/dynamic_import_static_analysis_no_permissions/empty_1.ts diff --git a/tests/testdata/run/wasm_shared.out b/tests/specs/run/dynamic_import_static_analysis_no_permissions/empty_2.ts similarity index 100% rename from tests/testdata/run/wasm_shared.out rename to tests/specs/run/dynamic_import_static_analysis_no_permissions/empty_2.ts diff --git a/tests/specs/run/dynamic_import_static_analysis_no_permissions/static_analysis_no_permissions.ts b/tests/specs/run/dynamic_import_static_analysis_no_permissions/static_analysis_no_permissions.ts new file mode 100644 index 0000000000..de75ba87b6 --- /dev/null +++ b/tests/specs/run/dynamic_import_static_analysis_no_permissions/static_analysis_no_permissions.ts @@ -0,0 +1,13 @@ +try { + await import("./empty_1.ts"); + console.log("✅ Succeeded importing statically analyzable specifier"); +} catch { + console.log("❌ Failed importing statically analyzable specifier"); +} + +try { + await import("" + "./empty_2.ts"); + console.log("❌ Succeeded importing non-statically analyzable specifier"); +} catch { + console.log("✅ Failed importing non-statically analyzable specifier"); +} diff --git a/tests/specs/run/dynamic_import_static_analysis_no_permissions/static_analysis_no_permissions.ts.out b/tests/specs/run/dynamic_import_static_analysis_no_permissions/static_analysis_no_permissions.ts.out new file mode 100644 index 0000000000..ba9249ab0b --- /dev/null +++ b/tests/specs/run/dynamic_import_static_analysis_no_permissions/static_analysis_no_permissions.ts.out @@ -0,0 +1,2 @@ +✅ Succeeded importing statically analyzable specifier +✅ Failed importing non-statically analyzable specifier diff --git a/tests/specs/run/dynamic_import_syntax_error/__test__.jsonc b/tests/specs/run/dynamic_import_syntax_error/__test__.jsonc new file mode 100644 index 0000000000..1971d3184c --- /dev/null +++ b/tests/specs/run/dynamic_import_syntax_error/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run -A dynamic_import_syntax_error.js", + "output": "dynamic_import_syntax_error.js.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/dynamic_import_syntax_error.js b/tests/specs/run/dynamic_import_syntax_error/dynamic_import_syntax_error.js similarity index 100% rename from tests/testdata/run/dynamic_import_syntax_error.js rename to tests/specs/run/dynamic_import_syntax_error/dynamic_import_syntax_error.js diff --git a/tests/testdata/run/dynamic_import_syntax_error.js.out b/tests/specs/run/dynamic_import_syntax_error/dynamic_import_syntax_error.js.out similarity index 100% rename from tests/testdata/run/dynamic_import_syntax_error.js.out rename to tests/specs/run/dynamic_import_syntax_error/dynamic_import_syntax_error.js.out diff --git a/tests/specs/run/dynamic_import_syntax_error/dynamic_import_syntax_error_import.js b/tests/specs/run/dynamic_import_syntax_error/dynamic_import_syntax_error_import.js new file mode 100644 index 0000000000..bcf0756385 --- /dev/null +++ b/tests/specs/run/dynamic_import_syntax_error/dynamic_import_syntax_error_import.js @@ -0,0 +1,5 @@ +// deno-lint-ignore-file +function foo() { + await Promise.resolve(); +} +foo(); diff --git a/tests/specs/run/empty_typescript/__test__.jsonc b/tests/specs/run/empty_typescript/__test__.jsonc new file mode 100644 index 0000000000..8090c50f68 --- /dev/null +++ b/tests/specs/run/empty_typescript/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --check empty.ts", + "output": "Check file:[WILDCARD]/empty.ts\n" +} diff --git a/tests/testdata/run/worker_close_race.js.out b/tests/specs/run/empty_typescript/empty.ts similarity index 100% rename from tests/testdata/run/worker_close_race.js.out rename to tests/specs/run/empty_typescript/empty.ts diff --git a/tests/specs/run/error_001/__test__.jsonc b/tests/specs/run/error_001/__test__.jsonc new file mode 100644 index 0000000000..7b9158e4f5 --- /dev/null +++ b/tests/specs/run/error_001/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload error_001.ts", + "output": "error_001.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/run/error_001/error_001.ts b/tests/specs/run/error_001/error_001.ts new file mode 100644 index 0000000000..b01068bc01 --- /dev/null +++ b/tests/specs/run/error_001/error_001.ts @@ -0,0 +1,9 @@ +function foo(): never { + throw Error("bad"); +} + +function bar() { + foo(); +} + +bar(); diff --git a/tests/testdata/run/error_001.ts.out b/tests/specs/run/error_001/error_001.ts.out similarity index 100% rename from tests/testdata/run/error_001.ts.out rename to tests/specs/run/error_001/error_001.ts.out diff --git a/tests/specs/run/error_002/__test__.jsonc b/tests/specs/run/error_002/__test__.jsonc new file mode 100644 index 0000000000..3a68a86751 --- /dev/null +++ b/tests/specs/run/error_002/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload error_002.ts", + "output": "error_002.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/run/error_002/error_002.ts b/tests/specs/run/error_002/error_002.ts new file mode 100644 index 0000000000..ac712fbf71 --- /dev/null +++ b/tests/specs/run/error_002/error_002.ts @@ -0,0 +1,7 @@ +import { throwsError } from "./mod1.ts"; + +function foo() { + throwsError(); +} + +foo(); diff --git a/tests/testdata/run/error_002.ts.out b/tests/specs/run/error_002/error_002.ts.out similarity index 78% rename from tests/testdata/run/error_002.ts.out rename to tests/specs/run/error_002/error_002.ts.out index 9fec5d968a..1051e7360c 100644 --- a/tests/testdata/run/error_002.ts.out +++ b/tests/specs/run/error_002/error_002.ts.out @@ -1,6 +1,6 @@ [WILDCARD]error: Uncaught (in promise) Error: exception from mod1 throw Error("exception from mod1"); ^ - at throwsError ([WILDCARD]/subdir/mod1.ts:16:9) + at throwsError ([WILDCARD]/mod1.ts:16:9) at foo ([WILDCARD]/error_002.ts:4:3) at [WILDCARD]/error_002.ts:7:1 diff --git a/tests/specs/run/error_002/mod1.ts b/tests/specs/run/error_002/mod1.ts new file mode 100644 index 0000000000..5e58f432ed --- /dev/null +++ b/tests/specs/run/error_002/mod1.ts @@ -0,0 +1,17 @@ +import { printHello2, returnsFoo } from "./subdir2/mod2.ts"; + +export function returnsHi(): string { + return "Hi"; +} + +export function returnsFoo2(): string { + return returnsFoo(); +} + +export function printHello3() { + printHello2(); +} + +export function throwsError() { + throw Error("exception from mod1"); +} diff --git a/tests/specs/run/error_002/print_hello.ts b/tests/specs/run/error_002/print_hello.ts new file mode 100644 index 0000000000..b9c0ad5275 --- /dev/null +++ b/tests/specs/run/error_002/print_hello.ts @@ -0,0 +1,3 @@ +export function printHello() { + console.log("Hello"); +} diff --git a/tests/specs/run/error_002/subdir2/mod2.ts b/tests/specs/run/error_002/subdir2/mod2.ts new file mode 100644 index 0000000000..9071d0aeb4 --- /dev/null +++ b/tests/specs/run/error_002/subdir2/mod2.ts @@ -0,0 +1,9 @@ +import { printHello } from "../print_hello.ts"; + +export function returnsFoo(): string { + return "Foo"; +} + +export function printHello2() { + printHello(); +} diff --git a/tests/specs/run/error_003_typescript/__test__.jsonc b/tests/specs/run/error_003_typescript/__test__.jsonc new file mode 100644 index 0000000000..f7ef69b268 --- /dev/null +++ b/tests/specs/run/error_003_typescript/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload --check error_003_typescript.ts", + "output": "error_003_typescript.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_003_typescript.ts b/tests/specs/run/error_003_typescript/error_003_typescript.ts similarity index 100% rename from tests/testdata/run/error_003_typescript.ts rename to tests/specs/run/error_003_typescript/error_003_typescript.ts diff --git a/tests/testdata/run/error_003_typescript.ts.out b/tests/specs/run/error_003_typescript/error_003_typescript.ts.out similarity index 100% rename from tests/testdata/run/error_003_typescript.ts.out rename to tests/specs/run/error_003_typescript/error_003_typescript.ts.out diff --git a/tests/specs/run/error_003_typescript2/__test__.jsonc b/tests/specs/run/error_003_typescript2/__test__.jsonc new file mode 100644 index 0000000000..ceeb6e7d94 --- /dev/null +++ b/tests/specs/run/error_003_typescript2/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --check error_003_typescript.ts", + "output": "error_003_typescript.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/run/error_003_typescript2/error_003_typescript.ts b/tests/specs/run/error_003_typescript2/error_003_typescript.ts new file mode 100644 index 0000000000..e1f882123c --- /dev/null +++ b/tests/specs/run/error_003_typescript2/error_003_typescript.ts @@ -0,0 +1,20 @@ +// deno-lint-ignore-file +let x = { + a: { + b: { + c() { + return { d: "hello" }; + }, + }, + }, +}; +let y = { + a: { + b: { + c() { + return { d: 1234 }; + }, + }, + }, +}; +x = y; diff --git a/tests/specs/run/error_003_typescript2/error_003_typescript.ts.out b/tests/specs/run/error_003_typescript2/error_003_typescript.ts.out new file mode 100644 index 0000000000..bbb2ec4708 --- /dev/null +++ b/tests/specs/run/error_003_typescript2/error_003_typescript.ts.out @@ -0,0 +1,7 @@ +[WILDCARD] +error: TS2322 [ERROR]: Type '{ a: { b: { c(): { d: number; }; }; }; }' is not assignable to type '{ a: { b: { c(): { d: string; }; }; }; }'. + The types of 'a.b.c().d' are incompatible between these types. + Type 'number' is not assignable to type 'string'. +x = y; +^ + at [WILDCARD]/error_003_typescript.ts:20:1 diff --git a/tests/specs/run/error_004_missing_module/__test__.jsonc b/tests/specs/run/error_004_missing_module/__test__.jsonc new file mode 100644 index 0000000000..824b9d8c9c --- /dev/null +++ b/tests/specs/run/error_004_missing_module/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload error_004_missing_module.ts", + "output": "error_004_missing_module.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_004_missing_module.ts b/tests/specs/run/error_004_missing_module/error_004_missing_module.ts similarity index 100% rename from tests/testdata/run/error_004_missing_module.ts rename to tests/specs/run/error_004_missing_module/error_004_missing_module.ts diff --git a/tests/testdata/run/error_004_missing_module.ts.out b/tests/specs/run/error_004_missing_module/error_004_missing_module.ts.out similarity index 100% rename from tests/testdata/run/error_004_missing_module.ts.out rename to tests/specs/run/error_004_missing_module/error_004_missing_module.ts.out diff --git a/tests/specs/run/error_005_missing_dynamic_import/__test__.jsonc b/tests/specs/run/error_005_missing_dynamic_import/__test__.jsonc new file mode 100644 index 0000000000..b9f6a1b747 --- /dev/null +++ b/tests/specs/run/error_005_missing_dynamic_import/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload --allow-read --quiet error_005_missing_dynamic_import.ts", + "output": "error_005_missing_dynamic_import.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_005_missing_dynamic_import.ts b/tests/specs/run/error_005_missing_dynamic_import/error_005_missing_dynamic_import.ts similarity index 100% rename from tests/testdata/run/error_005_missing_dynamic_import.ts rename to tests/specs/run/error_005_missing_dynamic_import/error_005_missing_dynamic_import.ts diff --git a/tests/testdata/run/error_005_missing_dynamic_import.ts.out b/tests/specs/run/error_005_missing_dynamic_import/error_005_missing_dynamic_import.ts.out similarity index 100% rename from tests/testdata/run/error_005_missing_dynamic_import.ts.out rename to tests/specs/run/error_005_missing_dynamic_import/error_005_missing_dynamic_import.ts.out diff --git a/tests/specs/run/error_006_import_ext_failure/__test__.jsonc b/tests/specs/run/error_006_import_ext_failure/__test__.jsonc new file mode 100644 index 0000000000..0e70bdcaf6 --- /dev/null +++ b/tests/specs/run/error_006_import_ext_failure/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload error_006_import_ext_failure.ts", + "output": "error_006_import_ext_failure.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_006_import_ext_failure.ts b/tests/specs/run/error_006_import_ext_failure/error_006_import_ext_failure.ts similarity index 100% rename from tests/testdata/run/error_006_import_ext_failure.ts rename to tests/specs/run/error_006_import_ext_failure/error_006_import_ext_failure.ts diff --git a/tests/testdata/run/error_006_import_ext_failure.ts.out b/tests/specs/run/error_006_import_ext_failure/error_006_import_ext_failure.ts.out similarity index 100% rename from tests/testdata/run/error_006_import_ext_failure.ts.out rename to tests/specs/run/error_006_import_ext_failure/error_006_import_ext_failure.ts.out diff --git a/tests/specs/run/error_007_any/__test__.jsonc b/tests/specs/run/error_007_any/__test__.jsonc new file mode 100644 index 0000000000..8a1c0d27e6 --- /dev/null +++ b/tests/specs/run/error_007_any/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload error_007_any.ts", + "output": "error_007_any.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_007_any.ts b/tests/specs/run/error_007_any/error_007_any.ts similarity index 100% rename from tests/testdata/run/error_007_any.ts rename to tests/specs/run/error_007_any/error_007_any.ts diff --git a/tests/testdata/run/error_007_any.ts.out b/tests/specs/run/error_007_any/error_007_any.ts.out similarity index 100% rename from tests/testdata/run/error_007_any.ts.out rename to tests/specs/run/error_007_any/error_007_any.ts.out diff --git a/tests/specs/run/error_008_checkjs/__test__.jsonc b/tests/specs/run/error_008_checkjs/__test__.jsonc new file mode 100644 index 0000000000..f735be953c --- /dev/null +++ b/tests/specs/run/error_008_checkjs/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload error_008_checkjs.js", + "output": "error_008_checkjs.js.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_008_checkjs.js b/tests/specs/run/error_008_checkjs/error_008_checkjs.js similarity index 100% rename from tests/testdata/run/error_008_checkjs.js rename to tests/specs/run/error_008_checkjs/error_008_checkjs.js diff --git a/tests/testdata/run/error_008_checkjs.js.out b/tests/specs/run/error_008_checkjs/error_008_checkjs.js.out similarity index 100% rename from tests/testdata/run/error_008_checkjs.js.out rename to tests/specs/run/error_008_checkjs/error_008_checkjs.js.out diff --git a/tests/specs/run/error_009_extensions_error/__test__.jsonc b/tests/specs/run/error_009_extensions_error/__test__.jsonc new file mode 100644 index 0000000000..740d5119f5 --- /dev/null +++ b/tests/specs/run/error_009_extensions_error/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run error_009_extensions_error.js", + "output": "error_009_extensions_error.js.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_009_extensions_error.js b/tests/specs/run/error_009_extensions_error/error_009_extensions_error.js similarity index 100% rename from tests/testdata/run/error_009_extensions_error.js rename to tests/specs/run/error_009_extensions_error/error_009_extensions_error.js diff --git a/tests/testdata/run/error_009_extensions_error.js.out b/tests/specs/run/error_009_extensions_error/error_009_extensions_error.js.out similarity index 100% rename from tests/testdata/run/error_009_extensions_error.js.out rename to tests/specs/run/error_009_extensions_error/error_009_extensions_error.js.out diff --git a/tests/specs/run/error_011_bad_module_specifier/__test__.jsonc b/tests/specs/run/error_011_bad_module_specifier/__test__.jsonc new file mode 100644 index 0000000000..5ca5146bec --- /dev/null +++ b/tests/specs/run/error_011_bad_module_specifier/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload error_011_bad_module_specifier.ts", + "output": "error_011_bad_module_specifier.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_011_bad_module_specifier.ts b/tests/specs/run/error_011_bad_module_specifier/error_011_bad_module_specifier.ts similarity index 100% rename from tests/testdata/run/error_011_bad_module_specifier.ts rename to tests/specs/run/error_011_bad_module_specifier/error_011_bad_module_specifier.ts diff --git a/tests/testdata/run/error_011_bad_module_specifier.ts.out b/tests/specs/run/error_011_bad_module_specifier/error_011_bad_module_specifier.ts.out similarity index 100% rename from tests/testdata/run/error_011_bad_module_specifier.ts.out rename to tests/specs/run/error_011_bad_module_specifier/error_011_bad_module_specifier.ts.out diff --git a/tests/specs/run/error_012_bad_dynamic_import_specifier/__test__.jsonc b/tests/specs/run/error_012_bad_dynamic_import_specifier/__test__.jsonc new file mode 100644 index 0000000000..9344f730dc --- /dev/null +++ b/tests/specs/run/error_012_bad_dynamic_import_specifier/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload --check error_012_bad_dynamic_import_specifier.ts", + "output": "error_012_bad_dynamic_import_specifier.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_012_bad_dynamic_import_specifier.ts b/tests/specs/run/error_012_bad_dynamic_import_specifier/error_012_bad_dynamic_import_specifier.ts similarity index 100% rename from tests/testdata/run/error_012_bad_dynamic_import_specifier.ts rename to tests/specs/run/error_012_bad_dynamic_import_specifier/error_012_bad_dynamic_import_specifier.ts diff --git a/tests/testdata/run/error_012_bad_dynamic_import_specifier.ts.out b/tests/specs/run/error_012_bad_dynamic_import_specifier/error_012_bad_dynamic_import_specifier.ts.out similarity index 100% rename from tests/testdata/run/error_012_bad_dynamic_import_specifier.ts.out rename to tests/specs/run/error_012_bad_dynamic_import_specifier/error_012_bad_dynamic_import_specifier.ts.out diff --git a/tests/specs/run/error_014_catch_dynamic_import_error/__test__.jsonc b/tests/specs/run/error_014_catch_dynamic_import_error/__test__.jsonc new file mode 100644 index 0000000000..94957dc659 --- /dev/null +++ b/tests/specs/run/error_014_catch_dynamic_import_error/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --allow-read error_014_catch_dynamic_import_error.js", + "output": "error_014_catch_dynamic_import_error.js.out" +} diff --git a/tests/testdata/run/error_014_catch_dynamic_import_error.js b/tests/specs/run/error_014_catch_dynamic_import_error/error_014_catch_dynamic_import_error.js similarity index 79% rename from tests/testdata/run/error_014_catch_dynamic_import_error.js rename to tests/specs/run/error_014_catch_dynamic_import_error/error_014_catch_dynamic_import_error.js index c58e54dcbb..05b021d15d 100644 --- a/tests/testdata/run/error_014_catch_dynamic_import_error.js +++ b/tests/specs/run/error_014_catch_dynamic_import_error/error_014_catch_dynamic_import_error.js @@ -7,21 +7,21 @@ } try { - await import("../subdir/indirect_import_error.js"); + await import("./indirect_import_error.js"); } catch (err) { console.log("Caught indirect direct dynamic import error."); console.log(err); } try { - await import("../subdir/throws.js"); + await import("./throws.js"); } catch (err) { console.log("Caught error thrown by dynamically imported module."); console.log(err); } try { - await import("../subdir/indirect_throws.js"); + await import("./indirect_throws.js"); } catch (err) { console.log( "Caught error thrown indirectly by dynamically imported module.", diff --git a/tests/testdata/run/error_014_catch_dynamic_import_error.js.out b/tests/specs/run/error_014_catch_dynamic_import_error/error_014_catch_dynamic_import_error.js.out similarity index 83% rename from tests/testdata/run/error_014_catch_dynamic_import_error.js.out rename to tests/specs/run/error_014_catch_dynamic_import_error/error_014_catch_dynamic_import_error.js.out index 868c971940..71feaa55bf 100644 --- a/tests/testdata/run/error_014_catch_dynamic_import_error.js.out +++ b/tests/specs/run/error_014_catch_dynamic_import_error/error_014_catch_dynamic_import_error.js.out @@ -7,13 +7,13 @@ TypeError: Relative import path "does not exist" not prefixed with / or ./ or .. } Caught indirect direct dynamic import error. TypeError: Relative import path "does not exist either" not prefixed with / or ./ or ../ - at [WILDCARD]/subdir/indirect_import_error.js:1:15 + at [WILDCARD]/indirect_import_error.js:1:15 at async [WILDCARD]/error_014_catch_dynamic_import_error.js:10:5 { code: "ERR_MODULE_NOT_FOUND" } Caught error thrown by dynamically imported module. Error: An error - at [WILDCARD]/subdir/throws.js:6:7 + at [WILDCARD]/throws.js:6:7 Caught error thrown indirectly by dynamically imported module. Error: An error - at [WILDCARD]/subdir/throws.js:6:7 + at [WILDCARD]/throws.js:6:7 diff --git a/tests/specs/run/error_014_catch_dynamic_import_error/indirect_import_error.js b/tests/specs/run/error_014_catch_dynamic_import_error/indirect_import_error.js new file mode 100644 index 0000000000..84011d2913 --- /dev/null +++ b/tests/specs/run/error_014_catch_dynamic_import_error/indirect_import_error.js @@ -0,0 +1 @@ +export * from "does not exist either"; diff --git a/tests/specs/run/error_014_catch_dynamic_import_error/indirect_throws.js b/tests/specs/run/error_014_catch_dynamic_import_error/indirect_throws.js new file mode 100644 index 0000000000..e1810a66cb --- /dev/null +++ b/tests/specs/run/error_014_catch_dynamic_import_error/indirect_throws.js @@ -0,0 +1 @@ +export * from "./throws.js"; diff --git a/tests/specs/run/error_014_catch_dynamic_import_error/throws.js b/tests/specs/run/error_014_catch_dynamic_import_error/throws.js new file mode 100644 index 0000000000..abdf291568 --- /dev/null +++ b/tests/specs/run/error_014_catch_dynamic_import_error/throws.js @@ -0,0 +1,6 @@ +// deno-lint-ignore-file +export function boo() { + console.log("Boo!"); +} + +throw new Error("An error"); diff --git a/tests/specs/run/error_015_dynamic_import_permissions/__test__.jsonc b/tests/specs/run/error_015_dynamic_import_permissions/__test__.jsonc new file mode 100644 index 0000000000..3ab25f1a52 --- /dev/null +++ b/tests/specs/run/error_015_dynamic_import_permissions/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload --quiet error_015_dynamic_import_permissions.js", + "output": "error_015_dynamic_import_permissions.out", + "exitCode": 1 +} diff --git a/tests/specs/run/error_015_dynamic_import_permissions/error_015_dynamic_import_permissions.js b/tests/specs/run/error_015_dynamic_import_permissions/error_015_dynamic_import_permissions.js new file mode 100644 index 0000000000..6e7daf5d01 --- /dev/null +++ b/tests/specs/run/error_015_dynamic_import_permissions/error_015_dynamic_import_permissions.js @@ -0,0 +1,3 @@ +(async () => { + await import("" + "http://example.com/mod4.js"); +})(); diff --git a/tests/testdata/run/error_015_dynamic_import_permissions.out b/tests/specs/run/error_015_dynamic_import_permissions/error_015_dynamic_import_permissions.out similarity index 77% rename from tests/testdata/run/error_015_dynamic_import_permissions.out rename to tests/specs/run/error_015_dynamic_import_permissions/error_015_dynamic_import_permissions.out index 15c26b4251..8ef2f6f1e4 100644 --- a/tests/testdata/run/error_015_dynamic_import_permissions.out +++ b/tests/specs/run/error_015_dynamic_import_permissions/error_015_dynamic_import_permissions.out @@ -1,4 +1,4 @@ error: Uncaught (in promise) TypeError: Requires import access to "example.com:80", run again with the --allow-import flag - await import("" + "http://example.com/subdir/mod4.js"); + await import("" + "http://example.com/mod4.js"); ^ at async file://[WILDCARD]/error_015_dynamic_import_permissions.js:2:3 diff --git a/tests/specs/run/error_015_dynamic_import_permissions/mod4.js b/tests/specs/run/error_015_dynamic_import_permissions/mod4.js new file mode 100644 index 0000000000..71332dbc42 --- /dev/null +++ b/tests/specs/run/error_015_dynamic_import_permissions/mod4.js @@ -0,0 +1 @@ +export const isMod4 = true; diff --git a/tests/specs/run/error_017_hide_long_source_ts/__test__.jsonc b/tests/specs/run/error_017_hide_long_source_ts/__test__.jsonc new file mode 100644 index 0000000000..382d560391 --- /dev/null +++ b/tests/specs/run/error_017_hide_long_source_ts/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload --check error_017_hide_long_source_ts.ts", + "output": "error_017_hide_long_source_ts.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_017_hide_long_source_ts.ts b/tests/specs/run/error_017_hide_long_source_ts/error_017_hide_long_source_ts.ts similarity index 100% rename from tests/testdata/run/error_017_hide_long_source_ts.ts rename to tests/specs/run/error_017_hide_long_source_ts/error_017_hide_long_source_ts.ts diff --git a/tests/testdata/run/error_017_hide_long_source_ts.ts.out b/tests/specs/run/error_017_hide_long_source_ts/error_017_hide_long_source_ts.ts.out similarity index 100% rename from tests/testdata/run/error_017_hide_long_source_ts.ts.out rename to tests/specs/run/error_017_hide_long_source_ts/error_017_hide_long_source_ts.ts.out diff --git a/tests/specs/run/error_018_hide_long_source_js/__test__.jsonc b/tests/specs/run/error_018_hide_long_source_js/__test__.jsonc new file mode 100644 index 0000000000..4e91a820df --- /dev/null +++ b/tests/specs/run/error_018_hide_long_source_js/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run error_018_hide_long_source_js.js", + "output": "error_018_hide_long_source_js.js.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_018_hide_long_source_js.js b/tests/specs/run/error_018_hide_long_source_js/error_018_hide_long_source_js.js similarity index 100% rename from tests/testdata/run/error_018_hide_long_source_js.js rename to tests/specs/run/error_018_hide_long_source_js/error_018_hide_long_source_js.js diff --git a/tests/testdata/run/error_018_hide_long_source_js.js.out b/tests/specs/run/error_018_hide_long_source_js/error_018_hide_long_source_js.js.out similarity index 100% rename from tests/testdata/run/error_018_hide_long_source_js.js.out rename to tests/specs/run/error_018_hide_long_source_js/error_018_hide_long_source_js.js.out diff --git a/tests/specs/run/error_019_stack_function/__test__.jsonc b/tests/specs/run/error_019_stack_function/__test__.jsonc new file mode 100644 index 0000000000..5e272ee492 --- /dev/null +++ b/tests/specs/run/error_019_stack_function/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run error_019_stack_function.ts", + "output": "error_019_stack_function.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_019_stack_function.ts b/tests/specs/run/error_019_stack_function/error_019_stack_function.ts similarity index 100% rename from tests/testdata/run/error_019_stack_function.ts rename to tests/specs/run/error_019_stack_function/error_019_stack_function.ts diff --git a/tests/testdata/run/error_019_stack_function.ts.out b/tests/specs/run/error_019_stack_function/error_019_stack_function.ts.out similarity index 100% rename from tests/testdata/run/error_019_stack_function.ts.out rename to tests/specs/run/error_019_stack_function/error_019_stack_function.ts.out diff --git a/tests/specs/run/error_020_stack_constructor/__test__.jsonc b/tests/specs/run/error_020_stack_constructor/__test__.jsonc new file mode 100644 index 0000000000..2dd574565e --- /dev/null +++ b/tests/specs/run/error_020_stack_constructor/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run error_020_stack_constructor.ts", + "output": "error_020_stack_constructor.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_020_stack_constructor.ts b/tests/specs/run/error_020_stack_constructor/error_020_stack_constructor.ts similarity index 100% rename from tests/testdata/run/error_020_stack_constructor.ts rename to tests/specs/run/error_020_stack_constructor/error_020_stack_constructor.ts diff --git a/tests/testdata/run/error_020_stack_constructor.ts.out b/tests/specs/run/error_020_stack_constructor/error_020_stack_constructor.ts.out similarity index 100% rename from tests/testdata/run/error_020_stack_constructor.ts.out rename to tests/specs/run/error_020_stack_constructor/error_020_stack_constructor.ts.out diff --git a/tests/specs/run/error_021_stack_method/__test__.jsonc b/tests/specs/run/error_021_stack_method/__test__.jsonc new file mode 100644 index 0000000000..db78cac094 --- /dev/null +++ b/tests/specs/run/error_021_stack_method/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run error_021_stack_method.ts", + "output": "error_021_stack_method.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_021_stack_method.ts b/tests/specs/run/error_021_stack_method/error_021_stack_method.ts similarity index 100% rename from tests/testdata/run/error_021_stack_method.ts rename to tests/specs/run/error_021_stack_method/error_021_stack_method.ts diff --git a/tests/testdata/run/error_021_stack_method.ts.out b/tests/specs/run/error_021_stack_method/error_021_stack_method.ts.out similarity index 100% rename from tests/testdata/run/error_021_stack_method.ts.out rename to tests/specs/run/error_021_stack_method/error_021_stack_method.ts.out diff --git a/tests/specs/run/error_022_stack_custom_error/__test__.jsonc b/tests/specs/run/error_022_stack_custom_error/__test__.jsonc new file mode 100644 index 0000000000..f315058338 --- /dev/null +++ b/tests/specs/run/error_022_stack_custom_error/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run error_022_stack_custom_error.ts", + "output": "error_022_stack_custom_error.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_022_stack_custom_error.ts b/tests/specs/run/error_022_stack_custom_error/error_022_stack_custom_error.ts similarity index 100% rename from tests/testdata/run/error_022_stack_custom_error.ts rename to tests/specs/run/error_022_stack_custom_error/error_022_stack_custom_error.ts diff --git a/tests/testdata/run/error_022_stack_custom_error.ts.out b/tests/specs/run/error_022_stack_custom_error/error_022_stack_custom_error.ts.out similarity index 100% rename from tests/testdata/run/error_022_stack_custom_error.ts.out rename to tests/specs/run/error_022_stack_custom_error/error_022_stack_custom_error.ts.out diff --git a/tests/specs/run/error_023_stack_async/__test__.jsonc b/tests/specs/run/error_023_stack_async/__test__.jsonc new file mode 100644 index 0000000000..76cdff013d --- /dev/null +++ b/tests/specs/run/error_023_stack_async/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run error_023_stack_async.ts", + "output": "error_023_stack_async.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_023_stack_async.ts b/tests/specs/run/error_023_stack_async/error_023_stack_async.ts similarity index 100% rename from tests/testdata/run/error_023_stack_async.ts rename to tests/specs/run/error_023_stack_async/error_023_stack_async.ts diff --git a/tests/testdata/run/error_023_stack_async.ts.out b/tests/specs/run/error_023_stack_async/error_023_stack_async.ts.out similarity index 100% rename from tests/testdata/run/error_023_stack_async.ts.out rename to tests/specs/run/error_023_stack_async/error_023_stack_async.ts.out diff --git a/tests/specs/run/error_024_stack_promise_all/__test__.jsonc b/tests/specs/run/error_024_stack_promise_all/__test__.jsonc new file mode 100644 index 0000000000..7c733f9711 --- /dev/null +++ b/tests/specs/run/error_024_stack_promise_all/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run error_024_stack_promise_all.ts", + "output": "error_024_stack_promise_all.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_024_stack_promise_all.ts b/tests/specs/run/error_024_stack_promise_all/error_024_stack_promise_all.ts similarity index 100% rename from tests/testdata/run/error_024_stack_promise_all.ts rename to tests/specs/run/error_024_stack_promise_all/error_024_stack_promise_all.ts diff --git a/tests/testdata/run/error_024_stack_promise_all.ts.out b/tests/specs/run/error_024_stack_promise_all/error_024_stack_promise_all.ts.out similarity index 100% rename from tests/testdata/run/error_024_stack_promise_all.ts.out rename to tests/specs/run/error_024_stack_promise_all/error_024_stack_promise_all.ts.out diff --git a/tests/specs/run/error_025_tab_indent/__test__.jsonc b/tests/specs/run/error_025_tab_indent/__test__.jsonc new file mode 100644 index 0000000000..23c49458e5 --- /dev/null +++ b/tests/specs/run/error_025_tab_indent/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run error_025_tab_indent", + "output": "error_025_tab_indent.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_025_tab_indent b/tests/specs/run/error_025_tab_indent/error_025_tab_indent similarity index 100% rename from tests/testdata/run/error_025_tab_indent rename to tests/specs/run/error_025_tab_indent/error_025_tab_indent diff --git a/tests/testdata/run/error_025_tab_indent.out b/tests/specs/run/error_025_tab_indent/error_025_tab_indent.out similarity index 100% rename from tests/testdata/run/error_025_tab_indent.out rename to tests/specs/run/error_025_tab_indent/error_025_tab_indent.out diff --git a/tests/specs/run/error_cause/__test__.jsonc b/tests/specs/run/error_cause/__test__.jsonc new file mode 100644 index 0000000000..ccbf71dea7 --- /dev/null +++ b/tests/specs/run/error_cause/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run error_cause.ts", + "output": "error_cause.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_cause.ts b/tests/specs/run/error_cause/error_cause.ts similarity index 100% rename from tests/testdata/run/error_cause.ts rename to tests/specs/run/error_cause/error_cause.ts diff --git a/tests/testdata/run/error_cause.ts.out b/tests/specs/run/error_cause/error_cause.ts.out similarity index 100% rename from tests/testdata/run/error_cause.ts.out rename to tests/specs/run/error_cause/error_cause.ts.out diff --git a/tests/specs/run/error_cause_recursive/__test__.jsonc b/tests/specs/run/error_cause_recursive/__test__.jsonc new file mode 100644 index 0000000000..71c4cf3cc1 --- /dev/null +++ b/tests/specs/run/error_cause_recursive/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run error_cause_recursive.ts", + "output": "error_cause_recursive.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_cause_recursive.ts b/tests/specs/run/error_cause_recursive/error_cause_recursive.ts similarity index 100% rename from tests/testdata/run/error_cause_recursive.ts rename to tests/specs/run/error_cause_recursive/error_cause_recursive.ts diff --git a/tests/testdata/run/error_cause_recursive.ts.out b/tests/specs/run/error_cause_recursive/error_cause_recursive.ts.out similarity index 100% rename from tests/testdata/run/error_cause_recursive.ts.out rename to tests/specs/run/error_cause_recursive/error_cause_recursive.ts.out diff --git a/tests/specs/run/error_cause_recursive_aggregate/__test__.jsonc b/tests/specs/run/error_cause_recursive_aggregate/__test__.jsonc new file mode 100644 index 0000000000..2aabee0ecb --- /dev/null +++ b/tests/specs/run/error_cause_recursive_aggregate/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run error_cause_recursive_aggregate.ts", + "output": "error_cause_recursive_aggregate.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/error_cause_recursive_aggregate.ts b/tests/specs/run/error_cause_recursive_aggregate/error_cause_recursive_aggregate.ts similarity index 100% rename from tests/testdata/error_cause_recursive_aggregate.ts rename to tests/specs/run/error_cause_recursive_aggregate/error_cause_recursive_aggregate.ts diff --git a/tests/testdata/error_cause_recursive_aggregate.ts.out b/tests/specs/run/error_cause_recursive_aggregate/error_cause_recursive_aggregate.ts.out similarity index 100% rename from tests/testdata/error_cause_recursive_aggregate.ts.out rename to tests/specs/run/error_cause_recursive_aggregate/error_cause_recursive_aggregate.ts.out diff --git a/tests/specs/run/error_cause_recursive_tail/__test__.jsonc b/tests/specs/run/error_cause_recursive_tail/__test__.jsonc new file mode 100644 index 0000000000..249ccac483 --- /dev/null +++ b/tests/specs/run/error_cause_recursive_tail/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run error_cause_recursive_tail.ts", + "output": "error_cause_recursive_tail.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/error_cause_recursive_tail.ts b/tests/specs/run/error_cause_recursive_tail/error_cause_recursive_tail.ts similarity index 100% rename from tests/testdata/error_cause_recursive_tail.ts rename to tests/specs/run/error_cause_recursive_tail/error_cause_recursive_tail.ts diff --git a/tests/testdata/error_cause_recursive_tail.ts.out b/tests/specs/run/error_cause_recursive_tail/error_cause_recursive_tail.ts.out similarity index 100% rename from tests/testdata/error_cause_recursive_tail.ts.out rename to tests/specs/run/error_cause_recursive_tail/error_cause_recursive_tail.ts.out diff --git a/tests/specs/run/error_for_await/__test__.jsonc b/tests/specs/run/error_for_await/__test__.jsonc new file mode 100644 index 0000000000..b67f67ecee --- /dev/null +++ b/tests/specs/run/error_for_await/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload --check error_for_await.ts", + "output": "error_for_await.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_for_await.ts b/tests/specs/run/error_for_await/error_for_await.ts similarity index 100% rename from tests/testdata/run/error_for_await.ts rename to tests/specs/run/error_for_await/error_for_await.ts diff --git a/tests/testdata/run/error_for_await.ts.out b/tests/specs/run/error_for_await/error_for_await.ts.out similarity index 100% rename from tests/testdata/run/error_for_await.ts.out rename to tests/specs/run/error_for_await/error_for_await.ts.out diff --git a/tests/specs/run/error_import_map_unable_to_load/__test__.jsonc b/tests/specs/run/error_import_map_unable_to_load/__test__.jsonc new file mode 100644 index 0000000000..c7dd939a45 --- /dev/null +++ b/tests/specs/run/error_import_map_unable_to_load/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --import-map=import_maps/does_not_exist.json import_maps/test.ts", + "output": "error_import_map_unable_to_load.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_import_map_unable_to_load.out b/tests/specs/run/error_import_map_unable_to_load/error_import_map_unable_to_load.out similarity index 100% rename from tests/testdata/run/error_import_map_unable_to_load.out rename to tests/specs/run/error_import_map_unable_to_load/error_import_map_unable_to_load.out diff --git a/tests/specs/run/error_import_map_unable_to_load/import_maps/test_data.ts b/tests/specs/run/error_import_map_unable_to_load/import_maps/test_data.ts new file mode 100644 index 0000000000..5e8efea69b --- /dev/null +++ b/tests/specs/run/error_import_map_unable_to_load/import_maps/test_data.ts @@ -0,0 +1 @@ +import "test_server/import_maps/lodash/lodash.ts"; diff --git a/tests/specs/run/error_import_map_unable_to_load/import_maps/test_data.ts.out b/tests/specs/run/error_import_map_unable_to_load/import_maps/test_data.ts.out new file mode 100644 index 0000000000..da996dc0d9 --- /dev/null +++ b/tests/specs/run/error_import_map_unable_to_load/import_maps/test_data.ts.out @@ -0,0 +1 @@ +Hello from remapped lodash! diff --git a/tests/specs/run/error_missing_module_named_import/__test__.jsonc b/tests/specs/run/error_missing_module_named_import/__test__.jsonc new file mode 100644 index 0000000000..9f5780d2a9 --- /dev/null +++ b/tests/specs/run/error_missing_module_named_import/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload error_missing_module_named_import.ts", + "output": "error_missing_module_named_import.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_missing_module_named_import.ts b/tests/specs/run/error_missing_module_named_import/error_missing_module_named_import.ts similarity index 100% rename from tests/testdata/run/error_missing_module_named_import.ts rename to tests/specs/run/error_missing_module_named_import/error_missing_module_named_import.ts diff --git a/tests/testdata/run/error_missing_module_named_import.ts.out b/tests/specs/run/error_missing_module_named_import/error_missing_module_named_import.ts.out similarity index 100% rename from tests/testdata/run/error_missing_module_named_import.ts.out rename to tests/specs/run/error_missing_module_named_import/error_missing_module_named_import.ts.out diff --git a/tests/specs/run/error_name_non_string/__test__.jsonc b/tests/specs/run/error_name_non_string/__test__.jsonc new file mode 100644 index 0000000000..a6748b56a2 --- /dev/null +++ b/tests/specs/run/error_name_non_string/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet error_name_non_string.js", + "output": "error_name_non_string.js.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_name_non_string.js b/tests/specs/run/error_name_non_string/error_name_non_string.js similarity index 100% rename from tests/testdata/run/error_name_non_string.js rename to tests/specs/run/error_name_non_string/error_name_non_string.js diff --git a/tests/testdata/run/error_name_non_string.js.out b/tests/specs/run/error_name_non_string/error_name_non_string.js.out similarity index 100% rename from tests/testdata/run/error_name_non_string.js.out rename to tests/specs/run/error_name_non_string/error_name_non_string.js.out diff --git a/tests/specs/run/error_no_check/__test__.jsonc b/tests/specs/run/error_no_check/__test__.jsonc new file mode 100644 index 0000000000..439dc5615d --- /dev/null +++ b/tests/specs/run/error_no_check/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload --no-check error_no_check.ts", + "output": "error_no_check.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/run/error_no_check/error_no_check.ts b/tests/specs/run/error_no_check/error_no_check.ts new file mode 100644 index 0000000000..95ebff0282 --- /dev/null +++ b/tests/specs/run/error_no_check/error_no_check.ts @@ -0,0 +1 @@ +export { AnInterface, isAnInterface } from "./type_and_code.ts"; diff --git a/tests/specs/run/error_no_check/error_no_check.ts.out b/tests/specs/run/error_no_check/error_no_check.ts.out new file mode 100644 index 0000000000..c4e85332d1 --- /dev/null +++ b/tests/specs/run/error_no_check/error_no_check.ts.out @@ -0,0 +1,2 @@ +error: Uncaught SyntaxError: The requested module './type_and_code.ts' does not provide an export named 'AnInterface' +[WILDCARD] \ No newline at end of file diff --git a/tests/specs/run/error_no_check/type_and_code.ts b/tests/specs/run/error_no_check/type_and_code.ts new file mode 100644 index 0000000000..b147134195 --- /dev/null +++ b/tests/specs/run/error_no_check/type_and_code.ts @@ -0,0 +1,7 @@ +export interface AnInterface { + a: string; +} + +export function isAnInterface(value: unknown): value is AnInterface { + return value && typeof value === "object" && "a" in value; +} diff --git a/tests/specs/run/error_syntax/__test__.jsonc b/tests/specs/run/error_syntax/__test__.jsonc new file mode 100644 index 0000000000..7a60f2c732 --- /dev/null +++ b/tests/specs/run/error_syntax/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload error_syntax.js", + "output": "error_syntax.js.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_syntax.js b/tests/specs/run/error_syntax/error_syntax.js similarity index 100% rename from tests/testdata/run/error_syntax.js rename to tests/specs/run/error_syntax/error_syntax.js diff --git a/tests/testdata/run/error_syntax.js.out b/tests/specs/run/error_syntax/error_syntax.js.out similarity index 100% rename from tests/testdata/run/error_syntax.js.out rename to tests/specs/run/error_syntax/error_syntax.js.out diff --git a/tests/specs/run/error_syntax_empty_trailing_line/__test__.jsonc b/tests/specs/run/error_syntax_empty_trailing_line/__test__.jsonc new file mode 100644 index 0000000000..72f1de1f7a --- /dev/null +++ b/tests/specs/run/error_syntax_empty_trailing_line/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload error_syntax_empty_trailing_line.mjs", + "output": "error_syntax_empty_trailing_line.mjs.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_syntax_empty_trailing_line.mjs b/tests/specs/run/error_syntax_empty_trailing_line/error_syntax_empty_trailing_line.mjs similarity index 100% rename from tests/testdata/run/error_syntax_empty_trailing_line.mjs rename to tests/specs/run/error_syntax_empty_trailing_line/error_syntax_empty_trailing_line.mjs diff --git a/tests/testdata/run/error_syntax_empty_trailing_line.mjs.out b/tests/specs/run/error_syntax_empty_trailing_line/error_syntax_empty_trailing_line.mjs.out similarity index 100% rename from tests/testdata/run/error_syntax_empty_trailing_line.mjs.out rename to tests/specs/run/error_syntax_empty_trailing_line/error_syntax_empty_trailing_line.mjs.out diff --git a/tests/specs/run/error_type_definitions/__test__.jsonc b/tests/specs/run/error_type_definitions/__test__.jsonc new file mode 100644 index 0000000000..0ea9bc0164 --- /dev/null +++ b/tests/specs/run/error_type_definitions/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload --check error_type_definitions.ts", + "output": "error_type_definitions.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/run/error_type_definitions/error_type_definitions.ts b/tests/specs/run/error_type_definitions/error_type_definitions.ts new file mode 100644 index 0000000000..ceb11787e5 --- /dev/null +++ b/tests/specs/run/error_type_definitions/error_type_definitions.ts @@ -0,0 +1,5 @@ +// @deno-types="./type_definitions/bar.d.ts" +import { Bar } from "./type_definitions/bar.js"; + +const bar = new Bar(); +console.log(bar); diff --git a/tests/testdata/run/error_type_definitions.ts.out b/tests/specs/run/error_type_definitions/error_type_definitions.ts.out similarity index 100% rename from tests/testdata/run/error_type_definitions.ts.out rename to tests/specs/run/error_type_definitions/error_type_definitions.ts.out diff --git a/tests/specs/run/error_type_definitions/type_definitions/bar.d.ts b/tests/specs/run/error_type_definitions/type_definitions/bar.d.ts new file mode 100644 index 0000000000..d43335dbb5 --- /dev/null +++ b/tests/specs/run/error_type_definitions/type_definitions/bar.d.ts @@ -0,0 +1,7 @@ +/// + +declare namespace bar { + export class Bar { + baz: string; + } +} diff --git a/tests/specs/run/error_type_definitions/type_definitions/bar.js b/tests/specs/run/error_type_definitions/type_definitions/bar.js new file mode 100644 index 0000000000..e9c2e5193c --- /dev/null +++ b/tests/specs/run/error_type_definitions/type_definitions/bar.js @@ -0,0 +1,5 @@ +export class Bar { + constructor() { + this.baz = "baz"; + } +} diff --git a/tests/specs/run/error_type_definitions/type_definitions/fizz.d.ts b/tests/specs/run/error_type_definitions/type_definitions/fizz.d.ts new file mode 100644 index 0000000000..34eb41b960 --- /dev/null +++ b/tests/specs/run/error_type_definitions/type_definitions/fizz.d.ts @@ -0,0 +1,2 @@ +/** A global value. */ +declare const fizz: string; diff --git a/tests/specs/run/error_type_definitions/type_definitions/fizz.js b/tests/specs/run/error_type_definitions/type_definitions/fizz.js new file mode 100644 index 0000000000..852162c940 --- /dev/null +++ b/tests/specs/run/error_type_definitions/type_definitions/fizz.js @@ -0,0 +1 @@ +globalThis.fizz = "fizz"; diff --git a/tests/specs/run/error_type_definitions/type_definitions/foo.d.ts b/tests/specs/run/error_type_definitions/type_definitions/foo.d.ts new file mode 100644 index 0000000000..ce39201e1b --- /dev/null +++ b/tests/specs/run/error_type_definitions/type_definitions/foo.d.ts @@ -0,0 +1,2 @@ +/** An exported value. */ +export const foo: string; diff --git a/tests/specs/run/error_type_definitions/type_definitions/foo.js b/tests/specs/run/error_type_definitions/type_definitions/foo.js new file mode 100644 index 0000000000..61d366eb25 --- /dev/null +++ b/tests/specs/run/error_type_definitions/type_definitions/foo.js @@ -0,0 +1 @@ +export const foo = "foo"; diff --git a/tests/specs/run/error_type_definitions/type_definitions/qat.ts b/tests/specs/run/error_type_definitions/type_definitions/qat.ts new file mode 100644 index 0000000000..6196c9d387 --- /dev/null +++ b/tests/specs/run/error_type_definitions/type_definitions/qat.ts @@ -0,0 +1 @@ +export const qat = "qat"; diff --git a/tests/specs/run/error_with_errors_prop/__test__.jsonc b/tests/specs/run/error_with_errors_prop/__test__.jsonc new file mode 100644 index 0000000000..afbfd24cfe --- /dev/null +++ b/tests/specs/run/error_with_errors_prop/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet error_with_errors_prop.js", + "output": "error_with_errors_prop.js.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/error_with_errors_prop.js b/tests/specs/run/error_with_errors_prop/error_with_errors_prop.js similarity index 100% rename from tests/testdata/run/error_with_errors_prop.js rename to tests/specs/run/error_with_errors_prop/error_with_errors_prop.js diff --git a/tests/testdata/run/error_with_errors_prop.js.out b/tests/specs/run/error_with_errors_prop/error_with_errors_prop.js.out similarity index 100% rename from tests/testdata/run/error_with_errors_prop.js.out rename to tests/specs/run/error_with_errors_prop/error_with_errors_prop.js.out diff --git a/tests/specs/run/es_private_fields/__test__.jsonc b/tests/specs/run/es_private_fields/__test__.jsonc new file mode 100644 index 0000000000..817efd67e3 --- /dev/null +++ b/tests/specs/run/es_private_fields/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload es_private_fields.js", + "output": "es_private_fields.js.out" +} diff --git a/tests/testdata/run/es_private_fields.js b/tests/specs/run/es_private_fields/es_private_fields.js similarity index 100% rename from tests/testdata/run/es_private_fields.js rename to tests/specs/run/es_private_fields/es_private_fields.js diff --git a/tests/testdata/run/es_private_fields.js.out b/tests/specs/run/es_private_fields/es_private_fields.js.out similarity index 100% rename from tests/testdata/run/es_private_fields.js.out rename to tests/specs/run/es_private_fields/es_private_fields.js.out diff --git a/tests/specs/run/eval_context_throw_dom_exception/__test__.jsonc b/tests/specs/run/eval_context_throw_dom_exception/__test__.jsonc new file mode 100644 index 0000000000..6ad302b03a --- /dev/null +++ b/tests/specs/run/eval_context_throw_dom_exception/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run eval_context_throw_dom_exception.js", + "output": "eval_context_throw_dom_exception.js.out" +} diff --git a/tests/testdata/run/eval_context_throw_dom_exception.js b/tests/specs/run/eval_context_throw_dom_exception/eval_context_throw_dom_exception.js similarity index 100% rename from tests/testdata/run/eval_context_throw_dom_exception.js rename to tests/specs/run/eval_context_throw_dom_exception/eval_context_throw_dom_exception.js diff --git a/tests/testdata/run/eval_context_throw_dom_exception.js.out b/tests/specs/run/eval_context_throw_dom_exception/eval_context_throw_dom_exception.js.out similarity index 100% rename from tests/testdata/run/eval_context_throw_dom_exception.js.out rename to tests/specs/run/eval_context_throw_dom_exception/eval_context_throw_dom_exception.js.out diff --git a/tests/specs/run/event_listener_error/__test__.jsonc b/tests/specs/run/event_listener_error/__test__.jsonc new file mode 100644 index 0000000000..b2540e03dc --- /dev/null +++ b/tests/specs/run/event_listener_error/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet event_listener_error.ts", + "output": "event_listener_error.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/event_listener_error.ts b/tests/specs/run/event_listener_error/event_listener_error.ts similarity index 100% rename from tests/testdata/run/event_listener_error.ts rename to tests/specs/run/event_listener_error/event_listener_error.ts diff --git a/tests/testdata/run/event_listener_error.ts.out b/tests/specs/run/event_listener_error/event_listener_error.ts.out similarity index 100% rename from tests/testdata/run/event_listener_error.ts.out rename to tests/specs/run/event_listener_error/event_listener_error.ts.out diff --git a/tests/specs/run/event_listener_error_handled/__test__.jsonc b/tests/specs/run/event_listener_error_handled/__test__.jsonc new file mode 100644 index 0000000000..f1fdcd5dba --- /dev/null +++ b/tests/specs/run/event_listener_error_handled/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet event_listener_error_handled.ts", + "output": "event_listener_error_handled.ts.out" +} diff --git a/tests/testdata/run/event_listener_error_handled.ts b/tests/specs/run/event_listener_error_handled/event_listener_error_handled.ts similarity index 100% rename from tests/testdata/run/event_listener_error_handled.ts rename to tests/specs/run/event_listener_error_handled/event_listener_error_handled.ts diff --git a/tests/testdata/run/event_listener_error_handled.ts.out b/tests/specs/run/event_listener_error_handled/event_listener_error_handled.ts.out similarity index 100% rename from tests/testdata/run/event_listener_error_handled.ts.out rename to tests/specs/run/event_listener_error_handled/event_listener_error_handled.ts.out diff --git a/tests/specs/run/event_listener_error_immediate_exit/__test__.jsonc b/tests/specs/run/event_listener_error_immediate_exit/__test__.jsonc new file mode 100644 index 0000000000..2974c0e422 --- /dev/null +++ b/tests/specs/run/event_listener_error_immediate_exit/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet event_listener_error_immediate_exit.ts", + "output": "event_listener_error_immediate_exit.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/event_listener_error_immediate_exit.ts b/tests/specs/run/event_listener_error_immediate_exit/event_listener_error_immediate_exit.ts similarity index 100% rename from tests/testdata/run/event_listener_error_immediate_exit.ts rename to tests/specs/run/event_listener_error_immediate_exit/event_listener_error_immediate_exit.ts diff --git a/tests/testdata/run/event_listener_error_immediate_exit.ts.out b/tests/specs/run/event_listener_error_immediate_exit/event_listener_error_immediate_exit.ts.out similarity index 100% rename from tests/testdata/run/event_listener_error_immediate_exit.ts.out rename to tests/specs/run/event_listener_error_immediate_exit/event_listener_error_immediate_exit.ts.out diff --git a/tests/specs/run/event_listener_error_immediate_exit_worker/__test__.jsonc b/tests/specs/run/event_listener_error_immediate_exit_worker/__test__.jsonc new file mode 100644 index 0000000000..6ef3ef2ed1 --- /dev/null +++ b/tests/specs/run/event_listener_error_immediate_exit_worker/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet -A event_listener_error_immediate_exit_worker.ts", + "output": "event_listener_error_immediate_exit_worker.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/run/event_listener_error_immediate_exit_worker/event_listener_error_immediate_exit.ts b/tests/specs/run/event_listener_error_immediate_exit_worker/event_listener_error_immediate_exit.ts new file mode 100644 index 0000000000..292a0df007 --- /dev/null +++ b/tests/specs/run/event_listener_error_immediate_exit_worker/event_listener_error_immediate_exit.ts @@ -0,0 +1,12 @@ +addEventListener("foo", () => { + queueMicrotask(() => console.log("queueMicrotask")); + setTimeout(() => console.log("timer"), 0); + throw new Error("bar"); +}); +console.log(1); +// @ts-ignore Deno[Deno.internal].core +Deno[Deno.internal].core.setNextTickCallback(() => console.log("nextTick")); +// @ts-ignore Deno[Deno.internal].core +Deno[Deno.internal].core.setHasTickScheduled(true); +dispatchEvent(new CustomEvent("foo")); +console.log(2); diff --git a/tests/testdata/run/event_listener_error_immediate_exit_worker.ts b/tests/specs/run/event_listener_error_immediate_exit_worker/event_listener_error_immediate_exit_worker.ts similarity index 100% rename from tests/testdata/run/event_listener_error_immediate_exit_worker.ts rename to tests/specs/run/event_listener_error_immediate_exit_worker/event_listener_error_immediate_exit_worker.ts diff --git a/tests/testdata/run/event_listener_error_immediate_exit_worker.ts.out b/tests/specs/run/event_listener_error_immediate_exit_worker/event_listener_error_immediate_exit_worker.ts.out similarity index 100% rename from tests/testdata/run/event_listener_error_immediate_exit_worker.ts.out rename to tests/specs/run/event_listener_error_immediate_exit_worker/event_listener_error_immediate_exit_worker.ts.out diff --git a/tests/specs/run/exit_error42/__test__.jsonc b/tests/specs/run/exit_error42/__test__.jsonc new file mode 100644 index 0000000000..43d3089566 --- /dev/null +++ b/tests/specs/run/exit_error42/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --reload exit_error42.ts", + "output": "exit_error42.ts.out", + "exitCode": 42 +} diff --git a/tests/testdata/run/exit_error42.ts b/tests/specs/run/exit_error42/exit_error42.ts similarity index 100% rename from tests/testdata/run/exit_error42.ts rename to tests/specs/run/exit_error42/exit_error42.ts diff --git a/tests/testdata/run/exit_error42.ts.out b/tests/specs/run/exit_error42/exit_error42.ts.out similarity index 100% rename from tests/testdata/run/exit_error42.ts.out rename to tests/specs/run/exit_error42/exit_error42.ts.out diff --git a/tests/specs/run/explicit_resource_management/__test__.jsonc b/tests/specs/run/explicit_resource_management/__test__.jsonc new file mode 100644 index 0000000000..7062e6f36f --- /dev/null +++ b/tests/specs/run/explicit_resource_management/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --check explicit_resource_management/main.ts", + "output": "explicit_resource_management/main.out" +} diff --git a/tests/testdata/run/explicit_resource_management/main.out b/tests/specs/run/explicit_resource_management/explicit_resource_management/main.out similarity index 100% rename from tests/testdata/run/explicit_resource_management/main.out rename to tests/specs/run/explicit_resource_management/explicit_resource_management/main.out diff --git a/tests/testdata/run/explicit_resource_management/main.ts b/tests/specs/run/explicit_resource_management/explicit_resource_management/main.ts similarity index 100% rename from tests/testdata/run/explicit_resource_management/main.ts rename to tests/specs/run/explicit_resource_management/explicit_resource_management/main.ts diff --git a/tests/specs/run/ext_flag_takes_precedence_over_extension/__test__.jsonc b/tests/specs/run/ext_flag_takes_precedence_over_extension/__test__.jsonc new file mode 100644 index 0000000000..0806088b4e --- /dev/null +++ b/tests/specs/run/ext_flag_takes_precedence_over_extension/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --ext ts --check ts_with_js_extension.js", + "output": "ts_with_js_extension.out", + "exitCode": 0 +} diff --git a/tests/specs/run/ext_flag_takes_precedence_over_extension/ts_with_js_extension.js b/tests/specs/run/ext_flag_takes_precedence_over_extension/ts_with_js_extension.js new file mode 100644 index 0000000000..3c49f74846 --- /dev/null +++ b/tests/specs/run/ext_flag_takes_precedence_over_extension/ts_with_js_extension.js @@ -0,0 +1,5 @@ +interface Lollipop { + _: number; +} + +console.log("executing typescript with extension"); diff --git a/tests/specs/run/ext_flag_takes_precedence_over_extension/ts_with_js_extension.out b/tests/specs/run/ext_flag_takes_precedence_over_extension/ts_with_js_extension.out new file mode 100644 index 0000000000..7ae7b9168f --- /dev/null +++ b/tests/specs/run/ext_flag_takes_precedence_over_extension/ts_with_js_extension.out @@ -0,0 +1,2 @@ +Check [WILDCARD]/ts_with_js_extension.js +executing typescript with extension diff --git a/tests/specs/run/fetch_async_error_stack/__test__.jsonc b/tests/specs/run/fetch_async_error_stack/__test__.jsonc new file mode 100644 index 0000000000..152f57807c --- /dev/null +++ b/tests/specs/run/fetch_async_error_stack/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet -A fetch_async_error_stack.ts", + "output": "fetch_async_error_stack.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/fetch_async_error_stack.ts b/tests/specs/run/fetch_async_error_stack/fetch_async_error_stack.ts similarity index 100% rename from tests/testdata/run/fetch_async_error_stack.ts rename to tests/specs/run/fetch_async_error_stack/fetch_async_error_stack.ts diff --git a/tests/testdata/run/fetch_async_error_stack.ts.out b/tests/specs/run/fetch_async_error_stack/fetch_async_error_stack.ts.out similarity index 100% rename from tests/testdata/run/fetch_async_error_stack.ts.out rename to tests/specs/run/fetch_async_error_stack/fetch_async_error_stack.ts.out diff --git a/tests/specs/run/fetch_response_finalization/__test__.jsonc b/tests/specs/run/fetch_response_finalization/__test__.jsonc new file mode 100644 index 0000000000..51a7e2b045 --- /dev/null +++ b/tests/specs/run/fetch_response_finalization/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --v8-flags=--expose-gc --allow-net fetch_response_finalization.js", + "output": "fetch_response_finalization.js.out", + "exitCode": 0 +} diff --git a/tests/testdata/run/fetch_response_finalization.js b/tests/specs/run/fetch_response_finalization/fetch_response_finalization.js similarity index 100% rename from tests/testdata/run/fetch_response_finalization.js rename to tests/specs/run/fetch_response_finalization/fetch_response_finalization.js diff --git a/tests/testdata/run/fetch_response_finalization.js.out b/tests/specs/run/fetch_response_finalization/fetch_response_finalization.js.out similarity index 100% rename from tests/testdata/run/fetch_response_finalization.js.out rename to tests/specs/run/fetch_response_finalization/fetch_response_finalization.js.out diff --git a/tests/specs/run/finalization_registry/__test__.jsonc b/tests/specs/run/finalization_registry/__test__.jsonc new file mode 100644 index 0000000000..f7526506c5 --- /dev/null +++ b/tests/specs/run/finalization_registry/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --v8-flags=--expose-gc finalization_registry.js", + "output": "finalization_registry.js.out" +} diff --git a/tests/testdata/run/finalization_registry.js b/tests/specs/run/finalization_registry/finalization_registry.js similarity index 100% rename from tests/testdata/run/finalization_registry.js rename to tests/specs/run/finalization_registry/finalization_registry.js diff --git a/tests/testdata/run/finalization_registry.js.out b/tests/specs/run/finalization_registry/finalization_registry.js.out similarity index 100% rename from tests/testdata/run/finalization_registry.js.out rename to tests/specs/run/finalization_registry/finalization_registry.js.out diff --git a/tests/specs/run/fix_dynamic_import_errors/__test__.jsonc b/tests/specs/run/fix_dynamic_import_errors/__test__.jsonc new file mode 100644 index 0000000000..d9302d2cae --- /dev/null +++ b/tests/specs/run/fix_dynamic_import_errors/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload fix_dynamic_import_errors.js", + "output": "fix_dynamic_import_errors.js.out" +} diff --git a/tests/specs/run/fix_dynamic_import_errors/b.js b/tests/specs/run/fix_dynamic_import_errors/b.js new file mode 100644 index 0000000000..6ea50d3608 --- /dev/null +++ b/tests/specs/run/fix_dynamic_import_errors/b.js @@ -0,0 +1,2 @@ +import "./bad.mjs"; +export default () => "error"; diff --git a/tests/specs/run/fix_dynamic_import_errors/c.js b/tests/specs/run/fix_dynamic_import_errors/c.js new file mode 100644 index 0000000000..20546455ea --- /dev/null +++ b/tests/specs/run/fix_dynamic_import_errors/c.js @@ -0,0 +1,2 @@ +await import("./bad2.mjs"); +export default () => "error"; diff --git a/tests/testdata/run/fix_dynamic_import_errors.js b/tests/specs/run/fix_dynamic_import_errors/fix_dynamic_import_errors.js similarity index 52% rename from tests/testdata/run/fix_dynamic_import_errors.js rename to tests/specs/run/fix_dynamic_import_errors/fix_dynamic_import_errors.js index 1d7be37e06..e105cbada6 100644 --- a/tests/testdata/run/fix_dynamic_import_errors.js +++ b/tests/specs/run/fix_dynamic_import_errors/fix_dynamic_import_errors.js @@ -1,7 +1,7 @@ -import("../dynamic_import/b.js").catch(() => { +import("./b.js").catch(() => { console.log("caught import error from b.js"); }); -import("../dynamic_import/c.js").catch(() => { +import("./c.js").catch(() => { console.log("caught import error from c.js"); }); diff --git a/tests/testdata/run/fix_dynamic_import_errors.js.out b/tests/specs/run/fix_dynamic_import_errors/fix_dynamic_import_errors.js.out similarity index 100% rename from tests/testdata/run/fix_dynamic_import_errors.js.out rename to tests/specs/run/fix_dynamic_import_errors/fix_dynamic_import_errors.js.out diff --git a/tests/specs/run/fix_emittable_skipped/__test__.jsonc b/tests/specs/run/fix_emittable_skipped/__test__.jsonc new file mode 100644 index 0000000000..ef1445e0e3 --- /dev/null +++ b/tests/specs/run/fix_emittable_skipped/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload fix_emittable_skipped.js", + "output": "fix_emittable_skipped.ts.out" +} diff --git a/tests/specs/run/fix_emittable_skipped/emittable.d.ts b/tests/specs/run/fix_emittable_skipped/emittable.d.ts new file mode 100644 index 0000000000..425b80f244 --- /dev/null +++ b/tests/specs/run/fix_emittable_skipped/emittable.d.ts @@ -0,0 +1 @@ +export const a: string; diff --git a/tests/specs/run/fix_emittable_skipped/fix_emittable_skipped.js b/tests/specs/run/fix_emittable_skipped/fix_emittable_skipped.js new file mode 100644 index 0000000000..b94af2730f --- /dev/null +++ b/tests/specs/run/fix_emittable_skipped/fix_emittable_skipped.js @@ -0,0 +1,7 @@ +/// + +import "./polyfill.ts"; + +export const a = "a"; + +console.log(globalThis.polyfill); diff --git a/tests/testdata/run/fix_emittable_skipped.ts.out b/tests/specs/run/fix_emittable_skipped/fix_emittable_skipped.ts.out similarity index 100% rename from tests/testdata/run/fix_emittable_skipped.ts.out rename to tests/specs/run/fix_emittable_skipped/fix_emittable_skipped.ts.out diff --git a/tests/specs/run/fix_emittable_skipped/polyfill.ts b/tests/specs/run/fix_emittable_skipped/polyfill.ts new file mode 100644 index 0000000000..7af67c4c03 --- /dev/null +++ b/tests/specs/run/fix_emittable_skipped/polyfill.ts @@ -0,0 +1,8 @@ +declare global { + const polyfill: () => void; +} + +// deno-lint-ignore no-explicit-any +(globalThis as any).polyfill = () => { + console.log("polyfill"); +}; diff --git a/tests/specs/run/fix_js_import_js/__test__.jsonc b/tests/specs/run/fix_js_import_js/__test__.jsonc new file mode 100644 index 0000000000..94b1df540a --- /dev/null +++ b/tests/specs/run/fix_js_import_js/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload fix_js_import_js.ts", + "output": "fix_js_import_js.ts.out" +} diff --git a/tests/specs/run/fix_js_import_js/fix_js_import_js.ts b/tests/specs/run/fix_js_import_js/fix_js_import_js.ts new file mode 100644 index 0000000000..4862f03e10 --- /dev/null +++ b/tests/specs/run/fix_js_import_js/fix_js_import_js.ts @@ -0,0 +1,3 @@ +import { isMod4 } from "./mod6.js"; + +console.log(isMod4); diff --git a/tests/testdata/run/fix_js_import_js.ts.out b/tests/specs/run/fix_js_import_js/fix_js_import_js.ts.out similarity index 100% rename from tests/testdata/run/fix_js_import_js.ts.out rename to tests/specs/run/fix_js_import_js/fix_js_import_js.ts.out diff --git a/tests/specs/run/fix_js_import_js/mod4.js b/tests/specs/run/fix_js_import_js/mod4.js new file mode 100644 index 0000000000..71332dbc42 --- /dev/null +++ b/tests/specs/run/fix_js_import_js/mod4.js @@ -0,0 +1 @@ +export const isMod4 = true; diff --git a/tests/specs/run/fix_js_import_js/mod6.js b/tests/specs/run/fix_js_import_js/mod6.js new file mode 100644 index 0000000000..5e17c9ee02 --- /dev/null +++ b/tests/specs/run/fix_js_import_js/mod6.js @@ -0,0 +1 @@ +export { isMod4 } from "./mod4.js"; diff --git a/tests/specs/run/fix_js_imports/__test__.jsonc b/tests/specs/run/fix_js_imports/__test__.jsonc new file mode 100644 index 0000000000..a3635d18c9 --- /dev/null +++ b/tests/specs/run/fix_js_imports/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload fix_js_imports.ts", + "output": "fix_js_imports.ts.out" +} diff --git a/tests/specs/run/fix_js_imports/amd_like.js b/tests/specs/run/fix_js_imports/amd_like.js new file mode 100644 index 0000000000..f27e505e4a --- /dev/null +++ b/tests/specs/run/fix_js_imports/amd_like.js @@ -0,0 +1,3 @@ +// looks like an AMD module, but isn't +const define = () => {}; +define(["fake_module"], () => {}); diff --git a/tests/specs/run/fix_js_imports/fix_js_imports.ts b/tests/specs/run/fix_js_imports/fix_js_imports.ts new file mode 100644 index 0000000000..07e68a1356 --- /dev/null +++ b/tests/specs/run/fix_js_imports/fix_js_imports.ts @@ -0,0 +1,3 @@ +import * as amdLike from "./amd_like.js"; + +console.log(amdLike); diff --git a/tests/testdata/run/fix_js_imports.ts.out b/tests/specs/run/fix_js_imports/fix_js_imports.ts.out similarity index 100% rename from tests/testdata/run/fix_js_imports.ts.out rename to tests/specs/run/fix_js_imports/fix_js_imports.ts.out diff --git a/tests/specs/run/fix_tsc_file_exists/__test__.jsonc b/tests/specs/run/fix_tsc_file_exists/__test__.jsonc new file mode 100644 index 0000000000..d2b0bda29f --- /dev/null +++ b/tests/specs/run/fix_tsc_file_exists/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload tsc/test.js", + "output": "fix_tsc_file_exists.out" +} diff --git a/tests/testdata/run/fix_tsc_file_exists.out b/tests/specs/run/fix_tsc_file_exists/fix_tsc_file_exists.out similarity index 100% rename from tests/testdata/run/fix_tsc_file_exists.out rename to tests/specs/run/fix_tsc_file_exists/fix_tsc_file_exists.out diff --git a/tests/specs/run/fix_tsc_file_exists/tsc/a.js b/tests/specs/run/fix_tsc_file_exists/tsc/a.js new file mode 100644 index 0000000000..5a7b3ff93c --- /dev/null +++ b/tests/specs/run/fix_tsc_file_exists/tsc/a.js @@ -0,0 +1,2 @@ +import { v4 } from "./d.ts"; +export function a() {} diff --git a/tests/specs/run/fix_tsc_file_exists/tsc/d.ts b/tests/specs/run/fix_tsc_file_exists/tsc/d.ts new file mode 100644 index 0000000000..3c74b8c836 --- /dev/null +++ b/tests/specs/run/fix_tsc_file_exists/tsc/d.ts @@ -0,0 +1,3 @@ +export function v4() { + return "hello"; +} diff --git a/tests/specs/run/fix_tsc_file_exists/tsc/node_modules/b.js b/tests/specs/run/fix_tsc_file_exists/tsc/node_modules/b.js new file mode 100644 index 0000000000..1916609355 --- /dev/null +++ b/tests/specs/run/fix_tsc_file_exists/tsc/node_modules/b.js @@ -0,0 +1,2 @@ +import c from "./c.js"; +export { c }; diff --git a/tests/specs/run/fix_tsc_file_exists/tsc/node_modules/c.js b/tests/specs/run/fix_tsc_file_exists/tsc/node_modules/c.js new file mode 100644 index 0000000000..cff71c44a0 --- /dev/null +++ b/tests/specs/run/fix_tsc_file_exists/tsc/node_modules/c.js @@ -0,0 +1 @@ +export default function c() {} diff --git a/tests/specs/run/fix_tsc_file_exists/tsc/test.js b/tests/specs/run/fix_tsc_file_exists/tsc/test.js new file mode 100644 index 0000000000..b7f46b351f --- /dev/null +++ b/tests/specs/run/fix_tsc_file_exists/tsc/test.js @@ -0,0 +1,4 @@ +import { a } from "./a.js"; +import { c } from "./node_modules/b.js"; + +console.log("hello"); diff --git a/tests/specs/run/fix_worker_dispatchevent/__test__.jsonc b/tests/specs/run/fix_worker_dispatchevent/__test__.jsonc new file mode 100644 index 0000000000..45e49b87f9 --- /dev/null +++ b/tests/specs/run/fix_worker_dispatchevent/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload fix_worker_dispatchevent.ts", + "output": "fix_worker_dispatchevent.ts.out" +} diff --git a/tests/testdata/run/fix_worker_dispatchevent.ts b/tests/specs/run/fix_worker_dispatchevent/fix_worker_dispatchevent.ts similarity index 100% rename from tests/testdata/run/fix_worker_dispatchevent.ts rename to tests/specs/run/fix_worker_dispatchevent/fix_worker_dispatchevent.ts diff --git a/tests/testdata/run/fix_worker_dispatchevent.ts.out b/tests/specs/run/fix_worker_dispatchevent/fix_worker_dispatchevent.ts.out similarity index 100% rename from tests/testdata/run/fix_worker_dispatchevent.ts.out rename to tests/specs/run/fix_worker_dispatchevent/fix_worker_dispatchevent.ts.out diff --git a/tests/specs/run/followup_dyn_import_resolved/__test__.jsonc b/tests/specs/run/followup_dyn_import_resolved/__test__.jsonc new file mode 100644 index 0000000000..b94e3d8c91 --- /dev/null +++ b/tests/specs/run/followup_dyn_import_resolved/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read followup_dyn_import_resolves/main.ts", + "output": "followup_dyn_import_resolves/main.ts.out" +} diff --git a/tests/testdata/run/followup_dyn_import_resolves/main.ts b/tests/specs/run/followup_dyn_import_resolved/followup_dyn_import_resolves/main.ts similarity index 100% rename from tests/testdata/run/followup_dyn_import_resolves/main.ts rename to tests/specs/run/followup_dyn_import_resolved/followup_dyn_import_resolves/main.ts diff --git a/tests/testdata/run/followup_dyn_import_resolves/main.ts.out b/tests/specs/run/followup_dyn_import_resolved/followup_dyn_import_resolves/main.ts.out similarity index 100% rename from tests/testdata/run/followup_dyn_import_resolves/main.ts.out rename to tests/specs/run/followup_dyn_import_resolved/followup_dyn_import_resolves/main.ts.out diff --git a/tests/specs/run/followup_dyn_import_resolved/followup_dyn_import_resolves/sub1.ts b/tests/specs/run/followup_dyn_import_resolved/followup_dyn_import_resolves/sub1.ts new file mode 100644 index 0000000000..d06c30221b --- /dev/null +++ b/tests/specs/run/followup_dyn_import_resolved/followup_dyn_import_resolves/sub1.ts @@ -0,0 +1,2 @@ +await import("./sub2.ts"); +console.log("sub1"); diff --git a/tests/specs/run/followup_dyn_import_resolved/followup_dyn_import_resolves/sub2.ts b/tests/specs/run/followup_dyn_import_resolved/followup_dyn_import_resolves/sub2.ts new file mode 100644 index 0000000000..cce2b524cd --- /dev/null +++ b/tests/specs/run/followup_dyn_import_resolved/followup_dyn_import_resolves/sub2.ts @@ -0,0 +1 @@ +console.log("sub2"); diff --git a/tests/specs/run/heapstats/__test__.jsonc b/tests/specs/run/heapstats/__test__.jsonc new file mode 100644 index 0000000000..6429d7cf5f --- /dev/null +++ b/tests/specs/run/heapstats/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --v8-flags=--expose-gc heapstats.js", + "output": "heapstats.js.out" +} diff --git a/tests/testdata/run/heapstats.js b/tests/specs/run/heapstats/heapstats.js similarity index 100% rename from tests/testdata/run/heapstats.js rename to tests/specs/run/heapstats/heapstats.js diff --git a/tests/testdata/run/heapstats.js.out b/tests/specs/run/heapstats/heapstats.js.out similarity index 100% rename from tests/testdata/run/heapstats.js.out rename to tests/specs/run/heapstats/heapstats.js.out diff --git a/tests/specs/run/https_import/RootCA.pem b/tests/specs/run/https_import/RootCA.pem new file mode 100644 index 0000000000..c2f84ceebc --- /dev/null +++ b/tests/specs/run/https_import/RootCA.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDIzCCAgugAwIBAgIJAMKPPW4tsOymMA0GCSqGSIb3DQEBCwUAMCcxCzAJBgNV +BAYTAlVTMRgwFgYDVQQDDA9FeGFtcGxlLVJvb3QtQ0EwIBcNMTkxMDIxMTYyODIy +WhgPMjExODA5MjcxNjI4MjJaMCcxCzAJBgNVBAYTAlVTMRgwFgYDVQQDDA9FeGFt +cGxlLVJvb3QtQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDMH/IO +2qtHfyBKwANNPB4K0q5JVSg8XxZdRpTTlz0CwU0oRO3uHrI52raCCfVeiQutyZop +eFZTDWeXGudGAFA2B5m3orWt0s+touPi8MzjsG2TQ+WSI66QgbXTNDitDDBtTVcV +5G3Ic+3SppQAYiHSekLISnYWgXLl+k5CnEfTowg6cjqjVr0KjL03cTN3H7b+6+0S +ws4rYbW1j4ExR7K6BFNH6572yq5qR20E6GqlY+EcOZpw4CbCk9lS8/CWuXze/vMs +OfDcc6K+B625d27wyEGZHedBomT2vAD7sBjvO8hn/DP1Qb46a8uCHR6NSfnJ7bXO +G1igaIbgY1zXirNdAgMBAAGjUDBOMB0GA1UdDgQWBBTzut+pwwDfqmMYcI9KNWRD +hxcIpTAfBgNVHSMEGDAWgBTzut+pwwDfqmMYcI9KNWRDhxcIpTAMBgNVHRMEBTAD +AQH/MA0GCSqGSIb3DQEBCwUAA4IBAQB9AqSbZ+hEglAgSHxAMCqRFdhVu7MvaQM0 +P090mhGlOCt3yB7kdGfsIrUW6nQcTz7PPQFRaJMrFHPvFvPootkBUpTYR4hTkdce +H6RCRu2Jxl4Y9bY/uezd9YhGCYfUtfjA6/TH9FcuZfttmOOlxOt01XfNvVMIR6RM +z/AYhd+DeOXjr35F/VHeVpnk+55L0PYJsm1CdEbOs5Hy1ecR7ACuDkXnbM4fpz9I +kyIWJwk2zJReKcJMgi1aIinDM9ao/dca1G99PHOw8dnr4oyoTiv8ao6PWiSRHHMi +MNf4EgWfK+tZMnuqfpfO9740KzfcVoMNo4QJD4yn5YxroUOO/Azi +-----END CERTIFICATE----- diff --git a/tests/specs/run/https_import/__test__.jsonc b/tests/specs/run/https_import/__test__.jsonc new file mode 100644 index 0000000000..9a37230f27 --- /dev/null +++ b/tests/specs/run/https_import/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --quiet --reload --cert RootCA.pem https_import.ts", + "output": "https_import.ts.out" +} diff --git a/tests/specs/run/https_import/https_import.ts b/tests/specs/run/https_import/https_import.ts new file mode 100644 index 0000000000..d392f4a5d1 --- /dev/null +++ b/tests/specs/run/https_import/https_import.ts @@ -0,0 +1,3 @@ +import { printHello } from "./print_hello.ts"; + +printHello(); diff --git a/tests/testdata/run/import_data_url_imports.ts.out b/tests/specs/run/https_import/https_import.ts.out similarity index 100% rename from tests/testdata/run/import_data_url_imports.ts.out rename to tests/specs/run/https_import/https_import.ts.out diff --git a/tests/specs/run/https_import/print_hello.ts b/tests/specs/run/https_import/print_hello.ts new file mode 100644 index 0000000000..b9c0ad5275 --- /dev/null +++ b/tests/specs/run/https_import/print_hello.ts @@ -0,0 +1,3 @@ +export function printHello() { + console.log("Hello"); +} diff --git a/tests/specs/run/if_main/__test__.jsonc b/tests/specs/run/if_main/__test__.jsonc new file mode 100644 index 0000000000..f6e2dbf273 --- /dev/null +++ b/tests/specs/run/if_main/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload if_main.ts", + "output": "if_main.ts.out" +} diff --git a/tests/testdata/run/if_main.ts b/tests/specs/run/if_main/if_main.ts similarity index 100% rename from tests/testdata/run/if_main.ts rename to tests/specs/run/if_main/if_main.ts diff --git a/tests/specs/run/if_main/if_main.ts.out b/tests/specs/run/if_main/if_main.ts.out new file mode 100644 index 0000000000..ba2906d066 --- /dev/null +++ b/tests/specs/run/if_main/if_main.ts.out @@ -0,0 +1 @@ +main diff --git a/tests/specs/run/import_attributes_dynamic_error/__test__.jsonc b/tests/specs/run/import_attributes_dynamic_error/__test__.jsonc new file mode 100644 index 0000000000..0a6137a2b5 --- /dev/null +++ b/tests/specs/run/import_attributes_dynamic_error/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --allow-read dynamic_error.ts", + "output": "dynamic_error.out", + "exitCode": 1 +} diff --git a/tests/specs/run/import_attributes_dynamic_error/data.json b/tests/specs/run/import_attributes_dynamic_error/data.json new file mode 100644 index 0000000000..37b3ee1e0a --- /dev/null +++ b/tests/specs/run/import_attributes_dynamic_error/data.json @@ -0,0 +1,6 @@ +{ + "a": "b", + "c": { + "d": 10 + } +} diff --git a/tests/specs/run/import_attributes_dynamic_error/dynamic_error.out b/tests/specs/run/import_attributes_dynamic_error/dynamic_error.out new file mode 100644 index 0000000000..24f29de72d --- /dev/null +++ b/tests/specs/run/import_attributes_dynamic_error/dynamic_error.out @@ -0,0 +1,4 @@ +error: Uncaught (in promise) TypeError: Attempted to load JSON module without specifying "type": "json" attribute in the import statement. +const data = await import("./data.json"); + ^ + at async [WILDCARD]dynamic_error.ts:1:14 diff --git a/tests/specs/run/import_attributes_dynamic_error/dynamic_error.ts b/tests/specs/run/import_attributes_dynamic_error/dynamic_error.ts new file mode 100644 index 0000000000..2d9c6757f6 --- /dev/null +++ b/tests/specs/run/import_attributes_dynamic_error/dynamic_error.ts @@ -0,0 +1,3 @@ +const data = await import("./data.json"); + +console.log(data); diff --git a/tests/specs/run/import_attributes_dynamic_import/__test__.jsonc b/tests/specs/run/import_attributes_dynamic_import/__test__.jsonc new file mode 100644 index 0000000000..75962e88db --- /dev/null +++ b/tests/specs/run/import_attributes_dynamic_import/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read --check dynamic_import.ts", + "output": "dynamic_import.out" +} diff --git a/tests/specs/run/import_attributes_dynamic_import/data.json b/tests/specs/run/import_attributes_dynamic_import/data.json new file mode 100644 index 0000000000..37b3ee1e0a --- /dev/null +++ b/tests/specs/run/import_attributes_dynamic_import/data.json @@ -0,0 +1,6 @@ +{ + "a": "b", + "c": { + "d": 10 + } +} diff --git a/tests/specs/run/import_attributes_dynamic_import/dynamic_import.out b/tests/specs/run/import_attributes_dynamic_import/dynamic_import.out new file mode 100644 index 0000000000..7a7b4c91fe --- /dev/null +++ b/tests/specs/run/import_attributes_dynamic_import/dynamic_import.out @@ -0,0 +1,2 @@ +[WILDCARD] +[Module: null prototype] { default: { a: "b", c: { d: 10 } } } diff --git a/tests/specs/run/import_attributes_dynamic_import/dynamic_import.ts b/tests/specs/run/import_attributes_dynamic_import/dynamic_import.ts new file mode 100644 index 0000000000..093136fb07 --- /dev/null +++ b/tests/specs/run/import_attributes_dynamic_import/dynamic_import.ts @@ -0,0 +1,3 @@ +const data1 = await import("./data.json", { with: { type: "json" } }); + +console.log(data1); diff --git a/tests/specs/run/import_attributes_static_error/__test__.jsonc b/tests/specs/run/import_attributes_static_error/__test__.jsonc new file mode 100644 index 0000000000..2d08c66d35 --- /dev/null +++ b/tests/specs/run/import_attributes_static_error/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --allow-read static_error.ts", + "output": "static_error.out", + "exitCode": 1 +} diff --git a/tests/specs/run/import_attributes_static_error/data.json b/tests/specs/run/import_attributes_static_error/data.json new file mode 100644 index 0000000000..37b3ee1e0a --- /dev/null +++ b/tests/specs/run/import_attributes_static_error/data.json @@ -0,0 +1,6 @@ +{ + "a": "b", + "c": { + "d": 10 + } +} diff --git a/tests/specs/run/import_attributes_static_error/static_error.out b/tests/specs/run/import_attributes_static_error/static_error.out new file mode 100644 index 0000000000..29b24b965a --- /dev/null +++ b/tests/specs/run/import_attributes_static_error/static_error.out @@ -0,0 +1,3 @@ +error: Expected a JavaScript or TypeScript module, but identified a Json module. Consider importing Json modules with an import attribute with the type of "json". + Specifier: [WILDCARD]/data.json + at [WILDCARD]static_error.ts:1:18 diff --git a/tests/specs/run/import_attributes_static_error/static_error.ts b/tests/specs/run/import_attributes_static_error/static_error.ts new file mode 100644 index 0000000000..0bc3a93f88 --- /dev/null +++ b/tests/specs/run/import_attributes_static_error/static_error.ts @@ -0,0 +1,3 @@ +import data from "./data.json"; + +console.log(data); diff --git a/tests/specs/run/import_attributes_static_export/__test__.jsonc b/tests/specs/run/import_attributes_static_export/__test__.jsonc new file mode 100644 index 0000000000..05a64aab53 --- /dev/null +++ b/tests/specs/run/import_attributes_static_export/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read static_export.ts", + "output": "static_export.out" +} diff --git a/tests/specs/run/import_attributes_static_export/data.json b/tests/specs/run/import_attributes_static_export/data.json new file mode 100644 index 0000000000..37b3ee1e0a --- /dev/null +++ b/tests/specs/run/import_attributes_static_export/data.json @@ -0,0 +1,6 @@ +{ + "a": "b", + "c": { + "d": 10 + } +} diff --git a/tests/specs/run/import_attributes_static_export/static_export.out b/tests/specs/run/import_attributes_static_export/static_export.out new file mode 100644 index 0000000000..41af79d7c8 --- /dev/null +++ b/tests/specs/run/import_attributes_static_export/static_export.out @@ -0,0 +1 @@ +{ a: "b", c: { d: 10 } } diff --git a/tests/specs/run/import_attributes_static_export/static_export.ts b/tests/specs/run/import_attributes_static_export/static_export.ts new file mode 100644 index 0000000000..ac3ee694f5 --- /dev/null +++ b/tests/specs/run/import_attributes_static_export/static_export.ts @@ -0,0 +1,3 @@ +import data from "./static_reexport.ts"; + +console.log(data); diff --git a/tests/specs/run/import_attributes_static_export/static_reexport.ts b/tests/specs/run/import_attributes_static_export/static_reexport.ts new file mode 100644 index 0000000000..e6175691c6 --- /dev/null +++ b/tests/specs/run/import_attributes_static_export/static_reexport.ts @@ -0,0 +1 @@ +export { default } from "./data.json" with { type: "json" }; diff --git a/tests/specs/run/import_attributes_static_import/__test__.jsonc b/tests/specs/run/import_attributes_static_import/__test__.jsonc new file mode 100644 index 0000000000..4ea39e6d32 --- /dev/null +++ b/tests/specs/run/import_attributes_static_import/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read static_import.ts", + "output": "static_import.out" +} diff --git a/tests/specs/run/import_attributes_static_import/data.json b/tests/specs/run/import_attributes_static_import/data.json new file mode 100644 index 0000000000..37b3ee1e0a --- /dev/null +++ b/tests/specs/run/import_attributes_static_import/data.json @@ -0,0 +1,6 @@ +{ + "a": "b", + "c": { + "d": 10 + } +} diff --git a/tests/specs/run/import_attributes_static_import/static_import.out b/tests/specs/run/import_attributes_static_import/static_import.out new file mode 100644 index 0000000000..e57dffa992 --- /dev/null +++ b/tests/specs/run/import_attributes_static_import/static_import.out @@ -0,0 +1,2 @@ +{ a: "b", c: { d: 10 } } +{ a: "b", c: { d: 10 } } diff --git a/tests/specs/run/import_attributes_static_import/static_import.ts b/tests/specs/run/import_attributes_static_import/static_import.ts new file mode 100644 index 0000000000..f585b893f3 --- /dev/null +++ b/tests/specs/run/import_attributes_static_import/static_import.ts @@ -0,0 +1,5 @@ +import data1 from "./data.json" with { type: "json" }; +import data2 from "./data.json" with { type: "json" }; + +console.log(data1); +console.log(data2); diff --git a/tests/specs/run/import_attributes_type_check/__test__.jsonc b/tests/specs/run/import_attributes_type_check/__test__.jsonc new file mode 100644 index 0000000000..89f6e0a79e --- /dev/null +++ b/tests/specs/run/import_attributes_type_check/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --allow-read --check type_check.ts", + "output": "type_check.out", + "exitCode": 1 +} diff --git a/tests/specs/run/import_attributes_type_check/data.json b/tests/specs/run/import_attributes_type_check/data.json new file mode 100644 index 0000000000..37b3ee1e0a --- /dev/null +++ b/tests/specs/run/import_attributes_type_check/data.json @@ -0,0 +1,6 @@ +{ + "a": "b", + "c": { + "d": 10 + } +} diff --git a/tests/specs/run/import_attributes_type_check/type_check.out b/tests/specs/run/import_attributes_type_check/type_check.out new file mode 100644 index 0000000000..2fc26dae36 --- /dev/null +++ b/tests/specs/run/import_attributes_type_check/type_check.out @@ -0,0 +1,12 @@ +Check file:///[WILDCARD]/type_check.ts +error: TS2339 [ERROR]: Property 'foo' does not exist on type '{ a: string; c: { d: number; }; }'. +console.log(data1.foo); + ~~~ + at [WILDCARD]type_check.ts:5:19 + +TS2339 [ERROR]: Property 'foo' does not exist on type '{ a: string; c: { d: number; }; }'. +console.log(data2.foo); + ~~~ + at [WILDCARD]type_check.ts:6:19 + +Found 2 errors. diff --git a/tests/specs/run/import_attributes_type_check/type_check.ts b/tests/specs/run/import_attributes_type_check/type_check.ts new file mode 100644 index 0000000000..36e47bd5b8 --- /dev/null +++ b/tests/specs/run/import_attributes_type_check/type_check.ts @@ -0,0 +1,6 @@ +import data1 from "./data.json" with { type: "json" }; +// deno-lint-ignore no-import-assertions +import data2 from "./data.json" assert { type: "json" }; + +console.log(data1.foo); +console.log(data2.foo); diff --git a/tests/specs/run/import_blob_url/__test__.jsonc b/tests/specs/run/import_blob_url/__test__.jsonc new file mode 100644 index 0000000000..9ae6b5a423 --- /dev/null +++ b/tests/specs/run/import_blob_url/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload import_blob_url.ts", + "output": "import_blob_url.ts.out" +} diff --git a/tests/testdata/run/import_blob_url.ts b/tests/specs/run/import_blob_url/import_blob_url.ts similarity index 100% rename from tests/testdata/run/import_blob_url.ts rename to tests/specs/run/import_blob_url/import_blob_url.ts diff --git a/tests/testdata/run/import_blob_url.ts.out b/tests/specs/run/import_blob_url/import_blob_url.ts.out similarity index 100% rename from tests/testdata/run/import_blob_url.ts.out rename to tests/specs/run/import_blob_url/import_blob_url.ts.out diff --git a/tests/specs/run/import_blob_url_error_stack/__test__.jsonc b/tests/specs/run/import_blob_url_error_stack/__test__.jsonc new file mode 100644 index 0000000000..56a1489cd7 --- /dev/null +++ b/tests/specs/run/import_blob_url_error_stack/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --reload import_blob_url_error_stack.ts", + "output": "import_blob_url_error_stack.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/import_blob_url_error_stack.ts b/tests/specs/run/import_blob_url_error_stack/import_blob_url_error_stack.ts similarity index 100% rename from tests/testdata/run/import_blob_url_error_stack.ts rename to tests/specs/run/import_blob_url_error_stack/import_blob_url_error_stack.ts diff --git a/tests/testdata/run/import_blob_url_error_stack.ts.out b/tests/specs/run/import_blob_url_error_stack/import_blob_url_error_stack.ts.out similarity index 100% rename from tests/testdata/run/import_blob_url_error_stack.ts.out rename to tests/specs/run/import_blob_url_error_stack/import_blob_url_error_stack.ts.out diff --git a/tests/specs/run/import_blob_url_import_relative/__test__.jsonc b/tests/specs/run/import_blob_url_import_relative/__test__.jsonc new file mode 100644 index 0000000000..4fda81b311 --- /dev/null +++ b/tests/specs/run/import_blob_url_import_relative/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --reload import_blob_url_import_relative.ts", + "output": "import_blob_url_import_relative.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/import_blob_url_import_relative.ts b/tests/specs/run/import_blob_url_import_relative/import_blob_url_import_relative.ts similarity index 100% rename from tests/testdata/run/import_blob_url_import_relative.ts rename to tests/specs/run/import_blob_url_import_relative/import_blob_url_import_relative.ts diff --git a/tests/testdata/run/import_blob_url_import_relative.ts.out b/tests/specs/run/import_blob_url_import_relative/import_blob_url_import_relative.ts.out similarity index 100% rename from tests/testdata/run/import_blob_url_import_relative.ts.out rename to tests/specs/run/import_blob_url_import_relative/import_blob_url_import_relative.ts.out diff --git a/tests/specs/run/import_blob_url_imports/__test__.jsonc b/tests/specs/run/import_blob_url_imports/__test__.jsonc new file mode 100644 index 0000000000..511d22a593 --- /dev/null +++ b/tests/specs/run/import_blob_url_imports/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --quiet --reload --allow-net=localhost:4545 import_blob_url_imports.ts", + "output": "import_blob_url_imports.ts.out" +} diff --git a/tests/testdata/run/import_blob_url_imports.ts b/tests/specs/run/import_blob_url_imports/import_blob_url_imports.ts similarity index 100% rename from tests/testdata/run/import_blob_url_imports.ts rename to tests/specs/run/import_blob_url_imports/import_blob_url_imports.ts diff --git a/tests/testdata/run/import_extensionless.ts.out b/tests/specs/run/import_blob_url_imports/import_blob_url_imports.ts.out similarity index 100% rename from tests/testdata/run/import_extensionless.ts.out rename to tests/specs/run/import_blob_url_imports/import_blob_url_imports.ts.out diff --git a/tests/specs/run/import_blob_url_jsx/__test__.jsonc b/tests/specs/run/import_blob_url_jsx/__test__.jsonc new file mode 100644 index 0000000000..985c6f8421 --- /dev/null +++ b/tests/specs/run/import_blob_url_jsx/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload import_blob_url_jsx.ts", + "output": "import_blob_url_jsx.ts.out" +} diff --git a/tests/testdata/run/import_blob_url_jsx.ts b/tests/specs/run/import_blob_url_jsx/import_blob_url_jsx.ts similarity index 100% rename from tests/testdata/run/import_blob_url_jsx.ts rename to tests/specs/run/import_blob_url_jsx/import_blob_url_jsx.ts diff --git a/tests/testdata/run/import_blob_url_jsx.ts.out b/tests/specs/run/import_blob_url_jsx/import_blob_url_jsx.ts.out similarity index 100% rename from tests/testdata/run/import_blob_url_jsx.ts.out rename to tests/specs/run/import_blob_url_jsx/import_blob_url_jsx.ts.out diff --git a/tests/specs/run/import_compression/__test__.jsonc b/tests/specs/run/import_compression/__test__.jsonc new file mode 100644 index 0000000000..c8f7af9e1c --- /dev/null +++ b/tests/specs/run/import_compression/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --quiet --reload --allow-net import_compression/main.ts", + "output": "import_compression/main.out" +} diff --git a/tests/specs/run/import_compression/import_compression/brotli b/tests/specs/run/import_compression/import_compression/brotli new file mode 100644 index 0000000000..65f679d571 --- /dev/null +++ b/tests/specs/run/import_compression/import_compression/brotli @@ -0,0 +1,2 @@ + +console.log('brotli'); \ No newline at end of file diff --git a/tests/specs/run/import_compression/import_compression/gziped b/tests/specs/run/import_compression/import_compression/gziped new file mode 100644 index 0000000000000000000000000000000000000000..9f9a7bc690b13f0c181a00031193b0302e9dda5a GIT binary patch literal 39 scmb2|=3oE;mjB-8&TF4L?|Jp~N&o8s{_9Wa1YBofSR`}vwlGi{048-0G5`Po literal 0 HcmV?d00001 diff --git a/tests/testdata/run/import_compression/main.out b/tests/specs/run/import_compression/import_compression/main.out similarity index 100% rename from tests/testdata/run/import_compression/main.out rename to tests/specs/run/import_compression/import_compression/main.out diff --git a/tests/testdata/run/import_compression/main.ts b/tests/specs/run/import_compression/import_compression/main.ts similarity index 100% rename from tests/testdata/run/import_compression/main.ts rename to tests/specs/run/import_compression/import_compression/main.ts diff --git a/tests/specs/run/import_data_url/__test__.jsonc b/tests/specs/run/import_data_url/__test__.jsonc new file mode 100644 index 0000000000..95d1c94a34 --- /dev/null +++ b/tests/specs/run/import_data_url/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload import_data_url.ts", + "output": "import_data_url.ts.out" +} diff --git a/tests/testdata/run/import_data_url.ts b/tests/specs/run/import_data_url/import_data_url.ts similarity index 100% rename from tests/testdata/run/import_data_url.ts rename to tests/specs/run/import_data_url/import_data_url.ts diff --git a/tests/testdata/run/import_data_url.ts.out b/tests/specs/run/import_data_url/import_data_url.ts.out similarity index 100% rename from tests/testdata/run/import_data_url.ts.out rename to tests/specs/run/import_data_url/import_data_url.ts.out diff --git a/tests/specs/run/import_data_url_error_stack/__test__.jsonc b/tests/specs/run/import_data_url_error_stack/__test__.jsonc new file mode 100644 index 0000000000..851aae191d --- /dev/null +++ b/tests/specs/run/import_data_url_error_stack/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --reload import_data_url_error_stack.ts", + "output": "import_data_url_error_stack.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/import_data_url_error_stack.ts b/tests/specs/run/import_data_url_error_stack/import_data_url_error_stack.ts similarity index 100% rename from tests/testdata/run/import_data_url_error_stack.ts rename to tests/specs/run/import_data_url_error_stack/import_data_url_error_stack.ts diff --git a/tests/testdata/run/import_data_url_error_stack.ts.out b/tests/specs/run/import_data_url_error_stack/import_data_url_error_stack.ts.out similarity index 100% rename from tests/testdata/run/import_data_url_error_stack.ts.out rename to tests/specs/run/import_data_url_error_stack/import_data_url_error_stack.ts.out diff --git a/tests/specs/run/import_data_url_import_relative/__test__.jsonc b/tests/specs/run/import_data_url_import_relative/__test__.jsonc new file mode 100644 index 0000000000..b241bc917c --- /dev/null +++ b/tests/specs/run/import_data_url_import_relative/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --reload import_data_url_import_relative.ts", + "output": "import_data_url_import_relative.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/import_data_url_import_relative.ts b/tests/specs/run/import_data_url_import_relative/import_data_url_import_relative.ts similarity index 100% rename from tests/testdata/run/import_data_url_import_relative.ts rename to tests/specs/run/import_data_url_import_relative/import_data_url_import_relative.ts diff --git a/tests/testdata/run/import_data_url_import_relative.ts.out b/tests/specs/run/import_data_url_import_relative/import_data_url_import_relative.ts.out similarity index 100% rename from tests/testdata/run/import_data_url_import_relative.ts.out rename to tests/specs/run/import_data_url_import_relative/import_data_url_import_relative.ts.out diff --git a/tests/specs/run/import_data_url_imports/__test__.jsonc b/tests/specs/run/import_data_url_imports/__test__.jsonc new file mode 100644 index 0000000000..7fc8df315c --- /dev/null +++ b/tests/specs/run/import_data_url_imports/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --quiet --reload import_data_url_imports.ts", + "output": "import_data_url_imports.ts.out" +} diff --git a/tests/testdata/run/import_data_url_imports.ts b/tests/specs/run/import_data_url_imports/import_data_url_imports.ts similarity index 100% rename from tests/testdata/run/import_data_url_imports.ts rename to tests/specs/run/import_data_url_imports/import_data_url_imports.ts diff --git a/tests/testdata/run/issue13562.ts.out b/tests/specs/run/import_data_url_imports/import_data_url_imports.ts.out similarity index 100% rename from tests/testdata/run/issue13562.ts.out rename to tests/specs/run/import_data_url_imports/import_data_url_imports.ts.out diff --git a/tests/specs/run/import_data_url_jsx/__test__.jsonc b/tests/specs/run/import_data_url_jsx/__test__.jsonc new file mode 100644 index 0000000000..8fb1f9a1d9 --- /dev/null +++ b/tests/specs/run/import_data_url_jsx/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload import_data_url_jsx.ts", + "output": "import_data_url_jsx.ts.out" +} diff --git a/tests/testdata/run/import_data_url_jsx.ts b/tests/specs/run/import_data_url_jsx/import_data_url_jsx.ts similarity index 100% rename from tests/testdata/run/import_data_url_jsx.ts rename to tests/specs/run/import_data_url_jsx/import_data_url_jsx.ts diff --git a/tests/testdata/run/import_data_url_jsx.ts.out b/tests/specs/run/import_data_url_jsx/import_data_url_jsx.ts.out similarity index 100% rename from tests/testdata/run/import_data_url_jsx.ts.out rename to tests/specs/run/import_data_url_jsx/import_data_url_jsx.ts.out diff --git a/tests/specs/run/import_dynamic_data_url/__test__.jsonc b/tests/specs/run/import_dynamic_data_url/__test__.jsonc new file mode 100644 index 0000000000..09ff77f419 --- /dev/null +++ b/tests/specs/run/import_dynamic_data_url/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload import_dynamic_data_url.ts", + "output": "import_dynamic_data_url.ts.out" +} diff --git a/tests/testdata/run/import_dynamic_data_url.ts b/tests/specs/run/import_dynamic_data_url/import_dynamic_data_url.ts similarity index 100% rename from tests/testdata/run/import_dynamic_data_url.ts rename to tests/specs/run/import_dynamic_data_url/import_dynamic_data_url.ts diff --git a/tests/testdata/run/import_dynamic_data_url.ts.out b/tests/specs/run/import_dynamic_data_url/import_dynamic_data_url.ts.out similarity index 100% rename from tests/testdata/run/import_dynamic_data_url.ts.out rename to tests/specs/run/import_dynamic_data_url/import_dynamic_data_url.ts.out diff --git a/tests/specs/run/import_extensionless/__test__.jsonc b/tests/specs/run/import_extensionless/__test__.jsonc new file mode 100644 index 0000000000..cde59b5e22 --- /dev/null +++ b/tests/specs/run/import_extensionless/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --quiet --reload import_extensionless.ts", + "output": "import_extensionless.ts.out" +} diff --git a/tests/testdata/run/import_extensionless.ts b/tests/specs/run/import_extensionless/import_extensionless.ts similarity index 100% rename from tests/testdata/run/import_extensionless.ts rename to tests/specs/run/import_extensionless/import_extensionless.ts diff --git a/tests/specs/run/import_extensionless/import_extensionless.ts.out b/tests/specs/run/import_extensionless/import_extensionless.ts.out new file mode 100644 index 0000000000..e965047ad7 --- /dev/null +++ b/tests/specs/run/import_extensionless/import_extensionless.ts.out @@ -0,0 +1 @@ +Hello diff --git a/tests/specs/run/import_file_with_colon/__test__.jsonc b/tests/specs/run/import_file_with_colon/__test__.jsonc new file mode 100644 index 0000000000..5e6602ab3e --- /dev/null +++ b/tests/specs/run/import_file_with_colon/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --quiet --reload import_file_with_colon.ts", + "output": "import_file_with_colon.ts.out" +} diff --git a/tests/testdata/run/import_file_with_colon.ts b/tests/specs/run/import_file_with_colon/import_file_with_colon.ts similarity index 100% rename from tests/testdata/run/import_file_with_colon.ts rename to tests/specs/run/import_file_with_colon/import_file_with_colon.ts diff --git a/tests/testdata/run/import_file_with_colon.ts.out b/tests/specs/run/import_file_with_colon/import_file_with_colon.ts.out similarity index 100% rename from tests/testdata/run/import_file_with_colon.ts.out rename to tests/specs/run/import_file_with_colon/import_file_with_colon.ts.out diff --git a/tests/specs/run/import_type/__test__.jsonc b/tests/specs/run/import_type/__test__.jsonc new file mode 100644 index 0000000000..2958483d00 --- /dev/null +++ b/tests/specs/run/import_type/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload import_type.ts", + "output": "import_type.ts.out" +} diff --git a/tests/specs/run/import_type/export_types.ts b/tests/specs/run/import_type/export_types.ts new file mode 100644 index 0000000000..18c8ed8810 --- /dev/null +++ b/tests/specs/run/import_type/export_types.ts @@ -0,0 +1,11 @@ +export interface A { + a: string; +} + +export class B implements A { + a = "a"; +} + +export function create(): B { + return new B(); +} diff --git a/tests/specs/run/import_type/import_type.ts b/tests/specs/run/import_type/import_type.ts new file mode 100644 index 0000000000..91baba19aa --- /dev/null +++ b/tests/specs/run/import_type/import_type.ts @@ -0,0 +1,5 @@ +import { type B, create } from "./export_types.ts"; + +const b: B = create(); + +console.log(b); diff --git a/tests/testdata/run/import_type.ts.out b/tests/specs/run/import_type/import_type.ts.out similarity index 100% rename from tests/testdata/run/import_type.ts.out rename to tests/specs/run/import_type/import_type.ts.out diff --git a/tests/specs/run/import_type_no_check/__test__.jsonc b/tests/specs/run/import_type_no_check/__test__.jsonc new file mode 100644 index 0000000000..d858f5fa10 --- /dev/null +++ b/tests/specs/run/import_type_no_check/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --no-check import_type.ts", + "output": "import_type.ts.out" +} diff --git a/tests/specs/run/import_type_no_check/export_types.ts b/tests/specs/run/import_type_no_check/export_types.ts new file mode 100644 index 0000000000..18c8ed8810 --- /dev/null +++ b/tests/specs/run/import_type_no_check/export_types.ts @@ -0,0 +1,11 @@ +export interface A { + a: string; +} + +export class B implements A { + a = "a"; +} + +export function create(): B { + return new B(); +} diff --git a/tests/specs/run/import_type_no_check/import_type.ts b/tests/specs/run/import_type_no_check/import_type.ts new file mode 100644 index 0000000000..91baba19aa --- /dev/null +++ b/tests/specs/run/import_type_no_check/import_type.ts @@ -0,0 +1,5 @@ +import { type B, create } from "./export_types.ts"; + +const b: B = create(); + +console.log(b); diff --git a/tests/specs/run/import_type_no_check/import_type.ts.out b/tests/specs/run/import_type_no_check/import_type.ts.out new file mode 100644 index 0000000000..e35539e352 --- /dev/null +++ b/tests/specs/run/import_type_no_check/import_type.ts.out @@ -0,0 +1 @@ +B { a: "a" } diff --git a/tests/specs/run/inline_js_source_map_2/__test__.jsonc b/tests/specs/run/inline_js_source_map_2/__test__.jsonc new file mode 100644 index 0000000000..99ca6c1aed --- /dev/null +++ b/tests/specs/run/inline_js_source_map_2/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet inline_js_source_map_2.js", + "output": "inline_js_source_map_2.js.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/inline_js_source_map_2.js b/tests/specs/run/inline_js_source_map_2/inline_js_source_map_2.js similarity index 84% rename from tests/testdata/run/inline_js_source_map_2.js rename to tests/specs/run/inline_js_source_map_2/inline_js_source_map_2.js index d14d906b80..87132ee6a7 100644 --- a/tests/testdata/run/inline_js_source_map_2.js +++ b/tests/specs/run/inline_js_source_map_2/inline_js_source_map_2.js @@ -1,4 +1,4 @@ "use strict"; 1 + 1; throw new Error("Hello world!"); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaHR0cDovL2xvY2FsaG9zdDo0NTQ1L3J1bi9pbmxpbmVfanNfc291cmNlX21hcF8yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxDQUFDLEdBQUMsQ0FBQyxDQUFDO0FBS0osTUFBTSxJQUFJLEtBQUssQ0FBQyxjQUErQixDQUFDLENBQUMifQ== \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaHR0cDovL2xvY2FsaG9zdDo0NTQ1L3J1bi9pbmxpbmVfanNfc291cmNlX21hcF8yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxDQUFDLEdBQUMsQ0FBQyxDQUFDO0FBS0osTUFBTSxJQUFJLEtBQUssQ0FBQyxjQUErQixDQUFDLENBQUMifQ== diff --git a/tests/testdata/run/inline_js_source_map_2.js.out b/tests/specs/run/inline_js_source_map_2/inline_js_source_map_2.js.out similarity index 100% rename from tests/testdata/run/inline_js_source_map_2.js.out rename to tests/specs/run/inline_js_source_map_2/inline_js_source_map_2.js.out diff --git a/tests/specs/run/inline_js_source_map_2_with_inline_contents/__test__.jsonc b/tests/specs/run/inline_js_source_map_2_with_inline_contents/__test__.jsonc new file mode 100644 index 0000000000..45fe6eba6d --- /dev/null +++ b/tests/specs/run/inline_js_source_map_2_with_inline_contents/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet inline_js_source_map_2_with_inline_contents.js", + "output": "inline_js_source_map_2_with_inline_contents.js.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/inline_js_source_map_2_with_inline_contents.js b/tests/specs/run/inline_js_source_map_2_with_inline_contents/inline_js_source_map_2_with_inline_contents.js similarity index 93% rename from tests/testdata/run/inline_js_source_map_2_with_inline_contents.js rename to tests/specs/run/inline_js_source_map_2_with_inline_contents/inline_js_source_map_2_with_inline_contents.js index 7660cc229b..41bee7fe4d 100644 --- a/tests/testdata/run/inline_js_source_map_2_with_inline_contents.js +++ b/tests/specs/run/inline_js_source_map_2_with_inline_contents/inline_js_source_map_2_with_inline_contents.js @@ -1,4 +1,4 @@ "use strict"; throw new Error("Hello world!"); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaHR0cDovL2xvY2FsaG9zdDo0NTQ1L3J1bi9pbmxpbmVfanNfc291cmNlX21hcF8yLnRzIl0sInNvdXJjZXNDb250ZW50IjpbIjErMTtcbmludGVyZmFjZSBUZXN0IHtcbiAgaGVsbG86IHN0cmluZztcbn1cblxudGhyb3cgbmV3IEVycm9yKFwiSGVsbG8gd29ybGQhXCIgYXMgdW5rbm93biBhcyBzdHJpbmcpO1xuIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxDQUFDLEdBQUMsQ0FBQyxDQUFDO0FBS0osTUFBTSxJQUFJLEtBQUssQ0FBQyxjQUErQixDQUFDLENBQUMifQ== \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaHR0cDovL2xvY2FsaG9zdDo0NTQ1L3J1bi9pbmxpbmVfanNfc291cmNlX21hcF8yLnRzIl0sInNvdXJjZXNDb250ZW50IjpbIjErMTtcbmludGVyZmFjZSBUZXN0IHtcbiAgaGVsbG86IHN0cmluZztcbn1cblxudGhyb3cgbmV3IEVycm9yKFwiSGVsbG8gd29ybGQhXCIgYXMgdW5rbm93biBhcyBzdHJpbmcpO1xuIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxDQUFDLEdBQUMsQ0FBQyxDQUFDO0FBS0osTUFBTSxJQUFJLEtBQUssQ0FBQyxjQUErQixDQUFDLENBQUMifQ== diff --git a/tests/testdata/run/inline_js_source_map_2_with_inline_contents.js.out b/tests/specs/run/inline_js_source_map_2_with_inline_contents/inline_js_source_map_2_with_inline_contents.js.out similarity index 100% rename from tests/testdata/run/inline_js_source_map_2_with_inline_contents.js.out rename to tests/specs/run/inline_js_source_map_2_with_inline_contents/inline_js_source_map_2_with_inline_contents.js.out diff --git a/tests/specs/run/inline_js_source_map_with_contents_from_graph/__test__.jsonc b/tests/specs/run/inline_js_source_map_with_contents_from_graph/__test__.jsonc new file mode 100644 index 0000000000..71dc4d509d --- /dev/null +++ b/tests/specs/run/inline_js_source_map_with_contents_from_graph/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --allow-import --quiet inline_js_source_map_with_contents_from_graph.js", + "output": "inline_js_source_map_with_contents_from_graph.js.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/inline_js_source_map_with_contents_from_graph.js b/tests/specs/run/inline_js_source_map_with_contents_from_graph/inline_js_source_map_with_contents_from_graph.js similarity index 86% rename from tests/testdata/run/inline_js_source_map_with_contents_from_graph.js rename to tests/specs/run/inline_js_source_map_with_contents_from_graph/inline_js_source_map_with_contents_from_graph.js index 887f023209..12fa1644df 100644 --- a/tests/testdata/run/inline_js_source_map_with_contents_from_graph.js +++ b/tests/specs/run/inline_js_source_map_with_contents_from_graph/inline_js_source_map_with_contents_from_graph.js @@ -1,4 +1,4 @@ "use strict"; import "http://localhost:4545/run/inline_js_source_map.ts"; throw new Error("Hello world!"); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaHR0cDovL2xvY2FsaG9zdDo0NTQ1L3J1bi9pbmxpbmVfanNfc291cmNlX21hcC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsQ0FBQyxHQUFDLENBQUMsQ0FBQztBQUtKLE1BQU0sSUFBSSxLQUFLLENBQUMsY0FBK0IsQ0FBQyxDQUFDIn0= \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaHR0cDovL2xvY2FsaG9zdDo0NTQ1L3J1bi9pbmxpbmVfanNfc291cmNlX21hcC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsQ0FBQyxHQUFDLENBQUMsQ0FBQztBQUtKLE1BQU0sSUFBSSxLQUFLLENBQUMsY0FBK0IsQ0FBQyxDQUFDIn0= diff --git a/tests/testdata/run/inline_js_source_map_with_contents_from_graph.js.out b/tests/specs/run/inline_js_source_map_with_contents_from_graph/inline_js_source_map_with_contents_from_graph.js.out similarity index 100% rename from tests/testdata/run/inline_js_source_map_with_contents_from_graph.js.out rename to tests/specs/run/inline_js_source_map_with_contents_from_graph/inline_js_source_map_with_contents_from_graph.js.out diff --git a/tests/specs/run/issue_13562/__test__.jsonc b/tests/specs/run/issue_13562/__test__.jsonc new file mode 100644 index 0000000000..1971d552b6 --- /dev/null +++ b/tests/specs/run/issue_13562/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run issue13562.ts", + "output": "issue13562.ts.out" +} diff --git a/tests/specs/run/issue_13562/issue13562.ts b/tests/specs/run/issue_13562/issue13562.ts new file mode 100644 index 0000000000..51e97629b6 --- /dev/null +++ b/tests/specs/run/issue_13562/issue13562.ts @@ -0,0 +1,3 @@ +import { printHello3 } from "./mod1.ts?q=.json"; + +printHello3(); diff --git a/tests/specs/run/issue_13562/issue13562.ts.out b/tests/specs/run/issue_13562/issue13562.ts.out new file mode 100644 index 0000000000..e965047ad7 --- /dev/null +++ b/tests/specs/run/issue_13562/issue13562.ts.out @@ -0,0 +1 @@ +Hello diff --git a/tests/specs/run/issue_13562/mod1.ts b/tests/specs/run/issue_13562/mod1.ts new file mode 100644 index 0000000000..5e58f432ed --- /dev/null +++ b/tests/specs/run/issue_13562/mod1.ts @@ -0,0 +1,17 @@ +import { printHello2, returnsFoo } from "./subdir2/mod2.ts"; + +export function returnsHi(): string { + return "Hi"; +} + +export function returnsFoo2(): string { + return returnsFoo(); +} + +export function printHello3() { + printHello2(); +} + +export function throwsError() { + throw Error("exception from mod1"); +} diff --git a/tests/specs/run/issue_13562/print_hello.ts b/tests/specs/run/issue_13562/print_hello.ts new file mode 100644 index 0000000000..b9c0ad5275 --- /dev/null +++ b/tests/specs/run/issue_13562/print_hello.ts @@ -0,0 +1,3 @@ +export function printHello() { + console.log("Hello"); +} diff --git a/tests/specs/run/issue_13562/subdir2/dynamic_import.ts b/tests/specs/run/issue_13562/subdir2/dynamic_import.ts new file mode 100644 index 0000000000..59beb64c33 --- /dev/null +++ b/tests/specs/run/issue_13562/subdir2/dynamic_import.ts @@ -0,0 +1,4 @@ +(async () => { + const { printHello } = await import("../mod2.ts"); + printHello(); +})(); diff --git a/tests/specs/run/issue_13562/subdir2/mod2.ts b/tests/specs/run/issue_13562/subdir2/mod2.ts new file mode 100644 index 0000000000..9071d0aeb4 --- /dev/null +++ b/tests/specs/run/issue_13562/subdir2/mod2.ts @@ -0,0 +1,9 @@ +import { printHello } from "../print_hello.ts"; + +export function returnsFoo(): string { + return "Foo"; +} + +export function printHello2() { + printHello(); +} diff --git a/tests/specs/run/js_import_detect/__test__.jsonc b/tests/specs/run/js_import_detect/__test__.jsonc new file mode 100644 index 0000000000..6a648f4763 --- /dev/null +++ b/tests/specs/run/js_import_detect/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --reload js_import_detect.ts", + "output": "js_import_detect.ts.out", + "exitCode": 0 +} diff --git a/tests/testdata/run/js_import_detect.ts b/tests/specs/run/js_import_detect/js_import_detect.ts similarity index 100% rename from tests/testdata/run/js_import_detect.ts rename to tests/specs/run/js_import_detect/js_import_detect.ts diff --git a/tests/testdata/run/js_import_detect.ts.out b/tests/specs/run/js_import_detect/js_import_detect.ts.out similarity index 100% rename from tests/testdata/run/js_import_detect.ts.out rename to tests/specs/run/js_import_detect/js_import_detect.ts.out diff --git a/tests/specs/run/js_root_with_ts_check/__test__.jsonc b/tests/specs/run/js_root_with_ts_check/__test__.jsonc new file mode 100644 index 0000000000..ebc4d75987 --- /dev/null +++ b/tests/specs/run/js_root_with_ts_check/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --check js_root_with_ts_check.js", + "output": "js_root_with_ts_check.js.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/js_root_with_ts_check.js b/tests/specs/run/js_root_with_ts_check/js_root_with_ts_check.js similarity index 100% rename from tests/testdata/run/js_root_with_ts_check.js rename to tests/specs/run/js_root_with_ts_check/js_root_with_ts_check.js diff --git a/tests/testdata/run/js_root_with_ts_check.js.out b/tests/specs/run/js_root_with_ts_check/js_root_with_ts_check.js.out similarity index 100% rename from tests/testdata/run/js_root_with_ts_check.js.out rename to tests/specs/run/js_root_with_ts_check/js_root_with_ts_check.js.out diff --git a/tests/specs/run/js_without_extension/__test__.jsonc b/tests/specs/run/js_without_extension/__test__.jsonc new file mode 100644 index 0000000000..0d2aac73b4 --- /dev/null +++ b/tests/specs/run/js_without_extension/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --ext js --check js_without_extension", + "output": "js_without_extension.out", + "exitCode": 0 +} diff --git a/tests/specs/run/js_without_extension/js_without_extension b/tests/specs/run/js_without_extension/js_without_extension new file mode 100644 index 0000000000..4774be3263 --- /dev/null +++ b/tests/specs/run/js_without_extension/js_without_extension @@ -0,0 +1,3 @@ +let i = 123; +i = "hello" +console.log("executing javascript with no extension"); diff --git a/tests/specs/run/js_without_extension/js_without_extension.out b/tests/specs/run/js_without_extension/js_without_extension.out new file mode 100644 index 0000000000..1236c1e534 --- /dev/null +++ b/tests/specs/run/js_without_extension/js_without_extension.out @@ -0,0 +1 @@ +executing javascript with no extension diff --git a/tests/specs/run/jsx_import_from_ts/__test__.jsonc b/tests/specs/run/jsx_import_from_ts/__test__.jsonc new file mode 100644 index 0000000000..0f89205dc1 --- /dev/null +++ b/tests/specs/run/jsx_import_from_ts/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload jsx_import_from_ts.ts", + "output": "jsx_import_from_ts.ts.out" +} diff --git a/tests/specs/run/jsx_import_from_ts/jsx_import_from_ts.App.jsx b/tests/specs/run/jsx_import_from_ts/jsx_import_from_ts.App.jsx new file mode 100644 index 0000000000..649230613c --- /dev/null +++ b/tests/specs/run/jsx_import_from_ts/jsx_import_from_ts.App.jsx @@ -0,0 +1,11 @@ +const React = { + createElement() {}, +}; + +export default function app() { + return ( +

+

asdf

+
+ ); +} diff --git a/tests/testdata/run/jsx_import_from_ts.ts b/tests/specs/run/jsx_import_from_ts/jsx_import_from_ts.ts similarity index 100% rename from tests/testdata/run/jsx_import_from_ts.ts rename to tests/specs/run/jsx_import_from_ts/jsx_import_from_ts.ts diff --git a/tests/testdata/run/jsx_import_from_ts.ts.out b/tests/specs/run/jsx_import_from_ts/jsx_import_from_ts.ts.out similarity index 100% rename from tests/testdata/run/jsx_import_from_ts.ts.out rename to tests/specs/run/jsx_import_from_ts/jsx_import_from_ts.ts.out diff --git a/tests/specs/run/jsx_import_source_error/__test__.jsonc b/tests/specs/run/jsx_import_source_error/__test__.jsonc new file mode 100644 index 0000000000..22b1d29cab --- /dev/null +++ b/tests/specs/run/jsx_import_source_error/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --config jsx/deno-jsx-error.jsonc --check jsx_import_source_no_pragma.tsx", + "output": "jsx_import_source_error.out", + "exitCode": 1 +} diff --git a/tests/specs/run/jsx_import_source_error/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_error/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_error/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_error/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_error/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_error/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_error/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_error/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_error/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_error/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_error/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_error/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_error/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_error/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_error/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_error/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_error/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_error/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_error/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_error/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_error/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_error/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_error/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_error/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_error/jsx/deno.lock b/tests/specs/run/jsx_import_source_error/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_error/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_error/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_error/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_error/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_error/jsx/import-map.json b/tests/specs/run/jsx_import_source_error/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_error/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_error/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_error/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_error/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_error/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_error/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_error/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_error/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_error/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_error/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/testdata/run/jsx_import_source_error.out b/tests/specs/run/jsx_import_source_error/jsx_import_source_error.out similarity index 100% rename from tests/testdata/run/jsx_import_source_error.out rename to tests/specs/run/jsx_import_source_error/jsx_import_source_error.out diff --git a/tests/specs/run/jsx_import_source_error/jsx_import_source_no_pragma.tsx b/tests/specs/run/jsx_import_source_error/jsx_import_source_no_pragma.tsx new file mode 100644 index 0000000000..2c756054fb --- /dev/null +++ b/tests/specs/run/jsx_import_source_error/jsx_import_source_no_pragma.tsx @@ -0,0 +1,7 @@ +function A() { + return "hello"; +} + +export function B() { + return ; +} diff --git a/tests/specs/run/jsx_import_source_import_map/__test__.jsonc b/tests/specs/run/jsx_import_source_import_map/__test__.jsonc new file mode 100644 index 0000000000..8a62c5243b --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --import-map jsx/import-map.json --no-lock --config jsx/deno-jsx-import-map.jsonc jsx_import_source_no_pragma.tsx", + "output": "jsx_import_source_import_map.out" +} diff --git a/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map/jsx/deno.lock b/tests/specs/run/jsx_import_source_import_map/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_import_map/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_import_map/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_import_map/jsx/import-map.json b/tests/specs/run/jsx_import_source_import_map/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_import_map/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_import_map/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_import_map/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_import_map/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_import_map/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_import_map/jsx_import_source_import_map.out b/tests/specs/run/jsx_import_source_import_map/jsx_import_source_import_map.out new file mode 100644 index 0000000000..0d32389677 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map/jsx_import_source_import_map.out @@ -0,0 +1,2 @@ +[WILDCARD] +imported http://localhost:4545/jsx/jsx-runtime/index.ts diff --git a/tests/specs/run/jsx_import_source_import_map/jsx_import_source_no_pragma.tsx b/tests/specs/run/jsx_import_source_import_map/jsx_import_source_no_pragma.tsx new file mode 100644 index 0000000000..2c756054fb --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map/jsx_import_source_no_pragma.tsx @@ -0,0 +1,7 @@ +function A() { + return "hello"; +} + +export function B() { + return ; +} diff --git a/tests/specs/run/jsx_import_source_import_map_dev/__test__.jsonc b/tests/specs/run/jsx_import_source_import_map_dev/__test__.jsonc new file mode 100644 index 0000000000..b62e7cb6f3 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_dev/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --import-map jsx/import-map.json --no-lock --config jsx/deno-jsxdev-import-map.jsonc jsx_import_source_no_pragma.tsx", + "output": "jsx_import_source_import_map_dev.out" +} diff --git a/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno.lock b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_dev/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_import_map_dev/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_import_map_dev/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_dev/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_dev/jsx/import-map.json b/tests/specs/run/jsx_import_source_import_map_dev/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_dev/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_dev/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_import_map_dev/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_dev/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_import_map_dev/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_import_map_dev/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_dev/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_dev/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_import_map_dev/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_dev/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_import_map_dev/jsx_import_source_import_map_dev.out b/tests/specs/run/jsx_import_source_import_map_dev/jsx_import_source_import_map_dev.out new file mode 100644 index 0000000000..56f514d90c --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_dev/jsx_import_source_import_map_dev.out @@ -0,0 +1,2 @@ +[WILDCARD] +imported http://localhost:4545/jsx/jsx-dev-runtime/index.ts diff --git a/tests/specs/run/jsx_import_source_import_map_dev/jsx_import_source_no_pragma.tsx b/tests/specs/run/jsx_import_source_import_map_dev/jsx_import_source_no_pragma.tsx new file mode 100644 index 0000000000..2c756054fb --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_dev/jsx_import_source_no_pragma.tsx @@ -0,0 +1,7 @@ +function A() { + return "hello"; +} + +export function B() { + return ; +} diff --git a/tests/specs/run/jsx_import_source_import_map_no_check/__test__.jsonc b/tests/specs/run/jsx_import_source_import_map_no_check/__test__.jsonc new file mode 100644 index 0000000000..ea42654848 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_no_check/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --import-map jsx/import-map.json --no-lock --config jsx/deno-jsx-import-map.jsonc --no-check jsx_import_source_no_pragma.tsx", + "output": "jsx_import_source_import_map.out" +} diff --git a/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno.lock b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_import_map_no_check/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_no_check/jsx/import-map.json b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_no_check/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_import_map_no_check/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_import_map_no_check/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_no_check/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_import_map_no_check/jsx_import_source_import_map.out b/tests/specs/run/jsx_import_source_import_map_no_check/jsx_import_source_import_map.out new file mode 100644 index 0000000000..0d32389677 --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_no_check/jsx_import_source_import_map.out @@ -0,0 +1,2 @@ +[WILDCARD] +imported http://localhost:4545/jsx/jsx-runtime/index.ts diff --git a/tests/specs/run/jsx_import_source_import_map_no_check/jsx_import_source_no_pragma.tsx b/tests/specs/run/jsx_import_source_import_map_no_check/jsx_import_source_no_pragma.tsx new file mode 100644 index 0000000000..2c756054fb --- /dev/null +++ b/tests/specs/run/jsx_import_source_import_map_no_check/jsx_import_source_no_pragma.tsx @@ -0,0 +1,7 @@ +function A() { + return "hello"; +} + +export function B() { + return ; +} diff --git a/tests/specs/run/jsx_import_source_no_pragma/__test__.jsonc b/tests/specs/run/jsx_import_source_no_pragma/__test__.jsonc new file mode 100644 index 0000000000..7678e18f46 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --config jsx/deno-jsx.jsonc --no-lock jsx_import_source_no_pragma.tsx", + "output": "jsx_import_source.out" +} diff --git a/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma/jsx/deno.lock b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_no_pragma/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_no_pragma/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma/jsx/import-map.json b/tests/specs/run/jsx_import_source_no_pragma/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_no_pragma/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_no_pragma/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_no_pragma/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_no_pragma/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/testdata/run/jsx_import_source.out b/tests/specs/run/jsx_import_source_no_pragma/jsx_import_source.out similarity index 100% rename from tests/testdata/run/jsx_import_source.out rename to tests/specs/run/jsx_import_source_no_pragma/jsx_import_source.out diff --git a/tests/specs/run/jsx_import_source_no_pragma/jsx_import_source_no_pragma.tsx b/tests/specs/run/jsx_import_source_no_pragma/jsx_import_source_no_pragma.tsx new file mode 100644 index 0000000000..2c756054fb --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma/jsx_import_source_no_pragma.tsx @@ -0,0 +1,7 @@ +function A() { + return "hello"; +} + +export function B() { + return ; +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_dev/__test__.jsonc b/tests/specs/run/jsx_import_source_no_pragma_dev/__test__.jsonc new file mode 100644 index 0000000000..8f9ee81f69 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_dev/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --config jsx/deno-jsxdev.jsonc --no-lock jsx_import_source_no_pragma.tsx", + "output": "jsx_import_source_dev.out" +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno.lock b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/import-map.json b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/testdata/run/jsx_import_source_dev.out b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx_import_source_dev.out similarity index 100% rename from tests/testdata/run/jsx_import_source_dev.out rename to tests/specs/run/jsx_import_source_no_pragma_dev/jsx_import_source_dev.out diff --git a/tests/specs/run/jsx_import_source_no_pragma_dev/jsx_import_source_no_pragma.tsx b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx_import_source_no_pragma.tsx new file mode 100644 index 0000000000..2c756054fb --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_dev/jsx_import_source_no_pragma.tsx @@ -0,0 +1,7 @@ +function A() { + return "hello"; +} + +export function B() { + return ; +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_no_check/__test__.jsonc b/tests/specs/run/jsx_import_source_no_pragma_no_check/__test__.jsonc new file mode 100644 index 0000000000..12cc9b0764 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_no_check/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --config jsx/deno-jsx.jsonc --no-lock --no-check jsx_import_source_no_pragma.tsx", + "output": "jsx_import_source.out" +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno.lock b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/import-map.json b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx_import_source.out b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx_import_source.out new file mode 100644 index 0000000000..b9555987a6 --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx_import_source.out @@ -0,0 +1,2 @@ +[WILDCARD] +imported http://localhost:4545/jsx/jsx-runtime diff --git a/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx_import_source_no_pragma.tsx b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx_import_source_no_pragma.tsx new file mode 100644 index 0000000000..2c756054fb --- /dev/null +++ b/tests/specs/run/jsx_import_source_no_pragma_no_check/jsx_import_source_no_pragma.tsx @@ -0,0 +1,7 @@ +function A() { + return "hello"; +} + +export function B() { + return ; +} diff --git a/tests/specs/run/jsx_import_source_pragma/__test__.jsonc b/tests/specs/run/jsx_import_source_pragma/__test__.jsonc new file mode 100644 index 0000000000..9d704c0650 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --allow-import jsx_import_source_pragma.tsx", + "output": "jsx_import_source.out" +} diff --git a/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma/jsx/deno.lock b/tests/specs/run/jsx_import_source_pragma/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_pragma/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_pragma/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma/jsx/import-map.json b/tests/specs/run/jsx_import_source_pragma/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_pragma/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma/jsx_import_source.out b/tests/specs/run/jsx_import_source_pragma/jsx_import_source.out new file mode 100644 index 0000000000..b9555987a6 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma/jsx_import_source.out @@ -0,0 +1,2 @@ +[WILDCARD] +imported http://localhost:4545/jsx/jsx-runtime diff --git a/tests/testdata/run/jsx_import_source_pragma.tsx b/tests/specs/run/jsx_import_source_pragma/jsx_import_source_pragma.tsx similarity index 100% rename from tests/testdata/run/jsx_import_source_pragma.tsx rename to tests/specs/run/jsx_import_source_pragma/jsx_import_source_pragma.tsx diff --git a/tests/specs/run/jsx_import_source_pragma_import_map/__test__.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map/__test__.jsonc new file mode 100644 index 0000000000..9eafe51968 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --import-map jsx/import-map.json jsx_import_source_pragma_import_map.tsx", + "output": "jsx_import_source_import_map.out" +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno.lock b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_pragma_import_map/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map/jsx/import-map.json b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma_import_map/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma_import_map/jsx_import_source_import_map.out b/tests/specs/run/jsx_import_source_pragma_import_map/jsx_import_source_import_map.out new file mode 100644 index 0000000000..0d32389677 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map/jsx_import_source_import_map.out @@ -0,0 +1,2 @@ +[WILDCARD] +imported http://localhost:4545/jsx/jsx-runtime/index.ts diff --git a/tests/testdata/run/jsx_import_source_pragma_import_map.tsx b/tests/specs/run/jsx_import_source_pragma_import_map/jsx_import_source_pragma_import_map.tsx similarity index 100% rename from tests/testdata/run/jsx_import_source_pragma_import_map.tsx rename to tests/specs/run/jsx_import_source_pragma_import_map/jsx_import_source_pragma_import_map.tsx diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_dev/__test__.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map_dev/__test__.jsonc new file mode 100644 index 0000000000..bb271c0eef --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_dev/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --import-map jsx/import-map.json --config jsx/deno-jsxdev-import-map.jsonc jsx_import_source_pragma_import_map.tsx", + "output": "jsx_import_source_import_map_dev.out" +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno.lock b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/import-map.json b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx_import_source_import_map_dev.out b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx_import_source_import_map_dev.out new file mode 100644 index 0000000000..56f514d90c --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx_import_source_import_map_dev.out @@ -0,0 +1,2 @@ +[WILDCARD] +imported http://localhost:4545/jsx/jsx-dev-runtime/index.ts diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx_import_source_pragma_import_map.tsx b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx_import_source_pragma_import_map.tsx new file mode 100644 index 0000000000..548365f182 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_dev/jsx_import_source_pragma_import_map.tsx @@ -0,0 +1,9 @@ +/** @jsxImportSource jsx */ + +function A() { + return "hello"; +} + +export function B() { + return ; +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_no_check/__test__.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/__test__.jsonc new file mode 100644 index 0000000000..dd42b71fda --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --import-map jsx/import-map.json --no-check jsx_import_source_pragma_import_map.tsx", + "output": "jsx_import_source_import_map.out" +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno.lock b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/import-map.json b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx_import_source_import_map.out b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx_import_source_import_map.out new file mode 100644 index 0000000000..0d32389677 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx_import_source_import_map.out @@ -0,0 +1,2 @@ +[WILDCARD] +imported http://localhost:4545/jsx/jsx-runtime/index.ts diff --git a/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx_import_source_pragma_import_map.tsx b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx_import_source_pragma_import_map.tsx new file mode 100644 index 0000000000..548365f182 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_import_map_no_check/jsx_import_source_pragma_import_map.tsx @@ -0,0 +1,9 @@ +/** @jsxImportSource jsx */ + +function A() { + return "hello"; +} + +export function B() { + return ; +} diff --git a/tests/specs/run/jsx_import_source_pragma_no_check/__test__.jsonc b/tests/specs/run/jsx_import_source_pragma_no_check/__test__.jsonc new file mode 100644 index 0000000000..0956b94a76 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_no_check/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --no-check jsx_import_source_pragma.tsx", + "output": "jsx_import_source.out" +} diff --git a/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno.lock b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_pragma_no_check/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_no_check/jsx/import-map.json b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_no_check/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma_no_check/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_no_check/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_no_check/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma_no_check/jsx_import_source.out b/tests/specs/run/jsx_import_source_pragma_no_check/jsx_import_source.out new file mode 100644 index 0000000000..b9555987a6 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_no_check/jsx_import_source.out @@ -0,0 +1,2 @@ +[WILDCARD] +imported http://localhost:4545/jsx/jsx-runtime diff --git a/tests/specs/run/jsx_import_source_pragma_no_check/jsx_import_source_pragma.tsx b/tests/specs/run/jsx_import_source_pragma_no_check/jsx_import_source_pragma.tsx new file mode 100644 index 0000000000..c19e53d4ff --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_no_check/jsx_import_source_pragma.tsx @@ -0,0 +1,9 @@ +/** @jsxImportSource http://localhost:4545/jsx */ + +function A() { + return "hello"; +} + +export function B() { + return ; +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config/__test__.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config/__test__.jsonc new file mode 100644 index 0000000000..aeaf209c3a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --allow-import --config jsx/deno-jsx.jsonc --no-lock jsx_import_source_pragma.tsx", + "output": "jsx_import_source.out" +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno.lock b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_pragma_with_config/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config/jsx/import-map.json b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma_with_config/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma_with_config/jsx_import_source.out b/tests/specs/run/jsx_import_source_pragma_with_config/jsx_import_source.out new file mode 100644 index 0000000000..b9555987a6 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config/jsx_import_source.out @@ -0,0 +1,2 @@ +[WILDCARD] +imported http://localhost:4545/jsx/jsx-runtime diff --git a/tests/specs/run/jsx_import_source_pragma_with_config/jsx_import_source_pragma.tsx b/tests/specs/run/jsx_import_source_pragma_with_config/jsx_import_source_pragma.tsx new file mode 100644 index 0000000000..c19e53d4ff --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config/jsx_import_source_pragma.tsx @@ -0,0 +1,9 @@ +/** @jsxImportSource http://localhost:4545/jsx */ + +function A() { + return "hello"; +} + +export function B() { + return ; +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_no_check/__test__.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/__test__.jsonc new file mode 100644 index 0000000000..3e8089fd2c --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --config jsx/deno-jsx.jsonc --no-lock --no-check jsx_import_source_pragma.tsx", + "output": "jsx_import_source.out" +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno.lock b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/import-map.json b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx_import_source.out b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx_import_source.out new file mode 100644 index 0000000000..b9555987a6 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx_import_source.out @@ -0,0 +1,2 @@ +[WILDCARD] +imported http://localhost:4545/jsx/jsx-runtime diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx_import_source_pragma.tsx b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx_import_source_pragma.tsx new file mode 100644 index 0000000000..c19e53d4ff --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_no_check/jsx_import_source_pragma.tsx @@ -0,0 +1,9 @@ +/** @jsxImportSource http://localhost:4545/jsx */ + +function A() { + return "hello"; +} + +export function B() { + return ; +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/__test__.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/__test__.jsonc new file mode 100644 index 0000000000..03ed1af1b6 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --config jsx/deno-jsx.jsonc --no-lock --vendor jsx_import_source_pragma.tsx", + "output": "jsx_import_source.out" +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno.lock b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/import-map.json b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/vendor/http_localhost_4545/jsx/#jsx-runtime_62ac8.js b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/vendor/http_localhost_4545/jsx/#jsx-runtime_62ac8.js new file mode 100644 index 0000000000..c8f0a908db --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/vendor/http_localhost_4545/jsx/#jsx-runtime_62ac8.js @@ -0,0 +1,11 @@ +export function jsx( + _type, + _props, + _key, + _source, + _self, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/vendor/manifest.json b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/vendor/manifest.json new file mode 100644 index 0000000000..a770c33669 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx/vendor/manifest.json @@ -0,0 +1,9 @@ +{ + "modules": { + "http://localhost:4545/jsx/jsx-runtime": { + "headers": { + "content-type": "application/javascript" + } + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx_import_source.out b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx_import_source.out new file mode 100644 index 0000000000..b9555987a6 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx_import_source.out @@ -0,0 +1,2 @@ +[WILDCARD] +imported http://localhost:4545/jsx/jsx-runtime diff --git a/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx_import_source_pragma.tsx b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx_import_source_pragma.tsx new file mode 100644 index 0000000000..c19e53d4ff --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_config_vendor_dir/jsx_import_source_pragma.tsx @@ -0,0 +1,9 @@ +/** @jsxImportSource http://localhost:4545/jsx */ + +function A() { + return "hello"; +} + +export function B() { + return ; +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_dev_config/__test__.jsonc b/tests/specs/run/jsx_import_source_pragma_with_dev_config/__test__.jsonc new file mode 100644 index 0000000000..56734e4678 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_dev_config/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --allow-import --config jsx/deno-jsxdev.jsonc --no-lock jsx_import_source_pragma.tsx", + "output": "jsx_import_source_dev.out" +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno.lock b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/import-map.json b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx_import_source_dev.out b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx_import_source_dev.out new file mode 100644 index 0000000000..38d7a12f05 --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx_import_source_dev.out @@ -0,0 +1,2 @@ +[WILDCARD] +imported http://localhost:4545/jsx/jsx-dev-runtime diff --git a/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx_import_source_pragma.tsx b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx_import_source_pragma.tsx new file mode 100644 index 0000000000..c19e53d4ff --- /dev/null +++ b/tests/specs/run/jsx_import_source_pragma_with_dev_config/jsx_import_source_pragma.tsx @@ -0,0 +1,9 @@ +/** @jsxImportSource http://localhost:4545/jsx */ + +function A() { + return "hello"; +} + +export function B() { + return ; +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map/__test__.jsonc b/tests/specs/run/jsx_import_source_precompile_import_map/__test__.jsonc new file mode 100644 index 0000000000..c795a9d8e6 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --check --import-map jsx/import-map.json --no-lock --config jsx/deno-jsx-precompile.jsonc jsx_precompile/no_pragma.tsx", + "output": "jsx_precompile/no_pragma.out" +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno.lock b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_precompile_import_map/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map/jsx/import-map.json b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_precompile_import_map/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/testdata/run/jsx_precompile/no_pragma.out b/tests/specs/run/jsx_import_source_precompile_import_map/jsx_precompile/no_pragma.out similarity index 67% rename from tests/testdata/run/jsx_precompile/no_pragma.out rename to tests/specs/run/jsx_import_source_precompile_import_map/jsx_precompile/no_pragma.out index 4379959230..f26984258c 100644 --- a/tests/testdata/run/jsx_precompile/no_pragma.out +++ b/tests/specs/run/jsx_import_source_precompile_import_map/jsx_precompile/no_pragma.out @@ -1,3 +1,3 @@ Download http://localhost:4545/jsx/jsx-precompile/index.ts -Check file:///[WILDCARD]/run/jsx_precompile/no_pragma.tsx +Check file:///[WILDCARD]/jsx_precompile/no_pragma.tsx imported http://localhost:4545/jsx/jsx-precompile/index.ts diff --git a/tests/testdata/run/jsx_precompile/no_pragma.tsx b/tests/specs/run/jsx_import_source_precompile_import_map/jsx_precompile/no_pragma.tsx similarity index 100% rename from tests/testdata/run/jsx_precompile/no_pragma.tsx rename to tests/specs/run/jsx_import_source_precompile_import_map/jsx_precompile/no_pragma.tsx diff --git a/tests/testdata/run/jsx_precompile/skip.out b/tests/specs/run/jsx_import_source_precompile_import_map/jsx_precompile/skip.out similarity index 100% rename from tests/testdata/run/jsx_precompile/skip.out rename to tests/specs/run/jsx_import_source_precompile_import_map/jsx_precompile/skip.out diff --git a/tests/testdata/run/jsx_precompile/skip.tsx b/tests/specs/run/jsx_import_source_precompile_import_map/jsx_precompile/skip.tsx similarity index 100% rename from tests/testdata/run/jsx_precompile/skip.tsx rename to tests/specs/run/jsx_import_source_precompile_import_map/jsx_precompile/skip.tsx diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/__test__.jsonc b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/__test__.jsonc new file mode 100644 index 0000000000..7163c83d00 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --check --import-map jsx/import-map.json --no-lock --config jsx/deno-jsx-precompile-skip.jsonc jsx_precompile/skip.tsx", + "output": "jsx_precompile/skip.out" +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx-error.jsonc b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx-error.jsonc new file mode 100644 index 0000000000..37cb4dd912 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx-error.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "./nonexistent" + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx-import-map.jsonc b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx-import-map.jsonc new file mode 100644 index 0000000000..5adbfa8b5a --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx-precompile-skip.jsonc b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx-precompile-skip.jsonc new file mode 100644 index 0000000000..3c9e4fa1f8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx-precompile-skip.jsonc @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile", + "jsxPrecompileSkipElements": ["a", "img"] + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx-precompile.jsonc b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx-precompile.jsonc new file mode 100644 index 0000000000..95ae1b9f31 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx-precompile.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "precompile", + "jsxImportSource": "jsx-precompile" + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx.json b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx.json new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx.jsonc b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx.jsonc new file mode 100644 index 0000000000..311409ea37 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsx.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsxdev-import-map.jsonc b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsxdev-import-map.jsonc new file mode 100644 index 0000000000..7481d5a2d8 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsxdev-import-map.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsxdev.jsonc b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsxdev.jsonc new file mode 100644 index 0000000000..ae5bdf9f16 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno-jsxdev.jsonc @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsxdev", + "jsxImportSource": "http://localhost:4545/jsx" + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno.lock b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno.lock new file mode 100644 index 0000000000..011e8fe108 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/deno.lock @@ -0,0 +1,6 @@ +{ + "version": "2", + "remote": { + "http://localhost:4545/jsx/jsx-dev-runtime/index.ts": "183c5bf1cfb82b15fc1e8cca15593d4816035759532d851abd4476df378c8412" + } +} \ No newline at end of file diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/import-map-scoped.json b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/import-map-scoped.json new file mode 100644 index 0000000000..9b2005128f --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/import-map.json b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/import-map.json new file mode 100644 index 0000000000..1bfa04e2f0 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/import-map.json @@ -0,0 +1,7 @@ +{ + "imports": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts", + "jsx-precompile/jsx-runtime": "http://localhost:4545/jsx/jsx-precompile/index.ts" + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/jsx-dev-runtime/index.ts b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/jsx-dev-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/jsx-dev-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/jsx-precompile/index.ts b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/jsx-precompile/index.ts new file mode 100644 index 0000000000..0d56095e0b --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/jsx-precompile/index.ts @@ -0,0 +1,23 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +// deno-lint-ignore-file no-explicit-any +export const jsxAttr = (name: string, value: any) => `${name}="${value}"`; +// deno-lint-ignore-file no-explicit-any +export const jsxTemplate = (_template: string[], ..._exprs: any[]) => ""; +// deno-lint-ignore-file no-explicit-any +export const jsxEscape = (_value: any) => ""; +console.log("imported", import.meta.url); + +declare global { + namespace JSX { + interface IntrinsicElements { + [tagName: string]: Record; + } + } +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/jsx-runtime/index.ts b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/jsx-runtime/index.ts new file mode 100644 index 0000000000..15e2029c8a --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx/jsx-runtime/index.ts @@ -0,0 +1,12 @@ +// deno-lint-ignore-file no-explicit-any +export function jsx( + _type: any, + _props: any, + _key: any, + _source: any, + _self: any, +) {} +export const jsxs = jsx; +export const jsxDEV = jsx; +export const Fragment = Symbol("Fragment"); +console.log("imported", import.meta.url); diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx_precompile/no_pragma.out b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx_precompile/no_pragma.out new file mode 100644 index 0000000000..f26984258c --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx_precompile/no_pragma.out @@ -0,0 +1,3 @@ +Download http://localhost:4545/jsx/jsx-precompile/index.ts +Check file:///[WILDCARD]/jsx_precompile/no_pragma.tsx +imported http://localhost:4545/jsx/jsx-precompile/index.ts diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx_precompile/no_pragma.tsx b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx_precompile/no_pragma.tsx new file mode 100644 index 0000000000..7ba21d80d2 --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx_precompile/no_pragma.tsx @@ -0,0 +1,3 @@ +export function A() { + return

hello

; +} diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx_precompile/skip.out b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx_precompile/skip.out new file mode 100644 index 0000000000..6696c550ca --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx_precompile/skip.out @@ -0,0 +1,3 @@ +Download http://localhost:4545/jsx/jsx-precompile/index.ts +Check file:///[WILDCARD]/jsx_precompile/skip.tsx +imported http://localhost:4545/jsx/jsx-precompile/index.ts diff --git a/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx_precompile/skip.tsx b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx_precompile/skip.tsx new file mode 100644 index 0000000000..49bc4e2b7a --- /dev/null +++ b/tests/specs/run/jsx_import_source_precompile_import_map_skip_element/jsx_precompile/skip.tsx @@ -0,0 +1,9 @@ +export function A() { + return ( +
+ foo +

hello

+ +
+ ); +} diff --git a/tests/specs/run/lock_check_ok/003_relative_import.ts b/tests/specs/run/lock_check_ok/003_relative_import.ts new file mode 100644 index 0000000000..d392f4a5d1 --- /dev/null +++ b/tests/specs/run/lock_check_ok/003_relative_import.ts @@ -0,0 +1,3 @@ +import { printHello } from "./print_hello.ts"; + +printHello(); diff --git a/tests/specs/run/lock_check_ok/003_relative_import.ts.out b/tests/specs/run/lock_check_ok/003_relative_import.ts.out new file mode 100644 index 0000000000..e965047ad7 --- /dev/null +++ b/tests/specs/run/lock_check_ok/003_relative_import.ts.out @@ -0,0 +1 @@ +Hello diff --git a/tests/specs/run/lock_check_ok/__test__.jsonc b/tests/specs/run/lock_check_ok/__test__.jsonc new file mode 100644 index 0000000000..e8ce4572e4 --- /dev/null +++ b/tests/specs/run/lock_check_ok/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --allow-import --lock=lock_check_ok.json 003_relative_import.ts", + "output": "003_relative_import.ts.out" +} diff --git a/tests/specs/run/lock_check_ok/lock_check_ok.json b/tests/specs/run/lock_check_ok/lock_check_ok.json new file mode 100644 index 0000000000..20f7e20005 --- /dev/null +++ b/tests/specs/run/lock_check_ok/lock_check_ok.json @@ -0,0 +1,4 @@ +{ + "http://127.0.0.1:4545/print_hello.ts": "fa6692c8f9ff3fb107e773c3ece5274e9d08be282867a1e3ded1d9c00fcaa63c", + "http://127.0.0.1:4545/003_relative_import.ts": "a1572e8fd2c2712b33f04aed2561505b5feb2c8696f1f2cded3de7127931b97e" +} diff --git a/tests/specs/run/lock_check_ok/print_hello.ts b/tests/specs/run/lock_check_ok/print_hello.ts new file mode 100644 index 0000000000..b9c0ad5275 --- /dev/null +++ b/tests/specs/run/lock_check_ok/print_hello.ts @@ -0,0 +1,3 @@ +export function printHello() { + console.log("Hello"); +} diff --git a/tests/specs/run/lock_check_ok2/019_media_types.ts b/tests/specs/run/lock_check_ok2/019_media_types.ts new file mode 100644 index 0000000000..d985bd2496 --- /dev/null +++ b/tests/specs/run/lock_check_ok2/019_media_types.ts @@ -0,0 +1,24 @@ +// When run against the test HTTP server, it will serve different media types +// based on the URL containing `.t#.` strings, which exercises the different +// mapping of media types end to end. + +import { loaded as loadedTs1 } from "http://localhost:4545/subdir/mt_text_typescript.t1.ts"; +import { loaded as loadedTs2 } from "http://localhost:4545/subdir/mt_video_vdn.t2.ts"; +import { loaded as loadedTs3 } from "http://localhost:4545/subdir/mt_video_mp2t.t3.ts"; +import { loaded as loadedTs4 } from "http://localhost:4545/subdir/mt_application_x_typescript.t4.ts"; +import { loaded as loadedJs1 } from "http://localhost:4545/subdir/mt_text_javascript.j1.js"; +import { loaded as loadedJs2 } from "http://localhost:4545/subdir/mt_application_ecmascript.j2.js"; +import { loaded as loadedJs3 } from "http://localhost:4545/subdir/mt_text_ecmascript.j3.js"; +import { loaded as loadedJs4 } from "http://localhost:4545/subdir/mt_application_x_javascript.j4.js"; + +console.log( + "success", + loadedTs1, + loadedTs2, + loadedTs3, + loadedTs4, + loadedJs1, + loadedJs2, + loadedJs3, + loadedJs4, +); diff --git a/tests/specs/run/lock_check_ok2/019_media_types.ts.out b/tests/specs/run/lock_check_ok2/019_media_types.ts.out new file mode 100644 index 0000000000..b3e94678c5 --- /dev/null +++ b/tests/specs/run/lock_check_ok2/019_media_types.ts.out @@ -0,0 +1 @@ +[WILDCARD]success true true true true true true true true diff --git a/tests/specs/run/lock_check_ok2/__test__.jsonc b/tests/specs/run/lock_check_ok2/__test__.jsonc new file mode 100644 index 0000000000..dc790528a2 --- /dev/null +++ b/tests/specs/run/lock_check_ok2/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --lock=lock_check_ok2.json 019_media_types.ts", + "output": "019_media_types.ts.out" +} diff --git a/tests/testdata/run/lock_check_ok2.json b/tests/specs/run/lock_check_ok2/lock_check_ok2.json similarity index 100% rename from tests/testdata/run/lock_check_ok2.json rename to tests/specs/run/lock_check_ok2/lock_check_ok2.json diff --git a/tests/specs/run/lock_v2_check_ok/003_relative_import.ts b/tests/specs/run/lock_v2_check_ok/003_relative_import.ts new file mode 100644 index 0000000000..d392f4a5d1 --- /dev/null +++ b/tests/specs/run/lock_v2_check_ok/003_relative_import.ts @@ -0,0 +1,3 @@ +import { printHello } from "./print_hello.ts"; + +printHello(); diff --git a/tests/specs/run/lock_v2_check_ok/003_relative_import.ts.out b/tests/specs/run/lock_v2_check_ok/003_relative_import.ts.out new file mode 100644 index 0000000000..e965047ad7 --- /dev/null +++ b/tests/specs/run/lock_v2_check_ok/003_relative_import.ts.out @@ -0,0 +1 @@ +Hello diff --git a/tests/specs/run/lock_v2_check_ok/__test__.jsonc b/tests/specs/run/lock_v2_check_ok/__test__.jsonc new file mode 100644 index 0000000000..d7b819d569 --- /dev/null +++ b/tests/specs/run/lock_v2_check_ok/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --quiet --lock=lock_v2_check_ok.json 003_relative_import.ts", + "output": "003_relative_import.ts.out" +} diff --git a/tests/specs/run/lock_v2_check_ok/lock_v2_check_ok.json b/tests/specs/run/lock_v2_check_ok/lock_v2_check_ok.json new file mode 100644 index 0000000000..47a761fbdb --- /dev/null +++ b/tests/specs/run/lock_v2_check_ok/lock_v2_check_ok.json @@ -0,0 +1,7 @@ +{ + "version": "2", + "remote": { + "http://127.0.0.1:4545/print_hello.ts": "fa6692c8f9ff3fb107e773c3ece5274e9d08be282867a1e3ded1d9c00fcaa63c", + "http://127.0.0.1:4545/003_relative_import.ts": "a1572e8fd2c2712b33f04aed2561505b5feb2c8696f1f2cded3de7127931b97e" + } +} diff --git a/tests/specs/run/lock_v2_check_ok/print_hello.ts b/tests/specs/run/lock_v2_check_ok/print_hello.ts new file mode 100644 index 0000000000..b9c0ad5275 --- /dev/null +++ b/tests/specs/run/lock_v2_check_ok/print_hello.ts @@ -0,0 +1,3 @@ +export function printHello() { + console.log("Hello"); +} diff --git a/tests/specs/run/lock_v2_check_ok2/019_media_types.ts b/tests/specs/run/lock_v2_check_ok2/019_media_types.ts new file mode 100644 index 0000000000..d985bd2496 --- /dev/null +++ b/tests/specs/run/lock_v2_check_ok2/019_media_types.ts @@ -0,0 +1,24 @@ +// When run against the test HTTP server, it will serve different media types +// based on the URL containing `.t#.` strings, which exercises the different +// mapping of media types end to end. + +import { loaded as loadedTs1 } from "http://localhost:4545/subdir/mt_text_typescript.t1.ts"; +import { loaded as loadedTs2 } from "http://localhost:4545/subdir/mt_video_vdn.t2.ts"; +import { loaded as loadedTs3 } from "http://localhost:4545/subdir/mt_video_mp2t.t3.ts"; +import { loaded as loadedTs4 } from "http://localhost:4545/subdir/mt_application_x_typescript.t4.ts"; +import { loaded as loadedJs1 } from "http://localhost:4545/subdir/mt_text_javascript.j1.js"; +import { loaded as loadedJs2 } from "http://localhost:4545/subdir/mt_application_ecmascript.j2.js"; +import { loaded as loadedJs3 } from "http://localhost:4545/subdir/mt_text_ecmascript.j3.js"; +import { loaded as loadedJs4 } from "http://localhost:4545/subdir/mt_application_x_javascript.j4.js"; + +console.log( + "success", + loadedTs1, + loadedTs2, + loadedTs3, + loadedTs4, + loadedJs1, + loadedJs2, + loadedJs3, + loadedJs4, +); diff --git a/tests/specs/run/lock_v2_check_ok2/019_media_types.ts.out b/tests/specs/run/lock_v2_check_ok2/019_media_types.ts.out new file mode 100644 index 0000000000..b3e94678c5 --- /dev/null +++ b/tests/specs/run/lock_v2_check_ok2/019_media_types.ts.out @@ -0,0 +1 @@ +[WILDCARD]success true true true true true true true true diff --git a/tests/specs/run/lock_v2_check_ok2/__test__.jsonc b/tests/specs/run/lock_v2_check_ok2/__test__.jsonc new file mode 100644 index 0000000000..a9430b4bcd --- /dev/null +++ b/tests/specs/run/lock_v2_check_ok2/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --lock=lock_v2_check_ok2.json 019_media_types.ts", + "output": "019_media_types.ts.out" +} diff --git a/tests/testdata/run/lock_v2_check_ok2.json b/tests/specs/run/lock_v2_check_ok2/lock_v2_check_ok2.json similarity index 100% rename from tests/testdata/run/lock_v2_check_ok2.json rename to tests/specs/run/lock_v2_check_ok2/lock_v2_check_ok2.json diff --git a/tests/specs/run/long_data_url_formatting/__test__.jsonc b/tests/specs/run/long_data_url_formatting/__test__.jsonc new file mode 100644 index 0000000000..f7ae56c635 --- /dev/null +++ b/tests/specs/run/long_data_url_formatting/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run long_data_url_formatting.ts", + "output": "long_data_url_formatting.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/long_data_url_formatting.ts b/tests/specs/run/long_data_url_formatting/long_data_url_formatting.ts similarity index 100% rename from tests/testdata/run/long_data_url_formatting.ts rename to tests/specs/run/long_data_url_formatting/long_data_url_formatting.ts diff --git a/tests/testdata/run/long_data_url_formatting.ts.out b/tests/specs/run/long_data_url_formatting/long_data_url_formatting.ts.out similarity index 100% rename from tests/testdata/run/long_data_url_formatting.ts.out rename to tests/specs/run/long_data_url_formatting/long_data_url_formatting.ts.out diff --git a/tests/specs/run/main_module/__test__.jsonc b/tests/specs/run/main_module/__test__.jsonc new file mode 100644 index 0000000000..0d70eddbd9 --- /dev/null +++ b/tests/specs/run/main_module/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload main_module/main.ts", + "output": "main_module/main.out" +} diff --git a/tests/testdata/run/main_module/main.out b/tests/specs/run/main_module/main_module/main.out similarity index 100% rename from tests/testdata/run/main_module/main.out rename to tests/specs/run/main_module/main_module/main.out diff --git a/tests/testdata/run/main_module/main.ts b/tests/specs/run/main_module/main_module/main.ts similarity index 100% rename from tests/testdata/run/main_module/main.ts rename to tests/specs/run/main_module/main_module/main.ts diff --git a/tests/testdata/run/main_module/other.ts b/tests/specs/run/main_module/main_module/other.ts similarity index 100% rename from tests/testdata/run/main_module/other.ts rename to tests/specs/run/main_module/main_module/other.ts diff --git a/tests/specs/run/mts_dmts_mjs/__test__.jsonc b/tests/specs/run/mts_dmts_mjs/__test__.jsonc new file mode 100644 index 0000000000..b50bb4b19b --- /dev/null +++ b/tests/specs/run/mts_dmts_mjs/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run import.mts", + "output": "mts_dmts_mjs.out" +} diff --git a/tests/specs/run/mts_dmts_mjs/import.mts b/tests/specs/run/mts_dmts_mjs/import.mts new file mode 100644 index 0000000000..eeb200f598 --- /dev/null +++ b/tests/specs/run/mts_dmts_mjs/import.mts @@ -0,0 +1,4 @@ +import * as a from "./mod.mjs"; +import { type A } from "./types.d.mts"; + +console.log(a.a as A); diff --git a/tests/specs/run/mts_dmts_mjs/mod.mjs b/tests/specs/run/mts_dmts_mjs/mod.mjs new file mode 100644 index 0000000000..9233cce2f0 --- /dev/null +++ b/tests/specs/run/mts_dmts_mjs/mod.mjs @@ -0,0 +1 @@ +export const a = "a"; diff --git a/tests/testdata/run/mts_dmts_mjs.out b/tests/specs/run/mts_dmts_mjs/mts_dmts_mjs.out similarity index 100% rename from tests/testdata/run/mts_dmts_mjs.out rename to tests/specs/run/mts_dmts_mjs/mts_dmts_mjs.out diff --git a/tests/specs/run/mts_dmts_mjs/types.d.mts b/tests/specs/run/mts_dmts_mjs/types.d.mts new file mode 100644 index 0000000000..28c2821466 --- /dev/null +++ b/tests/specs/run/mts_dmts_mjs/types.d.mts @@ -0,0 +1 @@ +export type A = "a"; diff --git a/tests/specs/run/mts_dmts_mjs_no_check/__test__.jsonc b/tests/specs/run/mts_dmts_mjs_no_check/__test__.jsonc new file mode 100644 index 0000000000..0d36517bc1 --- /dev/null +++ b/tests/specs/run/mts_dmts_mjs_no_check/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --no-check import.mts", + "output": "mts_dmts_mjs.out" +} diff --git a/tests/specs/run/mts_dmts_mjs_no_check/import.mts b/tests/specs/run/mts_dmts_mjs_no_check/import.mts new file mode 100644 index 0000000000..eeb200f598 --- /dev/null +++ b/tests/specs/run/mts_dmts_mjs_no_check/import.mts @@ -0,0 +1,4 @@ +import * as a from "./mod.mjs"; +import { type A } from "./types.d.mts"; + +console.log(a.a as A); diff --git a/tests/specs/run/mts_dmts_mjs_no_check/mod.mjs b/tests/specs/run/mts_dmts_mjs_no_check/mod.mjs new file mode 100644 index 0000000000..9233cce2f0 --- /dev/null +++ b/tests/specs/run/mts_dmts_mjs_no_check/mod.mjs @@ -0,0 +1 @@ +export const a = "a"; diff --git a/tests/specs/run/mts_dmts_mjs_no_check/mts_dmts_mjs.out b/tests/specs/run/mts_dmts_mjs_no_check/mts_dmts_mjs.out new file mode 100644 index 0000000000..7898192261 --- /dev/null +++ b/tests/specs/run/mts_dmts_mjs_no_check/mts_dmts_mjs.out @@ -0,0 +1 @@ +a diff --git a/tests/specs/run/mts_dmts_mjs_no_check/types.d.mts b/tests/specs/run/mts_dmts_mjs_no_check/types.d.mts new file mode 100644 index 0000000000..28c2821466 --- /dev/null +++ b/tests/specs/run/mts_dmts_mjs_no_check/types.d.mts @@ -0,0 +1 @@ +export type A = "a"; diff --git a/tests/specs/run/nested_error/__test__.jsonc b/tests/specs/run/nested_error/__test__.jsonc new file mode 100644 index 0000000000..d167832bae --- /dev/null +++ b/tests/specs/run/nested_error/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run nested_error/main.ts", + "output": "nested_error/main.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/nested_error/main.ts b/tests/specs/run/nested_error/nested_error/main.ts similarity index 100% rename from tests/testdata/run/nested_error/main.ts rename to tests/specs/run/nested_error/nested_error/main.ts diff --git a/tests/testdata/run/nested_error/main.ts.out b/tests/specs/run/nested_error/nested_error/main.ts.out similarity index 100% rename from tests/testdata/run/nested_error/main.ts.out rename to tests/specs/run/nested_error/nested_error/main.ts.out diff --git a/tests/specs/run/no_check/006_url_imports.ts b/tests/specs/run/no_check/006_url_imports.ts new file mode 100644 index 0000000000..ad2d259156 --- /dev/null +++ b/tests/specs/run/no_check/006_url_imports.ts @@ -0,0 +1,3 @@ +import { printHello } from "./mod2.ts"; +printHello(); +console.log("success"); diff --git a/tests/specs/run/no_check/006_url_imports.ts.out b/tests/specs/run/no_check/006_url_imports.ts.out new file mode 100644 index 0000000000..989ce33e93 --- /dev/null +++ b/tests/specs/run/no_check/006_url_imports.ts.out @@ -0,0 +1,2 @@ +Hello +success diff --git a/tests/specs/run/no_check/__test__.jsonc b/tests/specs/run/no_check/__test__.jsonc new file mode 100644 index 0000000000..696e08e2ad --- /dev/null +++ b/tests/specs/run/no_check/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --quiet --reload --no-check 006_url_imports.ts", + "output": "006_url_imports.ts.out" +} diff --git a/tests/specs/run/no_check/mod2.ts b/tests/specs/run/no_check/mod2.ts new file mode 100644 index 0000000000..ce1adc0e81 --- /dev/null +++ b/tests/specs/run/no_check/mod2.ts @@ -0,0 +1 @@ +export { printHello } from "./print_hello.ts"; diff --git a/tests/specs/run/no_check/print_hello.ts b/tests/specs/run/no_check/print_hello.ts new file mode 100644 index 0000000000..b9c0ad5275 --- /dev/null +++ b/tests/specs/run/no_check/print_hello.ts @@ -0,0 +1,3 @@ +export function printHello() { + console.log("Hello"); +} diff --git a/tests/specs/run/no_check_decorators/__test__.jsonc b/tests/specs/run/no_check_decorators/__test__.jsonc new file mode 100644 index 0000000000..da50d30a05 --- /dev/null +++ b/tests/specs/run/no_check_decorators/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --no-check decorators/experimental/no_check/main.ts", + "output": "decorators/experimental/no_check/main.out" +} diff --git a/tests/specs/run/no_check_decorators/decorators/experimental/deno.json b/tests/specs/run/no_check_decorators/decorators/experimental/deno.json new file mode 100644 index 0000000000..504cd646e1 --- /dev/null +++ b/tests/specs/run/no_check_decorators/decorators/experimental/deno.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "experimentalDecorators": true + } +} diff --git a/tests/specs/run/no_check_decorators/decorators/experimental/no_check/main.out b/tests/specs/run/no_check_decorators/decorators/experimental/no_check/main.out new file mode 100644 index 0000000000..015f7076e8 --- /dev/null +++ b/tests/specs/run/no_check_decorators/decorators/experimental/no_check/main.out @@ -0,0 +1,3 @@ +a(): evaluated +a(): called +method diff --git a/tests/specs/run/no_check_decorators/decorators/experimental/no_check/main.ts b/tests/specs/run/no_check_decorators/decorators/experimental/no_check/main.ts new file mode 100644 index 0000000000..9f7ec550d5 --- /dev/null +++ b/tests/specs/run/no_check_decorators/decorators/experimental/no_check/main.ts @@ -0,0 +1,21 @@ +// deno-lint-ignore-file +function a() { + console.log("a(): evaluated"); + return ( + _target: any, + _propertyKey: string, + _descriptor: PropertyDescriptor, + ) => { + console.log("a(): called"); + }; +} + +class B { + @a() + method() { + console.log("method"); + } +} + +const b = new B(); +b.method(); diff --git a/tests/specs/run/no_check_decorators/decorators/experimental/runtime/main.out b/tests/specs/run/no_check_decorators/decorators/experimental/runtime/main.out new file mode 100644 index 0000000000..0fc1d4590e --- /dev/null +++ b/tests/specs/run/no_check_decorators/decorators/experimental/runtime/main.out @@ -0,0 +1,7 @@ +@A evaluated +@B evaluated +@B called +@A called +fn() called from @A +fn() called from @B +C.test() called diff --git a/tests/specs/run/no_check_decorators/decorators/experimental/runtime/main.ts b/tests/specs/run/no_check_decorators/decorators/experimental/runtime/main.ts new file mode 100644 index 0000000000..40a26bbd4d --- /dev/null +++ b/tests/specs/run/no_check_decorators/decorators/experimental/runtime/main.ts @@ -0,0 +1,42 @@ +// deno-lint-ignore-file +function a() { + console.log("@A evaluated"); + return function ( + target: any, + propertyKey: string, + descriptor: PropertyDescriptor, + ) { + console.log("@A called"); + const fn = descriptor.value; + descriptor.value = function () { + console.log("fn() called from @A"); + fn(); + }; + }; +} + +function b() { + console.log("@B evaluated"); + return function ( + target: any, + propertyKey: string, + descriptor: PropertyDescriptor, + ) { + console.log("@B called"); + const fn = descriptor.value; + descriptor.value = function () { + console.log("fn() called from @B"); + fn(); + }; + }; +} + +class C { + @a() + @b() + static test() { + console.log("C.test() called"); + } +} + +C.test(); diff --git a/tests/specs/run/no_check_decorators/decorators/experimental/ts/main.out b/tests/specs/run/no_check_decorators/decorators/experimental/ts/main.out new file mode 100644 index 0000000000..ea64fbaa63 --- /dev/null +++ b/tests/specs/run/no_check_decorators/decorators/experimental/ts/main.out @@ -0,0 +1,3 @@ +Warning experimentalDecorators compiler option is deprecated and may be removed at any time +Check [WILDCARD] +SomeClass { someField: "asdf" } diff --git a/tests/specs/run/no_check_decorators/decorators/experimental/ts/main.ts b/tests/specs/run/no_check_decorators/decorators/experimental/ts/main.ts new file mode 100644 index 0000000000..95fba6cd48 --- /dev/null +++ b/tests/specs/run/no_check_decorators/decorators/experimental/ts/main.ts @@ -0,0 +1,14 @@ +// deno-lint-ignore-file + +function Decorate() { + return function (constructor: any): any { + return class extends constructor { + protected someField: string = "asdf"; + }; + }; +} + +@Decorate() +class SomeClass {} + +console.log(new SomeClass()); diff --git a/tests/specs/run/no_check_decorators/decorators/tc39_proposal/main.out b/tests/specs/run/no_check_decorators/decorators/tc39_proposal/main.out new file mode 100644 index 0000000000..39394952e8 --- /dev/null +++ b/tests/specs/run/no_check_decorators/decorators/tc39_proposal/main.out @@ -0,0 +1,3 @@ +starting m with arguments 1 +C.m 1 +ending m diff --git a/tests/specs/run/no_check_decorators/decorators/tc39_proposal/main.ts b/tests/specs/run/no_check_decorators/decorators/tc39_proposal/main.ts new file mode 100644 index 0000000000..00c8a85025 --- /dev/null +++ b/tests/specs/run/no_check_decorators/decorators/tc39_proposal/main.ts @@ -0,0 +1,21 @@ +// deno-lint-ignore no-explicit-any +function logged(value: any, { kind, name }: { kind: string; name: string }) { + if (kind === "method") { + return function (...args: unknown[]) { + console.log(`starting ${name} with arguments ${args.join(", ")}`); + // @ts-ignore this has implicit any type + const ret = value.call(this, ...args); + console.log(`ending ${name}`); + return ret; + }; + } +} + +class C { + @logged + m(arg: number) { + console.log("C.m", arg); + } +} + +new C().m(1); diff --git a/tests/specs/run/no_config_auto_discovery_for_local_script/__test__.jsonc b/tests/specs/run/no_config_auto_discovery_for_local_script/__test__.jsonc new file mode 100644 index 0000000000..0a03dbc228 --- /dev/null +++ b/tests/specs/run/no_config_auto_discovery_for_local_script/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --no-config --check frontend_work.ts", + "output": "no_auto_discovery.out", + "exitCode": 1 +} diff --git a/tests/specs/run/no_config_auto_discovery_for_local_script/frontend_work.ts b/tests/specs/run/no_config_auto_discovery_for_local_script/frontend_work.ts new file mode 100644 index 0000000000..783af44e4c --- /dev/null +++ b/tests/specs/run/no_config_auto_discovery_for_local_script/frontend_work.ts @@ -0,0 +1,4 @@ +function _main() { + console.log(document); +} +console.log("ok"); diff --git a/tests/testdata/run/with_config/no_auto_discovery.out b/tests/specs/run/no_config_auto_discovery_for_local_script/no_auto_discovery.out similarity index 78% rename from tests/testdata/run/with_config/no_auto_discovery.out rename to tests/specs/run/no_config_auto_discovery_for_local_script/no_auto_discovery.out index 59339ebe5f..f45a1097c7 100644 --- a/tests/testdata/run/with_config/no_auto_discovery.out +++ b/tests/specs/run/no_config_auto_discovery_for_local_script/no_auto_discovery.out @@ -1,4 +1,4 @@ error: TS2584 [ERROR]: Cannot find name 'document'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'. console.log(document); ~~~~~~~~ - at [WILDCARD]run/with_config/frontend_work.ts:2:15 + at [WILDCARD]frontend_work.ts:2:15 diff --git a/tests/specs/run/no_lock_flag/__test__.jsonc b/tests/specs/run/no_lock_flag/__test__.jsonc new file mode 100644 index 0000000000..b8485c8459 --- /dev/null +++ b/tests/specs/run/no_lock_flag/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --allow-import --no-lock no_lock_flag/main.ts", + "output": "no_lock_flag/main.out", + "exitCode": 0 +} diff --git a/tests/testdata/run/no_lock_flag/deno.json b/tests/specs/run/no_lock_flag/no_lock_flag/deno.json similarity index 100% rename from tests/testdata/run/no_lock_flag/deno.json rename to tests/specs/run/no_lock_flag/no_lock_flag/deno.json diff --git a/tests/testdata/run/no_lock_flag/deno.lock b/tests/specs/run/no_lock_flag/no_lock_flag/deno.lock similarity index 100% rename from tests/testdata/run/no_lock_flag/deno.lock rename to tests/specs/run/no_lock_flag/no_lock_flag/deno.lock diff --git a/tests/testdata/run/no_lock_flag/main.out b/tests/specs/run/no_lock_flag/no_lock_flag/main.out similarity index 100% rename from tests/testdata/run/no_lock_flag/main.out rename to tests/specs/run/no_lock_flag/no_lock_flag/main.out diff --git a/tests/testdata/run/no_lock_flag/main.ts b/tests/specs/run/no_lock_flag/no_lock_flag/main.ts similarity index 100% rename from tests/testdata/run/no_lock_flag/main.ts rename to tests/specs/run/no_lock_flag/no_lock_flag/main.ts diff --git a/tests/specs/run/no_prompt_flag/__test__.jsonc b/tests/specs/run/no_prompt_flag/__test__.jsonc new file mode 100644 index 0000000000..2342a63e80 --- /dev/null +++ b/tests/specs/run/no_prompt_flag/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --no-prompt no_prompt.ts", + "output": "" +} diff --git a/tests/specs/run/no_prompt_flag/no_prompt.ts b/tests/specs/run/no_prompt_flag/no_prompt.ts new file mode 100644 index 0000000000..17d54b92c1 --- /dev/null +++ b/tests/specs/run/no_prompt_flag/no_prompt.ts @@ -0,0 +1,10 @@ +new Worker("data:,setTimeout(() => Deno.exit(2), 200)", { type: "module" }); + +try { + await new Deno.Command("ps", { + stdout: "inherit", + stderr: "inherit", + }).output(); +} catch { + Deno.exit(0); +} diff --git a/tests/specs/run/node_env_var_allowlist/__test__.jsonc b/tests/specs/run/node_env_var_allowlist/__test__.jsonc new file mode 100644 index 0000000000..055ac62e89 --- /dev/null +++ b/tests/specs/run/node_env_var_allowlist/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --no-prompt node_env_var_allowlist.ts", + "output": "node_env_var_allowlist.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/node_env_var_allowlist.ts b/tests/specs/run/node_env_var_allowlist/node_env_var_allowlist.ts similarity index 100% rename from tests/testdata/run/node_env_var_allowlist.ts rename to tests/specs/run/node_env_var_allowlist/node_env_var_allowlist.ts diff --git a/tests/testdata/run/node_env_var_allowlist.ts.out b/tests/specs/run/node_env_var_allowlist/node_env_var_allowlist.ts.out similarity index 100% rename from tests/testdata/run/node_env_var_allowlist.ts.out rename to tests/specs/run/node_env_var_allowlist/node_env_var_allowlist.ts.out diff --git a/tests/specs/run/onload/__test__.jsonc b/tests/specs/run/onload/__test__.jsonc new file mode 100644 index 0000000000..b17dc665d1 --- /dev/null +++ b/tests/specs/run/onload/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --config deno.json onload/main.ts", + "output": "onload/main.out" +} diff --git a/tests/specs/run/onload/deno.json b/tests/specs/run/onload/deno.json new file mode 100644 index 0000000000..105514e133 --- /dev/null +++ b/tests/specs/run/onload/deno.json @@ -0,0 +1,4 @@ +{ + "lock": false, + "importMap": "../../../../import_map.json" +} diff --git a/tests/testdata/run/onload/imported.ts b/tests/specs/run/onload/onload/imported.ts similarity index 100% rename from tests/testdata/run/onload/imported.ts rename to tests/specs/run/onload/onload/imported.ts diff --git a/tests/testdata/run/onload/main.out b/tests/specs/run/onload/onload/main.out similarity index 100% rename from tests/testdata/run/onload/main.out rename to tests/specs/run/onload/onload/main.out diff --git a/tests/testdata/run/onload/main.ts b/tests/specs/run/onload/onload/main.ts similarity index 100% rename from tests/testdata/run/onload/main.ts rename to tests/specs/run/onload/onload/main.ts diff --git a/tests/testdata/run/onload/nest_imported.ts b/tests/specs/run/onload/onload/nest_imported.ts similarity index 100% rename from tests/testdata/run/onload/nest_imported.ts rename to tests/specs/run/onload/onload/nest_imported.ts diff --git a/tests/specs/run/op_exit_op_set_exit_code_in_worker/__test__.jsonc b/tests/specs/run/op_exit_op_set_exit_code_in_worker/__test__.jsonc new file mode 100644 index 0000000000..664fcb5c15 --- /dev/null +++ b/tests/specs/run/op_exit_op_set_exit_code_in_worker/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --no-check --allow-read op_exit_op_set_exit_code_in_worker.ts", + "output": "", + "exitCode": 21 +} diff --git a/tests/testdata/run/op_exit_op_set_exit_code_in_worker.ts b/tests/specs/run/op_exit_op_set_exit_code_in_worker/op_exit_op_set_exit_code_in_worker.ts similarity index 100% rename from tests/testdata/run/op_exit_op_set_exit_code_in_worker.ts rename to tests/specs/run/op_exit_op_set_exit_code_in_worker/op_exit_op_set_exit_code_in_worker.ts diff --git a/tests/specs/run/op_exit_op_set_exit_code_in_worker/op_exit_op_set_exit_code_worker.js b/tests/specs/run/op_exit_op_set_exit_code_in_worker/op_exit_op_set_exit_code_worker.js new file mode 100644 index 0000000000..9b284c37df --- /dev/null +++ b/tests/specs/run/op_exit_op_set_exit_code_in_worker/op_exit_op_set_exit_code_worker.js @@ -0,0 +1,4 @@ +self.onmessage = () => { + Deno[Deno.internal].core.ops.op_set_exit_code(42); + Deno.exit(); +}; diff --git a/tests/specs/run/package_json_auto_discovered_for_local_script_arg_with_stop/__test__.jsonc b/tests/specs/run/package_json_auto_discovered_for_local_script_arg_with_stop/__test__.jsonc new file mode 100644 index 0000000000..ac66ccdf14 --- /dev/null +++ b/tests/specs/run/package_json_auto_discovered_for_local_script_arg_with_stop/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run -L debug main.ts", + "output": "main.out", + "exitCode": 1 +} diff --git a/tests/specs/run/package_json_auto_discovered_for_local_script_arg_with_stop/deno.json b/tests/specs/run/package_json_auto_discovered_for_local_script_arg_with_stop/deno.json new file mode 100644 index 0000000000..36e1765d1a --- /dev/null +++ b/tests/specs/run/package_json_auto_discovered_for_local_script_arg_with_stop/deno.json @@ -0,0 +1,5 @@ +{ + "tasks": { + "dev": "deno run main.ts" + } +} diff --git a/tests/specs/run/package_json_auto_discovered_for_local_script_arg_with_stop/main.out b/tests/specs/run/package_json_auto_discovered_for_local_script_arg_with_stop/main.out new file mode 100644 index 0000000000..5ab43ac470 --- /dev/null +++ b/tests/specs/run/package_json_auto_discovered_for_local_script_arg_with_stop/main.out @@ -0,0 +1,5 @@ +[WILDCARD]Config file found at '[WILDCARD]deno.json' +[WILDCARD] +error: Relative import path "chalk" not prefixed with / or ./ or ../ + hint: If you want to use a JSR or npm package, try running `deno add jsr:chalk` or `deno add npm:chalk` + at file:///[WILDCARD]/main.ts:3:19 diff --git a/tests/specs/run/package_json_auto_discovered_for_local_script_arg_with_stop/main.ts b/tests/specs/run/package_json_auto_discovered_for_local_script_arg_with_stop/main.ts new file mode 100644 index 0000000000..6016470a10 --- /dev/null +++ b/tests/specs/run/package_json_auto_discovered_for_local_script_arg_with_stop/main.ts @@ -0,0 +1,6 @@ +// This import should fail, because `package.json` is not discovered, as we're +// stopping the discovery when encountering `deno.json`. +import chalk from "chalk"; + +console.log("ok"); +console.log(chalk); diff --git a/tests/specs/run/permission_args/001_hello.js b/tests/specs/run/permission_args/001_hello.js new file mode 100644 index 0000000000..accefceba6 --- /dev/null +++ b/tests/specs/run/permission_args/001_hello.js @@ -0,0 +1 @@ +console.log("Hello World"); diff --git a/tests/specs/run/permission_args/__test__.jsonc b/tests/specs/run/permission_args/__test__.jsonc new file mode 100644 index 0000000000..2843ee3955 --- /dev/null +++ b/tests/specs/run/permission_args/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run 001_hello.js --allow-net", + "output": "permission_args.out" +} diff --git a/tests/testdata/run/permission_args.out b/tests/specs/run/permission_args/permission_args.out similarity index 100% rename from tests/testdata/run/permission_args.out rename to tests/specs/run/permission_args/permission_args.out diff --git a/tests/specs/run/permission_args_quiet/001_hello.js b/tests/specs/run/permission_args_quiet/001_hello.js new file mode 100644 index 0000000000..accefceba6 --- /dev/null +++ b/tests/specs/run/permission_args_quiet/001_hello.js @@ -0,0 +1 @@ +console.log("Hello World"); diff --git a/tests/specs/run/permission_args_quiet/001_hello.js.out b/tests/specs/run/permission_args_quiet/001_hello.js.out new file mode 100644 index 0000000000..557db03de9 --- /dev/null +++ b/tests/specs/run/permission_args_quiet/001_hello.js.out @@ -0,0 +1 @@ +Hello World diff --git a/tests/specs/run/permission_args_quiet/__test__.jsonc b/tests/specs/run/permission_args_quiet/__test__.jsonc new file mode 100644 index 0000000000..2b98b963e3 --- /dev/null +++ b/tests/specs/run/permission_args_quiet/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet 001_hello.js --allow-net", + "output": "001_hello.js.out" +} diff --git a/tests/specs/run/private_field_presence/__test__.jsonc b/tests/specs/run/private_field_presence/__test__.jsonc new file mode 100644 index 0000000000..982b882896 --- /dev/null +++ b/tests/specs/run/private_field_presence/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload private_field_presence.ts", + "output": "private_field_presence.ts.out" +} diff --git a/tests/testdata/run/private_field_presence.ts b/tests/specs/run/private_field_presence/private_field_presence.ts similarity index 100% rename from tests/testdata/run/private_field_presence.ts rename to tests/specs/run/private_field_presence/private_field_presence.ts diff --git a/tests/testdata/run/private_field_presence.ts.out b/tests/specs/run/private_field_presence/private_field_presence.ts.out similarity index 100% rename from tests/testdata/run/private_field_presence.ts.out rename to tests/specs/run/private_field_presence/private_field_presence.ts.out diff --git a/tests/specs/run/private_field_presence_no_check/__test__.jsonc b/tests/specs/run/private_field_presence_no_check/__test__.jsonc new file mode 100644 index 0000000000..b7a26db256 --- /dev/null +++ b/tests/specs/run/private_field_presence_no_check/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --no-check private_field_presence.ts", + "output": "private_field_presence.ts.out" +} diff --git a/tests/specs/run/private_field_presence_no_check/private_field_presence.ts b/tests/specs/run/private_field_presence_no_check/private_field_presence.ts new file mode 100644 index 0000000000..7ce2840d8e --- /dev/null +++ b/tests/specs/run/private_field_presence_no_check/private_field_presence.ts @@ -0,0 +1,20 @@ +export class Person { + #name: string; + constructor(name: string) { + this.#name = name; + } + + equals(other: unknown) { + return other && + typeof other === "object" && + #name in other && + this.#name === other.#name; + } +} + +const a = new Person("alice"); +const b = new Person("bob"); +const c = new Person("alice"); + +console.log(a.equals(b)); +console.log(a.equals(c)); diff --git a/tests/specs/run/private_field_presence_no_check/private_field_presence.ts.out b/tests/specs/run/private_field_presence_no_check/private_field_presence.ts.out new file mode 100644 index 0000000000..1d474d5255 --- /dev/null +++ b/tests/specs/run/private_field_presence_no_check/private_field_presence.ts.out @@ -0,0 +1,2 @@ +false +true diff --git a/tests/specs/run/proto_exploit/__test__.jsonc b/tests/specs/run/proto_exploit/__test__.jsonc new file mode 100644 index 0000000000..218f38654a --- /dev/null +++ b/tests/specs/run/proto_exploit/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run proto_exploit.js", + "output": "proto_exploit.js.out" +} diff --git a/tests/testdata/run/proto_exploit.js b/tests/specs/run/proto_exploit/proto_exploit.js similarity index 100% rename from tests/testdata/run/proto_exploit.js rename to tests/specs/run/proto_exploit/proto_exploit.js diff --git a/tests/testdata/run/proto_exploit.js.out b/tests/specs/run/proto_exploit/proto_exploit.js.out similarity index 100% rename from tests/testdata/run/proto_exploit.js.out rename to tests/specs/run/proto_exploit/proto_exploit.js.out diff --git a/tests/specs/run/queue_microtask_error/__test__.jsonc b/tests/specs/run/queue_microtask_error/__test__.jsonc new file mode 100644 index 0000000000..30821d67f6 --- /dev/null +++ b/tests/specs/run/queue_microtask_error/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet queue_microtask_error.ts", + "output": "queue_microtask_error.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/queue_microtask_error.ts b/tests/specs/run/queue_microtask_error/queue_microtask_error.ts similarity index 100% rename from tests/testdata/run/queue_microtask_error.ts rename to tests/specs/run/queue_microtask_error/queue_microtask_error.ts diff --git a/tests/testdata/run/queue_microtask_error.ts.out b/tests/specs/run/queue_microtask_error/queue_microtask_error.ts.out similarity index 100% rename from tests/testdata/run/queue_microtask_error.ts.out rename to tests/specs/run/queue_microtask_error/queue_microtask_error.ts.out diff --git a/tests/specs/run/queue_microtask_error_handled/__test__.jsonc b/tests/specs/run/queue_microtask_error_handled/__test__.jsonc new file mode 100644 index 0000000000..c343acfb41 --- /dev/null +++ b/tests/specs/run/queue_microtask_error_handled/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet queue_microtask_error_handled.ts", + "output": "queue_microtask_error_handled.ts.out" +} diff --git a/tests/testdata/run/queue_microtask_error_handled.ts b/tests/specs/run/queue_microtask_error_handled/queue_microtask_error_handled.ts similarity index 100% rename from tests/testdata/run/queue_microtask_error_handled.ts rename to tests/specs/run/queue_microtask_error_handled/queue_microtask_error_handled.ts diff --git a/tests/testdata/run/queue_microtask_error_handled.ts.out b/tests/specs/run/queue_microtask_error_handled/queue_microtask_error_handled.ts.out similarity index 100% rename from tests/testdata/run/queue_microtask_error_handled.ts.out rename to tests/specs/run/queue_microtask_error_handled/queue_microtask_error_handled.ts.out diff --git a/tests/specs/run/reference_types/__test__.jsonc b/tests/specs/run/reference_types/__test__.jsonc new file mode 100644 index 0000000000..4e4bd08b89 --- /dev/null +++ b/tests/specs/run/reference_types/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --quiet reference_types.ts", + "output": "reference_types.ts.out" +} diff --git a/tests/testdata/run/reference_types.ts b/tests/specs/run/reference_types/reference_types.ts similarity index 100% rename from tests/testdata/run/reference_types.ts rename to tests/specs/run/reference_types/reference_types.ts diff --git a/tests/testdata/run/reference_types_remote.ts.out b/tests/specs/run/reference_types/reference_types.ts.out similarity index 100% rename from tests/testdata/run/reference_types_remote.ts.out rename to tests/specs/run/reference_types/reference_types.ts.out diff --git a/tests/specs/run/reference_types_error/__test__.jsonc b/tests/specs/run/reference_types_error/__test__.jsonc new file mode 100644 index 0000000000..08450acc10 --- /dev/null +++ b/tests/specs/run/reference_types_error/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --config checkjs.tsconfig.json --check reference_types_error.js", + "output": "reference_types_error.js.out", + "exitCode": 1 +} diff --git a/tests/specs/run/reference_types_error/checkjs.tsconfig.json b/tests/specs/run/reference_types_error/checkjs.tsconfig.json new file mode 100644 index 0000000000..08ac60b6cd --- /dev/null +++ b/tests/specs/run/reference_types_error/checkjs.tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "checkJs": true + } +} diff --git a/tests/testdata/run/reference_types_error.js b/tests/specs/run/reference_types_error/reference_types_error.js similarity index 100% rename from tests/testdata/run/reference_types_error.js rename to tests/specs/run/reference_types_error/reference_types_error.js diff --git a/tests/testdata/run/reference_types_error.js.out b/tests/specs/run/reference_types_error/reference_types_error.js.out similarity index 100% rename from tests/testdata/run/reference_types_error.js.out rename to tests/specs/run/reference_types_error/reference_types_error.js.out diff --git a/tests/specs/run/reference_types_error_no_check/__test__.jsonc b/tests/specs/run/reference_types_error_no_check/__test__.jsonc new file mode 100644 index 0000000000..78744759d1 --- /dev/null +++ b/tests/specs/run/reference_types_error_no_check/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --no-check reference_types_error.js", + "output": "" +} diff --git a/tests/specs/run/reference_types_error_no_check/reference_types_error.js b/tests/specs/run/reference_types_error_no_check/reference_types_error.js new file mode 100644 index 0000000000..68b6c21364 --- /dev/null +++ b/tests/specs/run/reference_types_error_no_check/reference_types_error.js @@ -0,0 +1,2 @@ +/// +export const a = 1; diff --git a/tests/specs/run/reference_types_error_vendor_dir/__test__.jsonc b/tests/specs/run/reference_types_error_vendor_dir/__test__.jsonc new file mode 100644 index 0000000000..c48dd1d5e1 --- /dev/null +++ b/tests/specs/run/reference_types_error_vendor_dir/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --config checkjs.tsconfig.json --check --vendor reference_types_error.js", + "output": "reference_types_error.js.out", + "exitCode": 1 +} diff --git a/tests/specs/run/reference_types_error_vendor_dir/checkjs.tsconfig.json b/tests/specs/run/reference_types_error_vendor_dir/checkjs.tsconfig.json new file mode 100644 index 0000000000..08ac60b6cd --- /dev/null +++ b/tests/specs/run/reference_types_error_vendor_dir/checkjs.tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "checkJs": true + } +} diff --git a/tests/specs/run/reference_types_error_vendor_dir/reference_types_error.js b/tests/specs/run/reference_types_error_vendor_dir/reference_types_error.js new file mode 100644 index 0000000000..68b6c21364 --- /dev/null +++ b/tests/specs/run/reference_types_error_vendor_dir/reference_types_error.js @@ -0,0 +1,2 @@ +/// +export const a = 1; diff --git a/tests/specs/run/reference_types_error_vendor_dir/reference_types_error.js.out b/tests/specs/run/reference_types_error_vendor_dir/reference_types_error.js.out new file mode 100644 index 0000000000..86055f3ac3 --- /dev/null +++ b/tests/specs/run/reference_types_error_vendor_dir/reference_types_error.js.out @@ -0,0 +1,2 @@ +error: Module not found "file:///[WILDCARD]/nonexistent.d.ts". + at file:///[WILDCARD]/reference_types_error.js:1:22 diff --git a/tests/specs/run/references_types_remote/__test__.jsonc b/tests/specs/run/references_types_remote/__test__.jsonc new file mode 100644 index 0000000000..3f7f27c268 --- /dev/null +++ b/tests/specs/run/references_types_remote/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --quiet reference_types_remote.ts", + "output": "reference_types_remote.ts.out" +} diff --git a/tests/testdata/run/reference_types_remote.ts b/tests/specs/run/references_types_remote/reference_types_remote.ts similarity index 100% rename from tests/testdata/run/reference_types_remote.ts rename to tests/specs/run/references_types_remote/reference_types_remote.ts diff --git a/tests/specs/run/references_types_remote/reference_types_remote.ts.out b/tests/specs/run/references_types_remote/reference_types_remote.ts.out new file mode 100644 index 0000000000..417b7b5370 --- /dev/null +++ b/tests/specs/run/references_types_remote/reference_types_remote.ts.out @@ -0,0 +1 @@ +undefined diff --git a/tests/specs/run/rejection_handled/__test__.jsonc b/tests/specs/run/rejection_handled/__test__.jsonc new file mode 100644 index 0000000000..7565a7dd10 --- /dev/null +++ b/tests/specs/run/rejection_handled/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --check rejection_handled.ts", + "output": "rejection_handled.out" +} diff --git a/tests/testdata/run/rejection_handled.out b/tests/specs/run/rejection_handled/rejection_handled.out similarity index 100% rename from tests/testdata/run/rejection_handled.out rename to tests/specs/run/rejection_handled/rejection_handled.out diff --git a/tests/testdata/run/rejection_handled.ts b/tests/specs/run/rejection_handled/rejection_handled.ts similarity index 100% rename from tests/testdata/run/rejection_handled.ts rename to tests/specs/run/rejection_handled/rejection_handled.ts diff --git a/tests/specs/run/replace_self/__test__.jsonc b/tests/specs/run/replace_self/__test__.jsonc new file mode 100644 index 0000000000..cfadbf7918 --- /dev/null +++ b/tests/specs/run/replace_self/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run replace_self.js", + "output": "replace_self.js.out" +} diff --git a/tests/testdata/run/replace_self.js b/tests/specs/run/replace_self/replace_self.js similarity index 100% rename from tests/testdata/run/replace_self.js rename to tests/specs/run/replace_self/replace_self.js diff --git a/tests/testdata/run/replace_self.js.out b/tests/specs/run/replace_self/replace_self.js.out similarity index 100% rename from tests/testdata/run/replace_self.js.out rename to tests/specs/run/replace_self/replace_self.js.out diff --git a/tests/specs/run/report_error/__test__.jsonc b/tests/specs/run/report_error/__test__.jsonc new file mode 100644 index 0000000000..0577ad2450 --- /dev/null +++ b/tests/specs/run/report_error/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet report_error.ts", + "output": "report_error.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/report_error.ts b/tests/specs/run/report_error/report_error.ts similarity index 100% rename from tests/testdata/run/report_error.ts rename to tests/specs/run/report_error/report_error.ts diff --git a/tests/testdata/run/report_error.ts.out b/tests/specs/run/report_error/report_error.ts.out similarity index 100% rename from tests/testdata/run/report_error.ts.out rename to tests/specs/run/report_error/report_error.ts.out diff --git a/tests/specs/run/report_error_end_of_program/__test__.jsonc b/tests/specs/run/report_error_end_of_program/__test__.jsonc new file mode 100644 index 0000000000..c34956b74a --- /dev/null +++ b/tests/specs/run/report_error_end_of_program/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet report_error_end_of_program.ts", + "output": "report_error_end_of_program.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/report_error_end_of_program.ts b/tests/specs/run/report_error_end_of_program/report_error_end_of_program.ts similarity index 100% rename from tests/testdata/run/report_error_end_of_program.ts rename to tests/specs/run/report_error_end_of_program/report_error_end_of_program.ts diff --git a/tests/testdata/run/report_error_end_of_program.ts.out b/tests/specs/run/report_error_end_of_program/report_error_end_of_program.ts.out similarity index 100% rename from tests/testdata/run/report_error_end_of_program.ts.out rename to tests/specs/run/report_error_end_of_program/report_error_end_of_program.ts.out diff --git a/tests/specs/run/report_error_handled/__test__.jsonc b/tests/specs/run/report_error_handled/__test__.jsonc new file mode 100644 index 0000000000..126687b95e --- /dev/null +++ b/tests/specs/run/report_error_handled/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet report_error_handled.ts", + "output": "report_error_handled.ts.out" +} diff --git a/tests/testdata/run/report_error_handled.ts b/tests/specs/run/report_error_handled/report_error_handled.ts similarity index 100% rename from tests/testdata/run/report_error_handled.ts rename to tests/specs/run/report_error_handled/report_error_handled.ts diff --git a/tests/testdata/run/report_error_handled.ts.out b/tests/specs/run/report_error_handled/report_error_handled.ts.out similarity index 100% rename from tests/testdata/run/report_error_handled.ts.out rename to tests/specs/run/report_error_handled/report_error_handled.ts.out diff --git a/tests/specs/run/runtime_decorators/__test__.jsonc b/tests/specs/run/runtime_decorators/__test__.jsonc new file mode 100644 index 0000000000..286fd377d8 --- /dev/null +++ b/tests/specs/run/runtime_decorators/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --no-check decorators/experimental/runtime/main.ts", + "output": "decorators/experimental/runtime/main.out" +} diff --git a/tests/specs/run/runtime_decorators/decorators/experimental/deno.json b/tests/specs/run/runtime_decorators/decorators/experimental/deno.json new file mode 100644 index 0000000000..504cd646e1 --- /dev/null +++ b/tests/specs/run/runtime_decorators/decorators/experimental/deno.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "experimentalDecorators": true + } +} diff --git a/tests/specs/run/runtime_decorators/decorators/experimental/no_check/main.out b/tests/specs/run/runtime_decorators/decorators/experimental/no_check/main.out new file mode 100644 index 0000000000..015f7076e8 --- /dev/null +++ b/tests/specs/run/runtime_decorators/decorators/experimental/no_check/main.out @@ -0,0 +1,3 @@ +a(): evaluated +a(): called +method diff --git a/tests/specs/run/runtime_decorators/decorators/experimental/no_check/main.ts b/tests/specs/run/runtime_decorators/decorators/experimental/no_check/main.ts new file mode 100644 index 0000000000..9f7ec550d5 --- /dev/null +++ b/tests/specs/run/runtime_decorators/decorators/experimental/no_check/main.ts @@ -0,0 +1,21 @@ +// deno-lint-ignore-file +function a() { + console.log("a(): evaluated"); + return ( + _target: any, + _propertyKey: string, + _descriptor: PropertyDescriptor, + ) => { + console.log("a(): called"); + }; +} + +class B { + @a() + method() { + console.log("method"); + } +} + +const b = new B(); +b.method(); diff --git a/tests/specs/run/runtime_decorators/decorators/experimental/runtime/main.out b/tests/specs/run/runtime_decorators/decorators/experimental/runtime/main.out new file mode 100644 index 0000000000..0fc1d4590e --- /dev/null +++ b/tests/specs/run/runtime_decorators/decorators/experimental/runtime/main.out @@ -0,0 +1,7 @@ +@A evaluated +@B evaluated +@B called +@A called +fn() called from @A +fn() called from @B +C.test() called diff --git a/tests/specs/run/runtime_decorators/decorators/experimental/runtime/main.ts b/tests/specs/run/runtime_decorators/decorators/experimental/runtime/main.ts new file mode 100644 index 0000000000..40a26bbd4d --- /dev/null +++ b/tests/specs/run/runtime_decorators/decorators/experimental/runtime/main.ts @@ -0,0 +1,42 @@ +// deno-lint-ignore-file +function a() { + console.log("@A evaluated"); + return function ( + target: any, + propertyKey: string, + descriptor: PropertyDescriptor, + ) { + console.log("@A called"); + const fn = descriptor.value; + descriptor.value = function () { + console.log("fn() called from @A"); + fn(); + }; + }; +} + +function b() { + console.log("@B evaluated"); + return function ( + target: any, + propertyKey: string, + descriptor: PropertyDescriptor, + ) { + console.log("@B called"); + const fn = descriptor.value; + descriptor.value = function () { + console.log("fn() called from @B"); + fn(); + }; + }; +} + +class C { + @a() + @b() + static test() { + console.log("C.test() called"); + } +} + +C.test(); diff --git a/tests/specs/run/runtime_decorators/decorators/experimental/ts/main.out b/tests/specs/run/runtime_decorators/decorators/experimental/ts/main.out new file mode 100644 index 0000000000..ea64fbaa63 --- /dev/null +++ b/tests/specs/run/runtime_decorators/decorators/experimental/ts/main.out @@ -0,0 +1,3 @@ +Warning experimentalDecorators compiler option is deprecated and may be removed at any time +Check [WILDCARD] +SomeClass { someField: "asdf" } diff --git a/tests/specs/run/runtime_decorators/decorators/experimental/ts/main.ts b/tests/specs/run/runtime_decorators/decorators/experimental/ts/main.ts new file mode 100644 index 0000000000..95fba6cd48 --- /dev/null +++ b/tests/specs/run/runtime_decorators/decorators/experimental/ts/main.ts @@ -0,0 +1,14 @@ +// deno-lint-ignore-file + +function Decorate() { + return function (constructor: any): any { + return class extends constructor { + protected someField: string = "asdf"; + }; + }; +} + +@Decorate() +class SomeClass {} + +console.log(new SomeClass()); diff --git a/tests/specs/run/runtime_decorators/decorators/tc39_proposal/main.out b/tests/specs/run/runtime_decorators/decorators/tc39_proposal/main.out new file mode 100644 index 0000000000..39394952e8 --- /dev/null +++ b/tests/specs/run/runtime_decorators/decorators/tc39_proposal/main.out @@ -0,0 +1,3 @@ +starting m with arguments 1 +C.m 1 +ending m diff --git a/tests/specs/run/runtime_decorators/decorators/tc39_proposal/main.ts b/tests/specs/run/runtime_decorators/decorators/tc39_proposal/main.ts new file mode 100644 index 0000000000..00c8a85025 --- /dev/null +++ b/tests/specs/run/runtime_decorators/decorators/tc39_proposal/main.ts @@ -0,0 +1,21 @@ +// deno-lint-ignore no-explicit-any +function logged(value: any, { kind, name }: { kind: string; name: string }) { + if (kind === "method") { + return function (...args: unknown[]) { + console.log(`starting ${name} with arguments ${args.join(", ")}`); + // @ts-ignore this has implicit any type + const ret = value.call(this, ...args); + console.log(`ending ${name}`); + return ret; + }; + } +} + +class C { + @logged + m(arg: number) { + console.log("C.m", arg); + } +} + +new C().m(1); diff --git a/tests/specs/run/seed_random/__test__.jsonc b/tests/specs/run/seed_random/__test__.jsonc new file mode 100644 index 0000000000..5a1876d6c3 --- /dev/null +++ b/tests/specs/run/seed_random/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --seed=100 seed_random.js", + "output": "seed_random.js.out" +} diff --git a/tests/testdata/run/seed_random.js b/tests/specs/run/seed_random/seed_random.js similarity index 100% rename from tests/testdata/run/seed_random.js rename to tests/specs/run/seed_random/seed_random.js diff --git a/tests/testdata/run/seed_random.js.out b/tests/specs/run/seed_random/seed_random.js.out similarity index 100% rename from tests/testdata/run/seed_random.js.out rename to tests/specs/run/seed_random/seed_random.js.out diff --git a/tests/specs/run/set_exit_code_0/__test__.jsonc b/tests/specs/run/set_exit_code_0/__test__.jsonc new file mode 100644 index 0000000000..a5866e8c69 --- /dev/null +++ b/tests/specs/run/set_exit_code_0/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --no-check set_exit_code_0.ts", + "output": "", + "exitCode": 0 +} diff --git a/tests/testdata/run/set_exit_code_0.ts b/tests/specs/run/set_exit_code_0/set_exit_code_0.ts similarity index 100% rename from tests/testdata/run/set_exit_code_0.ts rename to tests/specs/run/set_exit_code_0/set_exit_code_0.ts diff --git a/tests/specs/run/set_exit_code_1/__test__.jsonc b/tests/specs/run/set_exit_code_1/__test__.jsonc new file mode 100644 index 0000000000..1ca50c9827 --- /dev/null +++ b/tests/specs/run/set_exit_code_1/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --no-check set_exit_code_1.ts", + "output": "", + "exitCode": 42 +} diff --git a/tests/testdata/run/set_exit_code_1.ts b/tests/specs/run/set_exit_code_1/set_exit_code_1.ts similarity index 100% rename from tests/testdata/run/set_exit_code_1.ts rename to tests/specs/run/set_exit_code_1/set_exit_code_1.ts diff --git a/tests/specs/run/set_exit_code_2/__test__.jsonc b/tests/specs/run/set_exit_code_2/__test__.jsonc new file mode 100644 index 0000000000..af7411f7cb --- /dev/null +++ b/tests/specs/run/set_exit_code_2/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --no-check set_exit_code_2.ts", + "output": "", + "exitCode": 42 +} diff --git a/tests/testdata/run/set_exit_code_2.ts b/tests/specs/run/set_exit_code_2/set_exit_code_2.ts similarity index 100% rename from tests/testdata/run/set_exit_code_2.ts rename to tests/specs/run/set_exit_code_2/set_exit_code_2.ts diff --git a/tests/specs/run/set_timeout_error/__test__.jsonc b/tests/specs/run/set_timeout_error/__test__.jsonc new file mode 100644 index 0000000000..eea730fd87 --- /dev/null +++ b/tests/specs/run/set_timeout_error/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet set_timeout_error.ts", + "output": "set_timeout_error.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/set_timeout_error.ts b/tests/specs/run/set_timeout_error/set_timeout_error.ts similarity index 100% rename from tests/testdata/run/set_timeout_error.ts rename to tests/specs/run/set_timeout_error/set_timeout_error.ts diff --git a/tests/testdata/run/set_timeout_error.ts.out b/tests/specs/run/set_timeout_error/set_timeout_error.ts.out similarity index 100% rename from tests/testdata/run/set_timeout_error.ts.out rename to tests/specs/run/set_timeout_error/set_timeout_error.ts.out diff --git a/tests/specs/run/set_timeout_error_handled/__test__.jsonc b/tests/specs/run/set_timeout_error_handled/__test__.jsonc new file mode 100644 index 0000000000..39a9424bbc --- /dev/null +++ b/tests/specs/run/set_timeout_error_handled/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet set_timeout_error_handled.ts", + "output": "set_timeout_error_handled.ts.out" +} diff --git a/tests/testdata/run/set_timeout_error_handled.ts b/tests/specs/run/set_timeout_error_handled/set_timeout_error_handled.ts similarity index 100% rename from tests/testdata/run/set_timeout_error_handled.ts rename to tests/specs/run/set_timeout_error_handled/set_timeout_error_handled.ts diff --git a/tests/testdata/run/set_timeout_error_handled.ts.out b/tests/specs/run/set_timeout_error_handled/set_timeout_error_handled.ts.out similarity index 100% rename from tests/testdata/run/set_timeout_error_handled.ts.out rename to tests/specs/run/set_timeout_error_handled/set_timeout_error_handled.ts.out diff --git a/tests/specs/run/shebang_swc/__test__.jsonc b/tests/specs/run/shebang_swc/__test__.jsonc new file mode 100644 index 0000000000..65e0b5c9b1 --- /dev/null +++ b/tests/specs/run/shebang_swc/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet shebang.ts", + "output": "shebang.ts.out" +} diff --git a/tests/testdata/run/shebang.ts b/tests/specs/run/shebang_swc/shebang.ts similarity index 100% rename from tests/testdata/run/shebang.ts rename to tests/specs/run/shebang_swc/shebang.ts diff --git a/tests/testdata/run/shebang.ts.out b/tests/specs/run/shebang_swc/shebang.ts.out similarity index 100% rename from tests/testdata/run/shebang.ts.out rename to tests/specs/run/shebang_swc/shebang.ts.out diff --git a/tests/specs/run/shebang_swc/shebang2.ts b/tests/specs/run/shebang_swc/shebang2.ts new file mode 100644 index 0000000000..da0d7bf0c9 --- /dev/null +++ b/tests/specs/run/shebang_swc/shebang2.ts @@ -0,0 +1,3 @@ +#!/usr/bin/env -S deno run + +export default 42; diff --git a/tests/specs/run/shebang_tsc/__test__.jsonc b/tests/specs/run/shebang_tsc/__test__.jsonc new file mode 100644 index 0000000000..f78971d57d --- /dev/null +++ b/tests/specs/run/shebang_tsc/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --check shebang.ts", + "output": "shebang.ts.out" +} diff --git a/tests/specs/run/shebang_tsc/shebang.ts b/tests/specs/run/shebang_tsc/shebang.ts new file mode 100644 index 0000000000..00feb2da0a --- /dev/null +++ b/tests/specs/run/shebang_tsc/shebang.ts @@ -0,0 +1,5 @@ +#!/usr/bin/env -S deno run + +import test from "./shebang2.ts"; + +console.log(test as number); diff --git a/tests/testdata/run/wasm.ts.out b/tests/specs/run/shebang_tsc/shebang.ts.out similarity index 100% rename from tests/testdata/run/wasm.ts.out rename to tests/specs/run/shebang_tsc/shebang.ts.out diff --git a/tests/specs/run/shebang_tsc/shebang2.ts b/tests/specs/run/shebang_tsc/shebang2.ts new file mode 100644 index 0000000000..da0d7bf0c9 --- /dev/null +++ b/tests/specs/run/shebang_tsc/shebang2.ts @@ -0,0 +1,3 @@ +#!/usr/bin/env -S deno run + +export default 42; diff --git a/tests/specs/run/shebang_with_json_imports_swc/__test__.jsonc b/tests/specs/run/shebang_with_json_imports_swc/__test__.jsonc new file mode 100644 index 0000000000..90592757fe --- /dev/null +++ b/tests/specs/run/shebang_with_json_imports_swc/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --no-check json_with_shebang.ts", + "output": "json_with_shebang.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/run/shebang_with_json_imports_swc/json_with_shebang.json b/tests/specs/run/shebang_with_json_imports_swc/json_with_shebang.json new file mode 100644 index 0000000000..b695e44571 --- /dev/null +++ b/tests/specs/run/shebang_with_json_imports_swc/json_with_shebang.json @@ -0,0 +1,4 @@ +#!/usr/env -S deno run +{ + "test": null +} diff --git a/tests/specs/run/shebang_with_json_imports_swc/json_with_shebang.ts b/tests/specs/run/shebang_with_json_imports_swc/json_with_shebang.ts new file mode 100644 index 0000000000..9524026bce --- /dev/null +++ b/tests/specs/run/shebang_with_json_imports_swc/json_with_shebang.ts @@ -0,0 +1,3 @@ +import json from "./json_with_shebang.json" with { type: "json" }; + +console.log(json); diff --git a/tests/specs/run/shebang_with_json_imports_swc/json_with_shebang.ts.out b/tests/specs/run/shebang_with_json_imports_swc/json_with_shebang.ts.out new file mode 100644 index 0000000000..23eb03720e --- /dev/null +++ b/tests/specs/run/shebang_with_json_imports_swc/json_with_shebang.ts.out @@ -0,0 +1 @@ +error: Uncaught SyntaxError: Unexpected token '#', "#!/usr/env"... is not valid JSON diff --git a/tests/specs/run/shebang_with_json_imports_tsc/__test__.jsonc b/tests/specs/run/shebang_with_json_imports_tsc/__test__.jsonc new file mode 100644 index 0000000000..7fbb8a5d35 --- /dev/null +++ b/tests/specs/run/shebang_with_json_imports_tsc/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet json_with_shebang.ts", + "output": "json_with_shebang.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/run/shebang_with_json_imports_tsc/json_with_shebang.json b/tests/specs/run/shebang_with_json_imports_tsc/json_with_shebang.json new file mode 100644 index 0000000000..b695e44571 --- /dev/null +++ b/tests/specs/run/shebang_with_json_imports_tsc/json_with_shebang.json @@ -0,0 +1,4 @@ +#!/usr/env -S deno run +{ + "test": null +} diff --git a/tests/specs/run/shebang_with_json_imports_tsc/json_with_shebang.ts b/tests/specs/run/shebang_with_json_imports_tsc/json_with_shebang.ts new file mode 100644 index 0000000000..9524026bce --- /dev/null +++ b/tests/specs/run/shebang_with_json_imports_tsc/json_with_shebang.ts @@ -0,0 +1,3 @@ +import json from "./json_with_shebang.json" with { type: "json" }; + +console.log(json); diff --git a/tests/specs/run/shebang_with_json_imports_tsc/json_with_shebang.ts.out b/tests/specs/run/shebang_with_json_imports_tsc/json_with_shebang.ts.out new file mode 100644 index 0000000000..23eb03720e --- /dev/null +++ b/tests/specs/run/shebang_with_json_imports_tsc/json_with_shebang.ts.out @@ -0,0 +1 @@ +error: Uncaught SyntaxError: Unexpected token '#', "#!/usr/env"... is not valid JSON diff --git a/tests/specs/run/single_compile_with_reload/__test__.jsonc b/tests/specs/run/single_compile_with_reload/__test__.jsonc new file mode 100644 index 0000000000..3e2e043790 --- /dev/null +++ b/tests/specs/run/single_compile_with_reload/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --allow-read single_compile_with_reload.ts", + "output": "single_compile_with_reload.ts.out" +} diff --git a/tests/specs/run/single_compile_with_reload/mod1.ts b/tests/specs/run/single_compile_with_reload/mod1.ts new file mode 100644 index 0000000000..5e58f432ed --- /dev/null +++ b/tests/specs/run/single_compile_with_reload/mod1.ts @@ -0,0 +1,17 @@ +import { printHello2, returnsFoo } from "./subdir2/mod2.ts"; + +export function returnsHi(): string { + return "Hi"; +} + +export function returnsFoo2(): string { + return returnsFoo(); +} + +export function printHello3() { + printHello2(); +} + +export function throwsError() { + throw Error("exception from mod1"); +} diff --git a/tests/specs/run/single_compile_with_reload/print_hello.ts b/tests/specs/run/single_compile_with_reload/print_hello.ts new file mode 100644 index 0000000000..b9c0ad5275 --- /dev/null +++ b/tests/specs/run/single_compile_with_reload/print_hello.ts @@ -0,0 +1,3 @@ +export function printHello() { + console.log("Hello"); +} diff --git a/tests/testdata/run/single_compile_with_reload.ts b/tests/specs/run/single_compile_with_reload/single_compile_with_reload.ts similarity index 100% rename from tests/testdata/run/single_compile_with_reload.ts rename to tests/specs/run/single_compile_with_reload/single_compile_with_reload.ts diff --git a/tests/testdata/run/single_compile_with_reload.ts.out b/tests/specs/run/single_compile_with_reload/single_compile_with_reload.ts.out similarity index 100% rename from tests/testdata/run/single_compile_with_reload.ts.out rename to tests/specs/run/single_compile_with_reload/single_compile_with_reload.ts.out diff --git a/tests/specs/run/single_compile_with_reload/single_compile_with_reload_dyn.ts b/tests/specs/run/single_compile_with_reload/single_compile_with_reload_dyn.ts new file mode 100644 index 0000000000..c69556be15 --- /dev/null +++ b/tests/specs/run/single_compile_with_reload/single_compile_with_reload_dyn.ts @@ -0,0 +1,11 @@ +import { printHello3, returnsFoo2, returnsHi } from "./mod1.ts"; + +printHello3(); + +if (returnsHi() !== "Hi") { + throw Error("Unexpected"); +} + +if (returnsFoo2() !== "Foo") { + throw Error("Unexpected"); +} diff --git a/tests/specs/run/single_compile_with_reload/single_compile_with_reload_worker.ts b/tests/specs/run/single_compile_with_reload/single_compile_with_reload_worker.ts new file mode 100644 index 0000000000..103cafe20c --- /dev/null +++ b/tests/specs/run/single_compile_with_reload/single_compile_with_reload_worker.ts @@ -0,0 +1,3 @@ +console.log("Hello from worker"); +postMessage(null); +close(); diff --git a/tests/specs/run/single_compile_with_reload/subdir2/dynamic_import.ts b/tests/specs/run/single_compile_with_reload/subdir2/dynamic_import.ts new file mode 100644 index 0000000000..59beb64c33 --- /dev/null +++ b/tests/specs/run/single_compile_with_reload/subdir2/dynamic_import.ts @@ -0,0 +1,4 @@ +(async () => { + const { printHello } = await import("../mod2.ts"); + printHello(); +})(); diff --git a/tests/specs/run/single_compile_with_reload/subdir2/mod2.ts b/tests/specs/run/single_compile_with_reload/subdir2/mod2.ts new file mode 100644 index 0000000000..9071d0aeb4 --- /dev/null +++ b/tests/specs/run/single_compile_with_reload/subdir2/mod2.ts @@ -0,0 +1,9 @@ +import { printHello } from "../print_hello.ts"; + +export function returnsFoo(): string { + return "Foo"; +} + +export function printHello2() { + printHello(); +} diff --git a/tests/specs/run/spawn_stdout_inherit/__test__.jsonc b/tests/specs/run/spawn_stdout_inherit/__test__.jsonc new file mode 100644 index 0000000000..4dd5fe54ce --- /dev/null +++ b/tests/specs/run/spawn_stdout_inherit/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet -A spawn_stdout_inherit.ts", + "output": "spawn_stdout_inherit.ts.out" +} diff --git a/tests/testdata/run/spawn_stdout_inherit.ts b/tests/specs/run/spawn_stdout_inherit/spawn_stdout_inherit.ts similarity index 100% rename from tests/testdata/run/spawn_stdout_inherit.ts rename to tests/specs/run/spawn_stdout_inherit/spawn_stdout_inherit.ts diff --git a/tests/testdata/run/spawn_stdout_inherit.ts.out b/tests/specs/run/spawn_stdout_inherit/spawn_stdout_inherit.ts.out similarity index 100% rename from tests/testdata/run/spawn_stdout_inherit.ts.out rename to tests/specs/run/spawn_stdout_inherit/spawn_stdout_inherit.ts.out diff --git a/tests/specs/run/stdin_read_all/__test__.jsonc b/tests/specs/run/stdin_read_all/__test__.jsonc new file mode 100644 index 0000000000..6fc035aabd --- /dev/null +++ b/tests/specs/run/stdin_read_all/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet stdin_read_all.ts", + "output": "stdin_read_all.out", + "input": "01234567890123456789012345678901234567890123456789" +} diff --git a/tests/testdata/run/stdin_read_all.out b/tests/specs/run/stdin_read_all/stdin_read_all.out similarity index 100% rename from tests/testdata/run/stdin_read_all.out rename to tests/specs/run/stdin_read_all/stdin_read_all.out diff --git a/tests/testdata/run/stdin_read_all.ts b/tests/specs/run/stdin_read_all/stdin_read_all.ts similarity index 100% rename from tests/testdata/run/stdin_read_all.ts rename to tests/specs/run/stdin_read_all/stdin_read_all.ts diff --git a/tests/specs/run/stdout_write_all/__test__.jsonc b/tests/specs/run/stdout_write_all/__test__.jsonc new file mode 100644 index 0000000000..2057f4a115 --- /dev/null +++ b/tests/specs/run/stdout_write_all/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet stdout_write_all.ts", + "output": "stdout_write_all.out" +} diff --git a/tests/testdata/run/stdout_write_all.out b/tests/specs/run/stdout_write_all/stdout_write_all.out similarity index 100% rename from tests/testdata/run/stdout_write_all.out rename to tests/specs/run/stdout_write_all/stdout_write_all.out diff --git a/tests/testdata/run/stdout_write_all.ts b/tests/specs/run/stdout_write_all/stdout_write_all.ts similarity index 100% rename from tests/testdata/run/stdout_write_all.ts rename to tests/specs/run/stdout_write_all/stdout_write_all.ts diff --git a/tests/specs/run/stdout_write_sync_async/__test__.jsonc b/tests/specs/run/stdout_write_sync_async/__test__.jsonc new file mode 100644 index 0000000000..5032ca015f --- /dev/null +++ b/tests/specs/run/stdout_write_sync_async/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet stdout_write_sync_async.ts", + "output": "stdout_write_sync_async.out" +} diff --git a/tests/testdata/run/stdout_write_sync_async.out b/tests/specs/run/stdout_write_sync_async/stdout_write_sync_async.out similarity index 100% rename from tests/testdata/run/stdout_write_sync_async.out rename to tests/specs/run/stdout_write_sync_async/stdout_write_sync_async.out diff --git a/tests/testdata/run/stdout_write_sync_async.ts b/tests/specs/run/stdout_write_sync_async/stdout_write_sync_async.ts similarity index 100% rename from tests/testdata/run/stdout_write_sync_async.ts rename to tests/specs/run/stdout_write_sync_async/stdout_write_sync_async.ts diff --git a/tests/specs/run/swc_syntax_error/__test__.jsonc b/tests/specs/run/swc_syntax_error/__test__.jsonc new file mode 100644 index 0000000000..842a4fcf8e --- /dev/null +++ b/tests/specs/run/swc_syntax_error/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload --check swc_syntax_error.ts", + "output": "swc_syntax_error.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/swc_syntax_error.ts b/tests/specs/run/swc_syntax_error/swc_syntax_error.ts similarity index 100% rename from tests/testdata/run/swc_syntax_error.ts rename to tests/specs/run/swc_syntax_error/swc_syntax_error.ts diff --git a/tests/testdata/run/swc_syntax_error.ts.out b/tests/specs/run/swc_syntax_error/swc_syntax_error.ts.out similarity index 100% rename from tests/testdata/run/swc_syntax_error.ts.out rename to tests/specs/run/swc_syntax_error/swc_syntax_error.ts.out diff --git a/tests/specs/run/test_and_bench_are_noops_in_run/__test__.jsonc b/tests/specs/run/test_and_bench_are_noops_in_run/__test__.jsonc new file mode 100644 index 0000000000..3d8d2ba56e --- /dev/null +++ b/tests/specs/run/test_and_bench_are_noops_in_run/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run test_and_bench_in_run.js", + "output": "" +} diff --git a/tests/testdata/run/test_and_bench_in_run.js b/tests/specs/run/test_and_bench_are_noops_in_run/test_and_bench_in_run.js similarity index 100% rename from tests/testdata/run/test_and_bench_in_run.js rename to tests/specs/run/test_and_bench_are_noops_in_run/test_and_bench_in_run.js diff --git a/tests/specs/run/tls_connecttls/RootCA.pem b/tests/specs/run/tls_connecttls/RootCA.pem new file mode 100644 index 0000000000..c2f84ceebc --- /dev/null +++ b/tests/specs/run/tls_connecttls/RootCA.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDIzCCAgugAwIBAgIJAMKPPW4tsOymMA0GCSqGSIb3DQEBCwUAMCcxCzAJBgNV +BAYTAlVTMRgwFgYDVQQDDA9FeGFtcGxlLVJvb3QtQ0EwIBcNMTkxMDIxMTYyODIy +WhgPMjExODA5MjcxNjI4MjJaMCcxCzAJBgNVBAYTAlVTMRgwFgYDVQQDDA9FeGFt +cGxlLVJvb3QtQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDMH/IO +2qtHfyBKwANNPB4K0q5JVSg8XxZdRpTTlz0CwU0oRO3uHrI52raCCfVeiQutyZop +eFZTDWeXGudGAFA2B5m3orWt0s+touPi8MzjsG2TQ+WSI66QgbXTNDitDDBtTVcV +5G3Ic+3SppQAYiHSekLISnYWgXLl+k5CnEfTowg6cjqjVr0KjL03cTN3H7b+6+0S +ws4rYbW1j4ExR7K6BFNH6572yq5qR20E6GqlY+EcOZpw4CbCk9lS8/CWuXze/vMs +OfDcc6K+B625d27wyEGZHedBomT2vAD7sBjvO8hn/DP1Qb46a8uCHR6NSfnJ7bXO +G1igaIbgY1zXirNdAgMBAAGjUDBOMB0GA1UdDgQWBBTzut+pwwDfqmMYcI9KNWRD +hxcIpTAfBgNVHSMEGDAWgBTzut+pwwDfqmMYcI9KNWRDhxcIpTAMBgNVHRMEBTAD +AQH/MA0GCSqGSIb3DQEBCwUAA4IBAQB9AqSbZ+hEglAgSHxAMCqRFdhVu7MvaQM0 +P090mhGlOCt3yB7kdGfsIrUW6nQcTz7PPQFRaJMrFHPvFvPootkBUpTYR4hTkdce +H6RCRu2Jxl4Y9bY/uezd9YhGCYfUtfjA6/TH9FcuZfttmOOlxOt01XfNvVMIR6RM +z/AYhd+DeOXjr35F/VHeVpnk+55L0PYJsm1CdEbOs5Hy1ecR7ACuDkXnbM4fpz9I +kyIWJwk2zJReKcJMgi1aIinDM9ao/dca1G99PHOw8dnr4oyoTiv8ao6PWiSRHHMi +MNf4EgWfK+tZMnuqfpfO9740KzfcVoMNo4QJD4yn5YxroUOO/Azi +-----END CERTIFICATE----- diff --git a/tests/specs/run/tls_connecttls/__test__.jsonc b/tests/specs/run/tls_connecttls/__test__.jsonc new file mode 100644 index 0000000000..2e8f88339d --- /dev/null +++ b/tests/specs/run/tls_connecttls/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-net --allow-read --cert RootCA.pem --config deno.json tls_connecttls.js", + "output": "tls.out" +} diff --git a/tests/specs/run/tls_connecttls/deno.json b/tests/specs/run/tls_connecttls/deno.json new file mode 100644 index 0000000000..105514e133 --- /dev/null +++ b/tests/specs/run/tls_connecttls/deno.json @@ -0,0 +1,4 @@ +{ + "lock": false, + "importMap": "../../../../import_map.json" +} diff --git a/tests/specs/run/tls_connecttls/localhost.crt b/tests/specs/run/tls_connecttls/localhost.crt new file mode 100644 index 0000000000..a71ae9050f --- /dev/null +++ b/tests/specs/run/tls_connecttls/localhost.crt @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDajCCAlKgAwIBAgIJAOPyQVdy/UpPMA0GCSqGSIb3DQEBCwUAMCcxCzAJBgNV +BAYTAlVTMRgwFgYDVQQDDA9FeGFtcGxlLVJvb3QtQ0EwIBcNMTkxMDIxMTYyODU4 +WhgPMjExODA5MjcxNjI4NThaMG0xCzAJBgNVBAYTAlVTMRIwEAYDVQQIDAlZb3Vy +U3RhdGUxETAPBgNVBAcMCFlvdXJDaXR5MR0wGwYDVQQKDBRFeGFtcGxlLUNlcnRp +ZmljYXRlczEYMBYGA1UEAwwPbG9jYWxob3N0LmxvY2FsMIIBIjANBgkqhkiG9w0B +AQEFAAOCAQ8AMIIBCgKCAQEAz9svjVdf5jihUBtofd84XKdb8dEHQRJfDNKaJ4Ar +baqMHAdnqi/fWtlqEEMn8gweZ7+4hshECY5mnx4Hhy7IAbePDsTTbSm01dChhlxF +uvd9QuvzvrqSjSq+v4Jlau+pQIhUzzV12dF5bFvrIrGWxCZp+W7lLDZI6Pd6Su+y +ZIeiwrUaPMzdUePNf2hZI/IvWCUMCIyoqrrKHdHoPuvQCW17IyxsnFQJNbmN+Rtp +BQilhtwvBbggCBWhHxEdiqBaZHDw6Zl+bU7ejx1mu9A95wpQ9SCL2cRkAlz2LDOy +wznrTAwGcvqvFKxlV+3HsaD7rba4kCA1Ihp5mm/dS2k94QIDAQABo1EwTzAfBgNV +HSMEGDAWgBTzut+pwwDfqmMYcI9KNWRDhxcIpTAJBgNVHRMEAjAAMAsGA1UdDwQE +AwIE8DAUBgNVHREEDTALgglsb2NhbGhvc3QwDQYJKoZIhvcNAQELBQADggEBAKVu +vVpu5nPGAGn1SX4FQUcbn9Z5wgBkjnZxfJHJQX4sYIRlcirZviPHCZGPWex4VHC+ +lFMm+70YEN2uoe5jGrdgcugzx2Amc7/mLrsvvpMsaS0PlxNMcqhdM1WHbGjjdNln +XICVITSKnB1fSGH6uo9CMCWw5kgPS9o4QWrLLkxnds3hoz7gVEUyi/6V65mcfFNA +lof9iKcK9JsSHdBs35vpv7UKLX+96RM7Nm2Mu0yue5JiS79/zuMA/Kryxot4jv5z +ecdWFl0eIyQBZmBzMw2zPUqkxEnXLiKjV8jutEg/4qovTOB6YiA41qbARXdzNA2V +FYuchcTcWmnmVVRFyyU= +-----END CERTIFICATE----- diff --git a/tests/specs/run/tls_connecttls/localhost.key b/tests/specs/run/tls_connecttls/localhost.key new file mode 100644 index 0000000000..42774c9771 --- /dev/null +++ b/tests/specs/run/tls_connecttls/localhost.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDP2y+NV1/mOKFQ +G2h93zhcp1vx0QdBEl8M0pongCttqowcB2eqL99a2WoQQyfyDB5nv7iGyEQJjmaf +HgeHLsgBt48OxNNtKbTV0KGGXEW6931C6/O+upKNKr6/gmVq76lAiFTPNXXZ0Xls +W+sisZbEJmn5buUsNkjo93pK77Jkh6LCtRo8zN1R481/aFkj8i9YJQwIjKiqusod +0eg+69AJbXsjLGycVAk1uY35G2kFCKWG3C8FuCAIFaEfER2KoFpkcPDpmX5tTt6P +HWa70D3nClD1IIvZxGQCXPYsM7LDOetMDAZy+q8UrGVX7cexoPuttriQIDUiGnma +b91LaT3hAgMBAAECggEBAJABfn+BQorBP1m9s3ZJmcXvmW7+7/SwYrQCkRS+4te2 +6h1dMAAj7K4HpUkhDeLPbJ1aoeCXjTPFuemRp4uL6Lvvzahgy059L7FXOyFYemMf +pmQgDx5cKr6tF7yc/eDJrExuZ7urgTvouiRNxqmhuh+psZBDuXkZHwhwtQSH7uNg +KBDKu0qWO73vFLcLckdGEU3+H9oIWs5xcvvOkWzyvHbRGFJSihgcRpPPHodF5xB9 +T/gZIoJHMmCbUMlWaSasUyNXTuvCnkvBDol8vXrMJCVzKZj9GpPDcIFdc08GSn4I +pTdSNwzUcHbdERzdVU28Xt+t6W5rvp/4FWrssi4IzkUCgYEA//ZcEcBguRD4OFrx +6wbSjzCcUW1NWhzA8uTOORZi4SvndcH1cU4S2wznuHNubU1XlrGwJX6PUGebmY/l +53B5PJvStbVtZCVIxllR+ZVzRuL8wLodRHzlYH8GOzHwoa4ivSupkzl72ij1u/tI +NMLGfYEKVdNd8zXIESUY88NszvsCgYEAz+MDp3xOhFaCe+CPv80A592cJcfzc8Al ++rahEOu+VdN2QBZf86PIf2Bfv/t0QvnRvs1z648TuH6h83YSggOAbmfHyd789jkq +UWlktIaXbVn+VaHmPTcBWTg3ZTlvG+fiFCbZXiYhm+UUf1MDqZHdiifAoyVIjV/Z +YhCNJo3q39MCgYEAknrpK5t9fstwUcfyA/9OhnVaL9suVjB4V0iLn+3ovlXCywgp +ryLv9X3IKi2c9144jtu3I23vFCOGz3WjKzSZnQ7LogNmy9XudNxu5jcZ1mpWHPEl +iKk1F2j6Juwoek5OQRX4oHFYKHwiTOa75r3Em9Q6Fu20KVgQ24bwZafj3/sCgYAy +k0AoVw2jFIjaKl/Ogclen4OFjYek+XJD9Hpq62964d866Dafx5DXrFKfGkXGpZBp +owI4pK5fjC9KU8dc6g0szwLEEgPowy+QbtuZL8VXTTWbD7A75E3nrs2LStXFLDzM +OkdXqF801h6Oe1vAvUPwgItVJZTpEBCK0wwD/TLPEQKBgQDRkhlTtAoHW7W6STd0 +A/OWc0dxhzMurpxg0bLgCqUjw1ESGrSCGhffFn0IWa8sv19VWsZuBhTgjNatZsYB +AhDs/6OosT/3nJoh2/t0hYDj1FBI0lPXWYD4pesuZ5yIMrmSaAOtIzp4BGY7ui8N +wOqcq/jdiHj/MKEdqOXy3YAJrA== +-----END PRIVATE KEY----- diff --git a/tests/specs/run/tls_connecttls/textproto.ts b/tests/specs/run/tls_connecttls/textproto.ts new file mode 100644 index 0000000000..9e0f5f5f0a --- /dev/null +++ b/tests/specs/run/tls_connecttls/textproto.ts @@ -0,0 +1,170 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +/** **Deprecated**. Use `TextLineStream` from `std/steams` for line-by-line text reading instead. + * + * A reader for dealing with low level text based protocols. + * + * Based on + * [net/textproto](https://github.com/golang/go/tree/master/src/net/textproto). + * + * @deprecated (will be removed after 0.159.0) Use `TextLineStream` from `std/steams` for line-by-line text reading instead. + * @module + */ + +import type { BufReader, ReadLineResult } from "@std/io/buf-reader"; +import { concat } from "@std/bytes/concat"; + +// Constants created for DRY +const CHAR_SPACE: number = " ".charCodeAt(0); +const CHAR_TAB: number = "\t".charCodeAt(0); +const CHAR_COLON: number = ":".charCodeAt(0); + +const WHITESPACES: Array = [CHAR_SPACE, CHAR_TAB]; + +const decoder = new TextDecoder(); + +// FROM https://github.com/denoland/deno/blob/b34628a26ab0187a827aa4ebe256e23178e25d39/cli/js/web/headers.ts#L9 +const invalidHeaderCharRegex = /[^\t\x20-\x7e\x80-\xff]/g; + +function str(buf: Uint8Array | null | undefined): string { + return !buf ? "" : decoder.decode(buf); +} + +/** + * @deprecated (will be removed after 0.159.0) Use `TextLineStream` from `std/steams` for line-by-line text reading instead. + */ +export class TextProtoReader { + constructor(readonly r: BufReader) {} + + /** readLine() reads a single line from the TextProtoReader, + * eliding the final \n or \r\n from the returned string. + */ + async readLine(): Promise { + const s = await this.readLineSlice(); + return s === null ? null : str(s); + } + + /** ReadMimeHeader reads a MIME-style header from r. + * The header is a sequence of possibly continued Key: Value lines + * ending in a blank line. + * The returned map m maps CanonicalMIMEHeaderKey(key) to a + * sequence of values in the same order encountered in the input. + * + * For example, consider this input: + * + * My-Key: Value 1 + * Long-Key: Even + * Longer Value + * My-Key: Value 2 + * + * Given that input, ReadMIMEHeader returns the map: + * + * map[string][]string{ + * "My-Key": {"Value 1", "Value 2"}, + * "Long-Key": {"Even Longer Value"}, + * } + */ + async readMimeHeader(): Promise { + const m = new Headers(); + let line: Uint8Array | undefined; + + // The first line cannot start with a leading space. + let buf = await this.r.peek(1); + if (buf === null) { + return null; + } else if (WHITESPACES.includes(buf[0])) { + line = (await this.readLineSlice()) as Uint8Array; + } + + buf = await this.r.peek(1); + if (buf === null) { + throw new Deno.errors.UnexpectedEof(); + } else if (WHITESPACES.includes(buf[0])) { + throw new Deno.errors.InvalidData( + `malformed MIME header initial line: ${str(line)}`, + ); + } + + while (true) { + const kv = await this.readLineSlice(); // readContinuedLineSlice + if (kv === null) throw new Deno.errors.UnexpectedEof(); + if (kv.byteLength === 0) return m; + + // Key ends at first colon + let i = kv.indexOf(CHAR_COLON); + if (i < 0) { + throw new Deno.errors.InvalidData( + `malformed MIME header line: ${str(kv)}`, + ); + } + + //let key = canonicalMIMEHeaderKey(kv.subarray(0, endKey)); + const key = str(kv.subarray(0, i)); + + // As per RFC 7230 field-name is a token, + // tokens consist of one or more chars. + // We could throw `Deno.errors.InvalidData` here, + // but better to be liberal in what we + // accept, so if we get an empty key, skip it. + if (key == "") { + continue; + } + + // Skip initial spaces in value. + i++; // skip colon + while ( + i < kv.byteLength && + (WHITESPACES.includes(kv[i])) + ) { + i++; + } + const value = str(kv.subarray(i)).replace( + invalidHeaderCharRegex, + encodeURI, + ); + + // In case of invalid header we swallow the error + // example: "Audio Mode" => invalid due to space in the key + try { + m.append(key, value); + } catch { + // Pass + } + } + } + + async readLineSlice(): Promise { + let line = new Uint8Array(0); + let r: ReadLineResult | null = null; + + do { + r = await this.r.readLine(); + // TODO(ry): + // This skipSpace() is definitely misplaced, but I don't know where it + // comes from nor how to fix it. + + //TODO(SmashingQuasar): Kept skipSpace to preserve behavior but it should be looked into to check if it makes sense when this is used. + + if (r !== null && this.skipSpace(r.line) !== 0) { + line = concat([line, r.line]); + } + } while (r !== null && r.more); + + return r === null ? null : line; + } + + skipSpace(l: Uint8Array): number { + let n = 0; + + for (const val of l) { + if (!WHITESPACES.includes(val)) { + n++; + } + } + + return n; + } +} diff --git a/tests/testdata/run/tls.out b/tests/specs/run/tls_connecttls/tls.out similarity index 100% rename from tests/testdata/run/tls.out rename to tests/specs/run/tls_connecttls/tls.out diff --git a/tests/testdata/run/tls_connecttls.js b/tests/specs/run/tls_connecttls/tls_connecttls.js similarity index 94% rename from tests/testdata/run/tls_connecttls.js rename to tests/specs/run/tls_connecttls/tls_connecttls.js index 07b361f9ce..686b13aea3 100644 --- a/tests/testdata/run/tls_connecttls.js +++ b/tests/specs/run/tls_connecttls/tls_connecttls.js @@ -12,8 +12,8 @@ const port = 3505; const listener = Deno.listenTls({ hostname, port, - cert: Deno.readTextFileSync("./tls/localhost.crt"), - key: Deno.readTextFileSync("./tls/localhost.key"), + cert: Deno.readTextFileSync("./localhost.crt"), + key: Deno.readTextFileSync("./localhost.key"), }); const response = encoder.encode( diff --git a/tests/specs/run/tls_starttls/RootCA.pem b/tests/specs/run/tls_starttls/RootCA.pem new file mode 100644 index 0000000000..c2f84ceebc --- /dev/null +++ b/tests/specs/run/tls_starttls/RootCA.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDIzCCAgugAwIBAgIJAMKPPW4tsOymMA0GCSqGSIb3DQEBCwUAMCcxCzAJBgNV +BAYTAlVTMRgwFgYDVQQDDA9FeGFtcGxlLVJvb3QtQ0EwIBcNMTkxMDIxMTYyODIy +WhgPMjExODA5MjcxNjI4MjJaMCcxCzAJBgNVBAYTAlVTMRgwFgYDVQQDDA9FeGFt +cGxlLVJvb3QtQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDMH/IO +2qtHfyBKwANNPB4K0q5JVSg8XxZdRpTTlz0CwU0oRO3uHrI52raCCfVeiQutyZop +eFZTDWeXGudGAFA2B5m3orWt0s+touPi8MzjsG2TQ+WSI66QgbXTNDitDDBtTVcV +5G3Ic+3SppQAYiHSekLISnYWgXLl+k5CnEfTowg6cjqjVr0KjL03cTN3H7b+6+0S +ws4rYbW1j4ExR7K6BFNH6572yq5qR20E6GqlY+EcOZpw4CbCk9lS8/CWuXze/vMs +OfDcc6K+B625d27wyEGZHedBomT2vAD7sBjvO8hn/DP1Qb46a8uCHR6NSfnJ7bXO +G1igaIbgY1zXirNdAgMBAAGjUDBOMB0GA1UdDgQWBBTzut+pwwDfqmMYcI9KNWRD +hxcIpTAfBgNVHSMEGDAWgBTzut+pwwDfqmMYcI9KNWRDhxcIpTAMBgNVHRMEBTAD +AQH/MA0GCSqGSIb3DQEBCwUAA4IBAQB9AqSbZ+hEglAgSHxAMCqRFdhVu7MvaQM0 +P090mhGlOCt3yB7kdGfsIrUW6nQcTz7PPQFRaJMrFHPvFvPootkBUpTYR4hTkdce +H6RCRu2Jxl4Y9bY/uezd9YhGCYfUtfjA6/TH9FcuZfttmOOlxOt01XfNvVMIR6RM +z/AYhd+DeOXjr35F/VHeVpnk+55L0PYJsm1CdEbOs5Hy1ecR7ACuDkXnbM4fpz9I +kyIWJwk2zJReKcJMgi1aIinDM9ao/dca1G99PHOw8dnr4oyoTiv8ao6PWiSRHHMi +MNf4EgWfK+tZMnuqfpfO9740KzfcVoMNo4QJD4yn5YxroUOO/Azi +-----END CERTIFICATE----- diff --git a/tests/specs/run/tls_starttls/__test__.jsonc b/tests/specs/run/tls_starttls/__test__.jsonc new file mode 100644 index 0000000000..4c1fe6324d --- /dev/null +++ b/tests/specs/run/tls_starttls/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-net --allow-read --cert RootCA.pem --config deno.json tls_starttls.js", + "output": "tls.out" +} diff --git a/tests/specs/run/tls_starttls/deno.json b/tests/specs/run/tls_starttls/deno.json new file mode 100644 index 0000000000..105514e133 --- /dev/null +++ b/tests/specs/run/tls_starttls/deno.json @@ -0,0 +1,4 @@ +{ + "lock": false, + "importMap": "../../../../import_map.json" +} diff --git a/tests/specs/run/tls_starttls/localhost.crt b/tests/specs/run/tls_starttls/localhost.crt new file mode 100644 index 0000000000..a71ae9050f --- /dev/null +++ b/tests/specs/run/tls_starttls/localhost.crt @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDajCCAlKgAwIBAgIJAOPyQVdy/UpPMA0GCSqGSIb3DQEBCwUAMCcxCzAJBgNV +BAYTAlVTMRgwFgYDVQQDDA9FeGFtcGxlLVJvb3QtQ0EwIBcNMTkxMDIxMTYyODU4 +WhgPMjExODA5MjcxNjI4NThaMG0xCzAJBgNVBAYTAlVTMRIwEAYDVQQIDAlZb3Vy +U3RhdGUxETAPBgNVBAcMCFlvdXJDaXR5MR0wGwYDVQQKDBRFeGFtcGxlLUNlcnRp +ZmljYXRlczEYMBYGA1UEAwwPbG9jYWxob3N0LmxvY2FsMIIBIjANBgkqhkiG9w0B +AQEFAAOCAQ8AMIIBCgKCAQEAz9svjVdf5jihUBtofd84XKdb8dEHQRJfDNKaJ4Ar +baqMHAdnqi/fWtlqEEMn8gweZ7+4hshECY5mnx4Hhy7IAbePDsTTbSm01dChhlxF +uvd9QuvzvrqSjSq+v4Jlau+pQIhUzzV12dF5bFvrIrGWxCZp+W7lLDZI6Pd6Su+y +ZIeiwrUaPMzdUePNf2hZI/IvWCUMCIyoqrrKHdHoPuvQCW17IyxsnFQJNbmN+Rtp +BQilhtwvBbggCBWhHxEdiqBaZHDw6Zl+bU7ejx1mu9A95wpQ9SCL2cRkAlz2LDOy +wznrTAwGcvqvFKxlV+3HsaD7rba4kCA1Ihp5mm/dS2k94QIDAQABo1EwTzAfBgNV +HSMEGDAWgBTzut+pwwDfqmMYcI9KNWRDhxcIpTAJBgNVHRMEAjAAMAsGA1UdDwQE +AwIE8DAUBgNVHREEDTALgglsb2NhbGhvc3QwDQYJKoZIhvcNAQELBQADggEBAKVu +vVpu5nPGAGn1SX4FQUcbn9Z5wgBkjnZxfJHJQX4sYIRlcirZviPHCZGPWex4VHC+ +lFMm+70YEN2uoe5jGrdgcugzx2Amc7/mLrsvvpMsaS0PlxNMcqhdM1WHbGjjdNln +XICVITSKnB1fSGH6uo9CMCWw5kgPS9o4QWrLLkxnds3hoz7gVEUyi/6V65mcfFNA +lof9iKcK9JsSHdBs35vpv7UKLX+96RM7Nm2Mu0yue5JiS79/zuMA/Kryxot4jv5z +ecdWFl0eIyQBZmBzMw2zPUqkxEnXLiKjV8jutEg/4qovTOB6YiA41qbARXdzNA2V +FYuchcTcWmnmVVRFyyU= +-----END CERTIFICATE----- diff --git a/tests/specs/run/tls_starttls/localhost.key b/tests/specs/run/tls_starttls/localhost.key new file mode 100644 index 0000000000..42774c9771 --- /dev/null +++ b/tests/specs/run/tls_starttls/localhost.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDP2y+NV1/mOKFQ +G2h93zhcp1vx0QdBEl8M0pongCttqowcB2eqL99a2WoQQyfyDB5nv7iGyEQJjmaf +HgeHLsgBt48OxNNtKbTV0KGGXEW6931C6/O+upKNKr6/gmVq76lAiFTPNXXZ0Xls +W+sisZbEJmn5buUsNkjo93pK77Jkh6LCtRo8zN1R481/aFkj8i9YJQwIjKiqusod +0eg+69AJbXsjLGycVAk1uY35G2kFCKWG3C8FuCAIFaEfER2KoFpkcPDpmX5tTt6P +HWa70D3nClD1IIvZxGQCXPYsM7LDOetMDAZy+q8UrGVX7cexoPuttriQIDUiGnma +b91LaT3hAgMBAAECggEBAJABfn+BQorBP1m9s3ZJmcXvmW7+7/SwYrQCkRS+4te2 +6h1dMAAj7K4HpUkhDeLPbJ1aoeCXjTPFuemRp4uL6Lvvzahgy059L7FXOyFYemMf +pmQgDx5cKr6tF7yc/eDJrExuZ7urgTvouiRNxqmhuh+psZBDuXkZHwhwtQSH7uNg +KBDKu0qWO73vFLcLckdGEU3+H9oIWs5xcvvOkWzyvHbRGFJSihgcRpPPHodF5xB9 +T/gZIoJHMmCbUMlWaSasUyNXTuvCnkvBDol8vXrMJCVzKZj9GpPDcIFdc08GSn4I +pTdSNwzUcHbdERzdVU28Xt+t6W5rvp/4FWrssi4IzkUCgYEA//ZcEcBguRD4OFrx +6wbSjzCcUW1NWhzA8uTOORZi4SvndcH1cU4S2wznuHNubU1XlrGwJX6PUGebmY/l +53B5PJvStbVtZCVIxllR+ZVzRuL8wLodRHzlYH8GOzHwoa4ivSupkzl72ij1u/tI +NMLGfYEKVdNd8zXIESUY88NszvsCgYEAz+MDp3xOhFaCe+CPv80A592cJcfzc8Al ++rahEOu+VdN2QBZf86PIf2Bfv/t0QvnRvs1z648TuH6h83YSggOAbmfHyd789jkq +UWlktIaXbVn+VaHmPTcBWTg3ZTlvG+fiFCbZXiYhm+UUf1MDqZHdiifAoyVIjV/Z +YhCNJo3q39MCgYEAknrpK5t9fstwUcfyA/9OhnVaL9suVjB4V0iLn+3ovlXCywgp +ryLv9X3IKi2c9144jtu3I23vFCOGz3WjKzSZnQ7LogNmy9XudNxu5jcZ1mpWHPEl +iKk1F2j6Juwoek5OQRX4oHFYKHwiTOa75r3Em9Q6Fu20KVgQ24bwZafj3/sCgYAy +k0AoVw2jFIjaKl/Ogclen4OFjYek+XJD9Hpq62964d866Dafx5DXrFKfGkXGpZBp +owI4pK5fjC9KU8dc6g0szwLEEgPowy+QbtuZL8VXTTWbD7A75E3nrs2LStXFLDzM +OkdXqF801h6Oe1vAvUPwgItVJZTpEBCK0wwD/TLPEQKBgQDRkhlTtAoHW7W6STd0 +A/OWc0dxhzMurpxg0bLgCqUjw1ESGrSCGhffFn0IWa8sv19VWsZuBhTgjNatZsYB +AhDs/6OosT/3nJoh2/t0hYDj1FBI0lPXWYD4pesuZ5yIMrmSaAOtIzp4BGY7ui8N +wOqcq/jdiHj/MKEdqOXy3YAJrA== +-----END PRIVATE KEY----- diff --git a/tests/specs/run/tls_starttls/textproto.ts b/tests/specs/run/tls_starttls/textproto.ts new file mode 100644 index 0000000000..9e0f5f5f0a --- /dev/null +++ b/tests/specs/run/tls_starttls/textproto.ts @@ -0,0 +1,170 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +/** **Deprecated**. Use `TextLineStream` from `std/steams` for line-by-line text reading instead. + * + * A reader for dealing with low level text based protocols. + * + * Based on + * [net/textproto](https://github.com/golang/go/tree/master/src/net/textproto). + * + * @deprecated (will be removed after 0.159.0) Use `TextLineStream` from `std/steams` for line-by-line text reading instead. + * @module + */ + +import type { BufReader, ReadLineResult } from "@std/io/buf-reader"; +import { concat } from "@std/bytes/concat"; + +// Constants created for DRY +const CHAR_SPACE: number = " ".charCodeAt(0); +const CHAR_TAB: number = "\t".charCodeAt(0); +const CHAR_COLON: number = ":".charCodeAt(0); + +const WHITESPACES: Array = [CHAR_SPACE, CHAR_TAB]; + +const decoder = new TextDecoder(); + +// FROM https://github.com/denoland/deno/blob/b34628a26ab0187a827aa4ebe256e23178e25d39/cli/js/web/headers.ts#L9 +const invalidHeaderCharRegex = /[^\t\x20-\x7e\x80-\xff]/g; + +function str(buf: Uint8Array | null | undefined): string { + return !buf ? "" : decoder.decode(buf); +} + +/** + * @deprecated (will be removed after 0.159.0) Use `TextLineStream` from `std/steams` for line-by-line text reading instead. + */ +export class TextProtoReader { + constructor(readonly r: BufReader) {} + + /** readLine() reads a single line from the TextProtoReader, + * eliding the final \n or \r\n from the returned string. + */ + async readLine(): Promise { + const s = await this.readLineSlice(); + return s === null ? null : str(s); + } + + /** ReadMimeHeader reads a MIME-style header from r. + * The header is a sequence of possibly continued Key: Value lines + * ending in a blank line. + * The returned map m maps CanonicalMIMEHeaderKey(key) to a + * sequence of values in the same order encountered in the input. + * + * For example, consider this input: + * + * My-Key: Value 1 + * Long-Key: Even + * Longer Value + * My-Key: Value 2 + * + * Given that input, ReadMIMEHeader returns the map: + * + * map[string][]string{ + * "My-Key": {"Value 1", "Value 2"}, + * "Long-Key": {"Even Longer Value"}, + * } + */ + async readMimeHeader(): Promise { + const m = new Headers(); + let line: Uint8Array | undefined; + + // The first line cannot start with a leading space. + let buf = await this.r.peek(1); + if (buf === null) { + return null; + } else if (WHITESPACES.includes(buf[0])) { + line = (await this.readLineSlice()) as Uint8Array; + } + + buf = await this.r.peek(1); + if (buf === null) { + throw new Deno.errors.UnexpectedEof(); + } else if (WHITESPACES.includes(buf[0])) { + throw new Deno.errors.InvalidData( + `malformed MIME header initial line: ${str(line)}`, + ); + } + + while (true) { + const kv = await this.readLineSlice(); // readContinuedLineSlice + if (kv === null) throw new Deno.errors.UnexpectedEof(); + if (kv.byteLength === 0) return m; + + // Key ends at first colon + let i = kv.indexOf(CHAR_COLON); + if (i < 0) { + throw new Deno.errors.InvalidData( + `malformed MIME header line: ${str(kv)}`, + ); + } + + //let key = canonicalMIMEHeaderKey(kv.subarray(0, endKey)); + const key = str(kv.subarray(0, i)); + + // As per RFC 7230 field-name is a token, + // tokens consist of one or more chars. + // We could throw `Deno.errors.InvalidData` here, + // but better to be liberal in what we + // accept, so if we get an empty key, skip it. + if (key == "") { + continue; + } + + // Skip initial spaces in value. + i++; // skip colon + while ( + i < kv.byteLength && + (WHITESPACES.includes(kv[i])) + ) { + i++; + } + const value = str(kv.subarray(i)).replace( + invalidHeaderCharRegex, + encodeURI, + ); + + // In case of invalid header we swallow the error + // example: "Audio Mode" => invalid due to space in the key + try { + m.append(key, value); + } catch { + // Pass + } + } + } + + async readLineSlice(): Promise { + let line = new Uint8Array(0); + let r: ReadLineResult | null = null; + + do { + r = await this.r.readLine(); + // TODO(ry): + // This skipSpace() is definitely misplaced, but I don't know where it + // comes from nor how to fix it. + + //TODO(SmashingQuasar): Kept skipSpace to preserve behavior but it should be looked into to check if it makes sense when this is used. + + if (r !== null && this.skipSpace(r.line) !== 0) { + line = concat([line, r.line]); + } + } while (r !== null && r.more); + + return r === null ? null : line; + } + + skipSpace(l: Uint8Array): number { + let n = 0; + + for (const val of l) { + if (!WHITESPACES.includes(val)) { + n++; + } + } + + return n; + } +} diff --git a/tests/specs/run/tls_starttls/tls.out b/tests/specs/run/tls_starttls/tls.out new file mode 100644 index 0000000000..c8e8a135c9 --- /dev/null +++ b/tests/specs/run/tls_starttls/tls.out @@ -0,0 +1 @@ +DONE diff --git a/tests/testdata/run/tls_starttls.js b/tests/specs/run/tls_starttls/tls_starttls.js similarity index 94% rename from tests/testdata/run/tls_starttls.js rename to tests/specs/run/tls_starttls/tls_starttls.js index 8e7ac03ee6..cd5718ff5a 100644 --- a/tests/testdata/run/tls_starttls.js +++ b/tests/specs/run/tls_starttls/tls_starttls.js @@ -13,8 +13,8 @@ const port = 3504; const listener = Deno.listenTls({ hostname, port, - cert: Deno.readTextFileSync("./tls/localhost.crt"), - key: Deno.readTextFileSync("./tls/localhost.key"), + cert: Deno.readTextFileSync("./localhost.crt"), + key: Deno.readTextFileSync("./localhost.key"), }); const response = encoder.encode( diff --git a/tests/specs/run/top_level_await/__test__.jsonc b/tests/specs/run/top_level_await/__test__.jsonc new file mode 100644 index 0000000000..25537db5f4 --- /dev/null +++ b/tests/specs/run/top_level_await/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read top_level_await/top_level_await.js", + "output": "top_level_await/top_level_await.out" +} diff --git a/tests/specs/run/top_level_await/hello.txt b/tests/specs/run/top_level_await/hello.txt new file mode 100644 index 0000000000..6769dd60bd --- /dev/null +++ b/tests/specs/run/top_level_await/hello.txt @@ -0,0 +1 @@ +Hello world! \ No newline at end of file diff --git a/tests/testdata/run/top_level_await/circular.js b/tests/specs/run/top_level_await/top_level_await/circular.js similarity index 100% rename from tests/testdata/run/top_level_await/circular.js rename to tests/specs/run/top_level_await/top_level_await/circular.js diff --git a/tests/testdata/run/top_level_await/circular.out b/tests/specs/run/top_level_await/top_level_await/circular.out similarity index 100% rename from tests/testdata/run/top_level_await/circular.out rename to tests/specs/run/top_level_await/top_level_await/circular.out diff --git a/tests/specs/run/top_level_await/top_level_await/loop.js b/tests/specs/run/top_level_await/top_level_await/loop.js new file mode 100644 index 0000000000..f229e03f61 --- /dev/null +++ b/tests/specs/run/top_level_await/top_level_await/loop.js @@ -0,0 +1,20 @@ +const importsDir = Deno.readDirSync( + Deno.realPathSync("./top_level_await/tla2"), +); + +const resolvedPaths = []; + +for (const { name } of importsDir) { + const filePath = Deno.realPathSync(`./top_level_await/tla2/${name}`); + resolvedPaths.push(filePath); +} + +resolvedPaths.sort(); + +for (const filePath of resolvedPaths) { + console.log("loading", filePath); + const mod = await import(`file://${filePath}`); + console.log("loaded", mod); +} + +console.log("all loaded"); diff --git a/tests/testdata/run/top_level_await/loop.out b/tests/specs/run/top_level_await/top_level_await/loop.out similarity index 100% rename from tests/testdata/run/top_level_await/loop.out rename to tests/specs/run/top_level_await/top_level_await/loop.out diff --git a/tests/testdata/run/top_level_await/nested.out b/tests/specs/run/top_level_await/top_level_await/nested.out similarity index 100% rename from tests/testdata/run/top_level_await/nested.out rename to tests/specs/run/top_level_await/top_level_await/nested.out diff --git a/tests/testdata/run/top_level_await/nested/a.js b/tests/specs/run/top_level_await/top_level_await/nested/a.js similarity index 100% rename from tests/testdata/run/top_level_await/nested/a.js rename to tests/specs/run/top_level_await/top_level_await/nested/a.js diff --git a/tests/testdata/run/top_level_await/nested/b.js b/tests/specs/run/top_level_await/top_level_await/nested/b.js similarity index 100% rename from tests/testdata/run/top_level_await/nested/b.js rename to tests/specs/run/top_level_await/top_level_await/nested/b.js diff --git a/tests/testdata/run/top_level_await/nested/main.js b/tests/specs/run/top_level_await/top_level_await/nested/main.js similarity index 100% rename from tests/testdata/run/top_level_await/nested/main.js rename to tests/specs/run/top_level_await/top_level_await/nested/main.js diff --git a/tests/testdata/run/top_level_await/order.js b/tests/specs/run/top_level_await/top_level_await/order.js similarity index 100% rename from tests/testdata/run/top_level_await/order.js rename to tests/specs/run/top_level_await/top_level_await/order.js diff --git a/tests/testdata/run/top_level_await/order.out b/tests/specs/run/top_level_await/top_level_await/order.out similarity index 100% rename from tests/testdata/run/top_level_await/order.out rename to tests/specs/run/top_level_await/top_level_await/order.out diff --git a/tests/specs/run/top_level_await/top_level_await/tla/a.js b/tests/specs/run/top_level_await/top_level_await/tla/a.js new file mode 100644 index 0000000000..c3ef3f7dbc --- /dev/null +++ b/tests/specs/run/top_level_await/top_level_await/tla/a.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("b"); diff --git a/tests/specs/run/top_level_await/top_level_await/tla/b.js b/tests/specs/run/top_level_await/top_level_await/tla/b.js new file mode 100644 index 0000000000..3271c92d8f --- /dev/null +++ b/tests/specs/run/top_level_await/top_level_await/tla/b.js @@ -0,0 +1,7 @@ +import order from "./order.js"; + +await new Promise((resolve) => { + setTimeout(resolve, 200); +}); + +order.push("a"); diff --git a/tests/specs/run/top_level_await/top_level_await/tla/c.js b/tests/specs/run/top_level_await/top_level_await/tla/c.js new file mode 100644 index 0000000000..806eb0a8be --- /dev/null +++ b/tests/specs/run/top_level_await/top_level_await/tla/c.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("c"); diff --git a/tests/specs/run/top_level_await/top_level_await/tla/d.js b/tests/specs/run/top_level_await/top_level_await/tla/d.js new file mode 100644 index 0000000000..283ebf817f --- /dev/null +++ b/tests/specs/run/top_level_await/top_level_await/tla/d.js @@ -0,0 +1,8 @@ +import order from "./order.js"; + +const end = Date.now() + 500; +while (end < Date.now()) { + // pass +} + +order.push("d"); diff --git a/tests/specs/run/top_level_await/top_level_await/tla/order.js b/tests/specs/run/top_level_await/top_level_await/tla/order.js new file mode 100644 index 0000000000..f213a562ce --- /dev/null +++ b/tests/specs/run/top_level_await/top_level_await/tla/order.js @@ -0,0 +1 @@ +export default ["order"]; diff --git a/tests/specs/run/top_level_await/top_level_await/tla/parent.js b/tests/specs/run/top_level_await/top_level_await/tla/parent.js new file mode 100644 index 0000000000..1ecc154634 --- /dev/null +++ b/tests/specs/run/top_level_await/top_level_await/tla/parent.js @@ -0,0 +1,9 @@ +import order from "./order.js"; +import "./a.js"; +import "./b.js"; +import "./c.js"; +import "./d.js"; + +order.push("parent"); + +export default order; diff --git a/tests/specs/run/top_level_await/top_level_await/tla2/a.js b/tests/specs/run/top_level_await/top_level_await/tla2/a.js new file mode 100644 index 0000000000..d07bcb94db --- /dev/null +++ b/tests/specs/run/top_level_await/top_level_await/tla2/a.js @@ -0,0 +1,5 @@ +export default class Foo { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_await/top_level_await/tla2/b.js b/tests/specs/run/top_level_await/top_level_await/tla2/b.js new file mode 100644 index 0000000000..68e357c1e9 --- /dev/null +++ b/tests/specs/run/top_level_await/top_level_await/tla2/b.js @@ -0,0 +1,5 @@ +export default class Bar { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_await/top_level_await/tla3/b.js b/tests/specs/run/top_level_await/top_level_await/tla3/b.js new file mode 100644 index 0000000000..d0349545e9 --- /dev/null +++ b/tests/specs/run/top_level_await/top_level_await/tla3/b.js @@ -0,0 +1,7 @@ +import { foo } from "./timeout_loop.js"; +import { collection } from "../circular.js"; + +console.log("collection in b", collection); +console.log("foo in b", foo); + +export const a = "a"; diff --git a/tests/specs/run/top_level_await/top_level_await/tla3/timeout_loop.js b/tests/specs/run/top_level_await/top_level_await/tla3/timeout_loop.js new file mode 100644 index 0000000000..860e6cd2ae --- /dev/null +++ b/tests/specs/run/top_level_await/top_level_await/tla3/timeout_loop.js @@ -0,0 +1,23 @@ +export const foo = "foo"; + +export function delay(ms) { + return new Promise((res) => + setTimeout(() => { + res(); + }, ms) + ); +} + +let i = 0; + +async function timeoutLoop() { + await delay(1000); + console.log("timeout loop", i); + i++; + if (i > 5) { + return; + } + timeoutLoop(); +} + +timeoutLoop(); diff --git a/tests/specs/run/top_level_await/top_level_await/top_level_await.js b/tests/specs/run/top_level_await/top_level_await/top_level_await.js new file mode 100644 index 0000000000..31c83caedc --- /dev/null +++ b/tests/specs/run/top_level_await/top_level_await/top_level_await.js @@ -0,0 +1,3 @@ +const buf = await Deno.readFile("./hello.txt"); +const n = await Deno.stdout.write(buf); +console.log(`\n\nwrite ${n}`); diff --git a/tests/testdata/run/top_level_await/top_level_await.out b/tests/specs/run/top_level_await/top_level_await/top_level_await.out similarity index 100% rename from tests/testdata/run/top_level_await/top_level_await.out rename to tests/specs/run/top_level_await/top_level_await/top_level_await.out diff --git a/tests/testdata/run/top_level_await/top_level_await.ts b/tests/specs/run/top_level_await/top_level_await/top_level_await.ts similarity index 100% rename from tests/testdata/run/top_level_await/top_level_await.ts rename to tests/specs/run/top_level_await/top_level_await/top_level_await.ts diff --git a/tests/testdata/run/top_level_await/top_level_for_await.js b/tests/specs/run/top_level_await/top_level_await/top_level_for_await.js similarity index 100% rename from tests/testdata/run/top_level_await/top_level_for_await.js rename to tests/specs/run/top_level_await/top_level_await/top_level_for_await.js diff --git a/tests/testdata/run/top_level_await/top_level_for_await.out b/tests/specs/run/top_level_await/top_level_await/top_level_for_await.out similarity index 100% rename from tests/testdata/run/top_level_await/top_level_for_await.out rename to tests/specs/run/top_level_await/top_level_await/top_level_for_await.out diff --git a/tests/testdata/run/top_level_await/top_level_for_await.ts b/tests/specs/run/top_level_await/top_level_await/top_level_for_await.ts similarity index 100% rename from tests/testdata/run/top_level_await/top_level_for_await.ts rename to tests/specs/run/top_level_await/top_level_await/top_level_for_await.ts diff --git a/tests/testdata/run/top_level_await/unresolved.js b/tests/specs/run/top_level_await/top_level_await/unresolved.js similarity index 100% rename from tests/testdata/run/top_level_await/unresolved.js rename to tests/specs/run/top_level_await/top_level_await/unresolved.js diff --git a/tests/testdata/run/top_level_await/unresolved.out b/tests/specs/run/top_level_await/top_level_await/unresolved.out similarity index 100% rename from tests/testdata/run/top_level_await/unresolved.out rename to tests/specs/run/top_level_await/top_level_await/unresolved.out diff --git a/tests/specs/run/top_level_await_circular/__test__.jsonc b/tests/specs/run/top_level_await_circular/__test__.jsonc new file mode 100644 index 0000000000..3e236b2107 --- /dev/null +++ b/tests/specs/run/top_level_await_circular/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --allow-read top_level_await/circular.js", + "output": "top_level_await/circular.out", + "exitCode": 1 +} diff --git a/tests/specs/run/top_level_await_circular/top_level_await/circular.js b/tests/specs/run/top_level_await_circular/top_level_await/circular.js new file mode 100644 index 0000000000..ff2964b6a5 --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/circular.js @@ -0,0 +1,8 @@ +import { foo } from "./tla3/timeout_loop.js"; + +export const collection = []; + +const mod = await import("./tla3/b.js"); + +console.log("foo in main", foo); +console.log("mod", mod); diff --git a/tests/specs/run/top_level_await_circular/top_level_await/circular.out b/tests/specs/run/top_level_await_circular/top_level_await/circular.out new file mode 100644 index 0000000000..c889789613 --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/circular.out @@ -0,0 +1,10 @@ +timeout loop 0 +timeout loop 1 +timeout loop 2 +timeout loop 3 +timeout loop 4 +timeout loop 5 +error: Top-level await promise never resolved +const mod = await import("./tla3/b.js"); + ^ + at ([WILDCARD]/top_level_await/circular.js:5:13) diff --git a/tests/specs/run/top_level_await_circular/top_level_await/loop.js b/tests/specs/run/top_level_await_circular/top_level_await/loop.js new file mode 100644 index 0000000000..f229e03f61 --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/loop.js @@ -0,0 +1,20 @@ +const importsDir = Deno.readDirSync( + Deno.realPathSync("./top_level_await/tla2"), +); + +const resolvedPaths = []; + +for (const { name } of importsDir) { + const filePath = Deno.realPathSync(`./top_level_await/tla2/${name}`); + resolvedPaths.push(filePath); +} + +resolvedPaths.sort(); + +for (const filePath of resolvedPaths) { + console.log("loading", filePath); + const mod = await import(`file://${filePath}`); + console.log("loaded", mod); +} + +console.log("all loaded"); diff --git a/tests/specs/run/top_level_await_circular/top_level_await/loop.out b/tests/specs/run/top_level_await_circular/top_level_await/loop.out new file mode 100644 index 0000000000..1bdffbf660 --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/loop.out @@ -0,0 +1,5 @@ +loading [WILDCARD]a.js +loaded [Module: null prototype] { default: [class Foo] } +loading [WILDCARD]b.js +loaded [Module: null prototype] { default: [class Bar] } +all loaded diff --git a/tests/specs/run/top_level_await_circular/top_level_await/nested.out b/tests/specs/run/top_level_await_circular/top_level_await/nested.out new file mode 100644 index 0000000000..8a1218a102 --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/nested.out @@ -0,0 +1,5 @@ +1 +2 +3 +4 +5 diff --git a/tests/specs/run/top_level_await_circular/top_level_await/nested/a.js b/tests/specs/run/top_level_await_circular/top_level_await/nested/a.js new file mode 100644 index 0000000000..74837d4ba1 --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/nested/a.js @@ -0,0 +1,3 @@ +console.log(2); +await import("./b.js"); +console.log(4); diff --git a/tests/specs/run/top_level_await_circular/top_level_await/nested/b.js b/tests/specs/run/top_level_await_circular/top_level_await/nested/b.js new file mode 100644 index 0000000000..3bd241b50e --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/nested/b.js @@ -0,0 +1 @@ +console.log(3); diff --git a/tests/specs/run/top_level_await_circular/top_level_await/nested/main.js b/tests/specs/run/top_level_await_circular/top_level_await/nested/main.js new file mode 100644 index 0000000000..ed46a47175 --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/nested/main.js @@ -0,0 +1,3 @@ +console.log(1); +await import("./a.js"); +console.log(5); diff --git a/tests/specs/run/top_level_await_circular/top_level_await/order.js b/tests/specs/run/top_level_await_circular/top_level_await/order.js new file mode 100644 index 0000000000..30659cdfbf --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/order.js @@ -0,0 +1,21 @@ +// Ported from Node +// https://github.com/nodejs/node/blob/54746bb763ebea0dc7e99d88ff4b379bcd680964/test/es-module/test-esm-tla.mjs + +const { default: order } = await import("./tla/parent.js"); + +console.log("order", JSON.stringify(order)); + +if ( + !( + order[0] === "order" && + order[1] === "b" && + order[2] === "c" && + order[3] === "d" && + order[4] === "a" && + order[5] === "parent" + ) +) { + throw new Error("TLA wrong order"); +} + +console.log("TLA order correct"); diff --git a/tests/specs/run/top_level_await_circular/top_level_await/order.out b/tests/specs/run/top_level_await_circular/top_level_await/order.out new file mode 100644 index 0000000000..4cc27858cf --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/order.out @@ -0,0 +1,2 @@ +order ["order","b","c","d","a","parent"] +TLA order correct diff --git a/tests/specs/run/top_level_await_circular/top_level_await/tla/a.js b/tests/specs/run/top_level_await_circular/top_level_await/tla/a.js new file mode 100644 index 0000000000..c3ef3f7dbc --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/tla/a.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("b"); diff --git a/tests/specs/run/top_level_await_circular/top_level_await/tla/b.js b/tests/specs/run/top_level_await_circular/top_level_await/tla/b.js new file mode 100644 index 0000000000..3271c92d8f --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/tla/b.js @@ -0,0 +1,7 @@ +import order from "./order.js"; + +await new Promise((resolve) => { + setTimeout(resolve, 200); +}); + +order.push("a"); diff --git a/tests/specs/run/top_level_await_circular/top_level_await/tla/c.js b/tests/specs/run/top_level_await_circular/top_level_await/tla/c.js new file mode 100644 index 0000000000..806eb0a8be --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/tla/c.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("c"); diff --git a/tests/specs/run/top_level_await_circular/top_level_await/tla/d.js b/tests/specs/run/top_level_await_circular/top_level_await/tla/d.js new file mode 100644 index 0000000000..283ebf817f --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/tla/d.js @@ -0,0 +1,8 @@ +import order from "./order.js"; + +const end = Date.now() + 500; +while (end < Date.now()) { + // pass +} + +order.push("d"); diff --git a/tests/specs/run/top_level_await_circular/top_level_await/tla/order.js b/tests/specs/run/top_level_await_circular/top_level_await/tla/order.js new file mode 100644 index 0000000000..f213a562ce --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/tla/order.js @@ -0,0 +1 @@ +export default ["order"]; diff --git a/tests/specs/run/top_level_await_circular/top_level_await/tla/parent.js b/tests/specs/run/top_level_await_circular/top_level_await/tla/parent.js new file mode 100644 index 0000000000..1ecc154634 --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/tla/parent.js @@ -0,0 +1,9 @@ +import order from "./order.js"; +import "./a.js"; +import "./b.js"; +import "./c.js"; +import "./d.js"; + +order.push("parent"); + +export default order; diff --git a/tests/specs/run/top_level_await_circular/top_level_await/tla2/a.js b/tests/specs/run/top_level_await_circular/top_level_await/tla2/a.js new file mode 100644 index 0000000000..d07bcb94db --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/tla2/a.js @@ -0,0 +1,5 @@ +export default class Foo { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_await_circular/top_level_await/tla2/b.js b/tests/specs/run/top_level_await_circular/top_level_await/tla2/b.js new file mode 100644 index 0000000000..68e357c1e9 --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/tla2/b.js @@ -0,0 +1,5 @@ +export default class Bar { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_await_circular/top_level_await/tla3/b.js b/tests/specs/run/top_level_await_circular/top_level_await/tla3/b.js new file mode 100644 index 0000000000..d0349545e9 --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/tla3/b.js @@ -0,0 +1,7 @@ +import { foo } from "./timeout_loop.js"; +import { collection } from "../circular.js"; + +console.log("collection in b", collection); +console.log("foo in b", foo); + +export const a = "a"; diff --git a/tests/specs/run/top_level_await_circular/top_level_await/tla3/timeout_loop.js b/tests/specs/run/top_level_await_circular/top_level_await/tla3/timeout_loop.js new file mode 100644 index 0000000000..860e6cd2ae --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/tla3/timeout_loop.js @@ -0,0 +1,23 @@ +export const foo = "foo"; + +export function delay(ms) { + return new Promise((res) => + setTimeout(() => { + res(); + }, ms) + ); +} + +let i = 0; + +async function timeoutLoop() { + await delay(1000); + console.log("timeout loop", i); + i++; + if (i > 5) { + return; + } + timeoutLoop(); +} + +timeoutLoop(); diff --git a/tests/testdata/run/top_level_await/top_level_await.js b/tests/specs/run/top_level_await_circular/top_level_await/top_level_await.js similarity index 100% rename from tests/testdata/run/top_level_await/top_level_await.js rename to tests/specs/run/top_level_await_circular/top_level_await/top_level_await.js diff --git a/tests/specs/run/top_level_await_circular/top_level_await/top_level_await.out b/tests/specs/run/top_level_await_circular/top_level_await/top_level_await.out new file mode 100644 index 0000000000..4b65d15fe3 --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/top_level_await.out @@ -0,0 +1,3 @@ +Hello world! + +write 12 diff --git a/tests/specs/run/top_level_await_circular/top_level_await/top_level_await.ts b/tests/specs/run/top_level_await_circular/top_level_await/top_level_await.ts new file mode 100644 index 0000000000..8d47ceb21e --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/top_level_await.ts @@ -0,0 +1,3 @@ +const buf: Uint8Array = await Deno.readFile("./assets/hello.txt"); +const n: number = await Deno.stdout.write(buf); +console.log(`\n\nwrite ${n}`); diff --git a/tests/specs/run/top_level_await_circular/top_level_await/top_level_for_await.js b/tests/specs/run/top_level_await_circular/top_level_await/top_level_for_await.js new file mode 100644 index 0000000000..a330f6c711 --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/top_level_for_await.js @@ -0,0 +1,10 @@ +function* asyncGenerator() { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +} diff --git a/tests/specs/run/top_level_await_circular/top_level_await/top_level_for_await.out b/tests/specs/run/top_level_await_circular/top_level_await/top_level_for_await.out new file mode 100644 index 0000000000..4539bbf2d2 --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/top_level_for_await.out @@ -0,0 +1,3 @@ +0 +1 +2 diff --git a/tests/specs/run/top_level_await_circular/top_level_await/top_level_for_await.ts b/tests/specs/run/top_level_await_circular/top_level_await/top_level_for_await.ts new file mode 100644 index 0000000000..9179322d78 --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/top_level_for_await.ts @@ -0,0 +1,10 @@ +async function* asyncGenerator(): AsyncIterableIterator { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +} diff --git a/tests/specs/run/top_level_await_circular/top_level_await/unresolved.js b/tests/specs/run/top_level_await_circular/top_level_await/unresolved.js new file mode 100644 index 0000000000..231a8cd634 --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/unresolved.js @@ -0,0 +1 @@ +await new Promise(() => {}); diff --git a/tests/specs/run/top_level_await_circular/top_level_await/unresolved.out b/tests/specs/run/top_level_await_circular/top_level_await/unresolved.out new file mode 100644 index 0000000000..1f4ea5d382 --- /dev/null +++ b/tests/specs/run/top_level_await_circular/top_level_await/unresolved.out @@ -0,0 +1,4 @@ +error: Top-level await promise never resolved +await new Promise(() => {}); +^ + at ([WILDCARD]top_level_await/unresolved.js:1:1) diff --git a/tests/specs/run/top_level_await_loop/__test__.jsonc b/tests/specs/run/top_level_await_loop/__test__.jsonc new file mode 100644 index 0000000000..b2f5c84c03 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read top_level_await/loop.js", + "output": "top_level_await/loop.out" +} diff --git a/tests/specs/run/top_level_await_loop/top_level_await/circular.js b/tests/specs/run/top_level_await_loop/top_level_await/circular.js new file mode 100644 index 0000000000..ff2964b6a5 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/circular.js @@ -0,0 +1,8 @@ +import { foo } from "./tla3/timeout_loop.js"; + +export const collection = []; + +const mod = await import("./tla3/b.js"); + +console.log("foo in main", foo); +console.log("mod", mod); diff --git a/tests/specs/run/top_level_await_loop/top_level_await/circular.out b/tests/specs/run/top_level_await_loop/top_level_await/circular.out new file mode 100644 index 0000000000..c889789613 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/circular.out @@ -0,0 +1,10 @@ +timeout loop 0 +timeout loop 1 +timeout loop 2 +timeout loop 3 +timeout loop 4 +timeout loop 5 +error: Top-level await promise never resolved +const mod = await import("./tla3/b.js"); + ^ + at ([WILDCARD]/top_level_await/circular.js:5:13) diff --git a/tests/specs/run/top_level_await_loop/top_level_await/loop.js b/tests/specs/run/top_level_await_loop/top_level_await/loop.js new file mode 100644 index 0000000000..f229e03f61 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/loop.js @@ -0,0 +1,20 @@ +const importsDir = Deno.readDirSync( + Deno.realPathSync("./top_level_await/tla2"), +); + +const resolvedPaths = []; + +for (const { name } of importsDir) { + const filePath = Deno.realPathSync(`./top_level_await/tla2/${name}`); + resolvedPaths.push(filePath); +} + +resolvedPaths.sort(); + +for (const filePath of resolvedPaths) { + console.log("loading", filePath); + const mod = await import(`file://${filePath}`); + console.log("loaded", mod); +} + +console.log("all loaded"); diff --git a/tests/specs/run/top_level_await_loop/top_level_await/loop.out b/tests/specs/run/top_level_await_loop/top_level_await/loop.out new file mode 100644 index 0000000000..1bdffbf660 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/loop.out @@ -0,0 +1,5 @@ +loading [WILDCARD]a.js +loaded [Module: null prototype] { default: [class Foo] } +loading [WILDCARD]b.js +loaded [Module: null prototype] { default: [class Bar] } +all loaded diff --git a/tests/specs/run/top_level_await_loop/top_level_await/nested.out b/tests/specs/run/top_level_await_loop/top_level_await/nested.out new file mode 100644 index 0000000000..8a1218a102 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/nested.out @@ -0,0 +1,5 @@ +1 +2 +3 +4 +5 diff --git a/tests/specs/run/top_level_await_loop/top_level_await/nested/a.js b/tests/specs/run/top_level_await_loop/top_level_await/nested/a.js new file mode 100644 index 0000000000..74837d4ba1 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/nested/a.js @@ -0,0 +1,3 @@ +console.log(2); +await import("./b.js"); +console.log(4); diff --git a/tests/specs/run/top_level_await_loop/top_level_await/nested/b.js b/tests/specs/run/top_level_await_loop/top_level_await/nested/b.js new file mode 100644 index 0000000000..3bd241b50e --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/nested/b.js @@ -0,0 +1 @@ +console.log(3); diff --git a/tests/specs/run/top_level_await_loop/top_level_await/nested/main.js b/tests/specs/run/top_level_await_loop/top_level_await/nested/main.js new file mode 100644 index 0000000000..ed46a47175 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/nested/main.js @@ -0,0 +1,3 @@ +console.log(1); +await import("./a.js"); +console.log(5); diff --git a/tests/specs/run/top_level_await_loop/top_level_await/order.js b/tests/specs/run/top_level_await_loop/top_level_await/order.js new file mode 100644 index 0000000000..30659cdfbf --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/order.js @@ -0,0 +1,21 @@ +// Ported from Node +// https://github.com/nodejs/node/blob/54746bb763ebea0dc7e99d88ff4b379bcd680964/test/es-module/test-esm-tla.mjs + +const { default: order } = await import("./tla/parent.js"); + +console.log("order", JSON.stringify(order)); + +if ( + !( + order[0] === "order" && + order[1] === "b" && + order[2] === "c" && + order[3] === "d" && + order[4] === "a" && + order[5] === "parent" + ) +) { + throw new Error("TLA wrong order"); +} + +console.log("TLA order correct"); diff --git a/tests/specs/run/top_level_await_loop/top_level_await/order.out b/tests/specs/run/top_level_await_loop/top_level_await/order.out new file mode 100644 index 0000000000..4cc27858cf --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/order.out @@ -0,0 +1,2 @@ +order ["order","b","c","d","a","parent"] +TLA order correct diff --git a/tests/specs/run/top_level_await_loop/top_level_await/tla/a.js b/tests/specs/run/top_level_await_loop/top_level_await/tla/a.js new file mode 100644 index 0000000000..c3ef3f7dbc --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/tla/a.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("b"); diff --git a/tests/specs/run/top_level_await_loop/top_level_await/tla/b.js b/tests/specs/run/top_level_await_loop/top_level_await/tla/b.js new file mode 100644 index 0000000000..3271c92d8f --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/tla/b.js @@ -0,0 +1,7 @@ +import order from "./order.js"; + +await new Promise((resolve) => { + setTimeout(resolve, 200); +}); + +order.push("a"); diff --git a/tests/specs/run/top_level_await_loop/top_level_await/tla/c.js b/tests/specs/run/top_level_await_loop/top_level_await/tla/c.js new file mode 100644 index 0000000000..806eb0a8be --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/tla/c.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("c"); diff --git a/tests/specs/run/top_level_await_loop/top_level_await/tla/d.js b/tests/specs/run/top_level_await_loop/top_level_await/tla/d.js new file mode 100644 index 0000000000..283ebf817f --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/tla/d.js @@ -0,0 +1,8 @@ +import order from "./order.js"; + +const end = Date.now() + 500; +while (end < Date.now()) { + // pass +} + +order.push("d"); diff --git a/tests/specs/run/top_level_await_loop/top_level_await/tla/order.js b/tests/specs/run/top_level_await_loop/top_level_await/tla/order.js new file mode 100644 index 0000000000..f213a562ce --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/tla/order.js @@ -0,0 +1 @@ +export default ["order"]; diff --git a/tests/specs/run/top_level_await_loop/top_level_await/tla/parent.js b/tests/specs/run/top_level_await_loop/top_level_await/tla/parent.js new file mode 100644 index 0000000000..1ecc154634 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/tla/parent.js @@ -0,0 +1,9 @@ +import order from "./order.js"; +import "./a.js"; +import "./b.js"; +import "./c.js"; +import "./d.js"; + +order.push("parent"); + +export default order; diff --git a/tests/specs/run/top_level_await_loop/top_level_await/tla2/a.js b/tests/specs/run/top_level_await_loop/top_level_await/tla2/a.js new file mode 100644 index 0000000000..d07bcb94db --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/tla2/a.js @@ -0,0 +1,5 @@ +export default class Foo { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_await_loop/top_level_await/tla2/b.js b/tests/specs/run/top_level_await_loop/top_level_await/tla2/b.js new file mode 100644 index 0000000000..68e357c1e9 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/tla2/b.js @@ -0,0 +1,5 @@ +export default class Bar { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_await_loop/top_level_await/tla3/b.js b/tests/specs/run/top_level_await_loop/top_level_await/tla3/b.js new file mode 100644 index 0000000000..d0349545e9 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/tla3/b.js @@ -0,0 +1,7 @@ +import { foo } from "./timeout_loop.js"; +import { collection } from "../circular.js"; + +console.log("collection in b", collection); +console.log("foo in b", foo); + +export const a = "a"; diff --git a/tests/specs/run/top_level_await_loop/top_level_await/tla3/timeout_loop.js b/tests/specs/run/top_level_await_loop/top_level_await/tla3/timeout_loop.js new file mode 100644 index 0000000000..860e6cd2ae --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/tla3/timeout_loop.js @@ -0,0 +1,23 @@ +export const foo = "foo"; + +export function delay(ms) { + return new Promise((res) => + setTimeout(() => { + res(); + }, ms) + ); +} + +let i = 0; + +async function timeoutLoop() { + await delay(1000); + console.log("timeout loop", i); + i++; + if (i > 5) { + return; + } + timeoutLoop(); +} + +timeoutLoop(); diff --git a/tests/specs/run/top_level_await_loop/top_level_await/top_level_await.js b/tests/specs/run/top_level_await_loop/top_level_await/top_level_await.js new file mode 100644 index 0000000000..ea319ea124 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/top_level_await.js @@ -0,0 +1,3 @@ +const buf = await Deno.readFile("./assets/hello.txt"); +const n = await Deno.stdout.write(buf); +console.log(`\n\nwrite ${n}`); diff --git a/tests/specs/run/top_level_await_loop/top_level_await/top_level_await.out b/tests/specs/run/top_level_await_loop/top_level_await/top_level_await.out new file mode 100644 index 0000000000..4b65d15fe3 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/top_level_await.out @@ -0,0 +1,3 @@ +Hello world! + +write 12 diff --git a/tests/specs/run/top_level_await_loop/top_level_await/top_level_await.ts b/tests/specs/run/top_level_await_loop/top_level_await/top_level_await.ts new file mode 100644 index 0000000000..8d47ceb21e --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/top_level_await.ts @@ -0,0 +1,3 @@ +const buf: Uint8Array = await Deno.readFile("./assets/hello.txt"); +const n: number = await Deno.stdout.write(buf); +console.log(`\n\nwrite ${n}`); diff --git a/tests/specs/run/top_level_await_loop/top_level_await/top_level_for_await.js b/tests/specs/run/top_level_await_loop/top_level_await/top_level_for_await.js new file mode 100644 index 0000000000..a330f6c711 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/top_level_for_await.js @@ -0,0 +1,10 @@ +function* asyncGenerator() { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +} diff --git a/tests/specs/run/top_level_await_loop/top_level_await/top_level_for_await.out b/tests/specs/run/top_level_await_loop/top_level_await/top_level_for_await.out new file mode 100644 index 0000000000..4539bbf2d2 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/top_level_for_await.out @@ -0,0 +1,3 @@ +0 +1 +2 diff --git a/tests/specs/run/top_level_await_loop/top_level_await/top_level_for_await.ts b/tests/specs/run/top_level_await_loop/top_level_await/top_level_for_await.ts new file mode 100644 index 0000000000..9179322d78 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/top_level_for_await.ts @@ -0,0 +1,10 @@ +async function* asyncGenerator(): AsyncIterableIterator { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +} diff --git a/tests/specs/run/top_level_await_loop/top_level_await/unresolved.js b/tests/specs/run/top_level_await_loop/top_level_await/unresolved.js new file mode 100644 index 0000000000..231a8cd634 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/unresolved.js @@ -0,0 +1 @@ +await new Promise(() => {}); diff --git a/tests/specs/run/top_level_await_loop/top_level_await/unresolved.out b/tests/specs/run/top_level_await_loop/top_level_await/unresolved.out new file mode 100644 index 0000000000..1f4ea5d382 --- /dev/null +++ b/tests/specs/run/top_level_await_loop/top_level_await/unresolved.out @@ -0,0 +1,4 @@ +error: Top-level await promise never resolved +await new Promise(() => {}); +^ + at ([WILDCARD]top_level_await/unresolved.js:1:1) diff --git a/tests/specs/run/top_level_await_nested/__test__.jsonc b/tests/specs/run/top_level_await_nested/__test__.jsonc new file mode 100644 index 0000000000..376180ecdc --- /dev/null +++ b/tests/specs/run/top_level_await_nested/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read top_level_await/nested/main.js", + "output": "top_level_await/nested.out" +} diff --git a/tests/specs/run/top_level_await_nested/top_level_await/circular.js b/tests/specs/run/top_level_await_nested/top_level_await/circular.js new file mode 100644 index 0000000000..ff2964b6a5 --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/circular.js @@ -0,0 +1,8 @@ +import { foo } from "./tla3/timeout_loop.js"; + +export const collection = []; + +const mod = await import("./tla3/b.js"); + +console.log("foo in main", foo); +console.log("mod", mod); diff --git a/tests/specs/run/top_level_await_nested/top_level_await/circular.out b/tests/specs/run/top_level_await_nested/top_level_await/circular.out new file mode 100644 index 0000000000..c889789613 --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/circular.out @@ -0,0 +1,10 @@ +timeout loop 0 +timeout loop 1 +timeout loop 2 +timeout loop 3 +timeout loop 4 +timeout loop 5 +error: Top-level await promise never resolved +const mod = await import("./tla3/b.js"); + ^ + at ([WILDCARD]/top_level_await/circular.js:5:13) diff --git a/tests/testdata/run/top_level_await/loop.js b/tests/specs/run/top_level_await_nested/top_level_await/loop.js similarity index 100% rename from tests/testdata/run/top_level_await/loop.js rename to tests/specs/run/top_level_await_nested/top_level_await/loop.js diff --git a/tests/specs/run/top_level_await_nested/top_level_await/loop.out b/tests/specs/run/top_level_await_nested/top_level_await/loop.out new file mode 100644 index 0000000000..1bdffbf660 --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/loop.out @@ -0,0 +1,5 @@ +loading [WILDCARD]a.js +loaded [Module: null prototype] { default: [class Foo] } +loading [WILDCARD]b.js +loaded [Module: null prototype] { default: [class Bar] } +all loaded diff --git a/tests/specs/run/top_level_await_nested/top_level_await/nested.out b/tests/specs/run/top_level_await_nested/top_level_await/nested.out new file mode 100644 index 0000000000..8a1218a102 --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/nested.out @@ -0,0 +1,5 @@ +1 +2 +3 +4 +5 diff --git a/tests/specs/run/top_level_await_nested/top_level_await/nested/a.js b/tests/specs/run/top_level_await_nested/top_level_await/nested/a.js new file mode 100644 index 0000000000..74837d4ba1 --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/nested/a.js @@ -0,0 +1,3 @@ +console.log(2); +await import("./b.js"); +console.log(4); diff --git a/tests/specs/run/top_level_await_nested/top_level_await/nested/b.js b/tests/specs/run/top_level_await_nested/top_level_await/nested/b.js new file mode 100644 index 0000000000..3bd241b50e --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/nested/b.js @@ -0,0 +1 @@ +console.log(3); diff --git a/tests/specs/run/top_level_await_nested/top_level_await/nested/main.js b/tests/specs/run/top_level_await_nested/top_level_await/nested/main.js new file mode 100644 index 0000000000..ed46a47175 --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/nested/main.js @@ -0,0 +1,3 @@ +console.log(1); +await import("./a.js"); +console.log(5); diff --git a/tests/specs/run/top_level_await_nested/top_level_await/order.js b/tests/specs/run/top_level_await_nested/top_level_await/order.js new file mode 100644 index 0000000000..30659cdfbf --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/order.js @@ -0,0 +1,21 @@ +// Ported from Node +// https://github.com/nodejs/node/blob/54746bb763ebea0dc7e99d88ff4b379bcd680964/test/es-module/test-esm-tla.mjs + +const { default: order } = await import("./tla/parent.js"); + +console.log("order", JSON.stringify(order)); + +if ( + !( + order[0] === "order" && + order[1] === "b" && + order[2] === "c" && + order[3] === "d" && + order[4] === "a" && + order[5] === "parent" + ) +) { + throw new Error("TLA wrong order"); +} + +console.log("TLA order correct"); diff --git a/tests/specs/run/top_level_await_nested/top_level_await/order.out b/tests/specs/run/top_level_await_nested/top_level_await/order.out new file mode 100644 index 0000000000..4cc27858cf --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/order.out @@ -0,0 +1,2 @@ +order ["order","b","c","d","a","parent"] +TLA order correct diff --git a/tests/specs/run/top_level_await_nested/top_level_await/tla/a.js b/tests/specs/run/top_level_await_nested/top_level_await/tla/a.js new file mode 100644 index 0000000000..c3ef3f7dbc --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/tla/a.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("b"); diff --git a/tests/specs/run/top_level_await_nested/top_level_await/tla/b.js b/tests/specs/run/top_level_await_nested/top_level_await/tla/b.js new file mode 100644 index 0000000000..3271c92d8f --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/tla/b.js @@ -0,0 +1,7 @@ +import order from "./order.js"; + +await new Promise((resolve) => { + setTimeout(resolve, 200); +}); + +order.push("a"); diff --git a/tests/specs/run/top_level_await_nested/top_level_await/tla/c.js b/tests/specs/run/top_level_await_nested/top_level_await/tla/c.js new file mode 100644 index 0000000000..806eb0a8be --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/tla/c.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("c"); diff --git a/tests/specs/run/top_level_await_nested/top_level_await/tla/d.js b/tests/specs/run/top_level_await_nested/top_level_await/tla/d.js new file mode 100644 index 0000000000..283ebf817f --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/tla/d.js @@ -0,0 +1,8 @@ +import order from "./order.js"; + +const end = Date.now() + 500; +while (end < Date.now()) { + // pass +} + +order.push("d"); diff --git a/tests/specs/run/top_level_await_nested/top_level_await/tla/order.js b/tests/specs/run/top_level_await_nested/top_level_await/tla/order.js new file mode 100644 index 0000000000..f213a562ce --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/tla/order.js @@ -0,0 +1 @@ +export default ["order"]; diff --git a/tests/specs/run/top_level_await_nested/top_level_await/tla/parent.js b/tests/specs/run/top_level_await_nested/top_level_await/tla/parent.js new file mode 100644 index 0000000000..1ecc154634 --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/tla/parent.js @@ -0,0 +1,9 @@ +import order from "./order.js"; +import "./a.js"; +import "./b.js"; +import "./c.js"; +import "./d.js"; + +order.push("parent"); + +export default order; diff --git a/tests/specs/run/top_level_await_nested/top_level_await/tla2/a.js b/tests/specs/run/top_level_await_nested/top_level_await/tla2/a.js new file mode 100644 index 0000000000..d07bcb94db --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/tla2/a.js @@ -0,0 +1,5 @@ +export default class Foo { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_await_nested/top_level_await/tla2/b.js b/tests/specs/run/top_level_await_nested/top_level_await/tla2/b.js new file mode 100644 index 0000000000..68e357c1e9 --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/tla2/b.js @@ -0,0 +1,5 @@ +export default class Bar { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_await_nested/top_level_await/tla3/b.js b/tests/specs/run/top_level_await_nested/top_level_await/tla3/b.js new file mode 100644 index 0000000000..d0349545e9 --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/tla3/b.js @@ -0,0 +1,7 @@ +import { foo } from "./timeout_loop.js"; +import { collection } from "../circular.js"; + +console.log("collection in b", collection); +console.log("foo in b", foo); + +export const a = "a"; diff --git a/tests/specs/run/top_level_await_nested/top_level_await/tla3/timeout_loop.js b/tests/specs/run/top_level_await_nested/top_level_await/tla3/timeout_loop.js new file mode 100644 index 0000000000..860e6cd2ae --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/tla3/timeout_loop.js @@ -0,0 +1,23 @@ +export const foo = "foo"; + +export function delay(ms) { + return new Promise((res) => + setTimeout(() => { + res(); + }, ms) + ); +} + +let i = 0; + +async function timeoutLoop() { + await delay(1000); + console.log("timeout loop", i); + i++; + if (i > 5) { + return; + } + timeoutLoop(); +} + +timeoutLoop(); diff --git a/tests/specs/run/top_level_await_nested/top_level_await/top_level_await.js b/tests/specs/run/top_level_await_nested/top_level_await/top_level_await.js new file mode 100644 index 0000000000..ea319ea124 --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/top_level_await.js @@ -0,0 +1,3 @@ +const buf = await Deno.readFile("./assets/hello.txt"); +const n = await Deno.stdout.write(buf); +console.log(`\n\nwrite ${n}`); diff --git a/tests/specs/run/top_level_await_nested/top_level_await/top_level_await.out b/tests/specs/run/top_level_await_nested/top_level_await/top_level_await.out new file mode 100644 index 0000000000..4b65d15fe3 --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/top_level_await.out @@ -0,0 +1,3 @@ +Hello world! + +write 12 diff --git a/tests/specs/run/top_level_await_nested/top_level_await/top_level_await.ts b/tests/specs/run/top_level_await_nested/top_level_await/top_level_await.ts new file mode 100644 index 0000000000..8d47ceb21e --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/top_level_await.ts @@ -0,0 +1,3 @@ +const buf: Uint8Array = await Deno.readFile("./assets/hello.txt"); +const n: number = await Deno.stdout.write(buf); +console.log(`\n\nwrite ${n}`); diff --git a/tests/specs/run/top_level_await_nested/top_level_await/top_level_for_await.js b/tests/specs/run/top_level_await_nested/top_level_await/top_level_for_await.js new file mode 100644 index 0000000000..a330f6c711 --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/top_level_for_await.js @@ -0,0 +1,10 @@ +function* asyncGenerator() { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +} diff --git a/tests/specs/run/top_level_await_nested/top_level_await/top_level_for_await.out b/tests/specs/run/top_level_await_nested/top_level_await/top_level_for_await.out new file mode 100644 index 0000000000..4539bbf2d2 --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/top_level_for_await.out @@ -0,0 +1,3 @@ +0 +1 +2 diff --git a/tests/specs/run/top_level_await_nested/top_level_await/top_level_for_await.ts b/tests/specs/run/top_level_await_nested/top_level_await/top_level_for_await.ts new file mode 100644 index 0000000000..9179322d78 --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/top_level_for_await.ts @@ -0,0 +1,10 @@ +async function* asyncGenerator(): AsyncIterableIterator { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +} diff --git a/tests/specs/run/top_level_await_nested/top_level_await/unresolved.js b/tests/specs/run/top_level_await_nested/top_level_await/unresolved.js new file mode 100644 index 0000000000..231a8cd634 --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/unresolved.js @@ -0,0 +1 @@ +await new Promise(() => {}); diff --git a/tests/specs/run/top_level_await_nested/top_level_await/unresolved.out b/tests/specs/run/top_level_await_nested/top_level_await/unresolved.out new file mode 100644 index 0000000000..1f4ea5d382 --- /dev/null +++ b/tests/specs/run/top_level_await_nested/top_level_await/unresolved.out @@ -0,0 +1,4 @@ +error: Top-level await promise never resolved +await new Promise(() => {}); +^ + at ([WILDCARD]top_level_await/unresolved.js:1:1) diff --git a/tests/specs/run/top_level_await_order/__test__.jsonc b/tests/specs/run/top_level_await_order/__test__.jsonc new file mode 100644 index 0000000000..65d00d607d --- /dev/null +++ b/tests/specs/run/top_level_await_order/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read top_level_await/order.js", + "output": "top_level_await/order.out" +} diff --git a/tests/specs/run/top_level_await_order/top_level_await/circular.js b/tests/specs/run/top_level_await_order/top_level_await/circular.js new file mode 100644 index 0000000000..ff2964b6a5 --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/circular.js @@ -0,0 +1,8 @@ +import { foo } from "./tla3/timeout_loop.js"; + +export const collection = []; + +const mod = await import("./tla3/b.js"); + +console.log("foo in main", foo); +console.log("mod", mod); diff --git a/tests/specs/run/top_level_await_order/top_level_await/circular.out b/tests/specs/run/top_level_await_order/top_level_await/circular.out new file mode 100644 index 0000000000..c889789613 --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/circular.out @@ -0,0 +1,10 @@ +timeout loop 0 +timeout loop 1 +timeout loop 2 +timeout loop 3 +timeout loop 4 +timeout loop 5 +error: Top-level await promise never resolved +const mod = await import("./tla3/b.js"); + ^ + at ([WILDCARD]/top_level_await/circular.js:5:13) diff --git a/tests/specs/run/top_level_await_order/top_level_await/loop.js b/tests/specs/run/top_level_await_order/top_level_await/loop.js new file mode 100644 index 0000000000..415db5ec78 --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/loop.js @@ -0,0 +1,20 @@ +const importsDir = Deno.readDirSync( + Deno.realPathSync("./run/top_level_await/tla2"), +); + +const resolvedPaths = []; + +for (const { name } of importsDir) { + const filePath = Deno.realPathSync(`./run/top_level_await/tla2/${name}`); + resolvedPaths.push(filePath); +} + +resolvedPaths.sort(); + +for (const filePath of resolvedPaths) { + console.log("loading", filePath); + const mod = await import(`file://${filePath}`); + console.log("loaded", mod); +} + +console.log("all loaded"); diff --git a/tests/specs/run/top_level_await_order/top_level_await/loop.out b/tests/specs/run/top_level_await_order/top_level_await/loop.out new file mode 100644 index 0000000000..1bdffbf660 --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/loop.out @@ -0,0 +1,5 @@ +loading [WILDCARD]a.js +loaded [Module: null prototype] { default: [class Foo] } +loading [WILDCARD]b.js +loaded [Module: null prototype] { default: [class Bar] } +all loaded diff --git a/tests/specs/run/top_level_await_order/top_level_await/nested.out b/tests/specs/run/top_level_await_order/top_level_await/nested.out new file mode 100644 index 0000000000..8a1218a102 --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/nested.out @@ -0,0 +1,5 @@ +1 +2 +3 +4 +5 diff --git a/tests/specs/run/top_level_await_order/top_level_await/nested/a.js b/tests/specs/run/top_level_await_order/top_level_await/nested/a.js new file mode 100644 index 0000000000..74837d4ba1 --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/nested/a.js @@ -0,0 +1,3 @@ +console.log(2); +await import("./b.js"); +console.log(4); diff --git a/tests/specs/run/top_level_await_order/top_level_await/nested/b.js b/tests/specs/run/top_level_await_order/top_level_await/nested/b.js new file mode 100644 index 0000000000..3bd241b50e --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/nested/b.js @@ -0,0 +1 @@ +console.log(3); diff --git a/tests/specs/run/top_level_await_order/top_level_await/nested/main.js b/tests/specs/run/top_level_await_order/top_level_await/nested/main.js new file mode 100644 index 0000000000..ed46a47175 --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/nested/main.js @@ -0,0 +1,3 @@ +console.log(1); +await import("./a.js"); +console.log(5); diff --git a/tests/specs/run/top_level_await_order/top_level_await/order.js b/tests/specs/run/top_level_await_order/top_level_await/order.js new file mode 100644 index 0000000000..30659cdfbf --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/order.js @@ -0,0 +1,21 @@ +// Ported from Node +// https://github.com/nodejs/node/blob/54746bb763ebea0dc7e99d88ff4b379bcd680964/test/es-module/test-esm-tla.mjs + +const { default: order } = await import("./tla/parent.js"); + +console.log("order", JSON.stringify(order)); + +if ( + !( + order[0] === "order" && + order[1] === "b" && + order[2] === "c" && + order[3] === "d" && + order[4] === "a" && + order[5] === "parent" + ) +) { + throw new Error("TLA wrong order"); +} + +console.log("TLA order correct"); diff --git a/tests/specs/run/top_level_await_order/top_level_await/order.out b/tests/specs/run/top_level_await_order/top_level_await/order.out new file mode 100644 index 0000000000..4cc27858cf --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/order.out @@ -0,0 +1,2 @@ +order ["order","b","c","d","a","parent"] +TLA order correct diff --git a/tests/specs/run/top_level_await_order/top_level_await/tla/a.js b/tests/specs/run/top_level_await_order/top_level_await/tla/a.js new file mode 100644 index 0000000000..c3ef3f7dbc --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/tla/a.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("b"); diff --git a/tests/specs/run/top_level_await_order/top_level_await/tla/b.js b/tests/specs/run/top_level_await_order/top_level_await/tla/b.js new file mode 100644 index 0000000000..3271c92d8f --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/tla/b.js @@ -0,0 +1,7 @@ +import order from "./order.js"; + +await new Promise((resolve) => { + setTimeout(resolve, 200); +}); + +order.push("a"); diff --git a/tests/specs/run/top_level_await_order/top_level_await/tla/c.js b/tests/specs/run/top_level_await_order/top_level_await/tla/c.js new file mode 100644 index 0000000000..806eb0a8be --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/tla/c.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("c"); diff --git a/tests/specs/run/top_level_await_order/top_level_await/tla/d.js b/tests/specs/run/top_level_await_order/top_level_await/tla/d.js new file mode 100644 index 0000000000..283ebf817f --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/tla/d.js @@ -0,0 +1,8 @@ +import order from "./order.js"; + +const end = Date.now() + 500; +while (end < Date.now()) { + // pass +} + +order.push("d"); diff --git a/tests/specs/run/top_level_await_order/top_level_await/tla/order.js b/tests/specs/run/top_level_await_order/top_level_await/tla/order.js new file mode 100644 index 0000000000..f213a562ce --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/tla/order.js @@ -0,0 +1 @@ +export default ["order"]; diff --git a/tests/specs/run/top_level_await_order/top_level_await/tla/parent.js b/tests/specs/run/top_level_await_order/top_level_await/tla/parent.js new file mode 100644 index 0000000000..1ecc154634 --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/tla/parent.js @@ -0,0 +1,9 @@ +import order from "./order.js"; +import "./a.js"; +import "./b.js"; +import "./c.js"; +import "./d.js"; + +order.push("parent"); + +export default order; diff --git a/tests/specs/run/top_level_await_order/top_level_await/tla2/a.js b/tests/specs/run/top_level_await_order/top_level_await/tla2/a.js new file mode 100644 index 0000000000..d07bcb94db --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/tla2/a.js @@ -0,0 +1,5 @@ +export default class Foo { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_await_order/top_level_await/tla2/b.js b/tests/specs/run/top_level_await_order/top_level_await/tla2/b.js new file mode 100644 index 0000000000..68e357c1e9 --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/tla2/b.js @@ -0,0 +1,5 @@ +export default class Bar { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_await_order/top_level_await/tla3/b.js b/tests/specs/run/top_level_await_order/top_level_await/tla3/b.js new file mode 100644 index 0000000000..d0349545e9 --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/tla3/b.js @@ -0,0 +1,7 @@ +import { foo } from "./timeout_loop.js"; +import { collection } from "../circular.js"; + +console.log("collection in b", collection); +console.log("foo in b", foo); + +export const a = "a"; diff --git a/tests/specs/run/top_level_await_order/top_level_await/tla3/timeout_loop.js b/tests/specs/run/top_level_await_order/top_level_await/tla3/timeout_loop.js new file mode 100644 index 0000000000..860e6cd2ae --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/tla3/timeout_loop.js @@ -0,0 +1,23 @@ +export const foo = "foo"; + +export function delay(ms) { + return new Promise((res) => + setTimeout(() => { + res(); + }, ms) + ); +} + +let i = 0; + +async function timeoutLoop() { + await delay(1000); + console.log("timeout loop", i); + i++; + if (i > 5) { + return; + } + timeoutLoop(); +} + +timeoutLoop(); diff --git a/tests/specs/run/top_level_await_order/top_level_await/top_level_await.js b/tests/specs/run/top_level_await_order/top_level_await/top_level_await.js new file mode 100644 index 0000000000..ea319ea124 --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/top_level_await.js @@ -0,0 +1,3 @@ +const buf = await Deno.readFile("./assets/hello.txt"); +const n = await Deno.stdout.write(buf); +console.log(`\n\nwrite ${n}`); diff --git a/tests/specs/run/top_level_await_order/top_level_await/top_level_await.out b/tests/specs/run/top_level_await_order/top_level_await/top_level_await.out new file mode 100644 index 0000000000..4b65d15fe3 --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/top_level_await.out @@ -0,0 +1,3 @@ +Hello world! + +write 12 diff --git a/tests/specs/run/top_level_await_order/top_level_await/top_level_await.ts b/tests/specs/run/top_level_await_order/top_level_await/top_level_await.ts new file mode 100644 index 0000000000..8d47ceb21e --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/top_level_await.ts @@ -0,0 +1,3 @@ +const buf: Uint8Array = await Deno.readFile("./assets/hello.txt"); +const n: number = await Deno.stdout.write(buf); +console.log(`\n\nwrite ${n}`); diff --git a/tests/specs/run/top_level_await_order/top_level_await/top_level_for_await.js b/tests/specs/run/top_level_await_order/top_level_await/top_level_for_await.js new file mode 100644 index 0000000000..a330f6c711 --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/top_level_for_await.js @@ -0,0 +1,10 @@ +function* asyncGenerator() { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +} diff --git a/tests/specs/run/top_level_await_order/top_level_await/top_level_for_await.out b/tests/specs/run/top_level_await_order/top_level_await/top_level_for_await.out new file mode 100644 index 0000000000..4539bbf2d2 --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/top_level_for_await.out @@ -0,0 +1,3 @@ +0 +1 +2 diff --git a/tests/specs/run/top_level_await_order/top_level_await/top_level_for_await.ts b/tests/specs/run/top_level_await_order/top_level_await/top_level_for_await.ts new file mode 100644 index 0000000000..9179322d78 --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/top_level_for_await.ts @@ -0,0 +1,10 @@ +async function* asyncGenerator(): AsyncIterableIterator { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +} diff --git a/tests/specs/run/top_level_await_order/top_level_await/unresolved.js b/tests/specs/run/top_level_await_order/top_level_await/unresolved.js new file mode 100644 index 0000000000..231a8cd634 --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/unresolved.js @@ -0,0 +1 @@ +await new Promise(() => {}); diff --git a/tests/specs/run/top_level_await_order/top_level_await/unresolved.out b/tests/specs/run/top_level_await_order/top_level_await/unresolved.out new file mode 100644 index 0000000000..1f4ea5d382 --- /dev/null +++ b/tests/specs/run/top_level_await_order/top_level_await/unresolved.out @@ -0,0 +1,4 @@ +error: Top-level await promise never resolved +await new Promise(() => {}); +^ + at ([WILDCARD]top_level_await/unresolved.js:1:1) diff --git a/tests/specs/run/top_level_await_ts/__test__.jsonc b/tests/specs/run/top_level_await_ts/__test__.jsonc new file mode 100644 index 0000000000..15f937df19 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --allow-read top_level_await/top_level_await.ts", + "output": "top_level_await/top_level_await.out" +} diff --git a/tests/specs/run/top_level_await_ts/hello.txt b/tests/specs/run/top_level_await_ts/hello.txt new file mode 100644 index 0000000000..6769dd60bd --- /dev/null +++ b/tests/specs/run/top_level_await_ts/hello.txt @@ -0,0 +1 @@ +Hello world! \ No newline at end of file diff --git a/tests/specs/run/top_level_await_ts/top_level_await/circular.js b/tests/specs/run/top_level_await_ts/top_level_await/circular.js new file mode 100644 index 0000000000..ff2964b6a5 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/circular.js @@ -0,0 +1,8 @@ +import { foo } from "./tla3/timeout_loop.js"; + +export const collection = []; + +const mod = await import("./tla3/b.js"); + +console.log("foo in main", foo); +console.log("mod", mod); diff --git a/tests/specs/run/top_level_await_ts/top_level_await/circular.out b/tests/specs/run/top_level_await_ts/top_level_await/circular.out new file mode 100644 index 0000000000..c889789613 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/circular.out @@ -0,0 +1,10 @@ +timeout loop 0 +timeout loop 1 +timeout loop 2 +timeout loop 3 +timeout loop 4 +timeout loop 5 +error: Top-level await promise never resolved +const mod = await import("./tla3/b.js"); + ^ + at ([WILDCARD]/top_level_await/circular.js:5:13) diff --git a/tests/specs/run/top_level_await_ts/top_level_await/loop.js b/tests/specs/run/top_level_await_ts/top_level_await/loop.js new file mode 100644 index 0000000000..415db5ec78 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/loop.js @@ -0,0 +1,20 @@ +const importsDir = Deno.readDirSync( + Deno.realPathSync("./run/top_level_await/tla2"), +); + +const resolvedPaths = []; + +for (const { name } of importsDir) { + const filePath = Deno.realPathSync(`./run/top_level_await/tla2/${name}`); + resolvedPaths.push(filePath); +} + +resolvedPaths.sort(); + +for (const filePath of resolvedPaths) { + console.log("loading", filePath); + const mod = await import(`file://${filePath}`); + console.log("loaded", mod); +} + +console.log("all loaded"); diff --git a/tests/specs/run/top_level_await_ts/top_level_await/loop.out b/tests/specs/run/top_level_await_ts/top_level_await/loop.out new file mode 100644 index 0000000000..1bdffbf660 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/loop.out @@ -0,0 +1,5 @@ +loading [WILDCARD]a.js +loaded [Module: null prototype] { default: [class Foo] } +loading [WILDCARD]b.js +loaded [Module: null prototype] { default: [class Bar] } +all loaded diff --git a/tests/specs/run/top_level_await_ts/top_level_await/nested.out b/tests/specs/run/top_level_await_ts/top_level_await/nested.out new file mode 100644 index 0000000000..8a1218a102 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/nested.out @@ -0,0 +1,5 @@ +1 +2 +3 +4 +5 diff --git a/tests/specs/run/top_level_await_ts/top_level_await/nested/a.js b/tests/specs/run/top_level_await_ts/top_level_await/nested/a.js new file mode 100644 index 0000000000..74837d4ba1 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/nested/a.js @@ -0,0 +1,3 @@ +console.log(2); +await import("./b.js"); +console.log(4); diff --git a/tests/specs/run/top_level_await_ts/top_level_await/nested/b.js b/tests/specs/run/top_level_await_ts/top_level_await/nested/b.js new file mode 100644 index 0000000000..3bd241b50e --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/nested/b.js @@ -0,0 +1 @@ +console.log(3); diff --git a/tests/specs/run/top_level_await_ts/top_level_await/nested/main.js b/tests/specs/run/top_level_await_ts/top_level_await/nested/main.js new file mode 100644 index 0000000000..ed46a47175 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/nested/main.js @@ -0,0 +1,3 @@ +console.log(1); +await import("./a.js"); +console.log(5); diff --git a/tests/specs/run/top_level_await_ts/top_level_await/order.js b/tests/specs/run/top_level_await_ts/top_level_await/order.js new file mode 100644 index 0000000000..30659cdfbf --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/order.js @@ -0,0 +1,21 @@ +// Ported from Node +// https://github.com/nodejs/node/blob/54746bb763ebea0dc7e99d88ff4b379bcd680964/test/es-module/test-esm-tla.mjs + +const { default: order } = await import("./tla/parent.js"); + +console.log("order", JSON.stringify(order)); + +if ( + !( + order[0] === "order" && + order[1] === "b" && + order[2] === "c" && + order[3] === "d" && + order[4] === "a" && + order[5] === "parent" + ) +) { + throw new Error("TLA wrong order"); +} + +console.log("TLA order correct"); diff --git a/tests/specs/run/top_level_await_ts/top_level_await/order.out b/tests/specs/run/top_level_await_ts/top_level_await/order.out new file mode 100644 index 0000000000..4cc27858cf --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/order.out @@ -0,0 +1,2 @@ +order ["order","b","c","d","a","parent"] +TLA order correct diff --git a/tests/specs/run/top_level_await_ts/top_level_await/tla/a.js b/tests/specs/run/top_level_await_ts/top_level_await/tla/a.js new file mode 100644 index 0000000000..c3ef3f7dbc --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/tla/a.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("b"); diff --git a/tests/specs/run/top_level_await_ts/top_level_await/tla/b.js b/tests/specs/run/top_level_await_ts/top_level_await/tla/b.js new file mode 100644 index 0000000000..3271c92d8f --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/tla/b.js @@ -0,0 +1,7 @@ +import order from "./order.js"; + +await new Promise((resolve) => { + setTimeout(resolve, 200); +}); + +order.push("a"); diff --git a/tests/specs/run/top_level_await_ts/top_level_await/tla/c.js b/tests/specs/run/top_level_await_ts/top_level_await/tla/c.js new file mode 100644 index 0000000000..806eb0a8be --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/tla/c.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("c"); diff --git a/tests/specs/run/top_level_await_ts/top_level_await/tla/d.js b/tests/specs/run/top_level_await_ts/top_level_await/tla/d.js new file mode 100644 index 0000000000..283ebf817f --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/tla/d.js @@ -0,0 +1,8 @@ +import order from "./order.js"; + +const end = Date.now() + 500; +while (end < Date.now()) { + // pass +} + +order.push("d"); diff --git a/tests/specs/run/top_level_await_ts/top_level_await/tla/order.js b/tests/specs/run/top_level_await_ts/top_level_await/tla/order.js new file mode 100644 index 0000000000..f213a562ce --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/tla/order.js @@ -0,0 +1 @@ +export default ["order"]; diff --git a/tests/specs/run/top_level_await_ts/top_level_await/tla/parent.js b/tests/specs/run/top_level_await_ts/top_level_await/tla/parent.js new file mode 100644 index 0000000000..1ecc154634 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/tla/parent.js @@ -0,0 +1,9 @@ +import order from "./order.js"; +import "./a.js"; +import "./b.js"; +import "./c.js"; +import "./d.js"; + +order.push("parent"); + +export default order; diff --git a/tests/specs/run/top_level_await_ts/top_level_await/tla2/a.js b/tests/specs/run/top_level_await_ts/top_level_await/tla2/a.js new file mode 100644 index 0000000000..d07bcb94db --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/tla2/a.js @@ -0,0 +1,5 @@ +export default class Foo { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_await_ts/top_level_await/tla2/b.js b/tests/specs/run/top_level_await_ts/top_level_await/tla2/b.js new file mode 100644 index 0000000000..68e357c1e9 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/tla2/b.js @@ -0,0 +1,5 @@ +export default class Bar { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_await_ts/top_level_await/tla3/b.js b/tests/specs/run/top_level_await_ts/top_level_await/tla3/b.js new file mode 100644 index 0000000000..d0349545e9 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/tla3/b.js @@ -0,0 +1,7 @@ +import { foo } from "./timeout_loop.js"; +import { collection } from "../circular.js"; + +console.log("collection in b", collection); +console.log("foo in b", foo); + +export const a = "a"; diff --git a/tests/specs/run/top_level_await_ts/top_level_await/tla3/timeout_loop.js b/tests/specs/run/top_level_await_ts/top_level_await/tla3/timeout_loop.js new file mode 100644 index 0000000000..860e6cd2ae --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/tla3/timeout_loop.js @@ -0,0 +1,23 @@ +export const foo = "foo"; + +export function delay(ms) { + return new Promise((res) => + setTimeout(() => { + res(); + }, ms) + ); +} + +let i = 0; + +async function timeoutLoop() { + await delay(1000); + console.log("timeout loop", i); + i++; + if (i > 5) { + return; + } + timeoutLoop(); +} + +timeoutLoop(); diff --git a/tests/specs/run/top_level_await_ts/top_level_await/top_level_await.js b/tests/specs/run/top_level_await_ts/top_level_await/top_level_await.js new file mode 100644 index 0000000000..ea319ea124 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/top_level_await.js @@ -0,0 +1,3 @@ +const buf = await Deno.readFile("./assets/hello.txt"); +const n = await Deno.stdout.write(buf); +console.log(`\n\nwrite ${n}`); diff --git a/tests/specs/run/top_level_await_ts/top_level_await/top_level_await.out b/tests/specs/run/top_level_await_ts/top_level_await/top_level_await.out new file mode 100644 index 0000000000..4b65d15fe3 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/top_level_await.out @@ -0,0 +1,3 @@ +Hello world! + +write 12 diff --git a/tests/specs/run/top_level_await_ts/top_level_await/top_level_await.ts b/tests/specs/run/top_level_await_ts/top_level_await/top_level_await.ts new file mode 100644 index 0000000000..48f66545ac --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/top_level_await.ts @@ -0,0 +1,3 @@ +const buf: Uint8Array = await Deno.readFile("./hello.txt"); +const n: number = await Deno.stdout.write(buf); +console.log(`\n\nwrite ${n}`); diff --git a/tests/specs/run/top_level_await_ts/top_level_await/top_level_for_await.js b/tests/specs/run/top_level_await_ts/top_level_await/top_level_for_await.js new file mode 100644 index 0000000000..a330f6c711 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/top_level_for_await.js @@ -0,0 +1,10 @@ +function* asyncGenerator() { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +} diff --git a/tests/specs/run/top_level_await_ts/top_level_await/top_level_for_await.out b/tests/specs/run/top_level_await_ts/top_level_await/top_level_for_await.out new file mode 100644 index 0000000000..4539bbf2d2 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/top_level_for_await.out @@ -0,0 +1,3 @@ +0 +1 +2 diff --git a/tests/specs/run/top_level_await_ts/top_level_await/top_level_for_await.ts b/tests/specs/run/top_level_await_ts/top_level_await/top_level_for_await.ts new file mode 100644 index 0000000000..9179322d78 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/top_level_for_await.ts @@ -0,0 +1,10 @@ +async function* asyncGenerator(): AsyncIterableIterator { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +} diff --git a/tests/specs/run/top_level_await_ts/top_level_await/unresolved.js b/tests/specs/run/top_level_await_ts/top_level_await/unresolved.js new file mode 100644 index 0000000000..231a8cd634 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/unresolved.js @@ -0,0 +1 @@ +await new Promise(() => {}); diff --git a/tests/specs/run/top_level_await_ts/top_level_await/unresolved.out b/tests/specs/run/top_level_await_ts/top_level_await/unresolved.out new file mode 100644 index 0000000000..1f4ea5d382 --- /dev/null +++ b/tests/specs/run/top_level_await_ts/top_level_await/unresolved.out @@ -0,0 +1,4 @@ +error: Top-level await promise never resolved +await new Promise(() => {}); +^ + at ([WILDCARD]top_level_await/unresolved.js:1:1) diff --git a/tests/specs/run/top_level_await_unresolved/__test__.jsonc b/tests/specs/run/top_level_await_unresolved/__test__.jsonc new file mode 100644 index 0000000000..a92774c1b8 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run top_level_await/unresolved.js", + "output": "top_level_await/unresolved.out", + "exitCode": 1 +} diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/circular.js b/tests/specs/run/top_level_await_unresolved/top_level_await/circular.js new file mode 100644 index 0000000000..ff2964b6a5 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/circular.js @@ -0,0 +1,8 @@ +import { foo } from "./tla3/timeout_loop.js"; + +export const collection = []; + +const mod = await import("./tla3/b.js"); + +console.log("foo in main", foo); +console.log("mod", mod); diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/circular.out b/tests/specs/run/top_level_await_unresolved/top_level_await/circular.out new file mode 100644 index 0000000000..c889789613 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/circular.out @@ -0,0 +1,10 @@ +timeout loop 0 +timeout loop 1 +timeout loop 2 +timeout loop 3 +timeout loop 4 +timeout loop 5 +error: Top-level await promise never resolved +const mod = await import("./tla3/b.js"); + ^ + at ([WILDCARD]/top_level_await/circular.js:5:13) diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/loop.js b/tests/specs/run/top_level_await_unresolved/top_level_await/loop.js new file mode 100644 index 0000000000..415db5ec78 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/loop.js @@ -0,0 +1,20 @@ +const importsDir = Deno.readDirSync( + Deno.realPathSync("./run/top_level_await/tla2"), +); + +const resolvedPaths = []; + +for (const { name } of importsDir) { + const filePath = Deno.realPathSync(`./run/top_level_await/tla2/${name}`); + resolvedPaths.push(filePath); +} + +resolvedPaths.sort(); + +for (const filePath of resolvedPaths) { + console.log("loading", filePath); + const mod = await import(`file://${filePath}`); + console.log("loaded", mod); +} + +console.log("all loaded"); diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/loop.out b/tests/specs/run/top_level_await_unresolved/top_level_await/loop.out new file mode 100644 index 0000000000..1bdffbf660 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/loop.out @@ -0,0 +1,5 @@ +loading [WILDCARD]a.js +loaded [Module: null prototype] { default: [class Foo] } +loading [WILDCARD]b.js +loaded [Module: null prototype] { default: [class Bar] } +all loaded diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/nested.out b/tests/specs/run/top_level_await_unresolved/top_level_await/nested.out new file mode 100644 index 0000000000..8a1218a102 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/nested.out @@ -0,0 +1,5 @@ +1 +2 +3 +4 +5 diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/nested/a.js b/tests/specs/run/top_level_await_unresolved/top_level_await/nested/a.js new file mode 100644 index 0000000000..74837d4ba1 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/nested/a.js @@ -0,0 +1,3 @@ +console.log(2); +await import("./b.js"); +console.log(4); diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/nested/b.js b/tests/specs/run/top_level_await_unresolved/top_level_await/nested/b.js new file mode 100644 index 0000000000..3bd241b50e --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/nested/b.js @@ -0,0 +1 @@ +console.log(3); diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/nested/main.js b/tests/specs/run/top_level_await_unresolved/top_level_await/nested/main.js new file mode 100644 index 0000000000..ed46a47175 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/nested/main.js @@ -0,0 +1,3 @@ +console.log(1); +await import("./a.js"); +console.log(5); diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/order.js b/tests/specs/run/top_level_await_unresolved/top_level_await/order.js new file mode 100644 index 0000000000..30659cdfbf --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/order.js @@ -0,0 +1,21 @@ +// Ported from Node +// https://github.com/nodejs/node/blob/54746bb763ebea0dc7e99d88ff4b379bcd680964/test/es-module/test-esm-tla.mjs + +const { default: order } = await import("./tla/parent.js"); + +console.log("order", JSON.stringify(order)); + +if ( + !( + order[0] === "order" && + order[1] === "b" && + order[2] === "c" && + order[3] === "d" && + order[4] === "a" && + order[5] === "parent" + ) +) { + throw new Error("TLA wrong order"); +} + +console.log("TLA order correct"); diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/order.out b/tests/specs/run/top_level_await_unresolved/top_level_await/order.out new file mode 100644 index 0000000000..4cc27858cf --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/order.out @@ -0,0 +1,2 @@ +order ["order","b","c","d","a","parent"] +TLA order correct diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/tla/a.js b/tests/specs/run/top_level_await_unresolved/top_level_await/tla/a.js new file mode 100644 index 0000000000..c3ef3f7dbc --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/tla/a.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("b"); diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/tla/b.js b/tests/specs/run/top_level_await_unresolved/top_level_await/tla/b.js new file mode 100644 index 0000000000..3271c92d8f --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/tla/b.js @@ -0,0 +1,7 @@ +import order from "./order.js"; + +await new Promise((resolve) => { + setTimeout(resolve, 200); +}); + +order.push("a"); diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/tla/c.js b/tests/specs/run/top_level_await_unresolved/top_level_await/tla/c.js new file mode 100644 index 0000000000..806eb0a8be --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/tla/c.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("c"); diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/tla/d.js b/tests/specs/run/top_level_await_unresolved/top_level_await/tla/d.js new file mode 100644 index 0000000000..283ebf817f --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/tla/d.js @@ -0,0 +1,8 @@ +import order from "./order.js"; + +const end = Date.now() + 500; +while (end < Date.now()) { + // pass +} + +order.push("d"); diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/tla/order.js b/tests/specs/run/top_level_await_unresolved/top_level_await/tla/order.js new file mode 100644 index 0000000000..f213a562ce --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/tla/order.js @@ -0,0 +1 @@ +export default ["order"]; diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/tla/parent.js b/tests/specs/run/top_level_await_unresolved/top_level_await/tla/parent.js new file mode 100644 index 0000000000..1ecc154634 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/tla/parent.js @@ -0,0 +1,9 @@ +import order from "./order.js"; +import "./a.js"; +import "./b.js"; +import "./c.js"; +import "./d.js"; + +order.push("parent"); + +export default order; diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/tla2/a.js b/tests/specs/run/top_level_await_unresolved/top_level_await/tla2/a.js new file mode 100644 index 0000000000..d07bcb94db --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/tla2/a.js @@ -0,0 +1,5 @@ +export default class Foo { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/tla2/b.js b/tests/specs/run/top_level_await_unresolved/top_level_await/tla2/b.js new file mode 100644 index 0000000000..68e357c1e9 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/tla2/b.js @@ -0,0 +1,5 @@ +export default class Bar { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/tla3/b.js b/tests/specs/run/top_level_await_unresolved/top_level_await/tla3/b.js new file mode 100644 index 0000000000..d0349545e9 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/tla3/b.js @@ -0,0 +1,7 @@ +import { foo } from "./timeout_loop.js"; +import { collection } from "../circular.js"; + +console.log("collection in b", collection); +console.log("foo in b", foo); + +export const a = "a"; diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/tla3/timeout_loop.js b/tests/specs/run/top_level_await_unresolved/top_level_await/tla3/timeout_loop.js new file mode 100644 index 0000000000..860e6cd2ae --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/tla3/timeout_loop.js @@ -0,0 +1,23 @@ +export const foo = "foo"; + +export function delay(ms) { + return new Promise((res) => + setTimeout(() => { + res(); + }, ms) + ); +} + +let i = 0; + +async function timeoutLoop() { + await delay(1000); + console.log("timeout loop", i); + i++; + if (i > 5) { + return; + } + timeoutLoop(); +} + +timeoutLoop(); diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_await.js b/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_await.js new file mode 100644 index 0000000000..ea319ea124 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_await.js @@ -0,0 +1,3 @@ +const buf = await Deno.readFile("./assets/hello.txt"); +const n = await Deno.stdout.write(buf); +console.log(`\n\nwrite ${n}`); diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_await.out b/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_await.out new file mode 100644 index 0000000000..4b65d15fe3 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_await.out @@ -0,0 +1,3 @@ +Hello world! + +write 12 diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_await.ts b/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_await.ts new file mode 100644 index 0000000000..8d47ceb21e --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_await.ts @@ -0,0 +1,3 @@ +const buf: Uint8Array = await Deno.readFile("./assets/hello.txt"); +const n: number = await Deno.stdout.write(buf); +console.log(`\n\nwrite ${n}`); diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_for_await.js b/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_for_await.js new file mode 100644 index 0000000000..a330f6c711 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_for_await.js @@ -0,0 +1,10 @@ +function* asyncGenerator() { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +} diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_for_await.out b/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_for_await.out new file mode 100644 index 0000000000..4539bbf2d2 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_for_await.out @@ -0,0 +1,3 @@ +0 +1 +2 diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_for_await.ts b/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_for_await.ts new file mode 100644 index 0000000000..9179322d78 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/top_level_for_await.ts @@ -0,0 +1,10 @@ +async function* asyncGenerator(): AsyncIterableIterator { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +} diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/unresolved.js b/tests/specs/run/top_level_await_unresolved/top_level_await/unresolved.js new file mode 100644 index 0000000000..231a8cd634 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/unresolved.js @@ -0,0 +1 @@ +await new Promise(() => {}); diff --git a/tests/specs/run/top_level_await_unresolved/top_level_await/unresolved.out b/tests/specs/run/top_level_await_unresolved/top_level_await/unresolved.out new file mode 100644 index 0000000000..1f4ea5d382 --- /dev/null +++ b/tests/specs/run/top_level_await_unresolved/top_level_await/unresolved.out @@ -0,0 +1,4 @@ +error: Top-level await promise never resolved +await new Promise(() => {}); +^ + at ([WILDCARD]top_level_await/unresolved.js:1:1) diff --git a/tests/specs/run/top_level_for_await/__test__.jsonc b/tests/specs/run/top_level_for_await/__test__.jsonc new file mode 100644 index 0000000000..198008560b --- /dev/null +++ b/tests/specs/run/top_level_for_await/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet top_level_await/top_level_for_await.js", + "output": "top_level_await/top_level_for_await.out" +} diff --git a/tests/specs/run/top_level_for_await/top_level_await/circular.js b/tests/specs/run/top_level_for_await/top_level_await/circular.js new file mode 100644 index 0000000000..ff2964b6a5 --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/circular.js @@ -0,0 +1,8 @@ +import { foo } from "./tla3/timeout_loop.js"; + +export const collection = []; + +const mod = await import("./tla3/b.js"); + +console.log("foo in main", foo); +console.log("mod", mod); diff --git a/tests/specs/run/top_level_for_await/top_level_await/circular.out b/tests/specs/run/top_level_for_await/top_level_await/circular.out new file mode 100644 index 0000000000..c889789613 --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/circular.out @@ -0,0 +1,10 @@ +timeout loop 0 +timeout loop 1 +timeout loop 2 +timeout loop 3 +timeout loop 4 +timeout loop 5 +error: Top-level await promise never resolved +const mod = await import("./tla3/b.js"); + ^ + at ([WILDCARD]/top_level_await/circular.js:5:13) diff --git a/tests/specs/run/top_level_for_await/top_level_await/loop.js b/tests/specs/run/top_level_for_await/top_level_await/loop.js new file mode 100644 index 0000000000..415db5ec78 --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/loop.js @@ -0,0 +1,20 @@ +const importsDir = Deno.readDirSync( + Deno.realPathSync("./run/top_level_await/tla2"), +); + +const resolvedPaths = []; + +for (const { name } of importsDir) { + const filePath = Deno.realPathSync(`./run/top_level_await/tla2/${name}`); + resolvedPaths.push(filePath); +} + +resolvedPaths.sort(); + +for (const filePath of resolvedPaths) { + console.log("loading", filePath); + const mod = await import(`file://${filePath}`); + console.log("loaded", mod); +} + +console.log("all loaded"); diff --git a/tests/specs/run/top_level_for_await/top_level_await/loop.out b/tests/specs/run/top_level_for_await/top_level_await/loop.out new file mode 100644 index 0000000000..1bdffbf660 --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/loop.out @@ -0,0 +1,5 @@ +loading [WILDCARD]a.js +loaded [Module: null prototype] { default: [class Foo] } +loading [WILDCARD]b.js +loaded [Module: null prototype] { default: [class Bar] } +all loaded diff --git a/tests/specs/run/top_level_for_await/top_level_await/nested.out b/tests/specs/run/top_level_for_await/top_level_await/nested.out new file mode 100644 index 0000000000..8a1218a102 --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/nested.out @@ -0,0 +1,5 @@ +1 +2 +3 +4 +5 diff --git a/tests/specs/run/top_level_for_await/top_level_await/nested/a.js b/tests/specs/run/top_level_for_await/top_level_await/nested/a.js new file mode 100644 index 0000000000..74837d4ba1 --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/nested/a.js @@ -0,0 +1,3 @@ +console.log(2); +await import("./b.js"); +console.log(4); diff --git a/tests/specs/run/top_level_for_await/top_level_await/nested/b.js b/tests/specs/run/top_level_for_await/top_level_await/nested/b.js new file mode 100644 index 0000000000..3bd241b50e --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/nested/b.js @@ -0,0 +1 @@ +console.log(3); diff --git a/tests/specs/run/top_level_for_await/top_level_await/nested/main.js b/tests/specs/run/top_level_for_await/top_level_await/nested/main.js new file mode 100644 index 0000000000..ed46a47175 --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/nested/main.js @@ -0,0 +1,3 @@ +console.log(1); +await import("./a.js"); +console.log(5); diff --git a/tests/specs/run/top_level_for_await/top_level_await/order.js b/tests/specs/run/top_level_for_await/top_level_await/order.js new file mode 100644 index 0000000000..30659cdfbf --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/order.js @@ -0,0 +1,21 @@ +// Ported from Node +// https://github.com/nodejs/node/blob/54746bb763ebea0dc7e99d88ff4b379bcd680964/test/es-module/test-esm-tla.mjs + +const { default: order } = await import("./tla/parent.js"); + +console.log("order", JSON.stringify(order)); + +if ( + !( + order[0] === "order" && + order[1] === "b" && + order[2] === "c" && + order[3] === "d" && + order[4] === "a" && + order[5] === "parent" + ) +) { + throw new Error("TLA wrong order"); +} + +console.log("TLA order correct"); diff --git a/tests/specs/run/top_level_for_await/top_level_await/order.out b/tests/specs/run/top_level_for_await/top_level_await/order.out new file mode 100644 index 0000000000..4cc27858cf --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/order.out @@ -0,0 +1,2 @@ +order ["order","b","c","d","a","parent"] +TLA order correct diff --git a/tests/specs/run/top_level_for_await/top_level_await/tla/a.js b/tests/specs/run/top_level_for_await/top_level_await/tla/a.js new file mode 100644 index 0000000000..c3ef3f7dbc --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/tla/a.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("b"); diff --git a/tests/specs/run/top_level_for_await/top_level_await/tla/b.js b/tests/specs/run/top_level_for_await/top_level_await/tla/b.js new file mode 100644 index 0000000000..3271c92d8f --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/tla/b.js @@ -0,0 +1,7 @@ +import order from "./order.js"; + +await new Promise((resolve) => { + setTimeout(resolve, 200); +}); + +order.push("a"); diff --git a/tests/specs/run/top_level_for_await/top_level_await/tla/c.js b/tests/specs/run/top_level_for_await/top_level_await/tla/c.js new file mode 100644 index 0000000000..806eb0a8be --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/tla/c.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("c"); diff --git a/tests/specs/run/top_level_for_await/top_level_await/tla/d.js b/tests/specs/run/top_level_for_await/top_level_await/tla/d.js new file mode 100644 index 0000000000..283ebf817f --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/tla/d.js @@ -0,0 +1,8 @@ +import order from "./order.js"; + +const end = Date.now() + 500; +while (end < Date.now()) { + // pass +} + +order.push("d"); diff --git a/tests/specs/run/top_level_for_await/top_level_await/tla/order.js b/tests/specs/run/top_level_for_await/top_level_await/tla/order.js new file mode 100644 index 0000000000..f213a562ce --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/tla/order.js @@ -0,0 +1 @@ +export default ["order"]; diff --git a/tests/specs/run/top_level_for_await/top_level_await/tla/parent.js b/tests/specs/run/top_level_for_await/top_level_await/tla/parent.js new file mode 100644 index 0000000000..1ecc154634 --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/tla/parent.js @@ -0,0 +1,9 @@ +import order from "./order.js"; +import "./a.js"; +import "./b.js"; +import "./c.js"; +import "./d.js"; + +order.push("parent"); + +export default order; diff --git a/tests/specs/run/top_level_for_await/top_level_await/tla2/a.js b/tests/specs/run/top_level_for_await/top_level_await/tla2/a.js new file mode 100644 index 0000000000..d07bcb94db --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/tla2/a.js @@ -0,0 +1,5 @@ +export default class Foo { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_for_await/top_level_await/tla2/b.js b/tests/specs/run/top_level_for_await/top_level_await/tla2/b.js new file mode 100644 index 0000000000..68e357c1e9 --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/tla2/b.js @@ -0,0 +1,5 @@ +export default class Bar { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_for_await/top_level_await/tla3/b.js b/tests/specs/run/top_level_for_await/top_level_await/tla3/b.js new file mode 100644 index 0000000000..d0349545e9 --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/tla3/b.js @@ -0,0 +1,7 @@ +import { foo } from "./timeout_loop.js"; +import { collection } from "../circular.js"; + +console.log("collection in b", collection); +console.log("foo in b", foo); + +export const a = "a"; diff --git a/tests/specs/run/top_level_for_await/top_level_await/tla3/timeout_loop.js b/tests/specs/run/top_level_for_await/top_level_await/tla3/timeout_loop.js new file mode 100644 index 0000000000..860e6cd2ae --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/tla3/timeout_loop.js @@ -0,0 +1,23 @@ +export const foo = "foo"; + +export function delay(ms) { + return new Promise((res) => + setTimeout(() => { + res(); + }, ms) + ); +} + +let i = 0; + +async function timeoutLoop() { + await delay(1000); + console.log("timeout loop", i); + i++; + if (i > 5) { + return; + } + timeoutLoop(); +} + +timeoutLoop(); diff --git a/tests/specs/run/top_level_for_await/top_level_await/top_level_await.js b/tests/specs/run/top_level_for_await/top_level_await/top_level_await.js new file mode 100644 index 0000000000..ea319ea124 --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/top_level_await.js @@ -0,0 +1,3 @@ +const buf = await Deno.readFile("./assets/hello.txt"); +const n = await Deno.stdout.write(buf); +console.log(`\n\nwrite ${n}`); diff --git a/tests/specs/run/top_level_for_await/top_level_await/top_level_await.out b/tests/specs/run/top_level_for_await/top_level_await/top_level_await.out new file mode 100644 index 0000000000..4b65d15fe3 --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/top_level_await.out @@ -0,0 +1,3 @@ +Hello world! + +write 12 diff --git a/tests/specs/run/top_level_for_await/top_level_await/top_level_await.ts b/tests/specs/run/top_level_for_await/top_level_await/top_level_await.ts new file mode 100644 index 0000000000..8d47ceb21e --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/top_level_await.ts @@ -0,0 +1,3 @@ +const buf: Uint8Array = await Deno.readFile("./assets/hello.txt"); +const n: number = await Deno.stdout.write(buf); +console.log(`\n\nwrite ${n}`); diff --git a/tests/specs/run/top_level_for_await/top_level_await/top_level_for_await.js b/tests/specs/run/top_level_for_await/top_level_await/top_level_for_await.js new file mode 100644 index 0000000000..a330f6c711 --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/top_level_for_await.js @@ -0,0 +1,10 @@ +function* asyncGenerator() { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +} diff --git a/tests/specs/run/top_level_for_await/top_level_await/top_level_for_await.out b/tests/specs/run/top_level_for_await/top_level_await/top_level_for_await.out new file mode 100644 index 0000000000..4539bbf2d2 --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/top_level_for_await.out @@ -0,0 +1,3 @@ +0 +1 +2 diff --git a/tests/specs/run/top_level_for_await/top_level_await/top_level_for_await.ts b/tests/specs/run/top_level_for_await/top_level_await/top_level_for_await.ts new file mode 100644 index 0000000000..9179322d78 --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/top_level_for_await.ts @@ -0,0 +1,10 @@ +async function* asyncGenerator(): AsyncIterableIterator { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +} diff --git a/tests/specs/run/top_level_for_await/top_level_await/unresolved.js b/tests/specs/run/top_level_for_await/top_level_await/unresolved.js new file mode 100644 index 0000000000..231a8cd634 --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/unresolved.js @@ -0,0 +1 @@ +await new Promise(() => {}); diff --git a/tests/specs/run/top_level_for_await/top_level_await/unresolved.out b/tests/specs/run/top_level_for_await/top_level_await/unresolved.out new file mode 100644 index 0000000000..1f4ea5d382 --- /dev/null +++ b/tests/specs/run/top_level_for_await/top_level_await/unresolved.out @@ -0,0 +1,4 @@ +error: Top-level await promise never resolved +await new Promise(() => {}); +^ + at ([WILDCARD]top_level_await/unresolved.js:1:1) diff --git a/tests/specs/run/top_level_for_await_ts/__test__.jsonc b/tests/specs/run/top_level_for_await_ts/__test__.jsonc new file mode 100644 index 0000000000..22314e8e0d --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet top_level_await/top_level_for_await.ts", + "output": "top_level_await/top_level_for_await.out" +} diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/circular.js b/tests/specs/run/top_level_for_await_ts/top_level_await/circular.js new file mode 100644 index 0000000000..ff2964b6a5 --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/circular.js @@ -0,0 +1,8 @@ +import { foo } from "./tla3/timeout_loop.js"; + +export const collection = []; + +const mod = await import("./tla3/b.js"); + +console.log("foo in main", foo); +console.log("mod", mod); diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/circular.out b/tests/specs/run/top_level_for_await_ts/top_level_await/circular.out new file mode 100644 index 0000000000..c889789613 --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/circular.out @@ -0,0 +1,10 @@ +timeout loop 0 +timeout loop 1 +timeout loop 2 +timeout loop 3 +timeout loop 4 +timeout loop 5 +error: Top-level await promise never resolved +const mod = await import("./tla3/b.js"); + ^ + at ([WILDCARD]/top_level_await/circular.js:5:13) diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/loop.js b/tests/specs/run/top_level_for_await_ts/top_level_await/loop.js new file mode 100644 index 0000000000..415db5ec78 --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/loop.js @@ -0,0 +1,20 @@ +const importsDir = Deno.readDirSync( + Deno.realPathSync("./run/top_level_await/tla2"), +); + +const resolvedPaths = []; + +for (const { name } of importsDir) { + const filePath = Deno.realPathSync(`./run/top_level_await/tla2/${name}`); + resolvedPaths.push(filePath); +} + +resolvedPaths.sort(); + +for (const filePath of resolvedPaths) { + console.log("loading", filePath); + const mod = await import(`file://${filePath}`); + console.log("loaded", mod); +} + +console.log("all loaded"); diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/loop.out b/tests/specs/run/top_level_for_await_ts/top_level_await/loop.out new file mode 100644 index 0000000000..1bdffbf660 --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/loop.out @@ -0,0 +1,5 @@ +loading [WILDCARD]a.js +loaded [Module: null prototype] { default: [class Foo] } +loading [WILDCARD]b.js +loaded [Module: null prototype] { default: [class Bar] } +all loaded diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/nested.out b/tests/specs/run/top_level_for_await_ts/top_level_await/nested.out new file mode 100644 index 0000000000..8a1218a102 --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/nested.out @@ -0,0 +1,5 @@ +1 +2 +3 +4 +5 diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/nested/a.js b/tests/specs/run/top_level_for_await_ts/top_level_await/nested/a.js new file mode 100644 index 0000000000..74837d4ba1 --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/nested/a.js @@ -0,0 +1,3 @@ +console.log(2); +await import("./b.js"); +console.log(4); diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/nested/b.js b/tests/specs/run/top_level_for_await_ts/top_level_await/nested/b.js new file mode 100644 index 0000000000..3bd241b50e --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/nested/b.js @@ -0,0 +1 @@ +console.log(3); diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/nested/main.js b/tests/specs/run/top_level_for_await_ts/top_level_await/nested/main.js new file mode 100644 index 0000000000..ed46a47175 --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/nested/main.js @@ -0,0 +1,3 @@ +console.log(1); +await import("./a.js"); +console.log(5); diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/order.js b/tests/specs/run/top_level_for_await_ts/top_level_await/order.js new file mode 100644 index 0000000000..30659cdfbf --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/order.js @@ -0,0 +1,21 @@ +// Ported from Node +// https://github.com/nodejs/node/blob/54746bb763ebea0dc7e99d88ff4b379bcd680964/test/es-module/test-esm-tla.mjs + +const { default: order } = await import("./tla/parent.js"); + +console.log("order", JSON.stringify(order)); + +if ( + !( + order[0] === "order" && + order[1] === "b" && + order[2] === "c" && + order[3] === "d" && + order[4] === "a" && + order[5] === "parent" + ) +) { + throw new Error("TLA wrong order"); +} + +console.log("TLA order correct"); diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/order.out b/tests/specs/run/top_level_for_await_ts/top_level_await/order.out new file mode 100644 index 0000000000..4cc27858cf --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/order.out @@ -0,0 +1,2 @@ +order ["order","b","c","d","a","parent"] +TLA order correct diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/tla/a.js b/tests/specs/run/top_level_for_await_ts/top_level_await/tla/a.js new file mode 100644 index 0000000000..c3ef3f7dbc --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/tla/a.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("b"); diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/tla/b.js b/tests/specs/run/top_level_for_await_ts/top_level_await/tla/b.js new file mode 100644 index 0000000000..3271c92d8f --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/tla/b.js @@ -0,0 +1,7 @@ +import order from "./order.js"; + +await new Promise((resolve) => { + setTimeout(resolve, 200); +}); + +order.push("a"); diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/tla/c.js b/tests/specs/run/top_level_for_await_ts/top_level_await/tla/c.js new file mode 100644 index 0000000000..806eb0a8be --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/tla/c.js @@ -0,0 +1,3 @@ +import order from "./order.js"; + +order.push("c"); diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/tla/d.js b/tests/specs/run/top_level_for_await_ts/top_level_await/tla/d.js new file mode 100644 index 0000000000..283ebf817f --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/tla/d.js @@ -0,0 +1,8 @@ +import order from "./order.js"; + +const end = Date.now() + 500; +while (end < Date.now()) { + // pass +} + +order.push("d"); diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/tla/order.js b/tests/specs/run/top_level_for_await_ts/top_level_await/tla/order.js new file mode 100644 index 0000000000..f213a562ce --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/tla/order.js @@ -0,0 +1 @@ +export default ["order"]; diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/tla/parent.js b/tests/specs/run/top_level_for_await_ts/top_level_await/tla/parent.js new file mode 100644 index 0000000000..1ecc154634 --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/tla/parent.js @@ -0,0 +1,9 @@ +import order from "./order.js"; +import "./a.js"; +import "./b.js"; +import "./c.js"; +import "./d.js"; + +order.push("parent"); + +export default order; diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/tla2/a.js b/tests/specs/run/top_level_for_await_ts/top_level_await/tla2/a.js new file mode 100644 index 0000000000..d07bcb94db --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/tla2/a.js @@ -0,0 +1,5 @@ +export default class Foo { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/tla2/b.js b/tests/specs/run/top_level_for_await_ts/top_level_await/tla2/b.js new file mode 100644 index 0000000000..68e357c1e9 --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/tla2/b.js @@ -0,0 +1,5 @@ +export default class Bar { + constructor(message) { + this.message = message; + } +} diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/tla3/b.js b/tests/specs/run/top_level_for_await_ts/top_level_await/tla3/b.js new file mode 100644 index 0000000000..d0349545e9 --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/tla3/b.js @@ -0,0 +1,7 @@ +import { foo } from "./timeout_loop.js"; +import { collection } from "../circular.js"; + +console.log("collection in b", collection); +console.log("foo in b", foo); + +export const a = "a"; diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/tla3/timeout_loop.js b/tests/specs/run/top_level_for_await_ts/top_level_await/tla3/timeout_loop.js new file mode 100644 index 0000000000..860e6cd2ae --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/tla3/timeout_loop.js @@ -0,0 +1,23 @@ +export const foo = "foo"; + +export function delay(ms) { + return new Promise((res) => + setTimeout(() => { + res(); + }, ms) + ); +} + +let i = 0; + +async function timeoutLoop() { + await delay(1000); + console.log("timeout loop", i); + i++; + if (i > 5) { + return; + } + timeoutLoop(); +} + +timeoutLoop(); diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_await.js b/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_await.js new file mode 100644 index 0000000000..ea319ea124 --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_await.js @@ -0,0 +1,3 @@ +const buf = await Deno.readFile("./assets/hello.txt"); +const n = await Deno.stdout.write(buf); +console.log(`\n\nwrite ${n}`); diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_await.out b/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_await.out new file mode 100644 index 0000000000..4b65d15fe3 --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_await.out @@ -0,0 +1,3 @@ +Hello world! + +write 12 diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_await.ts b/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_await.ts new file mode 100644 index 0000000000..8d47ceb21e --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_await.ts @@ -0,0 +1,3 @@ +const buf: Uint8Array = await Deno.readFile("./assets/hello.txt"); +const n: number = await Deno.stdout.write(buf); +console.log(`\n\nwrite ${n}`); diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_for_await.js b/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_for_await.js new file mode 100644 index 0000000000..a330f6c711 --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_for_await.js @@ -0,0 +1,10 @@ +function* asyncGenerator() { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +} diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_for_await.out b/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_for_await.out new file mode 100644 index 0000000000..4539bbf2d2 --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_for_await.out @@ -0,0 +1,3 @@ +0 +1 +2 diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_for_await.ts b/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_for_await.ts new file mode 100644 index 0000000000..9179322d78 --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/top_level_for_await.ts @@ -0,0 +1,10 @@ +async function* asyncGenerator(): AsyncIterableIterator { + let i = 0; + while (i < 3) { + yield i++; + } +} + +for await (const num of asyncGenerator()) { + console.log(num); +} diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/unresolved.js b/tests/specs/run/top_level_for_await_ts/top_level_await/unresolved.js new file mode 100644 index 0000000000..231a8cd634 --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/unresolved.js @@ -0,0 +1 @@ +await new Promise(() => {}); diff --git a/tests/specs/run/top_level_for_await_ts/top_level_await/unresolved.out b/tests/specs/run/top_level_for_await_ts/top_level_await/unresolved.out new file mode 100644 index 0000000000..1f4ea5d382 --- /dev/null +++ b/tests/specs/run/top_level_for_await_ts/top_level_await/unresolved.out @@ -0,0 +1,4 @@ +error: Top-level await promise never resolved +await new Promise(() => {}); +^ + at ([WILDCARD]top_level_await/unresolved.js:1:1) diff --git a/tests/specs/run/ts_decorators/__test__.jsonc b/tests/specs/run/ts_decorators/__test__.jsonc new file mode 100644 index 0000000000..96e7cdf308 --- /dev/null +++ b/tests/specs/run/ts_decorators/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --check decorators/experimental/ts/main.ts", + "output": "decorators/experimental/ts/main.out" +} diff --git a/tests/specs/run/ts_decorators/decorators/experimental/deno.json b/tests/specs/run/ts_decorators/decorators/experimental/deno.json new file mode 100644 index 0000000000..504cd646e1 --- /dev/null +++ b/tests/specs/run/ts_decorators/decorators/experimental/deno.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "experimentalDecorators": true + } +} diff --git a/tests/specs/run/ts_decorators/decorators/experimental/no_check/main.out b/tests/specs/run/ts_decorators/decorators/experimental/no_check/main.out new file mode 100644 index 0000000000..015f7076e8 --- /dev/null +++ b/tests/specs/run/ts_decorators/decorators/experimental/no_check/main.out @@ -0,0 +1,3 @@ +a(): evaluated +a(): called +method diff --git a/tests/specs/run/ts_decorators/decorators/experimental/no_check/main.ts b/tests/specs/run/ts_decorators/decorators/experimental/no_check/main.ts new file mode 100644 index 0000000000..9f7ec550d5 --- /dev/null +++ b/tests/specs/run/ts_decorators/decorators/experimental/no_check/main.ts @@ -0,0 +1,21 @@ +// deno-lint-ignore-file +function a() { + console.log("a(): evaluated"); + return ( + _target: any, + _propertyKey: string, + _descriptor: PropertyDescriptor, + ) => { + console.log("a(): called"); + }; +} + +class B { + @a() + method() { + console.log("method"); + } +} + +const b = new B(); +b.method(); diff --git a/tests/specs/run/ts_decorators/decorators/experimental/runtime/main.out b/tests/specs/run/ts_decorators/decorators/experimental/runtime/main.out new file mode 100644 index 0000000000..0fc1d4590e --- /dev/null +++ b/tests/specs/run/ts_decorators/decorators/experimental/runtime/main.out @@ -0,0 +1,7 @@ +@A evaluated +@B evaluated +@B called +@A called +fn() called from @A +fn() called from @B +C.test() called diff --git a/tests/specs/run/ts_decorators/decorators/experimental/runtime/main.ts b/tests/specs/run/ts_decorators/decorators/experimental/runtime/main.ts new file mode 100644 index 0000000000..40a26bbd4d --- /dev/null +++ b/tests/specs/run/ts_decorators/decorators/experimental/runtime/main.ts @@ -0,0 +1,42 @@ +// deno-lint-ignore-file +function a() { + console.log("@A evaluated"); + return function ( + target: any, + propertyKey: string, + descriptor: PropertyDescriptor, + ) { + console.log("@A called"); + const fn = descriptor.value; + descriptor.value = function () { + console.log("fn() called from @A"); + fn(); + }; + }; +} + +function b() { + console.log("@B evaluated"); + return function ( + target: any, + propertyKey: string, + descriptor: PropertyDescriptor, + ) { + console.log("@B called"); + const fn = descriptor.value; + descriptor.value = function () { + console.log("fn() called from @B"); + fn(); + }; + }; +} + +class C { + @a() + @b() + static test() { + console.log("C.test() called"); + } +} + +C.test(); diff --git a/tests/specs/run/ts_decorators/decorators/experimental/ts/main.out b/tests/specs/run/ts_decorators/decorators/experimental/ts/main.out new file mode 100644 index 0000000000..ea64fbaa63 --- /dev/null +++ b/tests/specs/run/ts_decorators/decorators/experimental/ts/main.out @@ -0,0 +1,3 @@ +Warning experimentalDecorators compiler option is deprecated and may be removed at any time +Check [WILDCARD] +SomeClass { someField: "asdf" } diff --git a/tests/specs/run/ts_decorators/decorators/experimental/ts/main.ts b/tests/specs/run/ts_decorators/decorators/experimental/ts/main.ts new file mode 100644 index 0000000000..95fba6cd48 --- /dev/null +++ b/tests/specs/run/ts_decorators/decorators/experimental/ts/main.ts @@ -0,0 +1,14 @@ +// deno-lint-ignore-file + +function Decorate() { + return function (constructor: any): any { + return class extends constructor { + protected someField: string = "asdf"; + }; + }; +} + +@Decorate() +class SomeClass {} + +console.log(new SomeClass()); diff --git a/tests/specs/run/ts_decorators/decorators/tc39_proposal/main.out b/tests/specs/run/ts_decorators/decorators/tc39_proposal/main.out new file mode 100644 index 0000000000..39394952e8 --- /dev/null +++ b/tests/specs/run/ts_decorators/decorators/tc39_proposal/main.out @@ -0,0 +1,3 @@ +starting m with arguments 1 +C.m 1 +ending m diff --git a/tests/specs/run/ts_decorators/decorators/tc39_proposal/main.ts b/tests/specs/run/ts_decorators/decorators/tc39_proposal/main.ts new file mode 100644 index 0000000000..00c8a85025 --- /dev/null +++ b/tests/specs/run/ts_decorators/decorators/tc39_proposal/main.ts @@ -0,0 +1,21 @@ +// deno-lint-ignore no-explicit-any +function logged(value: any, { kind, name }: { kind: string; name: string }) { + if (kind === "method") { + return function (...args: unknown[]) { + console.log(`starting ${name} with arguments ${args.join(", ")}`); + // @ts-ignore this has implicit any type + const ret = value.call(this, ...args); + console.log(`ending ${name}`); + return ret; + }; + } +} + +class C { + @logged + m(arg: number) { + console.log("C.m", arg); + } +} + +new C().m(1); diff --git a/tests/specs/run/ts_import_from_js/005_more_imports.ts b/tests/specs/run/ts_import_from_js/005_more_imports.ts new file mode 100644 index 0000000000..c69556be15 --- /dev/null +++ b/tests/specs/run/ts_import_from_js/005_more_imports.ts @@ -0,0 +1,11 @@ +import { printHello3, returnsFoo2, returnsHi } from "./mod1.ts"; + +printHello3(); + +if (returnsHi() !== "Hi") { + throw Error("Unexpected"); +} + +if (returnsFoo2() !== "Foo") { + throw Error("Unexpected"); +} diff --git a/tests/specs/run/ts_import_from_js/__test__.jsonc b/tests/specs/run/ts_import_from_js/__test__.jsonc new file mode 100644 index 0000000000..de11873cbc --- /dev/null +++ b/tests/specs/run/ts_import_from_js/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --quiet --reload ts_import_from_js/main.js", + "output": "ts_import_from_js/main.out" +} diff --git a/tests/specs/run/ts_import_from_js/mod1.ts b/tests/specs/run/ts_import_from_js/mod1.ts new file mode 100644 index 0000000000..5e58f432ed --- /dev/null +++ b/tests/specs/run/ts_import_from_js/mod1.ts @@ -0,0 +1,17 @@ +import { printHello2, returnsFoo } from "./subdir2/mod2.ts"; + +export function returnsHi(): string { + return "Hi"; +} + +export function returnsFoo2(): string { + return returnsFoo(); +} + +export function printHello3() { + printHello2(); +} + +export function throwsError() { + throw Error("exception from mod1"); +} diff --git a/tests/specs/run/ts_import_from_js/mod2.ts b/tests/specs/run/ts_import_from_js/mod2.ts new file mode 100644 index 0000000000..ce1adc0e81 --- /dev/null +++ b/tests/specs/run/ts_import_from_js/mod2.ts @@ -0,0 +1 @@ +export { printHello } from "./print_hello.ts"; diff --git a/tests/specs/run/ts_import_from_js/print_hello.ts b/tests/specs/run/ts_import_from_js/print_hello.ts new file mode 100644 index 0000000000..b9c0ad5275 --- /dev/null +++ b/tests/specs/run/ts_import_from_js/print_hello.ts @@ -0,0 +1,3 @@ +export function printHello() { + console.log("Hello"); +} diff --git a/tests/specs/run/ts_import_from_js/subdir2/dynamic_import.ts b/tests/specs/run/ts_import_from_js/subdir2/dynamic_import.ts new file mode 100644 index 0000000000..59beb64c33 --- /dev/null +++ b/tests/specs/run/ts_import_from_js/subdir2/dynamic_import.ts @@ -0,0 +1,4 @@ +(async () => { + const { printHello } = await import("../mod2.ts"); + printHello(); +})(); diff --git a/tests/specs/run/ts_import_from_js/subdir2/mod2.ts b/tests/specs/run/ts_import_from_js/subdir2/mod2.ts new file mode 100644 index 0000000000..9071d0aeb4 --- /dev/null +++ b/tests/specs/run/ts_import_from_js/subdir2/mod2.ts @@ -0,0 +1,9 @@ +import { printHello } from "../print_hello.ts"; + +export function returnsFoo(): string { + return "Foo"; +} + +export function printHello2() { + printHello(); +} diff --git a/tests/testdata/run/ts_import_from_js/deps.js b/tests/specs/run/ts_import_from_js/ts_import_from_js/deps.js similarity index 100% rename from tests/testdata/run/ts_import_from_js/deps.js rename to tests/specs/run/ts_import_from_js/ts_import_from_js/deps.js diff --git a/tests/testdata/run/ts_import_from_js/main.js b/tests/specs/run/ts_import_from_js/ts_import_from_js/main.js similarity index 100% rename from tests/testdata/run/ts_import_from_js/main.js rename to tests/specs/run/ts_import_from_js/ts_import_from_js/main.js diff --git a/tests/testdata/run/ts_import_from_js/main.out b/tests/specs/run/ts_import_from_js/ts_import_from_js/main.out similarity index 100% rename from tests/testdata/run/ts_import_from_js/main.out rename to tests/specs/run/ts_import_from_js/ts_import_from_js/main.out diff --git a/tests/specs/run/ts_type_imports/__test__.jsonc b/tests/specs/run/ts_type_imports/__test__.jsonc new file mode 100644 index 0000000000..e9a925d1a8 --- /dev/null +++ b/tests/specs/run/ts_type_imports/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload --check ts_type_imports.ts", + "output": "ts_type_imports.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/ts_type_imports.ts b/tests/specs/run/ts_type_imports/ts_type_imports.ts similarity index 100% rename from tests/testdata/run/ts_type_imports.ts rename to tests/specs/run/ts_type_imports/ts_type_imports.ts diff --git a/tests/testdata/run/ts_type_imports.ts.out b/tests/specs/run/ts_type_imports/ts_type_imports.ts.out similarity index 100% rename from tests/testdata/run/ts_type_imports.ts.out rename to tests/specs/run/ts_type_imports/ts_type_imports.ts.out diff --git a/tests/specs/run/ts_type_imports/ts_type_imports_foo.ts b/tests/specs/run/ts_type_imports/ts_type_imports_foo.ts new file mode 100644 index 0000000000..db20773f63 --- /dev/null +++ b/tests/specs/run/ts_type_imports/ts_type_imports_foo.ts @@ -0,0 +1 @@ +export type Foo = Map; diff --git a/tests/specs/run/ts_type_only_import/__test__.jsonc b/tests/specs/run/ts_type_only_import/__test__.jsonc new file mode 100644 index 0000000000..977a6aba7a --- /dev/null +++ b/tests/specs/run/ts_type_only_import/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --check ts_type_only_import.ts", + "output": "ts_type_only_import.ts.out" +} diff --git a/tests/specs/run/ts_type_only_import/ts_type_only_import.d.ts b/tests/specs/run/ts_type_only_import/ts_type_only_import.d.ts new file mode 100644 index 0000000000..d48e4b48ab --- /dev/null +++ b/tests/specs/run/ts_type_only_import/ts_type_only_import.d.ts @@ -0,0 +1,3 @@ +export interface HelloWorld { + a: string; +} diff --git a/tests/testdata/run/ts_type_only_import.ts b/tests/specs/run/ts_type_only_import/ts_type_only_import.ts similarity index 100% rename from tests/testdata/run/ts_type_only_import.ts rename to tests/specs/run/ts_type_only_import/ts_type_only_import.ts diff --git a/tests/testdata/run/ts_type_only_import.ts.out b/tests/specs/run/ts_type_only_import/ts_type_only_import.ts.out similarity index 100% rename from tests/testdata/run/ts_type_only_import.ts.out rename to tests/specs/run/ts_type_only_import/ts_type_only_import.ts.out diff --git a/tests/specs/run/ts_without_extension/__test__.jsonc b/tests/specs/run/ts_without_extension/__test__.jsonc new file mode 100644 index 0000000000..a6c713bf5a --- /dev/null +++ b/tests/specs/run/ts_without_extension/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --ext ts --check ts_without_extension", + "output": "ts_without_extension.out", + "exitCode": 0 +} diff --git a/tests/specs/run/ts_without_extension/ts_without_extension b/tests/specs/run/ts_without_extension/ts_without_extension new file mode 100644 index 0000000000..f10891d7a2 --- /dev/null +++ b/tests/specs/run/ts_without_extension/ts_without_extension @@ -0,0 +1,3 @@ +interface Lollipop {} + +console.log("executing typescript with no extension"); diff --git a/tests/specs/run/ts_without_extension/ts_without_extension.out b/tests/specs/run/ts_without_extension/ts_without_extension.out new file mode 100644 index 0000000000..4f02dd4c33 --- /dev/null +++ b/tests/specs/run/ts_without_extension/ts_without_extension.out @@ -0,0 +1,2 @@ +Check [WILDCARD]/ts_without_extension +executing typescript with no extension diff --git a/tests/specs/run/tsx_imports/046_jsx_test.tsx b/tests/specs/run/tsx_imports/046_jsx_test.tsx new file mode 100644 index 0000000000..5ed3ff2fab --- /dev/null +++ b/tests/specs/run/tsx_imports/046_jsx_test.tsx @@ -0,0 +1,14 @@ +declare global { + export namespace JSX { + interface IntrinsicElements { + [elemName: string]: any; + } + } +} +const React = { + createElement(factory: any, props: any, ...children: any[]) { + return { factory, props, children }; + }, +}; +const View = () =>
land
; +console.log(); diff --git a/tests/specs/run/tsx_imports/__test__.jsonc b/tests/specs/run/tsx_imports/__test__.jsonc new file mode 100644 index 0000000000..2026804add --- /dev/null +++ b/tests/specs/run/tsx_imports/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --check tsx_imports/tsx_imports.ts", + "output": "tsx_imports/tsx_imports.ts.out" +} diff --git a/tests/testdata/run/tsx_imports/Component.tsx b/tests/specs/run/tsx_imports/tsx_imports/Component.tsx similarity index 100% rename from tests/testdata/run/tsx_imports/Component.tsx rename to tests/specs/run/tsx_imports/tsx_imports/Component.tsx diff --git a/tests/testdata/run/tsx_imports/tsx_imports.ts b/tests/specs/run/tsx_imports/tsx_imports/tsx_imports.ts similarity index 100% rename from tests/testdata/run/tsx_imports/tsx_imports.ts rename to tests/specs/run/tsx_imports/tsx_imports/tsx_imports.ts diff --git a/tests/testdata/run/tsx_imports/tsx_imports.ts.out b/tests/specs/run/tsx_imports/tsx_imports/tsx_imports.ts.out similarity index 100% rename from tests/testdata/run/tsx_imports/tsx_imports.ts.out rename to tests/specs/run/tsx_imports/tsx_imports/tsx_imports.ts.out diff --git a/tests/specs/run/type_definitions/__test__.jsonc b/tests/specs/run/type_definitions/__test__.jsonc new file mode 100644 index 0000000000..5030612a51 --- /dev/null +++ b/tests/specs/run/type_definitions/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload type_definitions.ts", + "output": "type_definitions.ts.out" +} diff --git a/tests/testdata/run/type_definitions.ts b/tests/specs/run/type_definitions/type_definitions.ts similarity index 56% rename from tests/testdata/run/type_definitions.ts rename to tests/specs/run/type_definitions/type_definitions.ts index 5948427219..0297c7e3d5 100644 --- a/tests/testdata/run/type_definitions.ts +++ b/tests/specs/run/type_definitions/type_definitions.ts @@ -1,11 +1,11 @@ // deno-lint-ignore-file // @deno-types="../type_definitions/foo.d.ts" -import { foo } from "../type_definitions/foo.js"; +import { foo } from "./type_definitions/foo.js"; // @deno-types="../type_definitions/fizz.d.ts" -import "../type_definitions/fizz.js"; +import "./type_definitions/fizz.js"; -import * as qat from "../type_definitions/qat.ts"; +import * as qat from "./type_definitions/qat.ts"; console.log(foo); console.log(fizz); diff --git a/tests/testdata/run/type_definitions.ts.out b/tests/specs/run/type_definitions/type_definitions.ts.out similarity index 100% rename from tests/testdata/run/type_definitions.ts.out rename to tests/specs/run/type_definitions/type_definitions.ts.out diff --git a/tests/specs/run/type_definitions/type_definitions/bar.d.ts b/tests/specs/run/type_definitions/type_definitions/bar.d.ts new file mode 100644 index 0000000000..d43335dbb5 --- /dev/null +++ b/tests/specs/run/type_definitions/type_definitions/bar.d.ts @@ -0,0 +1,7 @@ +/// + +declare namespace bar { + export class Bar { + baz: string; + } +} diff --git a/tests/specs/run/type_definitions/type_definitions/bar.js b/tests/specs/run/type_definitions/type_definitions/bar.js new file mode 100644 index 0000000000..e9c2e5193c --- /dev/null +++ b/tests/specs/run/type_definitions/type_definitions/bar.js @@ -0,0 +1,5 @@ +export class Bar { + constructor() { + this.baz = "baz"; + } +} diff --git a/tests/specs/run/type_definitions/type_definitions/fizz.d.ts b/tests/specs/run/type_definitions/type_definitions/fizz.d.ts new file mode 100644 index 0000000000..34eb41b960 --- /dev/null +++ b/tests/specs/run/type_definitions/type_definitions/fizz.d.ts @@ -0,0 +1,2 @@ +/** A global value. */ +declare const fizz: string; diff --git a/tests/specs/run/type_definitions/type_definitions/fizz.js b/tests/specs/run/type_definitions/type_definitions/fizz.js new file mode 100644 index 0000000000..852162c940 --- /dev/null +++ b/tests/specs/run/type_definitions/type_definitions/fizz.js @@ -0,0 +1 @@ +globalThis.fizz = "fizz"; diff --git a/tests/specs/run/type_definitions/type_definitions/foo.d.ts b/tests/specs/run/type_definitions/type_definitions/foo.d.ts new file mode 100644 index 0000000000..ce39201e1b --- /dev/null +++ b/tests/specs/run/type_definitions/type_definitions/foo.d.ts @@ -0,0 +1,2 @@ +/** An exported value. */ +export const foo: string; diff --git a/tests/specs/run/type_definitions/type_definitions/foo.js b/tests/specs/run/type_definitions/type_definitions/foo.js new file mode 100644 index 0000000000..61d366eb25 --- /dev/null +++ b/tests/specs/run/type_definitions/type_definitions/foo.js @@ -0,0 +1 @@ +export const foo = "foo"; diff --git a/tests/specs/run/type_definitions/type_definitions/qat.ts b/tests/specs/run/type_definitions/type_definitions/qat.ts new file mode 100644 index 0000000000..6196c9d387 --- /dev/null +++ b/tests/specs/run/type_definitions/type_definitions/qat.ts @@ -0,0 +1 @@ +export const qat = "qat"; diff --git a/tests/specs/run/type_definitions_for_export/__test__.jsonc b/tests/specs/run/type_definitions_for_export/__test__.jsonc new file mode 100644 index 0000000000..cf32bc9609 --- /dev/null +++ b/tests/specs/run/type_definitions_for_export/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --reload --check type_definitions_for_export.ts", + "output": "type_definitions_for_export.ts.out", + "exitCode": 1 +} diff --git a/tests/specs/run/type_definitions_for_export/export_type_def.ts b/tests/specs/run/type_definitions_for_export/export_type_def.ts new file mode 100644 index 0000000000..e33b70a644 --- /dev/null +++ b/tests/specs/run/type_definitions_for_export/export_type_def.ts @@ -0,0 +1,2 @@ +// @deno-types="./type_definitions/foo.d.ts" +export { foo } from "./type_definitions/foo.js"; diff --git a/tests/specs/run/type_definitions_for_export/type_definitions/bar.d.ts b/tests/specs/run/type_definitions_for_export/type_definitions/bar.d.ts new file mode 100644 index 0000000000..d43335dbb5 --- /dev/null +++ b/tests/specs/run/type_definitions_for_export/type_definitions/bar.d.ts @@ -0,0 +1,7 @@ +/// + +declare namespace bar { + export class Bar { + baz: string; + } +} diff --git a/tests/specs/run/type_definitions_for_export/type_definitions/bar.js b/tests/specs/run/type_definitions_for_export/type_definitions/bar.js new file mode 100644 index 0000000000..e9c2e5193c --- /dev/null +++ b/tests/specs/run/type_definitions_for_export/type_definitions/bar.js @@ -0,0 +1,5 @@ +export class Bar { + constructor() { + this.baz = "baz"; + } +} diff --git a/tests/specs/run/type_definitions_for_export/type_definitions/fizz.d.ts b/tests/specs/run/type_definitions_for_export/type_definitions/fizz.d.ts new file mode 100644 index 0000000000..34eb41b960 --- /dev/null +++ b/tests/specs/run/type_definitions_for_export/type_definitions/fizz.d.ts @@ -0,0 +1,2 @@ +/** A global value. */ +declare const fizz: string; diff --git a/tests/specs/run/type_definitions_for_export/type_definitions/fizz.js b/tests/specs/run/type_definitions_for_export/type_definitions/fizz.js new file mode 100644 index 0000000000..852162c940 --- /dev/null +++ b/tests/specs/run/type_definitions_for_export/type_definitions/fizz.js @@ -0,0 +1 @@ +globalThis.fizz = "fizz"; diff --git a/tests/specs/run/type_definitions_for_export/type_definitions/foo.d.ts b/tests/specs/run/type_definitions_for_export/type_definitions/foo.d.ts new file mode 100644 index 0000000000..ce39201e1b --- /dev/null +++ b/tests/specs/run/type_definitions_for_export/type_definitions/foo.d.ts @@ -0,0 +1,2 @@ +/** An exported value. */ +export const foo: string; diff --git a/tests/specs/run/type_definitions_for_export/type_definitions/foo.js b/tests/specs/run/type_definitions_for_export/type_definitions/foo.js new file mode 100644 index 0000000000..61d366eb25 --- /dev/null +++ b/tests/specs/run/type_definitions_for_export/type_definitions/foo.js @@ -0,0 +1 @@ +export const foo = "foo"; diff --git a/tests/specs/run/type_definitions_for_export/type_definitions/qat.ts b/tests/specs/run/type_definitions_for_export/type_definitions/qat.ts new file mode 100644 index 0000000000..6196c9d387 --- /dev/null +++ b/tests/specs/run/type_definitions_for_export/type_definitions/qat.ts @@ -0,0 +1 @@ +export const qat = "qat"; diff --git a/tests/testdata/run/type_definitions_for_export.ts b/tests/specs/run/type_definitions_for_export/type_definitions_for_export.ts similarity index 100% rename from tests/testdata/run/type_definitions_for_export.ts rename to tests/specs/run/type_definitions_for_export/type_definitions_for_export.ts diff --git a/tests/testdata/run/type_definitions_for_export.ts.out b/tests/specs/run/type_definitions_for_export/type_definitions_for_export.ts.out similarity index 100% rename from tests/testdata/run/type_definitions_for_export.ts.out rename to tests/specs/run/type_definitions_for_export/type_definitions_for_export.ts.out diff --git a/tests/specs/run/type_directives_01/__test__.jsonc b/tests/specs/run/type_directives_01/__test__.jsonc new file mode 100644 index 0000000000..08826b776e --- /dev/null +++ b/tests/specs/run/type_directives_01/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --check=all -L debug type_directives_01.ts", + "output": "type_directives_01.ts.out" +} diff --git a/tests/testdata/run/type_directives_01.ts b/tests/specs/run/type_directives_01/type_directives_01.ts similarity index 100% rename from tests/testdata/run/type_directives_01.ts rename to tests/specs/run/type_directives_01/type_directives_01.ts diff --git a/tests/testdata/run/type_directives_01.ts.out b/tests/specs/run/type_directives_01/type_directives_01.ts.out similarity index 100% rename from tests/testdata/run/type_directives_01.ts.out rename to tests/specs/run/type_directives_01/type_directives_01.ts.out diff --git a/tests/specs/run/type_directives_02/__test__.jsonc b/tests/specs/run/type_directives_02/__test__.jsonc new file mode 100644 index 0000000000..e731e393e1 --- /dev/null +++ b/tests/specs/run/type_directives_02/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --check=all -L debug type_directives_02.ts", + "output": "type_directives_02.ts.out" +} diff --git a/tests/specs/run/type_directives_02/type_directives_02.ts b/tests/specs/run/type_directives_02/type_directives_02.ts new file mode 100644 index 0000000000..f829c0cec3 --- /dev/null +++ b/tests/specs/run/type_directives_02/type_directives_02.ts @@ -0,0 +1,3 @@ +import * as foo from "./type_reference.js"; + +console.log(foo.foo); diff --git a/tests/specs/run/type_directives_02/type_directives_02.ts.out b/tests/specs/run/type_directives_02/type_directives_02.ts.out new file mode 100644 index 0000000000..d9bd381504 --- /dev/null +++ b/tests/specs/run/type_directives_02/type_directives_02.ts.out @@ -0,0 +1,3 @@ +[WILDCARD] +DEBUG TS - host.getSourceFile("file:///[WILDCARD]/type_reference.d.ts", Latest) +[WILDCARD] \ No newline at end of file diff --git a/tests/specs/run/type_directives_02/type_reference.d.ts b/tests/specs/run/type_directives_02/type_reference.d.ts new file mode 100644 index 0000000000..f9b8de5ede --- /dev/null +++ b/tests/specs/run/type_directives_02/type_reference.d.ts @@ -0,0 +1 @@ +export const foo: "foo"; diff --git a/tests/specs/run/type_directives_02/type_reference.js b/tests/specs/run/type_directives_02/type_reference.js new file mode 100644 index 0000000000..917d891980 --- /dev/null +++ b/tests/specs/run/type_directives_02/type_reference.js @@ -0,0 +1,3 @@ +/// + +export const foo = "foo"; diff --git a/tests/specs/run/type_headers_deno_types/__test__.jsonc b/tests/specs/run/type_headers_deno_types/__test__.jsonc new file mode 100644 index 0000000000..1a95fa2d45 --- /dev/null +++ b/tests/specs/run/type_headers_deno_types/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-import --reload --check type_headers_deno_types.ts", + "output": "type_headers_deno_types.ts.out" +} diff --git a/tests/testdata/run/type_headers_deno_types.ts b/tests/specs/run/type_headers_deno_types/type_headers_deno_types.ts similarity index 100% rename from tests/testdata/run/type_headers_deno_types.ts rename to tests/specs/run/type_headers_deno_types/type_headers_deno_types.ts diff --git a/tests/testdata/run/type_headers_deno_types.ts.out b/tests/specs/run/type_headers_deno_types/type_headers_deno_types.ts.out similarity index 100% rename from tests/testdata/run/type_headers_deno_types.ts.out rename to tests/specs/run/type_headers_deno_types/type_headers_deno_types.ts.out diff --git a/tests/specs/run/unbuffered_stderr/__test__.jsonc b/tests/specs/run/unbuffered_stderr/__test__.jsonc new file mode 100644 index 0000000000..4b8a091f24 --- /dev/null +++ b/tests/specs/run/unbuffered_stderr/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload unbuffered_stderr.ts", + "output": "unbuffered_stderr.ts.out" +} diff --git a/tests/testdata/run/unbuffered_stderr.ts b/tests/specs/run/unbuffered_stderr/unbuffered_stderr.ts similarity index 100% rename from tests/testdata/run/unbuffered_stderr.ts rename to tests/specs/run/unbuffered_stderr/unbuffered_stderr.ts diff --git a/tests/testdata/run/unbuffered_stderr.ts.out b/tests/specs/run/unbuffered_stderr/unbuffered_stderr.ts.out similarity index 100% rename from tests/testdata/run/unbuffered_stderr.ts.out rename to tests/specs/run/unbuffered_stderr/unbuffered_stderr.ts.out diff --git a/tests/specs/run/unbuffered_stdout/__test__.jsonc b/tests/specs/run/unbuffered_stdout/__test__.jsonc new file mode 100644 index 0000000000..4225e9d0a2 --- /dev/null +++ b/tests/specs/run/unbuffered_stdout/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload unbuffered_stdout.ts", + "output": "unbuffered_stdout.ts.out" +} diff --git a/tests/testdata/run/unbuffered_stdout.ts b/tests/specs/run/unbuffered_stdout/unbuffered_stdout.ts similarity index 100% rename from tests/testdata/run/unbuffered_stdout.ts rename to tests/specs/run/unbuffered_stdout/unbuffered_stdout.ts diff --git a/tests/testdata/run/unbuffered_stdout.ts.out b/tests/specs/run/unbuffered_stdout/unbuffered_stdout.ts.out similarity index 100% rename from tests/testdata/run/unbuffered_stdout.ts.out rename to tests/specs/run/unbuffered_stdout/unbuffered_stdout.ts.out diff --git a/tests/specs/run/unhandled_rejection/__test__.jsonc b/tests/specs/run/unhandled_rejection/__test__.jsonc new file mode 100644 index 0000000000..3a22292062 --- /dev/null +++ b/tests/specs/run/unhandled_rejection/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --check unhandled_rejection.ts", + "output": "unhandled_rejection.ts.out" +} diff --git a/tests/testdata/run/unhandled_rejection.ts b/tests/specs/run/unhandled_rejection/unhandled_rejection.ts similarity index 100% rename from tests/testdata/run/unhandled_rejection.ts rename to tests/specs/run/unhandled_rejection/unhandled_rejection.ts diff --git a/tests/specs/run/unhandled_rejection/unhandled_rejection.ts.out b/tests/specs/run/unhandled_rejection/unhandled_rejection.ts.out new file mode 100644 index 0000000000..fc5a3915f6 --- /dev/null +++ b/tests/specs/run/unhandled_rejection/unhandled_rejection.ts.out @@ -0,0 +1,9 @@ +[WILDCARD] +unhandled rejection at: Promise { + Error: bar not available + at new Foo (file:///[WILDCARD]/unhandled_rejection.ts:8:20) + at file:///[WILDCARD]/unhandled_rejection.ts:12:1 +} reason: Error: bar not available + at new Foo (file:///[WILDCARD]/unhandled_rejection.ts:8:20) + at file:///[WILDCARD]/unhandled_rejection.ts:12:1 +unhandled rejection at: Promise { undefined } reason: undefined diff --git a/tests/specs/run/unhandled_rejection_dynamic_import/__test__.jsonc b/tests/specs/run/unhandled_rejection_dynamic_import/__test__.jsonc new file mode 100644 index 0000000000..6ca0d093b9 --- /dev/null +++ b/tests/specs/run/unhandled_rejection_dynamic_import/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --allow-read unhandled_rejection_dynamic_import/main.ts", + "output": "unhandled_rejection_dynamic_import/main.ts.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/unhandled_rejection_dynamic_import/import.ts b/tests/specs/run/unhandled_rejection_dynamic_import/unhandled_rejection_dynamic_import/import.ts similarity index 100% rename from tests/testdata/run/unhandled_rejection_dynamic_import/import.ts rename to tests/specs/run/unhandled_rejection_dynamic_import/unhandled_rejection_dynamic_import/import.ts diff --git a/tests/testdata/run/unhandled_rejection_dynamic_import/main.ts b/tests/specs/run/unhandled_rejection_dynamic_import/unhandled_rejection_dynamic_import/main.ts similarity index 100% rename from tests/testdata/run/unhandled_rejection_dynamic_import/main.ts rename to tests/specs/run/unhandled_rejection_dynamic_import/unhandled_rejection_dynamic_import/main.ts diff --git a/tests/testdata/run/unhandled_rejection_dynamic_import/main.ts.out b/tests/specs/run/unhandled_rejection_dynamic_import/unhandled_rejection_dynamic_import/main.ts.out similarity index 100% rename from tests/testdata/run/unhandled_rejection_dynamic_import/main.ts.out rename to tests/specs/run/unhandled_rejection_dynamic_import/unhandled_rejection_dynamic_import/main.ts.out diff --git a/tests/specs/run/unhandled_rejection_dynamic_import2/__test__.jsonc b/tests/specs/run/unhandled_rejection_dynamic_import2/__test__.jsonc new file mode 100644 index 0000000000..a4e588f463 --- /dev/null +++ b/tests/specs/run/unhandled_rejection_dynamic_import2/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --allow-read unhandled_rejection_dynamic_import2/main.ts", + "output": "unhandled_rejection_dynamic_import2/main.ts.out" +} diff --git a/tests/testdata/run/unhandled_rejection_dynamic_import2/import.ts b/tests/specs/run/unhandled_rejection_dynamic_import2/unhandled_rejection_dynamic_import2/import.ts similarity index 100% rename from tests/testdata/run/unhandled_rejection_dynamic_import2/import.ts rename to tests/specs/run/unhandled_rejection_dynamic_import2/unhandled_rejection_dynamic_import2/import.ts diff --git a/tests/testdata/run/unhandled_rejection_dynamic_import2/main.ts b/tests/specs/run/unhandled_rejection_dynamic_import2/unhandled_rejection_dynamic_import2/main.ts similarity index 100% rename from tests/testdata/run/unhandled_rejection_dynamic_import2/main.ts rename to tests/specs/run/unhandled_rejection_dynamic_import2/unhandled_rejection_dynamic_import2/main.ts diff --git a/tests/testdata/run/unhandled_rejection_dynamic_import2/main.ts.out b/tests/specs/run/unhandled_rejection_dynamic_import2/unhandled_rejection_dynamic_import2/main.ts.out similarity index 100% rename from tests/testdata/run/unhandled_rejection_dynamic_import2/main.ts.out rename to tests/specs/run/unhandled_rejection_dynamic_import2/unhandled_rejection_dynamic_import2/main.ts.out diff --git a/tests/specs/run/unhandled_rejection_sync_error/__test__.jsonc b/tests/specs/run/unhandled_rejection_sync_error/__test__.jsonc new file mode 100644 index 0000000000..3f09f9c369 --- /dev/null +++ b/tests/specs/run/unhandled_rejection_sync_error/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --check unhandled_rejection_sync_error.ts", + "output": "unhandled_rejection_sync_error.ts.out" +} diff --git a/tests/testdata/run/unhandled_rejection_sync_error.ts b/tests/specs/run/unhandled_rejection_sync_error/unhandled_rejection_sync_error.ts similarity index 100% rename from tests/testdata/run/unhandled_rejection_sync_error.ts rename to tests/specs/run/unhandled_rejection_sync_error/unhandled_rejection_sync_error.ts diff --git a/tests/specs/run/unhandled_rejection_sync_error/unhandled_rejection_sync_error.ts.out b/tests/specs/run/unhandled_rejection_sync_error/unhandled_rejection_sync_error.ts.out new file mode 100644 index 0000000000..0c1115ef24 --- /dev/null +++ b/tests/specs/run/unhandled_rejection_sync_error/unhandled_rejection_sync_error.ts.out @@ -0,0 +1,6 @@ +[WILDCARD] +unhandled rejection at: Promise { + Error: boom! + at file:///[WILDCARD]unhandled_rejection_sync_error.ts:6:7 +} reason: Error: boom! + at file:///[WILDCARD]unhandled_rejection_sync_error.ts:6:7 diff --git a/tests/specs/run/unsafe_proto/__test__.jsonc b/tests/specs/run/unsafe_proto/__test__.jsonc new file mode 100644 index 0000000000..d1c608b515 --- /dev/null +++ b/tests/specs/run/unsafe_proto/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run -A unsafe_proto/main.js", + "output": "unsafe_proto/main.out", + "exitCode": 0 +} diff --git a/tests/testdata/run/unsafe_proto/main.js b/tests/specs/run/unsafe_proto/unsafe_proto/main.js similarity index 100% rename from tests/testdata/run/unsafe_proto/main.js rename to tests/specs/run/unsafe_proto/unsafe_proto/main.js diff --git a/tests/testdata/run/unsafe_proto/main.out b/tests/specs/run/unsafe_proto/unsafe_proto/main.out similarity index 100% rename from tests/testdata/run/unsafe_proto/main.out rename to tests/specs/run/unsafe_proto/unsafe_proto/main.out diff --git a/tests/testdata/run/unsafe_proto/main_with_unsafe_proto_flag.out b/tests/specs/run/unsafe_proto/unsafe_proto/main_with_unsafe_proto_flag.out similarity index 100% rename from tests/testdata/run/unsafe_proto/main_with_unsafe_proto_flag.out rename to tests/specs/run/unsafe_proto/unsafe_proto/main_with_unsafe_proto_flag.out diff --git a/tests/testdata/run/unsafe_proto/worker.js b/tests/specs/run/unsafe_proto/unsafe_proto/worker.js similarity index 100% rename from tests/testdata/run/unsafe_proto/worker.js rename to tests/specs/run/unsafe_proto/unsafe_proto/worker.js diff --git a/tests/specs/run/unsafe_proto_flag/__test__.jsonc b/tests/specs/run/unsafe_proto_flag/__test__.jsonc new file mode 100644 index 0000000000..8bd2b56ffc --- /dev/null +++ b/tests/specs/run/unsafe_proto_flag/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run -A --unstable-unsafe-proto unsafe_proto/main.js", + "output": "unsafe_proto/main_with_unsafe_proto_flag.out", + "exitCode": 0 +} diff --git a/tests/specs/run/unsafe_proto_flag/unsafe_proto/main.js b/tests/specs/run/unsafe_proto_flag/unsafe_proto/main.js new file mode 100644 index 0000000000..eb95c55a03 --- /dev/null +++ b/tests/specs/run/unsafe_proto_flag/unsafe_proto/main.js @@ -0,0 +1,5 @@ +console.log(Object.hasOwn(Object.prototype, "__proto__")); + +new Worker(import.meta.resolve("./worker.js"), { + type: "module", +}); diff --git a/tests/specs/run/unsafe_proto_flag/unsafe_proto/main.out b/tests/specs/run/unsafe_proto_flag/unsafe_proto/main.out new file mode 100644 index 0000000000..4b095fd0ff --- /dev/null +++ b/tests/specs/run/unsafe_proto_flag/unsafe_proto/main.out @@ -0,0 +1,2 @@ +false +false diff --git a/tests/specs/run/unsafe_proto_flag/unsafe_proto/main_with_unsafe_proto_flag.out b/tests/specs/run/unsafe_proto_flag/unsafe_proto/main_with_unsafe_proto_flag.out new file mode 100644 index 0000000000..bb101b641b --- /dev/null +++ b/tests/specs/run/unsafe_proto_flag/unsafe_proto/main_with_unsafe_proto_flag.out @@ -0,0 +1,2 @@ +true +true diff --git a/tests/specs/run/unsafe_proto_flag/unsafe_proto/worker.js b/tests/specs/run/unsafe_proto_flag/unsafe_proto/worker.js new file mode 100644 index 0000000000..b22bc87139 --- /dev/null +++ b/tests/specs/run/unsafe_proto_flag/unsafe_proto/worker.js @@ -0,0 +1,2 @@ +console.log(Object.hasOwn(Object.prototype, "__proto__")); +close(); diff --git a/tests/specs/run/unstable_broadcast_channel_disabled/__test__.jsonc b/tests/specs/run/unstable_broadcast_channel_disabled/__test__.jsonc new file mode 100644 index 0000000000..fa12c9f91d --- /dev/null +++ b/tests/specs/run/unstable_broadcast_channel_disabled/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-read unstable_broadcast_channel.js", + "output": "unstable_broadcast_channel.disabled.out" +} diff --git a/tests/testdata/run/unstable_broadcast_channel.disabled.out b/tests/specs/run/unstable_broadcast_channel_disabled/unstable_broadcast_channel.disabled.out similarity index 100% rename from tests/testdata/run/unstable_broadcast_channel.disabled.out rename to tests/specs/run/unstable_broadcast_channel_disabled/unstable_broadcast_channel.disabled.out diff --git a/tests/testdata/run/unstable_broadcast_channel.js b/tests/specs/run/unstable_broadcast_channel_disabled/unstable_broadcast_channel.js similarity index 100% rename from tests/testdata/run/unstable_broadcast_channel.js rename to tests/specs/run/unstable_broadcast_channel_disabled/unstable_broadcast_channel.js diff --git a/tests/specs/run/unstable_broadcast_channel_enabled/__test__.jsonc b/tests/specs/run/unstable_broadcast_channel_enabled/__test__.jsonc new file mode 100644 index 0000000000..f93c7785a4 --- /dev/null +++ b/tests/specs/run/unstable_broadcast_channel_enabled/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-read --unstable-broadcast-channel unstable_broadcast_channel.js", + "output": "unstable_broadcast_channel.enabled.out" +} diff --git a/tests/testdata/run/unstable_broadcast_channel.enabled.out b/tests/specs/run/unstable_broadcast_channel_enabled/unstable_broadcast_channel.enabled.out similarity index 100% rename from tests/testdata/run/unstable_broadcast_channel.enabled.out rename to tests/specs/run/unstable_broadcast_channel_enabled/unstable_broadcast_channel.enabled.out diff --git a/tests/specs/run/unstable_broadcast_channel_enabled/unstable_broadcast_channel.js b/tests/specs/run/unstable_broadcast_channel_enabled/unstable_broadcast_channel.js new file mode 100644 index 0000000000..b8576aa22f --- /dev/null +++ b/tests/specs/run/unstable_broadcast_channel_enabled/unstable_broadcast_channel.js @@ -0,0 +1,10 @@ +const scope = import.meta.url.slice(-7) === "#worker" ? "worker" : "main"; + +console.log(scope, globalThis.BroadcastChannel); + +if (scope === "worker") { + postMessage("done"); +} else { + const worker = new Worker(`${import.meta.url}#worker`, { type: "module" }); + worker.onmessage = () => Deno.exit(0); +} diff --git a/tests/specs/run/unstable_cron_disabled/__test__.jsonc b/tests/specs/run/unstable_cron_disabled/__test__.jsonc new file mode 100644 index 0000000000..be89db40b5 --- /dev/null +++ b/tests/specs/run/unstable_cron_disabled/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-read unstable_cron.js", + "output": "unstable_cron.disabled.out" +} diff --git a/tests/testdata/run/unstable_cron.disabled.out b/tests/specs/run/unstable_cron_disabled/unstable_cron.disabled.out similarity index 100% rename from tests/testdata/run/unstable_cron.disabled.out rename to tests/specs/run/unstable_cron_disabled/unstable_cron.disabled.out diff --git a/tests/testdata/run/unstable_cron.js b/tests/specs/run/unstable_cron_disabled/unstable_cron.js similarity index 100% rename from tests/testdata/run/unstable_cron.js rename to tests/specs/run/unstable_cron_disabled/unstable_cron.js diff --git a/tests/specs/run/unstable_cron_enabled/__test__.jsonc b/tests/specs/run/unstable_cron_enabled/__test__.jsonc new file mode 100644 index 0000000000..07a37e3fef --- /dev/null +++ b/tests/specs/run/unstable_cron_enabled/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-read --unstable-cron unstable_cron.js", + "output": "unstable_cron.enabled.out" +} diff --git a/tests/testdata/run/unstable_cron.enabled.out b/tests/specs/run/unstable_cron_enabled/unstable_cron.enabled.out similarity index 100% rename from tests/testdata/run/unstable_cron.enabled.out rename to tests/specs/run/unstable_cron_enabled/unstable_cron.enabled.out diff --git a/tests/specs/run/unstable_cron_enabled/unstable_cron.js b/tests/specs/run/unstable_cron_enabled/unstable_cron.js new file mode 100644 index 0000000000..3114f6e555 --- /dev/null +++ b/tests/specs/run/unstable_cron_enabled/unstable_cron.js @@ -0,0 +1,10 @@ +const scope = import.meta.url.slice(-7) === "#worker" ? "worker" : "main"; + +console.log(scope, Deno.cron); + +if (scope === "worker") { + postMessage("done"); +} else { + const worker = new Worker(`${import.meta.url}#worker`, { type: "module" }); + worker.onmessage = () => Deno.exit(0); +} diff --git a/tests/specs/run/unstable_kv_disabled/__test__.jsonc b/tests/specs/run/unstable_kv_disabled/__test__.jsonc new file mode 100644 index 0000000000..6521c180d8 --- /dev/null +++ b/tests/specs/run/unstable_kv_disabled/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-read unstable_kv.js", + "output": "unstable_kv.disabled.out" +} diff --git a/tests/testdata/run/unstable_kv.disabled.out b/tests/specs/run/unstable_kv_disabled/unstable_kv.disabled.out similarity index 100% rename from tests/testdata/run/unstable_kv.disabled.out rename to tests/specs/run/unstable_kv_disabled/unstable_kv.disabled.out diff --git a/tests/testdata/run/unstable_kv.js b/tests/specs/run/unstable_kv_disabled/unstable_kv.js similarity index 100% rename from tests/testdata/run/unstable_kv.js rename to tests/specs/run/unstable_kv_disabled/unstable_kv.js diff --git a/tests/specs/run/unstable_kv_enabled/__test__.jsonc b/tests/specs/run/unstable_kv_enabled/__test__.jsonc new file mode 100644 index 0000000000..6e9fea1000 --- /dev/null +++ b/tests/specs/run/unstable_kv_enabled/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-read --unstable-kv unstable_kv.js", + "output": "unstable_kv.enabled.out" +} diff --git a/tests/testdata/run/unstable_kv.enabled.out b/tests/specs/run/unstable_kv_enabled/unstable_kv.enabled.out similarity index 100% rename from tests/testdata/run/unstable_kv.enabled.out rename to tests/specs/run/unstable_kv_enabled/unstable_kv.enabled.out diff --git a/tests/specs/run/unstable_kv_enabled/unstable_kv.js b/tests/specs/run/unstable_kv_enabled/unstable_kv.js new file mode 100644 index 0000000000..17c0e05aa5 --- /dev/null +++ b/tests/specs/run/unstable_kv_enabled/unstable_kv.js @@ -0,0 +1,14 @@ +const scope = import.meta.url.slice(-7) === "#worker" ? "worker" : "main"; + +console.log(scope, Deno.AtomicOperation); +console.log(scope, Deno.Kv); +console.log(scope, Deno.KvListIterator); +console.log(scope, Deno.KvU64); +console.log(scope, Deno.openKv); + +if (scope === "worker") { + postMessage("done"); +} else { + const worker = new Worker(`${import.meta.url}#worker`, { type: "module" }); + worker.onmessage = () => Deno.exit(0); +} diff --git a/tests/specs/run/unstable_net_disabled/__test__.jsonc b/tests/specs/run/unstable_net_disabled/__test__.jsonc new file mode 100644 index 0000000000..6bccb2ef6c --- /dev/null +++ b/tests/specs/run/unstable_net_disabled/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-read unstable_net.js", + "output": "unstable_net.disabled.out" +} diff --git a/tests/testdata/run/unstable_net.disabled.out b/tests/specs/run/unstable_net_disabled/unstable_net.disabled.out similarity index 100% rename from tests/testdata/run/unstable_net.disabled.out rename to tests/specs/run/unstable_net_disabled/unstable_net.disabled.out diff --git a/tests/testdata/run/unstable_net.js b/tests/specs/run/unstable_net_disabled/unstable_net.js similarity index 100% rename from tests/testdata/run/unstable_net.js rename to tests/specs/run/unstable_net_disabled/unstable_net.js diff --git a/tests/specs/run/unstable_net_enabled/__test__.jsonc b/tests/specs/run/unstable_net_enabled/__test__.jsonc new file mode 100644 index 0000000000..8e9696f44a --- /dev/null +++ b/tests/specs/run/unstable_net_enabled/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-read --unstable-net unstable_net.js", + "output": "unstable_net.enabled.out" +} diff --git a/tests/testdata/run/unstable_net.enabled.out b/tests/specs/run/unstable_net_enabled/unstable_net.enabled.out similarity index 100% rename from tests/testdata/run/unstable_net.enabled.out rename to tests/specs/run/unstable_net_enabled/unstable_net.enabled.out diff --git a/tests/specs/run/unstable_net_enabled/unstable_net.js b/tests/specs/run/unstable_net_enabled/unstable_net.js new file mode 100644 index 0000000000..4492b202b1 --- /dev/null +++ b/tests/specs/run/unstable_net_enabled/unstable_net.js @@ -0,0 +1,11 @@ +const scope = import.meta.url.slice(-7) === "#worker" ? "worker" : "main"; + +console.log(scope, Deno.listenDatagram); +console.log(scope, globalThis.WebSocketStream); + +if (scope === "worker") { + postMessage("done"); +} else { + const worker = new Worker(`${import.meta.url}#worker`, { type: "module" }); + worker.onmessage = () => Deno.exit(0); +} diff --git a/tests/specs/run/unstable_worker/__test__.jsonc b/tests/specs/run/unstable_worker/__test__.jsonc new file mode 100644 index 0000000000..7a6e9bfbe0 --- /dev/null +++ b/tests/specs/run/unstable_worker/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --reload --quiet --allow-read unstable_worker.ts", + "output": "unstable_worker.ts.out" +} diff --git a/tests/testdata/run/unstable_worker.ts b/tests/specs/run/unstable_worker/unstable_worker.ts similarity index 62% rename from tests/testdata/run/unstable_worker.ts rename to tests/specs/run/unstable_worker/unstable_worker.ts index d111d2c7e3..b0554c5b21 100644 --- a/tests/testdata/run/unstable_worker.ts +++ b/tests/specs/run/unstable_worker/unstable_worker.ts @@ -1,5 +1,5 @@ const w = new Worker( - import.meta.resolve("../workers/worker_unstable.ts"), + import.meta.resolve("./worker_unstable.ts"), { type: "module", name: "Unstable Worker" }, ); diff --git a/tests/testdata/run/unstable_worker.ts.out b/tests/specs/run/unstable_worker/unstable_worker.ts.out similarity index 100% rename from tests/testdata/run/unstable_worker.ts.out rename to tests/specs/run/unstable_worker/unstable_worker.ts.out diff --git a/tests/specs/run/unstable_worker/worker_unstable.ts b/tests/specs/run/unstable_worker/worker_unstable.ts new file mode 100644 index 0000000000..219f34e7b8 --- /dev/null +++ b/tests/specs/run/unstable_worker/worker_unstable.ts @@ -0,0 +1,5 @@ +console.log(Deno.permissions.query); +console.log(Deno.consoleSize); +self.onmessage = () => { + self.close(); +}; diff --git a/tests/specs/run/unstable_worker_options_disabled/__test__.jsonc b/tests/specs/run/unstable_worker_options_disabled/__test__.jsonc new file mode 100644 index 0000000000..30087244ec --- /dev/null +++ b/tests/specs/run/unstable_worker_options_disabled/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --reload --allow-read unstable_worker_options.js", + "output": "unstable_worker_options.disabled.out", + "exitCode": 70 +} diff --git a/tests/testdata/run/unstable_worker_options.disabled.out b/tests/specs/run/unstable_worker_options_disabled/unstable_worker_options.disabled.out similarity index 100% rename from tests/testdata/run/unstable_worker_options.disabled.out rename to tests/specs/run/unstable_worker_options_disabled/unstable_worker_options.disabled.out diff --git a/tests/testdata/run/unstable_worker_options.js b/tests/specs/run/unstable_worker_options_disabled/unstable_worker_options.js similarity index 100% rename from tests/testdata/run/unstable_worker_options.js rename to tests/specs/run/unstable_worker_options_disabled/unstable_worker_options.js diff --git a/tests/specs/run/unstable_worker_options_enabled/__test__.jsonc b/tests/specs/run/unstable_worker_options_enabled/__test__.jsonc new file mode 100644 index 0000000000..1d397c5f24 --- /dev/null +++ b/tests/specs/run/unstable_worker_options_enabled/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-read --unstable-worker-options unstable_worker_options.js", + "output": "unstable_worker_options.enabled.out" +} diff --git a/tests/testdata/run/unstable_worker_options.enabled.out b/tests/specs/run/unstable_worker_options_enabled/unstable_worker_options.enabled.out similarity index 100% rename from tests/testdata/run/unstable_worker_options.enabled.out rename to tests/specs/run/unstable_worker_options_enabled/unstable_worker_options.enabled.out diff --git a/tests/specs/run/unstable_worker_options_enabled/unstable_worker_options.js b/tests/specs/run/unstable_worker_options_enabled/unstable_worker_options.js new file mode 100644 index 0000000000..213eb3ee67 --- /dev/null +++ b/tests/specs/run/unstable_worker_options_enabled/unstable_worker_options.js @@ -0,0 +1,19 @@ +const scope = import.meta.url.slice(-7) === "#worker" ? "worker" : "main"; + +new Worker(`data:application/javascript;base64,${btoa(`postMessage("ok");`)}`, { + type: "module", + deno: { + permissions: { + read: true, + }, + }, +}).onmessage = ({ data }) => { + console.log(scope, data); + + if (scope === "main") { + const worker = new Worker(`${import.meta.url}#worker`, { type: "module" }); + worker.onmessage = () => Deno.exit(0); + } else { + postMessage("done"); + } +}; diff --git a/tests/specs/run/unsupported_dynamic_import_scheme/__test__.jsonc b/tests/specs/run/unsupported_dynamic_import_scheme/__test__.jsonc new file mode 100644 index 0000000000..7f71dcebae --- /dev/null +++ b/tests/specs/run/unsupported_dynamic_import_scheme/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "eval import('xxx:')", + "output": "unsupported_dynamic_import_scheme.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/unsupported_dynamic_import_scheme.out b/tests/specs/run/unsupported_dynamic_import_scheme/unsupported_dynamic_import_scheme.out similarity index 100% rename from tests/testdata/run/unsupported_dynamic_import_scheme.out rename to tests/specs/run/unsupported_dynamic_import_scheme/unsupported_dynamic_import_scheme.out diff --git a/tests/specs/run/v8_flags_env_run/__test__.jsonc b/tests/specs/run/v8_flags_env_run/__test__.jsonc new file mode 100644 index 0000000000..39ea666b84 --- /dev/null +++ b/tests/specs/run/v8_flags_env_run/__test__.jsonc @@ -0,0 +1,7 @@ +{ + "args": "run v8_flags.js", + "output": "v8_flags.js.out", + "envs": { + "DENO_V8_FLAGS": "--expose-gc" + } +} diff --git a/tests/testdata/run/v8_flags.js b/tests/specs/run/v8_flags_env_run/v8_flags.js similarity index 100% rename from tests/testdata/run/v8_flags.js rename to tests/specs/run/v8_flags_env_run/v8_flags.js diff --git a/tests/testdata/run/v8_flags.js.out b/tests/specs/run/v8_flags_env_run/v8_flags.js.out similarity index 100% rename from tests/testdata/run/v8_flags.js.out rename to tests/specs/run/v8_flags_env_run/v8_flags.js.out diff --git a/tests/specs/run/v8_flags_run/__test__.jsonc b/tests/specs/run/v8_flags_run/__test__.jsonc new file mode 100644 index 0000000000..ff21fb8c5b --- /dev/null +++ b/tests/specs/run/v8_flags_run/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --v8-flags=--expose-gc v8_flags.js", + "output": "v8_flags.js.out" +} diff --git a/tests/specs/run/v8_flags_run/v8_flags.js b/tests/specs/run/v8_flags_run/v8_flags.js new file mode 100644 index 0000000000..f7999c4afd --- /dev/null +++ b/tests/specs/run/v8_flags_run/v8_flags.js @@ -0,0 +1 @@ +console.log(typeof gc); diff --git a/tests/specs/run/v8_flags_run/v8_flags.js.out b/tests/specs/run/v8_flags_run/v8_flags.js.out new file mode 100644 index 0000000000..e2dbde096f --- /dev/null +++ b/tests/specs/run/v8_flags_run/v8_flags.js.out @@ -0,0 +1 @@ +function diff --git a/tests/specs/run/v8_flags_unrecognized/__test__.jsonc b/tests/specs/run/v8_flags_unrecognized/__test__.jsonc new file mode 100644 index 0000000000..93472d0d74 --- /dev/null +++ b/tests/specs/run/v8_flags_unrecognized/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "repl --v8-flags=--foo,bar,--trace-gc,-baz", + "output": "v8_flags_unrecognized.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/v8_flags_unrecognized.out b/tests/specs/run/v8_flags_unrecognized/v8_flags_unrecognized.out similarity index 100% rename from tests/testdata/run/v8_flags_unrecognized.out rename to tests/specs/run/v8_flags_unrecognized/v8_flags_unrecognized.out diff --git a/tests/specs/run/v8_help/__test__.jsonc b/tests/specs/run/v8_help/__test__.jsonc new file mode 100644 index 0000000000..90cbeb2748 --- /dev/null +++ b/tests/specs/run/v8_help/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "repl --v8-flags=--help", + "output": "v8_help.out" +} diff --git a/tests/testdata/run/v8_help.out b/tests/specs/run/v8_help/v8_help.out similarity index 100% rename from tests/testdata/run/v8_help.out rename to tests/specs/run/v8_help/v8_help.out diff --git a/tests/specs/run/wasm/__test__.jsonc b/tests/specs/run/wasm/__test__.jsonc new file mode 100644 index 0000000000..a3c6f58b2b --- /dev/null +++ b/tests/specs/run/wasm/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet wasm.ts", + "output": "wasm.ts.out" +} diff --git a/tests/testdata/run/wasm.ts b/tests/specs/run/wasm/wasm.ts similarity index 100% rename from tests/testdata/run/wasm.ts rename to tests/specs/run/wasm/wasm.ts diff --git a/tests/specs/run/wasm/wasm.ts.out b/tests/specs/run/wasm/wasm.ts.out new file mode 100644 index 0000000000..d81cc0710e --- /dev/null +++ b/tests/specs/run/wasm/wasm.ts.out @@ -0,0 +1 @@ +42 diff --git a/tests/specs/run/wasm_async/__test__.jsonc b/tests/specs/run/wasm_async/__test__.jsonc new file mode 100644 index 0000000000..583da86e01 --- /dev/null +++ b/tests/specs/run/wasm_async/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run wasm_async.js", + "output": "wasm_async.out" +} diff --git a/tests/testdata/run/wasm_async.js b/tests/specs/run/wasm_async/wasm_async.js similarity index 100% rename from tests/testdata/run/wasm_async.js rename to tests/specs/run/wasm_async/wasm_async.js diff --git a/tests/testdata/run/wasm_async.out b/tests/specs/run/wasm_async/wasm_async.out similarity index 100% rename from tests/testdata/run/wasm_async.out rename to tests/specs/run/wasm_async/wasm_async.out diff --git a/tests/specs/run/wasm_shared/__test__.jsonc b/tests/specs/run/wasm_shared/__test__.jsonc new file mode 100644 index 0000000000..1b6ececa75 --- /dev/null +++ b/tests/specs/run/wasm_shared/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet wasm_shared.ts", + "output": "wasm_shared.out" +} diff --git a/tests/specs/run/wasm_shared/wasm_shared.out b/tests/specs/run/wasm_shared/wasm_shared.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/testdata/run/wasm_shared.ts b/tests/specs/run/wasm_shared/wasm_shared.ts similarity index 100% rename from tests/testdata/run/wasm_shared.ts rename to tests/specs/run/wasm_shared/wasm_shared.ts diff --git a/tests/specs/run/wasm_streaming_panic_test/__test__.jsonc b/tests/specs/run/wasm_streaming_panic_test/__test__.jsonc new file mode 100644 index 0000000000..e22e1f98a8 --- /dev/null +++ b/tests/specs/run/wasm_streaming_panic_test/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run wasm_streaming_panic_test.js", + "output": "wasm_streaming_panic_test.js.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/wasm_streaming_panic_test.js b/tests/specs/run/wasm_streaming_panic_test/wasm_streaming_panic_test.js similarity index 100% rename from tests/testdata/run/wasm_streaming_panic_test.js rename to tests/specs/run/wasm_streaming_panic_test/wasm_streaming_panic_test.js diff --git a/tests/testdata/run/wasm_streaming_panic_test.js.out b/tests/specs/run/wasm_streaming_panic_test/wasm_streaming_panic_test.js.out similarity index 100% rename from tests/testdata/run/wasm_streaming_panic_test.js.out rename to tests/specs/run/wasm_streaming_panic_test/wasm_streaming_panic_test.js.out diff --git a/tests/specs/run/wasm_unreachable/__test__.jsonc b/tests/specs/run/wasm_unreachable/__test__.jsonc new file mode 100644 index 0000000000..cd6165629c --- /dev/null +++ b/tests/specs/run/wasm_unreachable/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --allow-read wasm_unreachable.js", + "output": "wasm_unreachable.out", + "exitCode": 1 +} diff --git a/tests/specs/run/wasm_unreachable/unreachable.wasm b/tests/specs/run/wasm_unreachable/unreachable.wasm new file mode 100644 index 0000000000000000000000000000000000000000..a4110ee393142cdbea567a320004b81f78850559 GIT binary patch literal 42 xcmZQbEY4+QU|?WmVN76PU}j=uVCQG#F3l@SO-#;6Ov*`RVBlh9WM*LC1^|Ym25A5Q literal 0 HcmV?d00001 diff --git a/tests/testdata/run/wasm_unreachable.js b/tests/specs/run/wasm_unreachable/wasm_unreachable.js similarity index 82% rename from tests/testdata/run/wasm_unreachable.js rename to tests/specs/run/wasm_unreachable/wasm_unreachable.js index d6a4f59dbc..36aab0d84f 100644 --- a/tests/testdata/run/wasm_unreachable.js +++ b/tests/specs/run/wasm_unreachable/wasm_unreachable.js @@ -1,5 +1,5 @@ // WebAssembly module containing a single function with an unreachable instruction -const binary = await Deno.readFile("./assets/unreachable.wasm"); +const binary = await Deno.readFile("./unreachable.wasm"); const module = new WebAssembly.Module(binary); const instance = new WebAssembly.Instance(module); diff --git a/tests/testdata/run/wasm_unreachable.out b/tests/specs/run/wasm_unreachable/wasm_unreachable.out similarity index 100% rename from tests/testdata/run/wasm_unreachable.out rename to tests/specs/run/wasm_unreachable/wasm_unreachable.out diff --git a/tests/specs/run/wasm_url/__test__.jsonc b/tests/specs/run/wasm_url/__test__.jsonc new file mode 100644 index 0000000000..a776527b1f --- /dev/null +++ b/tests/specs/run/wasm_url/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --allow-net=localhost:4545 wasm_url.js", + "output": "wasm_url.out", + "exitCode": 1 +} diff --git a/tests/testdata/run/wasm_url.js b/tests/specs/run/wasm_url/wasm_url.js similarity index 100% rename from tests/testdata/run/wasm_url.js rename to tests/specs/run/wasm_url/wasm_url.js diff --git a/tests/testdata/run/wasm_url.out b/tests/specs/run/wasm_url/wasm_url.out similarity index 100% rename from tests/testdata/run/wasm_url.out rename to tests/specs/run/wasm_url/wasm_url.out diff --git a/tests/specs/run/weakref/__test__.jsonc b/tests/specs/run/weakref/__test__.jsonc new file mode 100644 index 0000000000..1a5808ec7b --- /dev/null +++ b/tests/specs/run/weakref/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload weakref.ts", + "output": "weakref.ts.out" +} diff --git a/tests/testdata/run/weakref.ts b/tests/specs/run/weakref/weakref.ts similarity index 100% rename from tests/testdata/run/weakref.ts rename to tests/specs/run/weakref/weakref.ts diff --git a/tests/testdata/run/weakref.ts.out b/tests/specs/run/weakref/weakref.ts.out similarity index 100% rename from tests/testdata/run/weakref.ts.out rename to tests/specs/run/weakref/weakref.ts.out diff --git a/tests/specs/run/webstorage_serialization/__test__.jsonc b/tests/specs/run/webstorage_serialization/__test__.jsonc new file mode 100644 index 0000000000..4362a84b26 --- /dev/null +++ b/tests/specs/run/webstorage_serialization/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run webstorage/serialization.ts", + "output": "webstorage/serialization.ts.out" +} diff --git a/tests/specs/run/webstorage_serialization/webstorage/config_a.jsonc b/tests/specs/run/webstorage_serialization/webstorage/config_a.jsonc new file mode 100644 index 0000000000..875cb60012 --- /dev/null +++ b/tests/specs/run/webstorage_serialization/webstorage/config_a.jsonc @@ -0,0 +1,3 @@ +{ + "compilerOptions": {} +} diff --git a/tests/specs/run/webstorage_serialization/webstorage/config_b.jsonc b/tests/specs/run/webstorage_serialization/webstorage/config_b.jsonc new file mode 100644 index 0000000000..875cb60012 --- /dev/null +++ b/tests/specs/run/webstorage_serialization/webstorage/config_b.jsonc @@ -0,0 +1,3 @@ +{ + "compilerOptions": {} +} diff --git a/tests/specs/run/webstorage_serialization/webstorage/fixture.ts b/tests/specs/run/webstorage_serialization/webstorage/fixture.ts new file mode 100644 index 0000000000..cf4bd9f1f1 --- /dev/null +++ b/tests/specs/run/webstorage_serialization/webstorage/fixture.ts @@ -0,0 +1,2 @@ +import "./logger.ts"; +import "./setter.ts"; diff --git a/tests/specs/run/webstorage_serialization/webstorage/logger.ts b/tests/specs/run/webstorage_serialization/webstorage/logger.ts new file mode 100644 index 0000000000..feadd39eb6 --- /dev/null +++ b/tests/specs/run/webstorage_serialization/webstorage/logger.ts @@ -0,0 +1 @@ +console.log(globalThis.localStorage); diff --git a/tests/testdata/run/webstorage/serialization.ts b/tests/specs/run/webstorage_serialization/webstorage/serialization.ts similarity index 100% rename from tests/testdata/run/webstorage/serialization.ts rename to tests/specs/run/webstorage_serialization/webstorage/serialization.ts diff --git a/tests/testdata/run/webstorage/serialization.ts.out b/tests/specs/run/webstorage_serialization/webstorage/serialization.ts.out similarity index 100% rename from tests/testdata/run/webstorage/serialization.ts.out rename to tests/specs/run/webstorage_serialization/webstorage/serialization.ts.out diff --git a/tests/specs/run/webstorage_serialization/webstorage/setter.ts b/tests/specs/run/webstorage_serialization/webstorage/setter.ts new file mode 100644 index 0000000000..cf5a7bfaf6 --- /dev/null +++ b/tests/specs/run/webstorage_serialization/webstorage/setter.ts @@ -0,0 +1 @@ +globalThis.localStorage.setItem("hello", "deno"); diff --git a/tests/specs/run/worker_close_in_wasm_reactions/__test__.jsonc b/tests/specs/run/worker_close_in_wasm_reactions/__test__.jsonc new file mode 100644 index 0000000000..104b547564 --- /dev/null +++ b/tests/specs/run/worker_close_in_wasm_reactions/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-read worker_close_in_wasm_reactions.js", + "output": "worker_close_in_wasm_reactions.js.out" +} diff --git a/tests/specs/run/worker_close_in_wasm_reactions/close_in_wasm_reactions.js b/tests/specs/run/worker_close_in_wasm_reactions/close_in_wasm_reactions.js new file mode 100644 index 0000000000..abe5731085 --- /dev/null +++ b/tests/specs/run/worker_close_in_wasm_reactions/close_in_wasm_reactions.js @@ -0,0 +1,21 @@ +// https://github.com/denoland/deno/issues/12263 +// Test for a panic that happens when a worker is closed in the reactions of a +// WASM async operation. + +// The minimum valid wasm module, plus two additional zero bytes. +const buffer = new Uint8Array([ + 0x00, + 0x61, + 0x73, + 0x6D, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, +]); +WebAssembly.compile(buffer).catch((err) => { + console.log("Error:", err); + self.close(); +}); diff --git a/tests/testdata/run/worker_close_in_wasm_reactions.js b/tests/specs/run/worker_close_in_wasm_reactions/worker_close_in_wasm_reactions.js similarity index 80% rename from tests/testdata/run/worker_close_in_wasm_reactions.js rename to tests/specs/run/worker_close_in_wasm_reactions/worker_close_in_wasm_reactions.js index 95f34e944d..828320a240 100644 --- a/tests/testdata/run/worker_close_in_wasm_reactions.js +++ b/tests/specs/run/worker_close_in_wasm_reactions/worker_close_in_wasm_reactions.js @@ -5,6 +5,6 @@ // WASM async operation. new Worker( - import.meta.resolve("../workers/close_in_wasm_reactions.js"), + import.meta.resolve("./close_in_wasm_reactions.js"), { type: "module" }, ); diff --git a/tests/testdata/run/worker_close_in_wasm_reactions.js.out b/tests/specs/run/worker_close_in_wasm_reactions/worker_close_in_wasm_reactions.js.out similarity index 100% rename from tests/testdata/run/worker_close_in_wasm_reactions.js.out rename to tests/specs/run/worker_close_in_wasm_reactions/worker_close_in_wasm_reactions.js.out diff --git a/tests/specs/run/worker_close_nested/__test__.jsonc b/tests/specs/run/worker_close_nested/__test__.jsonc new file mode 100644 index 0000000000..5cce107c7a --- /dev/null +++ b/tests/specs/run/worker_close_nested/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-read worker_close_nested.js", + "output": "worker_close_nested.js.out" +} diff --git a/tests/specs/run/worker_close_nested/close_nested_child.js b/tests/specs/run/worker_close_nested/close_nested_child.js new file mode 100644 index 0000000000..97980c689e --- /dev/null +++ b/tests/specs/run/worker_close_nested/close_nested_child.js @@ -0,0 +1,8 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. + +console.log("Starting the child worker"); + +setTimeout(() => { + console.log("The child worker survived the death of the parent!!!"); + Deno.exit(1); +}, 2000); diff --git a/tests/specs/run/worker_close_nested/close_nested_parent.js b/tests/specs/run/worker_close_nested/close_nested_parent.js new file mode 100644 index 0000000000..d1fe47553e --- /dev/null +++ b/tests/specs/run/worker_close_nested/close_nested_parent.js @@ -0,0 +1,13 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. + +console.log("Starting the parent worker"); + +new Worker( + import.meta.resolve("./close_nested_child.js"), + { type: "module" }, +); + +self.addEventListener("message", () => { + console.log("Closing"); + self.close(); +}); diff --git a/tests/testdata/run/worker_close_nested.js b/tests/specs/run/worker_close_nested/worker_close_nested.js similarity index 89% rename from tests/testdata/run/worker_close_nested.js rename to tests/specs/run/worker_close_nested/worker_close_nested.js index 37b6ed9c9a..8d9c88d1cf 100644 --- a/tests/testdata/run/worker_close_nested.js +++ b/tests/specs/run/worker_close_nested/worker_close_nested.js @@ -6,7 +6,7 @@ console.log("Starting the main thread"); const worker = new Worker( - import.meta.resolve("../workers/close_nested_parent.js"), + import.meta.resolve("./close_nested_parent.js"), { type: "module" }, ); diff --git a/tests/testdata/run/worker_close_nested.js.out b/tests/specs/run/worker_close_nested/worker_close_nested.js.out similarity index 100% rename from tests/testdata/run/worker_close_nested.js.out rename to tests/specs/run/worker_close_nested/worker_close_nested.js.out diff --git a/tests/specs/run/worker_close_race/__test__.jsonc b/tests/specs/run/worker_close_race/__test__.jsonc new file mode 100644 index 0000000000..bdb9665f7e --- /dev/null +++ b/tests/specs/run/worker_close_race/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-read worker_close_race.js", + "output": "worker_close_race.js.out" +} diff --git a/tests/specs/run/worker_close_race/close_race_worker.js b/tests/specs/run/worker_close_race/close_race_worker.js new file mode 100644 index 0000000000..6964be34a0 --- /dev/null +++ b/tests/specs/run/worker_close_race/close_race_worker.js @@ -0,0 +1,6 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. + +setTimeout(() => { + self.postMessage(""); + self.close(); +}, 500); diff --git a/tests/testdata/run/worker_close_race.js b/tests/specs/run/worker_close_race/worker_close_race.js similarity index 85% rename from tests/testdata/run/worker_close_race.js rename to tests/specs/run/worker_close_race/worker_close_race.js index 1da8324259..188cd9ed88 100644 --- a/tests/testdata/run/worker_close_race.js +++ b/tests/specs/run/worker_close_race/worker_close_race.js @@ -5,7 +5,7 @@ // `Worker.prototype.terminate()`. const worker = new Worker( - import.meta.resolve("../workers/close_race_worker.js"), + import.meta.resolve("./close_race_worker.js"), { type: "module" }, ); diff --git a/tests/specs/run/worker_close_race/worker_close_race.js.out b/tests/specs/run/worker_close_race/worker_close_race.js.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/specs/run/worker_drop_handle_race/__test__.jsonc b/tests/specs/run/worker_drop_handle_race/__test__.jsonc new file mode 100644 index 0000000000..cc600d5ef4 --- /dev/null +++ b/tests/specs/run/worker_drop_handle_race/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --quiet --reload --allow-read worker_drop_handle_race.js", + "output": "worker_drop_handle_race.js.out", + "exitCode": 1 +} diff --git a/tests/specs/run/worker_drop_handle_race/drop_handle_race.js b/tests/specs/run/worker_drop_handle_race/drop_handle_race.js new file mode 100644 index 0000000000..30676a600a --- /dev/null +++ b/tests/specs/run/worker_drop_handle_race/drop_handle_race.js @@ -0,0 +1,3 @@ +setTimeout(() => { + throw new Error(); +}, 1000); diff --git a/tests/testdata/run/worker_drop_handle_race.js b/tests/specs/run/worker_drop_handle_race/worker_drop_handle_race.js similarity index 88% rename from tests/testdata/run/worker_drop_handle_race.js rename to tests/specs/run/worker_drop_handle_race/worker_drop_handle_race.js index 731a369648..ef9bcbe072 100644 --- a/tests/testdata/run/worker_drop_handle_race.js +++ b/tests/specs/run/worker_drop_handle_race/worker_drop_handle_race.js @@ -7,6 +7,6 @@ // The exception thrown in the worker will not terminate the worker, but it will // propagate to the main thread and cause it to exit. new Worker( - import.meta.resolve("../workers/drop_handle_race.js"), + import.meta.resolve("./drop_handle_race.js"), { type: "module" }, ); diff --git a/tests/testdata/run/worker_drop_handle_race.js.out b/tests/specs/run/worker_drop_handle_race/worker_drop_handle_race.js.out similarity index 79% rename from tests/testdata/run/worker_drop_handle_race.js.out rename to tests/specs/run/worker_drop_handle_race/worker_drop_handle_race.js.out index 0820f164e5..a1c2e30ad4 100644 --- a/tests/testdata/run/worker_drop_handle_race.js.out +++ b/tests/specs/run/worker_drop_handle_race/worker_drop_handle_race.js.out @@ -1,7 +1,7 @@ error: Uncaught (in worker "") Error throw new Error(); ^ - at [WILDCARD]/workers/drop_handle_race.js:2:9 + at [WILDCARD]/drop_handle_race.js:2:9 at [WILDCARD] error: Uncaught (in promise) Error: Unhandled error in child worker. at Worker.#pollControl [WILDCARD] diff --git a/tests/specs/run/worker_drop_handle_race_terminate/__test__.jsonc b/tests/specs/run/worker_drop_handle_race_terminate/__test__.jsonc new file mode 100644 index 0000000000..e752074ebf --- /dev/null +++ b/tests/specs/run/worker_drop_handle_race_terminate/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run worker_drop_handle_race_terminate.js", + "output": "worker_drop_handle_race_terminate.js.out" +} diff --git a/tests/testdata/run/worker_drop_handle_race_terminate.js b/tests/specs/run/worker_drop_handle_race_terminate/worker_drop_handle_race_terminate.js similarity index 100% rename from tests/testdata/run/worker_drop_handle_race_terminate.js rename to tests/specs/run/worker_drop_handle_race_terminate/worker_drop_handle_race_terminate.js diff --git a/tests/testdata/run/worker_drop_handle_race_terminate.js.out b/tests/specs/run/worker_drop_handle_race_terminate/worker_drop_handle_race_terminate.js.out similarity index 100% rename from tests/testdata/run/worker_drop_handle_race_terminate.js.out rename to tests/specs/run/worker_drop_handle_race_terminate/worker_drop_handle_race_terminate.js.out diff --git a/tests/specs/run/worker_event_handler_test/__test__.jsonc b/tests/specs/run/worker_event_handler_test/__test__.jsonc new file mode 100644 index 0000000000..c07fca97c6 --- /dev/null +++ b/tests/specs/run/worker_event_handler_test/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-read worker_event_handler_test.js", + "output": "worker_event_handler_test.js.out" +} diff --git a/tests/testdata/run/worker_event_handler_test.js b/tests/specs/run/worker_event_handler_test/worker_event_handler_test.js similarity index 51% rename from tests/testdata/run/worker_event_handler_test.js rename to tests/specs/run/worker_event_handler_test/worker_event_handler_test.js index a91b0ec0b1..91c5ba9469 100644 --- a/tests/testdata/run/worker_event_handler_test.js +++ b/tests/specs/run/worker_event_handler_test/worker_event_handler_test.js @@ -1,5 +1,5 @@ const w = new Worker( - import.meta.resolve("../workers/worker_event_handlers.js"), + import.meta.resolve("./worker_event_handlers.js"), { type: "module" }, ); w.postMessage({}); diff --git a/tests/testdata/run/worker_event_handler_test.js.out b/tests/specs/run/worker_event_handler_test/worker_event_handler_test.js.out similarity index 100% rename from tests/testdata/run/worker_event_handler_test.js.out rename to tests/specs/run/worker_event_handler_test/worker_event_handler_test.js.out diff --git a/tests/specs/run/worker_event_handler_test/worker_event_handlers.js b/tests/specs/run/worker_event_handler_test/worker_event_handlers.js new file mode 100644 index 0000000000..5e457cd2e3 --- /dev/null +++ b/tests/specs/run/worker_event_handler_test/worker_event_handlers.js @@ -0,0 +1,26 @@ +self.onmessage = (evt) => { + console.log("Target from self.onmessage:", String(evt.target)); +}; + +self.addEventListener("message", (evt) => { + console.log("Target from message event listener:", String(evt.target)); + + // Throw an error here so the global's error event will fire. + throw new Error("Some error message"); +}); + +self.onerror = (...args) => { + // Take the last 100 characters so the filename doesn't get truncated + // depending on the dev's FS structure. + args = args.map((v) => typeof v == "string" ? v.slice(-100) : v); + console.log("Arguments from self.onerror:", args); + return true; +}; + +self.addEventListener("error", (evt) => { + // Returning true from self.onerror means that subsequent event listeners + // should see the event as canceled. + console.log("Is event canceled?:", evt.defaultPrevented); + + self.close(); +}); diff --git a/tests/specs/run/worker_message_before_close/__test__.jsonc b/tests/specs/run/worker_message_before_close/__test__.jsonc new file mode 100644 index 0000000000..ae2d65b919 --- /dev/null +++ b/tests/specs/run/worker_message_before_close/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "run --quiet --reload --allow-read worker_message_before_close.js", + "output": "worker_message_before_close.js.out" +} diff --git a/tests/specs/run/worker_message_before_close/message_before_close.js b/tests/specs/run/worker_message_before_close/message_before_close.js new file mode 100644 index 0000000000..9364b6d824 --- /dev/null +++ b/tests/specs/run/worker_message_before_close/message_before_close.js @@ -0,0 +1,4 @@ +onmessage = () => { + postMessage({}); + close(); +}; diff --git a/tests/testdata/run/worker_message_before_close.js b/tests/specs/run/worker_message_before_close/worker_message_before_close.js similarity index 89% rename from tests/testdata/run/worker_message_before_close.js rename to tests/specs/run/worker_message_before_close/worker_message_before_close.js index 569388b9bb..d613bd1cac 100644 --- a/tests/testdata/run/worker_message_before_close.js +++ b/tests/specs/run/worker_message_before_close/worker_message_before_close.js @@ -2,7 +2,7 @@ const messagesReceived = new Set(); for (let i = 0; i < 4; i++) { const worker = new Worker( - import.meta.resolve("../workers/message_before_close.js"), + import.meta.resolve("./message_before_close.js"), { type: "module", name: String(i) }, ); diff --git a/tests/testdata/run/worker_message_before_close.js.out b/tests/specs/run/worker_message_before_close/worker_message_before_close.js.out similarity index 100% rename from tests/testdata/run/worker_message_before_close.js.out rename to tests/specs/run/worker_message_before_close/worker_message_before_close.js.out diff --git a/tests/testdata/run/014_duplicate_import.ts b/tests/testdata/run/014_duplicate_import.ts deleted file mode 100644 index c7dd881cf0..0000000000 --- a/tests/testdata/run/014_duplicate_import.ts +++ /dev/null @@ -1,9 +0,0 @@ -// with all the imports of the same module, the module should only be -// instantiated once -import "../subdir/auto_print_hello.ts"; - -import "../subdir/auto_print_hello.ts"; - -(async () => { - await import("../subdir/auto_print_hello.ts"); -})(); diff --git a/tests/testdata/run/020_json_modules.ts b/tests/testdata/run/020_json_modules.ts deleted file mode 100644 index b4ae606654..0000000000 --- a/tests/testdata/run/020_json_modules.ts +++ /dev/null @@ -1,2 +0,0 @@ -import config from "../subdir/config.json"; -console.log(JSON.stringify(config)); diff --git a/tests/testdata/run/021_mjs_modules.ts b/tests/testdata/run/021_mjs_modules.ts deleted file mode 100644 index 838cd2c382..0000000000 --- a/tests/testdata/run/021_mjs_modules.ts +++ /dev/null @@ -1,2 +0,0 @@ -import { isMod5 } from "../subdir/mod5.mjs"; -console.log(isMod5); diff --git a/tests/testdata/run/035_cached_only_flag.out b/tests/testdata/run/035_cached_only_flag.out deleted file mode 100644 index f677ec9153..0000000000 --- a/tests/testdata/run/035_cached_only_flag.out +++ /dev/null @@ -1 +0,0 @@ -error: Specifier not found in cache: "http://127.0.0.1:4545/run/019_media_types.ts", --cached-only is specified. diff --git a/tests/testdata/run/044_bad_resource.ts b/tests/testdata/run/044_bad_resource.ts deleted file mode 100644 index b956a3e3f2..0000000000 --- a/tests/testdata/run/044_bad_resource.ts +++ /dev/null @@ -1,3 +0,0 @@ -const file = await Deno.open("./run/044_bad_resource.ts", { read: true }); -file.close(); -await file.seek(10, 0); diff --git a/tests/testdata/run/config_json_import.ts b/tests/testdata/run/config_json_import.ts deleted file mode 100644 index 7141f14950..0000000000 --- a/tests/testdata/run/config_json_import.ts +++ /dev/null @@ -1,2 +0,0 @@ -import config from "../jsx/deno-jsx.json" with { type: "json" }; -console.log(config); diff --git a/tests/testdata/run/error_002.ts b/tests/testdata/run/error_002.ts deleted file mode 100644 index 5f8179bbeb..0000000000 --- a/tests/testdata/run/error_002.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { throwsError } from "../subdir/mod1.ts"; - -function foo() { - throwsError(); -} - -foo(); diff --git a/tests/testdata/run/error_015_dynamic_import_permissions.js b/tests/testdata/run/error_015_dynamic_import_permissions.js deleted file mode 100644 index bdf423b59c..0000000000 --- a/tests/testdata/run/error_015_dynamic_import_permissions.js +++ /dev/null @@ -1,3 +0,0 @@ -(async () => { - await import("" + "http://example.com/subdir/mod4.js"); -})(); diff --git a/tests/testdata/run/error_no_check.ts b/tests/testdata/run/error_no_check.ts deleted file mode 100644 index 2da01e639a..0000000000 --- a/tests/testdata/run/error_no_check.ts +++ /dev/null @@ -1 +0,0 @@ -export { AnInterface, isAnInterface } from "../subdir/type_and_code.ts"; diff --git a/tests/testdata/run/error_no_check.ts.out b/tests/testdata/run/error_no_check.ts.out deleted file mode 100644 index 78f478045d..0000000000 --- a/tests/testdata/run/error_no_check.ts.out +++ /dev/null @@ -1,2 +0,0 @@ -error: Uncaught SyntaxError: The requested module '../subdir/type_and_code.ts' does not provide an export named 'AnInterface' -[WILDCARD] \ No newline at end of file diff --git a/tests/testdata/run/error_type_definitions.ts b/tests/testdata/run/error_type_definitions.ts deleted file mode 100644 index 86675cbaae..0000000000 --- a/tests/testdata/run/error_type_definitions.ts +++ /dev/null @@ -1,5 +0,0 @@ -// @deno-types="../type_definitions/bar.d.ts" -import { Bar } from "../type_definitions/bar.js"; - -const bar = new Bar(); -console.log(bar); diff --git a/tests/testdata/run/fix_emittable_skipped.js b/tests/testdata/run/fix_emittable_skipped.js deleted file mode 100644 index a4ccc9efda..0000000000 --- a/tests/testdata/run/fix_emittable_skipped.js +++ /dev/null @@ -1,7 +0,0 @@ -/// - -import "../subdir/polyfill.ts"; - -export const a = "a"; - -console.log(globalThis.polyfill); diff --git a/tests/testdata/run/fix_js_import_js.ts b/tests/testdata/run/fix_js_import_js.ts deleted file mode 100644 index 0f01877cd8..0000000000 --- a/tests/testdata/run/fix_js_import_js.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { isMod4 } from "../subdir/mod6.js"; - -console.log(isMod4); diff --git a/tests/testdata/run/fix_js_imports.ts b/tests/testdata/run/fix_js_imports.ts deleted file mode 100644 index 6ed13bae30..0000000000 --- a/tests/testdata/run/fix_js_imports.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as amdLike from "../subdir/amd_like.js"; - -console.log(amdLike); diff --git a/tests/testdata/run/import_type.ts b/tests/testdata/run/import_type.ts deleted file mode 100644 index 22c639cbcf..0000000000 --- a/tests/testdata/run/import_type.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { type B, create } from "../subdir/export_types.ts"; - -const b: B = create(); - -console.log(b); diff --git a/tests/testdata/run/issue13562.ts b/tests/testdata/run/issue13562.ts deleted file mode 100644 index afbf69f99e..0000000000 --- a/tests/testdata/run/issue13562.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { printHello3 } from "../subdir/mod1.ts?q=.json"; - -printHello3(); diff --git a/tests/testdata/run/lock_check_ok.json b/tests/testdata/run/lock_check_ok.json deleted file mode 100644 index 94de0f6307..0000000000 --- a/tests/testdata/run/lock_check_ok.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "http://127.0.0.1:4545/subdir/print_hello.ts": "fa6692c8f9ff3fb107e773c3ece5274e9d08be282867a1e3ded1d9c00fcaa63c", - "http://127.0.0.1:4545/run/003_relative_import.ts": "a1572e8fd2c2712b33f04aed2561505b5feb2c8696f1f2cded3de7127931b97e" -} diff --git a/tests/testdata/run/lock_v2_check_ok.json b/tests/testdata/run/lock_v2_check_ok.json deleted file mode 100644 index 63bec862a7..0000000000 --- a/tests/testdata/run/lock_v2_check_ok.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": "2", - "remote": { - "http://127.0.0.1:4545/subdir/print_hello.ts": "fa6692c8f9ff3fb107e773c3ece5274e9d08be282867a1e3ded1d9c00fcaa63c", - "http://127.0.0.1:4545/run/003_relative_import.ts": "a1572e8fd2c2712b33f04aed2561505b5feb2c8696f1f2cded3de7127931b97e" - } -} diff --git a/tests/testdata/run/type_directives_02.ts b/tests/testdata/run/type_directives_02.ts deleted file mode 100644 index 0c59346e2b..0000000000 --- a/tests/testdata/run/type_directives_02.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as foo from "../subdir/type_reference.js"; - -console.log(foo.foo); diff --git a/tests/testdata/run/type_directives_02.ts.out b/tests/testdata/run/type_directives_02.ts.out deleted file mode 100644 index b064483b41..0000000000 --- a/tests/testdata/run/type_directives_02.ts.out +++ /dev/null @@ -1,3 +0,0 @@ -[WILDCARD] -DEBUG TS - host.getSourceFile("file:///[WILDCARD]/subdir/type_reference.d.ts", Latest) -[WILDCARD] \ No newline at end of file diff --git a/tests/testdata/run/unhandled_rejection.ts.out b/tests/testdata/run/unhandled_rejection.ts.out deleted file mode 100644 index 6ab1667dc1..0000000000 --- a/tests/testdata/run/unhandled_rejection.ts.out +++ /dev/null @@ -1,9 +0,0 @@ -[WILDCARD] -unhandled rejection at: Promise { - Error: bar not available - at new Foo (file:///[WILDCARD]/testdata/run/unhandled_rejection.ts:8:20) - at file:///[WILDCARD]/testdata/run/unhandled_rejection.ts:12:1 -} reason: Error: bar not available - at new Foo (file:///[WILDCARD]/testdata/run/unhandled_rejection.ts:8:20) - at file:///[WILDCARD]/testdata/run/unhandled_rejection.ts:12:1 -unhandled rejection at: Promise { undefined } reason: undefined diff --git a/tests/testdata/run/unhandled_rejection_sync_error.ts.out b/tests/testdata/run/unhandled_rejection_sync_error.ts.out deleted file mode 100644 index e178373f03..0000000000 --- a/tests/testdata/run/unhandled_rejection_sync_error.ts.out +++ /dev/null @@ -1,6 +0,0 @@ -[WILDCARD] -unhandled rejection at: Promise { - Error: boom! - at file:///[WILDCARD]testdata/run/unhandled_rejection_sync_error.ts:6:7 -} reason: Error: boom! - at file:///[WILDCARD]testdata/run/unhandled_rejection_sync_error.ts:6:7 diff --git a/tests/testdata/run/with_package_json/with_stop/main.out b/tests/testdata/run/with_package_json/with_stop/main.out deleted file mode 100644 index 44098a2d86..0000000000 --- a/tests/testdata/run/with_package_json/with_stop/main.out +++ /dev/null @@ -1,5 +0,0 @@ -[WILDCARD]Config file found at '[WILDCARD]with_package_json[WILDCARD]with_stop[WILDCARD]some[WILDCARD]nested[WILDCARD]deno.json' -[WILDCARD] -error: Relative import path "chalk" not prefixed with / or ./ or ../ - hint: If you want to use a JSR or npm package, try running `deno add jsr:chalk` or `deno add npm:chalk` - at file:///[WILDCARD]with_package_json/with_stop/some/nested/dir/main.ts:3:19 diff --git a/tools/lint.js b/tools/lint.js index b591cae0ba..cc595c2b13 100755 --- a/tools/lint.js +++ b/tools/lint.js @@ -219,7 +219,7 @@ async function ensureNoNewITests() { "pm_tests.rs": 0, "publish_tests.rs": 0, "repl_tests.rs": 0, - "run_tests.rs": 331, + "run_tests.rs": 24, "shared_library_tests.rs": 0, "task_tests.rs": 2, "test_tests.rs": 0, From 4861108592e4543c6245f8b477f083ec1b34f627 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Tue, 5 Nov 2024 13:10:23 +0530 Subject: [PATCH 34/40] fix: panic_hook hangs without procfs (#26732) Fixes https://github.com/denoland/deno/issues/26701 Ref https://github.com/denoland/sui/commit/69e491353fb82ce15a861376ee8dc68f183e0486 --- Cargo.lock | 4 ++-- cli/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 73d417baae..29fe91641d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4195,9 +4195,9 @@ dependencies = [ [[package]] name = "libsui" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "205eca4e7beaad637dcd38fe41292065894ee7f498077cf3c135d5f7252b9f27" +checksum = "89795977654ad6250d6c0915411b622bac22f9efb4f852af94b2e00964cab832" dependencies = [ "editpe", "libc", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 1fa9692a4d..a91482c3e1 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -84,7 +84,7 @@ deno_runtime = { workspace = true, features = ["include_js_files_for_snapshottin deno_semver.workspace = true deno_task_shell = "=0.18.1" deno_terminal.workspace = true -libsui = "0.4.0" +libsui = "0.5.0" node_resolver.workspace = true anstream = "0.6.14" From 770ef1460085e1a1b706cc7f066e7b3ea5010eb0 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Tue, 5 Nov 2024 13:10:45 +0530 Subject: [PATCH 35/40] chore: upgrade publish workflow to ubuntu 24 (#26731) --- .github/workflows/cargo_publish.yml | 2 +- .github/workflows/post_publish.yml | 2 +- .github/workflows/start_release.yml | 2 +- .github/workflows/version_bump.yml | 2 +- .github/workflows/wpt_epoch.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cargo_publish.yml b/.github/workflows/cargo_publish.yml index f285b78919..3af97f4662 100644 --- a/.github/workflows/cargo_publish.yml +++ b/.github/workflows/cargo_publish.yml @@ -10,7 +10,7 @@ concurrency: jobs: build: name: cargo publish - runs-on: ubuntu-20.04-xl + runs-on: ubuntu-24.04-xl timeout-minutes: 90 env: diff --git a/.github/workflows/post_publish.yml b/.github/workflows/post_publish.yml index c0db0906df..dd80b3637a 100644 --- a/.github/workflows/post_publish.yml +++ b/.github/workflows/post_publish.yml @@ -7,7 +7,7 @@ on: jobs: update-dl-version: name: update dl.deno.land version - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 if: github.repository == 'denoland/deno' steps: - name: Authenticate with Google Cloud diff --git a/.github/workflows/start_release.yml b/.github/workflows/start_release.yml index 7c2f149e11..40a44bb61a 100644 --- a/.github/workflows/start_release.yml +++ b/.github/workflows/start_release.yml @@ -16,7 +16,7 @@ on: jobs: build: name: start release - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 timeout-minutes: 30 env: diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml index fd082bca3e..9038fe0d22 100644 --- a/.github/workflows/version_bump.yml +++ b/.github/workflows/version_bump.yml @@ -16,7 +16,7 @@ on: jobs: build: name: version bump - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 timeout-minutes: 90 env: diff --git a/.github/workflows/wpt_epoch.yml b/.github/workflows/wpt_epoch.yml index d679498b83..1d86ed5557 100644 --- a/.github/workflows/wpt_epoch.yml +++ b/.github/workflows/wpt_epoch.yml @@ -20,7 +20,7 @@ jobs: fail-fast: false matrix: deno-version: [v1.x, canary] - os: [ubuntu-22.04-xl] + os: [ubuntu-24.04-xl] steps: - name: Clone repository From ef7432c03f83ad9e9ca2812d0ab5653e87fa5259 Mon Sep 17 00:00:00 2001 From: denobot <33910674+denobot@users.noreply.github.com> Date: Tue, 5 Nov 2024 20:27:14 -0500 Subject: [PATCH 36/40] chore: forward v2.0.5 release commit to main (#26755) This is the release commit being forwarded back to main for 2.0.5 Co-authored-by: bartlomieju --- .github/workflows/ci.generate.ts | 2 +- .github/workflows/ci.yml | 8 ++--- Cargo.lock | 58 ++++++++++++++++---------------- Cargo.toml | 56 +++++++++++++++--------------- Releases.md | 36 ++++++++++++++++++++ bench_util/Cargo.toml | 2 +- cli/Cargo.toml | 2 +- ext/broadcast_channel/Cargo.toml | 2 +- ext/cache/Cargo.toml | 2 +- ext/canvas/Cargo.toml | 2 +- ext/console/Cargo.toml | 2 +- ext/cron/Cargo.toml | 2 +- ext/crypto/Cargo.toml | 2 +- ext/fetch/Cargo.toml | 2 +- ext/ffi/Cargo.toml | 2 +- ext/fs/Cargo.toml | 2 +- ext/http/Cargo.toml | 2 +- ext/io/Cargo.toml | 2 +- ext/kv/Cargo.toml | 2 +- ext/napi/Cargo.toml | 2 +- ext/napi/sym/Cargo.toml | 2 +- ext/net/Cargo.toml | 2 +- ext/node/Cargo.toml | 2 +- ext/tls/Cargo.toml | 2 +- ext/url/Cargo.toml | 2 +- ext/web/Cargo.toml | 2 +- ext/webgpu/Cargo.toml | 2 +- ext/webidl/Cargo.toml | 2 +- ext/websocket/Cargo.toml | 2 +- ext/webstorage/Cargo.toml | 2 +- resolvers/deno/Cargo.toml | 2 +- resolvers/node/Cargo.toml | 2 +- runtime/Cargo.toml | 2 +- runtime/permissions/Cargo.toml | 2 +- 34 files changed, 127 insertions(+), 91 deletions(-) diff --git a/.github/workflows/ci.generate.ts b/.github/workflows/ci.generate.ts index 0faf08a1a8..430387d5ba 100755 --- a/.github/workflows/ci.generate.ts +++ b/.github/workflows/ci.generate.ts @@ -5,7 +5,7 @@ import { stringify } from "jsr:@std/yaml@^0.221/stringify"; // Bump this number when you want to purge the cache. // Note: the tools/release/01_bump_crate_versions.ts script will update this version // automatically via regex, so ensure that this line maintains this format. -const cacheVersion = 23; +const cacheVersion = 24; const ubuntuX86Runner = "ubuntu-24.04"; const ubuntuX86XlRunner = "ubuntu-24.04-xl"; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5aafe89d27..7b621e1235 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -361,8 +361,8 @@ jobs: path: |- ~/.cargo/registry/index ~/.cargo/registry/cache - key: '23-cargo-home-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles(''Cargo.lock'') }}' - restore-keys: '23-cargo-home-${{ matrix.os }}-${{ matrix.arch }}' + key: '24-cargo-home-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles(''Cargo.lock'') }}' + restore-keys: '24-cargo-home-${{ matrix.os }}-${{ matrix.arch }}' if: '!(matrix.skip)' - name: Restore cache build output (PR) uses: actions/cache/restore@v4 @@ -375,7 +375,7 @@ jobs: !./target/*/*.zip !./target/*/*.tar.gz key: never_saved - restore-keys: '23-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-' + restore-keys: '24-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-' - name: Apply and update mtime cache if: '!(matrix.skip) && (!startsWith(github.ref, ''refs/tags/''))' uses: ./.github/mtime_cache @@ -685,7 +685,7 @@ jobs: !./target/*/*.zip !./target/*/*.sha256sum !./target/*/*.tar.gz - key: '23-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-${{ github.sha }}' + key: '24-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-${{ github.sha }}' publish-canary: name: publish canary runs-on: ubuntu-24.04 diff --git a/Cargo.lock b/Cargo.lock index 29fe91641d..2ae13eab0c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1154,7 +1154,7 @@ dependencies = [ [[package]] name = "deno" -version = "2.0.4" +version = "2.0.5" dependencies = [ "anstream", "async-trait", @@ -1323,7 +1323,7 @@ dependencies = [ [[package]] name = "deno_bench_util" -version = "0.169.0" +version = "0.170.0" dependencies = [ "bencher", "deno_core", @@ -1332,7 +1332,7 @@ dependencies = [ [[package]] name = "deno_broadcast_channel" -version = "0.169.0" +version = "0.170.0" dependencies = [ "async-trait", "deno_core", @@ -1343,7 +1343,7 @@ dependencies = [ [[package]] name = "deno_cache" -version = "0.107.0" +version = "0.108.0" dependencies = [ "async-trait", "deno_core", @@ -1376,7 +1376,7 @@ dependencies = [ [[package]] name = "deno_canvas" -version = "0.44.0" +version = "0.45.0" dependencies = [ "deno_core", "deno_webgpu", @@ -1411,7 +1411,7 @@ dependencies = [ [[package]] name = "deno_console" -version = "0.175.0" +version = "0.176.0" dependencies = [ "deno_core", ] @@ -1456,7 +1456,7 @@ checksum = "a13951ea98c0a4c372f162d669193b4c9d991512de9f2381dd161027f34b26b1" [[package]] name = "deno_cron" -version = "0.55.0" +version = "0.56.0" dependencies = [ "anyhow", "async-trait", @@ -1469,7 +1469,7 @@ dependencies = [ [[package]] name = "deno_crypto" -version = "0.189.0" +version = "0.190.0" dependencies = [ "aes", "aes-gcm", @@ -1531,7 +1531,7 @@ dependencies = [ [[package]] name = "deno_fetch" -version = "0.199.0" +version = "0.200.0" dependencies = [ "base64 0.21.7", "bytes", @@ -1564,7 +1564,7 @@ dependencies = [ [[package]] name = "deno_ffi" -version = "0.162.0" +version = "0.163.0" dependencies = [ "deno_core", "deno_permissions", @@ -1584,7 +1584,7 @@ dependencies = [ [[package]] name = "deno_fs" -version = "0.85.0" +version = "0.86.0" dependencies = [ "async-trait", "base32", @@ -1635,7 +1635,7 @@ dependencies = [ [[package]] name = "deno_http" -version = "0.173.0" +version = "0.174.0" dependencies = [ "async-compression", "async-trait", @@ -1674,7 +1674,7 @@ dependencies = [ [[package]] name = "deno_io" -version = "0.85.0" +version = "0.86.0" dependencies = [ "async-trait", "deno_core", @@ -1695,7 +1695,7 @@ dependencies = [ [[package]] name = "deno_kv" -version = "0.83.0" +version = "0.84.0" dependencies = [ "anyhow", "async-trait", @@ -1767,7 +1767,7 @@ dependencies = [ [[package]] name = "deno_napi" -version = "0.106.0" +version = "0.107.0" dependencies = [ "deno_core", "deno_permissions", @@ -1795,7 +1795,7 @@ dependencies = [ [[package]] name = "deno_net" -version = "0.167.0" +version = "0.168.0" dependencies = [ "deno_core", "deno_permissions", @@ -1812,7 +1812,7 @@ dependencies = [ [[package]] name = "deno_node" -version = "0.112.0" +version = "0.113.0" dependencies = [ "aead-gcm-stream", "aes", @@ -1961,7 +1961,7 @@ dependencies = [ [[package]] name = "deno_permissions" -version = "0.35.0" +version = "0.36.0" dependencies = [ "deno_core", "deno_path_util", @@ -1979,7 +1979,7 @@ dependencies = [ [[package]] name = "deno_resolver" -version = "0.7.0" +version = "0.8.0" dependencies = [ "anyhow", "base32", @@ -1995,7 +1995,7 @@ dependencies = [ [[package]] name = "deno_runtime" -version = "0.184.0" +version = "0.185.0" dependencies = [ "color-print", "deno_ast", @@ -2113,7 +2113,7 @@ dependencies = [ [[package]] name = "deno_tls" -version = "0.162.0" +version = "0.163.0" dependencies = [ "deno_core", "deno_native_certs", @@ -2162,7 +2162,7 @@ dependencies = [ [[package]] name = "deno_url" -version = "0.175.0" +version = "0.176.0" dependencies = [ "deno_bench_util", "deno_console", @@ -2174,7 +2174,7 @@ dependencies = [ [[package]] name = "deno_web" -version = "0.206.0" +version = "0.207.0" dependencies = [ "async-trait", "base64-simd 0.8.0", @@ -2196,7 +2196,7 @@ dependencies = [ [[package]] name = "deno_webgpu" -version = "0.142.0" +version = "0.143.0" dependencies = [ "deno_core", "raw-window-handle", @@ -2209,7 +2209,7 @@ dependencies = [ [[package]] name = "deno_webidl" -version = "0.175.0" +version = "0.176.0" dependencies = [ "deno_bench_util", "deno_core", @@ -2217,7 +2217,7 @@ dependencies = [ [[package]] name = "deno_websocket" -version = "0.180.0" +version = "0.181.0" dependencies = [ "bytes", "deno_core", @@ -2239,7 +2239,7 @@ dependencies = [ [[package]] name = "deno_webstorage" -version = "0.170.0" +version = "0.171.0" dependencies = [ "deno_core", "deno_web", @@ -4484,7 +4484,7 @@ dependencies = [ [[package]] name = "napi_sym" -version = "0.105.0" +version = "0.106.0" dependencies = [ "quote", "serde", @@ -4539,7 +4539,7 @@ dependencies = [ [[package]] name = "node_resolver" -version = "0.14.0" +version = "0.15.0" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 28ef2829e0..13140b65dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,16 +48,16 @@ repository = "https://github.com/denoland/deno" deno_ast = { version = "=0.43.3", features = ["transpiling"] } deno_core = { version = "0.318.0" } -deno_bench_util = { version = "0.169.0", path = "./bench_util" } +deno_bench_util = { version = "0.170.0", path = "./bench_util" } deno_lockfile = "=0.23.1" deno_media_type = { version = "0.2.0", features = ["module_specifier"] } deno_npm = "=0.25.4" deno_path_util = "=0.2.1" -deno_permissions = { version = "0.35.0", path = "./runtime/permissions" } -deno_runtime = { version = "0.184.0", path = "./runtime" } +deno_permissions = { version = "0.36.0", path = "./runtime/permissions" } +deno_runtime = { version = "0.185.0", path = "./runtime" } deno_semver = "=0.5.16" deno_terminal = "0.2.0" -napi_sym = { version = "0.105.0", path = "./ext/napi/sym" } +napi_sym = { version = "0.106.0", path = "./ext/napi/sym" } test_util = { package = "test_server", path = "./tests/util/server" } denokv_proto = "0.8.1" @@ -66,32 +66,32 @@ denokv_remote = "0.8.1" denokv_sqlite = { default-features = false, version = "0.8.2" } # exts -deno_broadcast_channel = { version = "0.169.0", path = "./ext/broadcast_channel" } -deno_cache = { version = "0.107.0", path = "./ext/cache" } -deno_canvas = { version = "0.44.0", path = "./ext/canvas" } -deno_console = { version = "0.175.0", path = "./ext/console" } -deno_cron = { version = "0.55.0", path = "./ext/cron" } -deno_crypto = { version = "0.189.0", path = "./ext/crypto" } -deno_fetch = { version = "0.199.0", path = "./ext/fetch" } -deno_ffi = { version = "0.162.0", path = "./ext/ffi" } -deno_fs = { version = "0.85.0", path = "./ext/fs" } -deno_http = { version = "0.173.0", path = "./ext/http" } -deno_io = { version = "0.85.0", path = "./ext/io" } -deno_kv = { version = "0.83.0", path = "./ext/kv" } -deno_napi = { version = "0.106.0", path = "./ext/napi" } -deno_net = { version = "0.167.0", path = "./ext/net" } -deno_node = { version = "0.112.0", path = "./ext/node" } -deno_tls = { version = "0.162.0", path = "./ext/tls" } -deno_url = { version = "0.175.0", path = "./ext/url" } -deno_web = { version = "0.206.0", path = "./ext/web" } -deno_webgpu = { version = "0.142.0", path = "./ext/webgpu" } -deno_webidl = { version = "0.175.0", path = "./ext/webidl" } -deno_websocket = { version = "0.180.0", path = "./ext/websocket" } -deno_webstorage = { version = "0.170.0", path = "./ext/webstorage" } +deno_broadcast_channel = { version = "0.170.0", path = "./ext/broadcast_channel" } +deno_cache = { version = "0.108.0", path = "./ext/cache" } +deno_canvas = { version = "0.45.0", path = "./ext/canvas" } +deno_console = { version = "0.176.0", path = "./ext/console" } +deno_cron = { version = "0.56.0", path = "./ext/cron" } +deno_crypto = { version = "0.190.0", path = "./ext/crypto" } +deno_fetch = { version = "0.200.0", path = "./ext/fetch" } +deno_ffi = { version = "0.163.0", path = "./ext/ffi" } +deno_fs = { version = "0.86.0", path = "./ext/fs" } +deno_http = { version = "0.174.0", path = "./ext/http" } +deno_io = { version = "0.86.0", path = "./ext/io" } +deno_kv = { version = "0.84.0", path = "./ext/kv" } +deno_napi = { version = "0.107.0", path = "./ext/napi" } +deno_net = { version = "0.168.0", path = "./ext/net" } +deno_node = { version = "0.113.0", path = "./ext/node" } +deno_tls = { version = "0.163.0", path = "./ext/tls" } +deno_url = { version = "0.176.0", path = "./ext/url" } +deno_web = { version = "0.207.0", path = "./ext/web" } +deno_webgpu = { version = "0.143.0", path = "./ext/webgpu" } +deno_webidl = { version = "0.176.0", path = "./ext/webidl" } +deno_websocket = { version = "0.181.0", path = "./ext/websocket" } +deno_webstorage = { version = "0.171.0", path = "./ext/webstorage" } # resolvers -deno_resolver = { version = "0.7.0", path = "./resolvers/deno" } -node_resolver = { version = "0.14.0", path = "./resolvers/node" } +deno_resolver = { version = "0.8.0", path = "./resolvers/deno" } +node_resolver = { version = "0.15.0", path = "./resolvers/node" } aes = "=0.8.3" anyhow = "1.0.57" diff --git a/Releases.md b/Releases.md index a183e01ecd..8010379309 100644 --- a/Releases.md +++ b/Releases.md @@ -6,6 +6,42 @@ https://github.com/denoland/deno/releases We also have one-line install commands at: https://github.com/denoland/deno_install +### 2.0.5 / 2024.11.05 + +- fix(add): better error message when adding package that only has pre-release + versions (#26724) +- fix(add): only add npm deps to package.json if it's at least as close as + deno.json (#26683) +- fix(cli): set `npm_config_user_agent` when running npm packages or tasks + (#26639) +- fix(coverage): exclude comment lines from coverage reports (#25939) +- fix(ext/node): add `findSourceMap` to the default export of `node:module` + (#26720) +- fix(ext/node): convert errors from `fs.readFile/fs.readFileSync` to node + format (#26632) +- fix(ext/node): resolve exports even if parent module filename isn't present + (#26553) +- fix(ext/node): return `this` from `http.Server.ref/unref()` (#26647) +- fix(fmt): do not panic for jsx ignore container followed by jsx text (#26723) +- fix(fmt): fix several HTML and components issues (#26654) +- fix(fmt): ignore file directive for YAML files (#26717) +- fix(install): handle invalid function error, and fallback to junctions + regardless of the error (#26730) +- fix(lsp): include unstable features from editor settings (#26655) +- fix(lsp): scope attribution for lazily loaded assets (#26699) +- fix(node): Implement `os.userInfo` properly, add missing `toPrimitive` + (#24702) +- fix(serve): support serve hmr (#26078) +- fix(types): missing `import` permission on `PermissionOptionsObject` (#26627) +- fix(workspace): support wildcard packages (#26568) +- fix: clamp smi in fast calls by default (#26506) +- fix: improved support for cjs and cts modules (#26558) +- fix: op_run_microtasks crash (#26718) +- fix: panic_hook hangs without procfs (#26732) +- fix: remove permission check in op_require_node_module_paths (#26645) +- fix: surface package.json location on dep parse failure (#26665) +- perf(lsp): don't walk coverage directory (#26715) + ### 2.0.4 / 2024.10.29 - Revert "fix(ext/node): fix dns.lookup result ordering (#26264)" (#26621) diff --git a/bench_util/Cargo.toml b/bench_util/Cargo.toml index 31c27b9a9d..ff48442b3b 100644 --- a/bench_util/Cargo.toml +++ b/bench_util/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_bench_util" -version = "0.169.0" +version = "0.170.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/cli/Cargo.toml b/cli/Cargo.toml index a91482c3e1..32229d816f 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno" -version = "2.0.4" +version = "2.0.5" authors.workspace = true default-run = "deno" edition.workspace = true diff --git a/ext/broadcast_channel/Cargo.toml b/ext/broadcast_channel/Cargo.toml index e6eeeed5ec..0951286f71 100644 --- a/ext/broadcast_channel/Cargo.toml +++ b/ext/broadcast_channel/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_broadcast_channel" -version = "0.169.0" +version = "0.170.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/cache/Cargo.toml b/ext/cache/Cargo.toml index 7cae8d88a2..20dc9ca48c 100644 --- a/ext/cache/Cargo.toml +++ b/ext/cache/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_cache" -version = "0.107.0" +version = "0.108.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/canvas/Cargo.toml b/ext/canvas/Cargo.toml index 5d2c371999..5c6e44f95c 100644 --- a/ext/canvas/Cargo.toml +++ b/ext/canvas/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_canvas" -version = "0.44.0" +version = "0.45.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/console/Cargo.toml b/ext/console/Cargo.toml index b3543ed85f..bf476574ee 100644 --- a/ext/console/Cargo.toml +++ b/ext/console/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_console" -version = "0.175.0" +version = "0.176.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/cron/Cargo.toml b/ext/cron/Cargo.toml index 0d52cb6a97..90b39aa0e2 100644 --- a/ext/cron/Cargo.toml +++ b/ext/cron/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_cron" -version = "0.55.0" +version = "0.56.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/crypto/Cargo.toml b/ext/crypto/Cargo.toml index 95981bba3b..890cd868ae 100644 --- a/ext/crypto/Cargo.toml +++ b/ext/crypto/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_crypto" -version = "0.189.0" +version = "0.190.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/fetch/Cargo.toml b/ext/fetch/Cargo.toml index 93fc88ae64..0b15d05b8f 100644 --- a/ext/fetch/Cargo.toml +++ b/ext/fetch/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_fetch" -version = "0.199.0" +version = "0.200.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/ffi/Cargo.toml b/ext/ffi/Cargo.toml index 58144790bf..27ecd1d546 100644 --- a/ext/ffi/Cargo.toml +++ b/ext/ffi/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_ffi" -version = "0.162.0" +version = "0.163.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/fs/Cargo.toml b/ext/fs/Cargo.toml index 0ccde7f7e2..d1720b7bc7 100644 --- a/ext/fs/Cargo.toml +++ b/ext/fs/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_fs" -version = "0.85.0" +version = "0.86.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/http/Cargo.toml b/ext/http/Cargo.toml index a1a4cb20be..1d7c4d87ed 100644 --- a/ext/http/Cargo.toml +++ b/ext/http/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_http" -version = "0.173.0" +version = "0.174.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/io/Cargo.toml b/ext/io/Cargo.toml index 7e858d298c..b791f16a3f 100644 --- a/ext/io/Cargo.toml +++ b/ext/io/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_io" -version = "0.85.0" +version = "0.86.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/kv/Cargo.toml b/ext/kv/Cargo.toml index bbd2349011..59b425d3cb 100644 --- a/ext/kv/Cargo.toml +++ b/ext/kv/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_kv" -version = "0.83.0" +version = "0.84.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/napi/Cargo.toml b/ext/napi/Cargo.toml index c31367118e..064d335689 100644 --- a/ext/napi/Cargo.toml +++ b/ext/napi/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_napi" -version = "0.106.0" +version = "0.107.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/napi/sym/Cargo.toml b/ext/napi/sym/Cargo.toml index c23054eb40..bf48d2742c 100644 --- a/ext/napi/sym/Cargo.toml +++ b/ext/napi/sym/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "napi_sym" -version = "0.105.0" +version = "0.106.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/net/Cargo.toml b/ext/net/Cargo.toml index 5ffd1b4504..b22fbe7b57 100644 --- a/ext/net/Cargo.toml +++ b/ext/net/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_net" -version = "0.167.0" +version = "0.168.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/node/Cargo.toml b/ext/node/Cargo.toml index ed31dbf17e..d830be5759 100644 --- a/ext/node/Cargo.toml +++ b/ext/node/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_node" -version = "0.112.0" +version = "0.113.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/tls/Cargo.toml b/ext/tls/Cargo.toml index 6871faa5b8..89a78f4b62 100644 --- a/ext/tls/Cargo.toml +++ b/ext/tls/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_tls" -version = "0.162.0" +version = "0.163.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/url/Cargo.toml b/ext/url/Cargo.toml index 24d81abf83..7f3fa97613 100644 --- a/ext/url/Cargo.toml +++ b/ext/url/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_url" -version = "0.175.0" +version = "0.176.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/web/Cargo.toml b/ext/web/Cargo.toml index a02cff98fc..faba8e9fb2 100644 --- a/ext/web/Cargo.toml +++ b/ext/web/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_web" -version = "0.206.0" +version = "0.207.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/webgpu/Cargo.toml b/ext/webgpu/Cargo.toml index 3bb814c25c..c682965d5e 100644 --- a/ext/webgpu/Cargo.toml +++ b/ext/webgpu/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_webgpu" -version = "0.142.0" +version = "0.143.0" authors = ["the Deno authors"] edition.workspace = true license = "MIT" diff --git a/ext/webidl/Cargo.toml b/ext/webidl/Cargo.toml index 1685bb1fd0..1e8dd77cf0 100644 --- a/ext/webidl/Cargo.toml +++ b/ext/webidl/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_webidl" -version = "0.175.0" +version = "0.176.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/websocket/Cargo.toml b/ext/websocket/Cargo.toml index 6a575cb416..6724cea2c1 100644 --- a/ext/websocket/Cargo.toml +++ b/ext/websocket/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_websocket" -version = "0.180.0" +version = "0.181.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/ext/webstorage/Cargo.toml b/ext/webstorage/Cargo.toml index 079ab2e4ee..c1d2092f13 100644 --- a/ext/webstorage/Cargo.toml +++ b/ext/webstorage/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_webstorage" -version = "0.170.0" +version = "0.171.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/resolvers/deno/Cargo.toml b/resolvers/deno/Cargo.toml index d8569d7219..060b3e7895 100644 --- a/resolvers/deno/Cargo.toml +++ b/resolvers/deno/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_resolver" -version = "0.7.0" +version = "0.8.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/resolvers/node/Cargo.toml b/resolvers/node/Cargo.toml index 95f7eabad8..6cbfc717d5 100644 --- a/resolvers/node/Cargo.toml +++ b/resolvers/node/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "node_resolver" -version = "0.14.0" +version = "0.15.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index c4c0c8ff9b..a509c711ee 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_runtime" -version = "0.184.0" +version = "0.185.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/runtime/permissions/Cargo.toml b/runtime/permissions/Cargo.toml index f0b2e71b55..5fcc8a3e13 100644 --- a/runtime/permissions/Cargo.toml +++ b/runtime/permissions/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_permissions" -version = "0.35.0" +version = "0.36.0" authors.workspace = true edition.workspace = true license.workspace = true From 5088b25f2315fa45e912377356a89ba2a44dbcda Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Wed, 6 Nov 2024 06:26:46 +0000 Subject: [PATCH 37/40] feat(lsp): auto-import completions from byonm dependencies (#26680) --- cli/lsp/analysis.rs | 76 +++++++++----- cli/lsp/documents.rs | 28 ----- cli/lsp/language_server.rs | 13 ++- cli/lsp/resolver.rs | 45 ++++++++ cli/lsp/tsc.rs | 102 ++++++++++++------ tests/integration/lsp_tests.rs | 185 +++++++++++++++++++++++++++++---- 6 files changed, 344 insertions(+), 105 deletions(-) diff --git a/cli/lsp/analysis.rs b/cli/lsp/analysis.rs index 0769c90477..98215855c9 100644 --- a/cli/lsp/analysis.rs +++ b/cli/lsp/analysis.rs @@ -12,7 +12,9 @@ use super::urls::url_to_uri; use crate::args::jsr_url; use crate::lsp::search::PackageSearchApi; use crate::tools::lint::CliLinter; +use crate::util::path::relative_specifier; use deno_config::workspace::MappedResolution; +use deno_graph::source::ResolutionMode; use deno_lint::diagnostic::LintDiagnosticRange; use deno_ast::SourceRange; @@ -228,6 +230,7 @@ pub struct TsResponseImportMapper<'a> { documents: &'a Documents, maybe_import_map: Option<&'a ImportMap>, resolver: &'a LspResolver, + tsc_specifier_map: &'a tsc::TscSpecifierMap, file_referrer: ModuleSpecifier, } @@ -236,12 +239,14 @@ impl<'a> TsResponseImportMapper<'a> { documents: &'a Documents, maybe_import_map: Option<&'a ImportMap>, resolver: &'a LspResolver, + tsc_specifier_map: &'a tsc::TscSpecifierMap, file_referrer: &ModuleSpecifier, ) -> Self { Self { documents, maybe_import_map, resolver, + tsc_specifier_map, file_referrer: file_referrer.clone(), } } @@ -387,6 +392,11 @@ impl<'a> TsResponseImportMapper<'a> { } } } + } else if let Some(dep_name) = self + .resolver + .file_url_to_package_json_dep(specifier, Some(&self.file_referrer)) + { + return Some(dep_name); } // check if the import map has this specifier @@ -457,19 +467,36 @@ impl<'a> TsResponseImportMapper<'a> { specifier: &str, referrer: &ModuleSpecifier, ) -> Option { - if let Ok(specifier) = referrer.join(specifier) { - if let Some(specifier) = self.check_specifier(&specifier, referrer) { - return Some(specifier); - } - } - let specifier = specifier.strip_suffix(".js").unwrap_or(specifier); - for ext in SUPPORTED_EXTENSIONS { - let specifier_with_ext = format!("{specifier}{ext}"); - if self - .documents - .contains_import(&specifier_with_ext, referrer) + let specifier_stem = specifier.strip_suffix(".js").unwrap_or(specifier); + let specifiers = std::iter::once(Cow::Borrowed(specifier)).chain( + SUPPORTED_EXTENSIONS + .iter() + .map(|ext| Cow::Owned(format!("{specifier_stem}{ext}"))), + ); + for specifier in specifiers { + if let Some(specifier) = self + .resolver + .as_graph_resolver(Some(&self.file_referrer)) + .resolve( + &specifier, + &deno_graph::Range { + specifier: referrer.clone(), + start: deno_graph::Position::zeroed(), + end: deno_graph::Position::zeroed(), + }, + ResolutionMode::Types, + ) + .ok() + .and_then(|s| self.tsc_specifier_map.normalize(s.as_str()).ok()) + .filter(|s| self.documents.exists(s, Some(&self.file_referrer))) { - return Some(specifier_with_ext); + if let Some(specifier) = self + .check_specifier(&specifier, referrer) + .or_else(|| relative_specifier(referrer, &specifier)) + .filter(|s| !s.contains("/node_modules/")) + { + return Some(specifier); + } } } None @@ -559,8 +586,9 @@ fn try_reverse_map_package_json_exports( pub fn fix_ts_import_changes( referrer: &ModuleSpecifier, changes: &[tsc::FileTextChanges], - import_mapper: &TsResponseImportMapper, + language_server: &language_server::Inner, ) -> Result, AnyError> { + let import_mapper = language_server.get_ts_response_import_mapper(referrer); let mut r = Vec::new(); for change in changes { let mut text_changes = Vec::new(); @@ -605,7 +633,7 @@ pub fn fix_ts_import_changes( fn fix_ts_import_action<'a>( referrer: &ModuleSpecifier, action: &'a tsc::CodeFixAction, - import_mapper: &TsResponseImportMapper, + language_server: &language_server::Inner, ) -> Option> { if !matches!( action.fix_name.as_str(), @@ -621,6 +649,7 @@ fn fix_ts_import_action<'a>( let Some(specifier) = specifier else { return Some(Cow::Borrowed(action)); }; + let import_mapper = language_server.get_ts_response_import_mapper(referrer); if let Some(new_specifier) = import_mapper.check_unresolved_specifier(specifier, referrer) { @@ -728,7 +757,7 @@ pub fn ts_changes_to_edit( })) } -#[derive(Debug, Deserialize)] +#[derive(Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct CodeActionData { pub specifier: ModuleSpecifier, @@ -998,11 +1027,8 @@ impl CodeActionCollection { "The action returned from TypeScript is unsupported.", )); } - let Some(action) = fix_ts_import_action( - specifier, - action, - &language_server.get_ts_response_import_mapper(specifier), - ) else { + let Some(action) = fix_ts_import_action(specifier, action, language_server) + else { return Ok(()); }; let edit = ts_changes_to_edit(&action.changes, language_server)?; @@ -1051,10 +1077,12 @@ impl CodeActionCollection { specifier: &ModuleSpecifier, diagnostic: &lsp::Diagnostic, ) { - let data = Some(json!({ - "specifier": specifier, - "fixId": action.fix_id, - })); + let data = action.fix_id.as_ref().map(|fix_id| { + json!(CodeActionData { + specifier: specifier.clone(), + fix_id: fix_id.clone(), + }) + }); let title = if let Some(description) = &action.fix_all_description { description.clone() } else { diff --git a/cli/lsp/documents.rs b/cli/lsp/documents.rs index 8609aed05e..ce13c32157 100644 --- a/cli/lsp/documents.rs +++ b/cli/lsp/documents.rs @@ -1059,34 +1059,6 @@ impl Documents { self.cache.is_valid_file_referrer(specifier) } - /// Return `true` if the provided specifier can be resolved to a document, - /// otherwise `false`. - pub fn contains_import( - &self, - specifier: &str, - referrer: &ModuleSpecifier, - ) -> bool { - let file_referrer = self.get_file_referrer(referrer); - let maybe_specifier = self - .resolver - .as_graph_resolver(file_referrer.as_deref()) - .resolve( - specifier, - &deno_graph::Range { - specifier: referrer.clone(), - start: deno_graph::Position::zeroed(), - end: deno_graph::Position::zeroed(), - }, - ResolutionMode::Types, - ) - .ok(); - if let Some(import_specifier) = maybe_specifier { - self.exists(&import_specifier, file_referrer.as_deref()) - } else { - false - } - } - pub fn resolve_document_specifier( &self, specifier: &ModuleSpecifier, diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 61a02f036e..2554fa34b1 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -1837,7 +1837,7 @@ impl Inner { fix_ts_import_changes( &code_action_data.specifier, &combined_code_actions.changes, - &self.get_ts_response_import_mapper(&code_action_data.specifier), + self, ) .map_err(|err| { error!("Unable to remap changes: {:#}", err); @@ -1890,7 +1890,7 @@ impl Inner { refactor_edit_info.edits = fix_ts_import_changes( &action_data.specifier, &refactor_edit_info.edits, - &self.get_ts_response_import_mapper(&action_data.specifier), + self, ) .map_err(|err| { error!("Unable to remap changes: {:#}", err); @@ -1921,7 +1921,8 @@ impl Inner { // todo(dsherret): this should probably just take the resolver itself // as the import map is an implementation detail .and_then(|d| d.resolver.maybe_import_map()), - self.resolver.as_ref(), + &self.resolver, + &self.ts_server.specifier_map, file_referrer, ) } @@ -2284,7 +2285,11 @@ impl Inner { .into(), scope.cloned(), ) - .await; + .await + .unwrap_or_else(|err| { + error!("Unable to get completion info from TypeScript: {:#}", err); + None + }); if let Some(completions) = maybe_completion_info { response = Some( diff --git a/cli/lsp/resolver.rs b/cli/lsp/resolver.rs index 9ce76005e5..f5df24d575 100644 --- a/cli/lsp/resolver.rs +++ b/cli/lsp/resolver.rs @@ -74,6 +74,7 @@ struct LspScopeResolver { pkg_json_resolver: Option>, redirect_resolver: Option>, graph_imports: Arc>, + package_json_deps_by_resolution: Arc>, config_data: Option>, } @@ -88,6 +89,7 @@ impl Default for LspScopeResolver { pkg_json_resolver: None, redirect_resolver: None, graph_imports: Default::default(), + package_json_deps_by_resolution: Default::default(), config_data: None, } } @@ -165,6 +167,33 @@ impl LspScopeResolver { ) }) .unwrap_or_default(); + let package_json_deps_by_resolution = (|| { + let node_resolver = node_resolver.as_ref()?; + let package_json = config_data?.maybe_pkg_json()?; + let referrer = package_json.specifier(); + let dependencies = package_json.dependencies.as_ref()?; + let result = dependencies + .iter() + .flat_map(|(name, _)| { + let req_ref = + NpmPackageReqReference::from_str(&format!("npm:{name}")).ok()?; + let specifier = into_specifier_and_media_type(Some( + node_resolver + .resolve_req_reference( + &req_ref, + &referrer, + NodeResolutionMode::Types, + ) + .ok()?, + )) + .0; + Some((specifier, name.clone())) + }) + .collect(); + Some(result) + })(); + let package_json_deps_by_resolution = + Arc::new(package_json_deps_by_resolution.unwrap_or_default()); Self { cjs_tracker: lsp_cjs_tracker, graph_resolver, @@ -174,6 +203,7 @@ impl LspScopeResolver { pkg_json_resolver: Some(pkg_json_resolver), redirect_resolver, graph_imports, + package_json_deps_by_resolution, config_data: config_data.cloned(), } } @@ -216,6 +246,9 @@ impl LspScopeResolver { redirect_resolver: self.redirect_resolver.clone(), pkg_json_resolver: Some(pkg_json_resolver), graph_imports: self.graph_imports.clone(), + package_json_deps_by_resolution: self + .package_json_deps_by_resolution + .clone(), config_data: self.config_data.clone(), }) } @@ -407,6 +440,18 @@ impl LspResolver { ))) } + pub fn file_url_to_package_json_dep( + &self, + specifier: &ModuleSpecifier, + file_referrer: Option<&ModuleSpecifier>, + ) -> Option { + let resolver = self.get_scope_resolver(file_referrer); + resolver + .package_json_deps_by_resolution + .get(specifier) + .cloned() + } + pub fn in_node_modules(&self, specifier: &ModuleSpecifier) -> bool { fn has_node_modules_dir(specifier: &ModuleSpecifier) -> bool { // consider any /node_modules/ directory as being in the node_modules diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 5fcdb3575a..6f63ced5be 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -236,7 +236,7 @@ pub struct TsServer { performance: Arc, sender: mpsc::UnboundedSender, receiver: Mutex>>, - specifier_map: Arc, + pub specifier_map: Arc, inspector_server: Mutex>>, pending_change: Mutex>, } @@ -882,20 +882,22 @@ impl TsServer { options: GetCompletionsAtPositionOptions, format_code_settings: FormatCodeSettings, scope: Option, - ) -> Option { + ) -> Result, AnyError> { let req = TscRequest::GetCompletionsAtPosition(Box::new(( self.specifier_map.denormalize(&specifier), position, options, format_code_settings, ))); - match self.request(snapshot, req, scope).await { - Ok(maybe_info) => maybe_info, - Err(err) => { - log::error!("Unable to get completion info from TypeScript: {:#}", err); - None - } - } + self + .request::>(snapshot, req, scope) + .await + .map(|mut info| { + if let Some(info) = &mut info { + info.normalize(&self.specifier_map); + } + info + }) } pub async fn get_completion_details( @@ -3642,6 +3644,12 @@ pub struct CompletionInfo { } impl CompletionInfo { + fn normalize(&mut self, specifier_map: &TscSpecifierMap) { + for entry in &mut self.entries { + entry.normalize(specifier_map); + } + } + pub fn as_completion_response( &self, line_index: Arc, @@ -3703,11 +3711,17 @@ pub struct CompletionItemData { #[derive(Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] -struct CompletionEntryDataImport { +struct CompletionEntryDataAutoImport { module_specifier: String, file_name: String, } +#[derive(Debug)] +pub struct CompletionNormalizedAutoImportData { + raw: CompletionEntryDataAutoImport, + normalized: ModuleSpecifier, +} + #[derive(Debug, Default, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct CompletionEntry { @@ -3740,9 +3754,28 @@ pub struct CompletionEntry { is_import_statement_completion: Option, #[serde(skip_serializing_if = "Option::is_none")] data: Option, + /// This is not from tsc, we add it for convenience during normalization. + /// Represents `self.data.file_name`, but normalized. + #[serde(skip)] + auto_import_data: Option, } impl CompletionEntry { + fn normalize(&mut self, specifier_map: &TscSpecifierMap) { + let Some(data) = &self.data else { + return; + }; + let Ok(raw) = + serde_json::from_value::(data.clone()) + else { + return; + }; + if let Ok(normalized) = specifier_map.normalize(&raw.file_name) { + self.auto_import_data = + Some(CompletionNormalizedAutoImportData { raw, normalized }); + } + } + fn get_commit_characters( &self, info: &CompletionInfo, @@ -3891,25 +3924,24 @@ impl CompletionEntry { if let Some(source) = &self.source { let mut display_source = source.clone(); - if let Some(data) = &self.data { - if let Ok(import_data) = - serde_json::from_value::(data.clone()) + if let Some(import_data) = &self.auto_import_data { + if let Some(new_module_specifier) = language_server + .get_ts_response_import_mapper(specifier) + .check_specifier(&import_data.normalized, specifier) + .or_else(|| relative_specifier(specifier, &import_data.normalized)) { - if let Ok(import_specifier) = resolve_url(&import_data.file_name) { - if let Some(new_module_specifier) = language_server - .get_ts_response_import_mapper(specifier) - .check_specifier(&import_specifier, specifier) - .or_else(|| relative_specifier(specifier, &import_specifier)) - { - display_source.clone_from(&new_module_specifier); - if new_module_specifier != import_data.module_specifier { - specifier_rewrite = - Some((import_data.module_specifier, new_module_specifier)); - } - } else if source.starts_with(jsr_url().as_str()) { - return None; - } + if new_module_specifier.contains("/node_modules/") { + return None; } + display_source.clone_from(&new_module_specifier); + if new_module_specifier != import_data.raw.module_specifier { + specifier_rewrite = Some(( + import_data.raw.module_specifier.clone(), + new_module_specifier, + )); + } + } else if source.starts_with(jsr_url().as_str()) { + return None; } } // We want relative or bare (import-mapped or otherwise) specifiers to @@ -4212,6 +4244,13 @@ impl TscSpecifierMap { return specifier.to_string(); } let mut specifier = original.to_string(); + if specifier.contains("/node_modules/.deno/") + && !specifier.contains("/node_modules/@types/node/") + { + // The ts server doesn't give completions from files in + // `node_modules/.deno/`. We work around it like this. + specifier = specifier.replace("/node_modules/", "/$node_modules/"); + } let media_type = MediaType::from_specifier(original); // If the URL-inferred media type doesn't correspond to tsc's path-inferred // media type, force it to be the same by appending an extension. @@ -4329,7 +4368,7 @@ fn op_is_cancelled(state: &mut OpState) -> bool { fn op_is_node_file(state: &mut OpState, #[string] path: String) -> bool { let state = state.borrow::(); let mark = state.performance.mark("tsc.op.op_is_node_file"); - let r = match ModuleSpecifier::parse(&path) { + let r = match state.specifier_map.normalize(path) { Ok(specifier) => state.state_snapshot.resolver.in_node_modules(&specifier), Err(_) => false, }; @@ -4609,7 +4648,10 @@ fn op_script_names(state: &mut OpState) -> ScriptNames { for doc in &docs { let specifier = doc.specifier(); let is_open = doc.is_open(); - if is_open || specifier.scheme() == "file" { + if is_open + || (specifier.scheme() == "file" + && !state.state_snapshot.resolver.in_node_modules(specifier)) + { let script_names = doc .scope() .and_then(|s| result.by_scope.get_mut(s)) @@ -6035,6 +6077,7 @@ mod tests { Some(temp_dir.url()), ) .await + .unwrap() .unwrap(); assert_eq!(info.entries.len(), 22); let details = ts_server @@ -6194,6 +6237,7 @@ mod tests { Some(temp_dir.url()), ) .await + .unwrap() .unwrap(); let entry = info .entries diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index 56221a0269..af5f9de23e 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -6628,6 +6628,23 @@ export class DuckConfig { }] }] } + }, { + "title": "Add all missing imports", + "kind": "quickfix", + "diagnostics": [{ + "range": { + "start": { "line": 0, "character": 50 }, + "end": { "line": 0, "character": 67 } + }, + "severity": 1, + "code": 2304, + "source": "deno-ts", + "message": "Cannot find name 'DuckConfigOptions'." + }], + "data": { + "specifier": "file:///a/file00.ts", + "fixId": "fixMissingImport" + } }, { "title": "Add import from \"./file01.ts\"", "kind": "quickfix", @@ -6656,23 +6673,6 @@ export class DuckConfig { }] }] } - }, { - "title": "Add all missing imports", - "kind": "quickfix", - "diagnostics": [{ - "range": { - "start": { "line": 0, "character": 50 }, - "end": { "line": 0, "character": 67 } - }, - "severity": 1, - "code": 2304, - "source": "deno-ts", - "message": "Cannot find name 'DuckConfigOptions'." - }], - "data": { - "specifier": "file:///a/file00.ts", - "fixId": "fixMissingImport" - } }]) ); let res = client.write_request( @@ -8125,6 +8125,151 @@ fn lsp_npm_completions_auto_import_and_quick_fix_no_import_map() { client.shutdown(); } +#[test] +fn lsp_npm_auto_import_and_quick_fix_byonm() { + let context = TestContextBuilder::new() + .use_http_server() + .use_temp_cwd() + .add_npm_env_vars() + .build(); + let temp_dir = context.temp_dir(); + temp_dir.write("deno.json", json!({}).to_string()); + temp_dir.write( + "package.json", + json!({ + "dependencies": { + "cowsay": "*", + }, + }) + .to_string(), + ); + context + .new_command() + .args("install") + .run() + .skip_output_check(); + temp_dir.write("other.ts", "import \"cowsay\";\n"); + let mut client = context.new_lsp_command().build(); + client.initialize_default(); + let diagnostics = client.did_open(json!({ + "textDocument": { + "uri": temp_dir.url().join("file.ts").unwrap(), + "languageId": "typescript", + "version": 1, + "text": "think({ text: \"foo\" });\n", + }, + })); + let list = client.get_completion_list( + temp_dir.url().join("file.ts").unwrap(), + (0, 5), + json!({ "triggerKind": 1 }), + ); + assert!(!list.is_incomplete); + let item = list + .items + .iter() + .find(|item| item.label == "think") + .unwrap(); + let res = client.write_request("completionItem/resolve", item); + assert_eq!( + res, + json!({ + "label": "think", + "labelDetails": { + "description": "cowsay", + }, + "kind": 3, + "detail": "function think(options: IOptions): string", + "documentation": { + "kind": "markdown", + "value": "\n\n*@param* \noptions ## Face :\nEither choose a mode (set the value as true) **_or_**\nset your own defined eyes and tongue to `e` and `T`.\n- ### `e` : eyes\n- ### `T` : tongue\n\n## Cow :\nEither specify a cow name (e.g. \"fox\") **_or_**\nset the value of `r` to true which selects a random cow.\n- ### `r` : random selection\n- ### `f` : cow name - from `cows` folder\n\n## Modes :\nModes are just ready-to-use faces, here's their list:\n- #### `b` : borg\n- #### `d` : dead \n- #### `g` : greedy\n- #### `p` : paranoia\n- #### `s` : stoned\n- #### `t` : tired\n- #### `w` : youthful\n- #### `y` : wired \n\n*@example* \n```\n// custom cow and face\ncowsay.think({\n text: 'Hello world!',\n e: '^^', // eyes\n T: 'U ', // tongue\n f: 'USA' // name of the cow from `cows` folder\n})\n\n// using a random cow\ncowsay.think({\n text: 'Hello world!',\n e: 'xx', // eyes\n r: true, // random mode - use a random cow.\n})\n\n// using a mode\ncowsay.think({\n text: 'Hello world!',\n y: true, // using y mode - youthful mode\n})\n```", + }, + "sortText": "￿16_0", + "additionalTextEdits": [ + { + "range": { + "start": { "line": 0, "character": 0 }, + "end": { "line": 0, "character": 0 }, + }, + "newText": "import { think } from \"cowsay\";\n\n", + }, + ], + }), + ); + let diagnostics = diagnostics + .messages_with_file_and_source( + temp_dir.url().join("file.ts").unwrap().as_str(), + "deno-ts", + ) + .diagnostics; + let res = client.write_request( + "textDocument/codeAction", + json!(json!({ + "textDocument": { + "uri": temp_dir.url().join("file.ts").unwrap(), + }, + "range": { + "start": { "line": 0, "character": 0 }, + "end": { "line": 0, "character": 5 }, + }, + "context": { + "diagnostics": &diagnostics, + "only": ["quickfix"], + }, + })), + ); + assert_eq!( + res, + json!([ + { + "title": "Add import from \"cowsay\"", + "kind": "quickfix", + "diagnostics": &diagnostics, + "edit": { + "documentChanges": [{ + "textDocument": { + "uri": temp_dir.url().join("file.ts").unwrap(), + "version": 1, + }, + "edits": [{ + "range": { + "start": { "line": 0, "character": 0 }, + "end": { "line": 0, "character": 0 }, + }, + "newText": "import { think } from \"cowsay\";\n\n", + }], + }], + }, + }, + { + "title": "Add missing function declaration 'think'", + "kind": "quickfix", + "diagnostics": &diagnostics, + "edit": { + "documentChanges": [ + { + "textDocument": { + "uri": temp_dir.url().join("file.ts").unwrap(), + "version": 1, + }, + "edits": [ + { + "range": { + "start": { "line": 1, "character": 0 }, + "end": { "line": 1, "character": 0 }, + }, + "newText": "\nfunction think(arg0: { text: string; }) {\n throw new Error(\"Function not implemented.\");\n}\n", + }, + ], + }, + ], + }, + }, + ]), + ); + client.shutdown(); +} + #[test] fn lsp_completions_node_specifier() { let context = TestContextBuilder::new().use_temp_cwd().build(); @@ -8237,8 +8382,8 @@ fn lsp_infer_return_type() { let context = TestContextBuilder::new().use_temp_cwd().build(); let temp_dir = context.temp_dir(); temp_dir.write("deno.json", json!({}).to_string()); - let types_file = source_file( - temp_dir.path().join("types.d.ts"), + temp_dir.write( + "types.d.ts", r#" export interface SomeInterface { someField: number; @@ -8319,7 +8464,7 @@ fn lsp_infer_return_type() { "start": { "line": 1, "character": 20 }, "end": { "line": 1, "character": 20 }, }, - "newText": format!(": import(\"{}\").SomeInterface", types_file.url()), + "newText": ": import(\"./types.d.ts\").SomeInterface", }, ], }, From 64e887083aa67047f5ad37b9d55c418274b03ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 6 Nov 2024 12:56:03 +0000 Subject: [PATCH 38/40] fix(fmt): don't use self-closing tags in HTML (#26754) Closes https://github.com/denoland/deno/issues/26748 --- cli/tools/fmt.rs | 2 +- tests/specs/fmt/html/well_formatted.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/tools/fmt.rs b/cli/tools/fmt.rs index 8378835612..f7f8dabc6f 100644 --- a/cli/tools/fmt.rs +++ b/cli/tools/fmt.rs @@ -1032,7 +1032,7 @@ fn get_resolved_markup_fmt_config( max_attrs_per_line: None, prefer_attrs_single_line: false, html_normal_self_closing: None, - html_void_self_closing: Some(true), + html_void_self_closing: None, component_self_closing: None, svg_self_closing: None, mathml_self_closing: None, diff --git a/tests/specs/fmt/html/well_formatted.html b/tests/specs/fmt/html/well_formatted.html index c0c06cd9bd..7af705c049 100644 --- a/tests/specs/fmt/html/well_formatted.html +++ b/tests/specs/fmt/html/well_formatted.html @@ -1,4 +1,4 @@ -
content
+
content