From 4b7c6049ef9d40394eb823859c82cbf8d293430d Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 31 Jan 2024 22:15:22 -0500 Subject: refactor: load bytes in deno_graph (#22212) Upgrades deno_graph to 0.64 where deno_graph is now responsible for turning bytes into a string. This is in preparation for Wasm modules. --- cli/tests/integration/compile_tests.rs | 29 ++++++++++++++++++++++ cli/tests/integration/npm_tests.rs | 6 ++--- cli/tests/testdata/fmt/invalid_data.out | 3 +++ .../testdata/npm/cjs_require_esm_error/main.out | 2 +- .../1.0.0/esm/my_es_module.js | 1 + .../1.0.0/esm/my_esm_module.js | 1 - .../@denotest/cjs-require-esm-error/1.0.0/index.js | 2 +- 7 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 cli/tests/testdata/npm/registry/@denotest/cjs-require-esm-error/1.0.0/esm/my_es_module.js delete mode 100644 cli/tests/testdata/npm/registry/@denotest/cjs-require-esm-error/1.0.0/esm/my_esm_module.js (limited to 'cli/tests') diff --git a/cli/tests/integration/compile_tests.rs b/cli/tests/integration/compile_tests.rs index d6c7febd5..cf3bf023d 100644 --- a/cli/tests/integration/compile_tests.rs +++ b/cli/tests/integration/compile_tests.rs @@ -1149,3 +1149,32 @@ fn granular_unstable_features() { output.assert_exit_code(0); output.assert_matches_text("Kv {}\n"); } + +#[test] +fn dynamic_import_bad_data_uri() { + let context = TestContextBuilder::new().build(); + let dir = context.temp_dir(); + let exe = if cfg!(windows) { + dir.path().join("app.exe") + } else { + dir.path().join("app") + }; + let file = dir.path().join("bad_data_uri.ts"); + file.write("await import('data:application/')"); + let output = context + .new_command() + .args_vec([ + "compile", + "--output", + &exe.to_string_lossy(), + &file.to_string_lossy(), + ]) + .run(); + output.assert_exit_code(0); + output.skip_output_check(); + let output = context.new_command().name(&exe).run(); + output.assert_exit_code(1); + output.assert_matches_text( + "[WILDCARD]TypeError: Unable to decode data url.[WILDCARD]", + ); +} diff --git a/cli/tests/integration/npm_tests.rs b/cli/tests/integration/npm_tests.rs index e3b1196b9..a63253260 100644 --- a/cli/tests/integration/npm_tests.rs +++ b/cli/tests/integration/npm_tests.rs @@ -12,14 +12,14 @@ use util::TestContextBuilder; // NOTE: See how to make test npm packages at ./testdata/npm/README.md -itest!(esm_module { +itest!(es_module { args: "run --allow-read --allow-env npm/esm/main.js", output: "npm/esm/main.out", envs: env_vars_for_npm_tests(), http_server: true, }); -itest!(esm_module_eval { +itest!(es_module_eval { args_vec: vec![ "eval", "import chalk from 'npm:chalk@5'; console.log(chalk.green('chalk esm loads'));", @@ -29,7 +29,7 @@ itest!(esm_module_eval { http_server: true, }); -itest!(esm_module_deno_test { +itest!(es_module_deno_test { args: "test --allow-read --allow-env npm/esm/test.js", output: "npm/esm/test.out", envs: env_vars_for_npm_tests(), diff --git a/cli/tests/testdata/fmt/invalid_data.out b/cli/tests/testdata/fmt/invalid_data.out index 7fd5046ee..dee00fcc5 100644 --- a/cli/tests/testdata/fmt/invalid_data.out +++ b/cli/tests/testdata/fmt/invalid_data.out @@ -1 +1,4 @@ error: [WILDCARD] is not a valid UTF-8 file + +Caused by: + invalid data diff --git a/cli/tests/testdata/npm/cjs_require_esm_error/main.out b/cli/tests/testdata/npm/cjs_require_esm_error/main.out index f24675de9..b6ade6904 100644 --- a/cli/tests/testdata/npm/cjs_require_esm_error/main.out +++ b/cli/tests/testdata/npm/cjs_require_esm_error/main.out @@ -1,2 +1,2 @@ -error: Uncaught (in promise) Error: require() of ES Module [WILDCARD]my_esm_module.js from [WILDCARD]index.js not supported. Instead change the require to a dynamic import() which is available in all CommonJS modules. +error: Uncaught (in promise) Error: require() of ES Module [WILDCARD]my_es_module.js from [WILDCARD]index.js not supported. Instead change the require to a dynamic import() which is available in all CommonJS modules. [WILDCARD] diff --git a/cli/tests/testdata/npm/registry/@denotest/cjs-require-esm-error/1.0.0/esm/my_es_module.js b/cli/tests/testdata/npm/registry/@denotest/cjs-require-esm-error/1.0.0/esm/my_es_module.js new file mode 100644 index 000000000..0613f1911 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/cjs-require-esm-error/1.0.0/esm/my_es_module.js @@ -0,0 +1 @@ +export class Test {} diff --git a/cli/tests/testdata/npm/registry/@denotest/cjs-require-esm-error/1.0.0/esm/my_esm_module.js b/cli/tests/testdata/npm/registry/@denotest/cjs-require-esm-error/1.0.0/esm/my_esm_module.js deleted file mode 100644 index 0613f1911..000000000 --- a/cli/tests/testdata/npm/registry/@denotest/cjs-require-esm-error/1.0.0/esm/my_esm_module.js +++ /dev/null @@ -1 +0,0 @@ -export class Test {} diff --git a/cli/tests/testdata/npm/registry/@denotest/cjs-require-esm-error/1.0.0/index.js b/cli/tests/testdata/npm/registry/@denotest/cjs-require-esm-error/1.0.0/index.js index 6db336dba..ba630f93b 100644 --- a/cli/tests/testdata/npm/registry/@denotest/cjs-require-esm-error/1.0.0/index.js +++ b/cli/tests/testdata/npm/registry/@denotest/cjs-require-esm-error/1.0.0/index.js @@ -1 +1 @@ -module.exports.Test = require("./esm/my_esm_module.js"); +module.exports.Test = require("./esm/my_es_module.js"); -- cgit v1.2.3