From b1c6142f741a507ba6594ab174065e00213100b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 30 Aug 2024 18:58:58 +0100 Subject: [PATCH] BREAKING: `DENO_FUTURE=1` by default, or welcome to Deno 2.0 (#25213) This commit effectively turns Deno into Deno 2.0. This is done by forcing `DENO_FUTURE=1` env var, that was available in the past few months to try Deno 2 changes. This commit contains several breaking changes scheduled for Deno 2: - all deprecated JavaScript APIs are not available any more, mostly `Deno.*` APIs - `window` global is removed - FFI, WebGPU and FS APIs are now stable and don't require `--unstable-*` flags - import assertions are no longer supported - "bring your own node modules" is enabled by default This is the first commit in a series that are scheduled before the Deno 2 release. Follow up work is tracked in https://github.com/denoland/deno/issues/25241. --------- Co-authored-by: Asher Gomez Co-authored-by: Nayeem Rahman Co-authored-by: Nathan Whitaker --- cli/args/flags.rs | 34 ++---- cli/args/mod.rs | 5 +- cli/lsp/config.rs | 30 ++++- cli/lsp/language_server.rs | 5 - tests/integration/cache_tests.rs | 2 + tests/integration/check_tests.rs | 57 +++++----- tests/integration/compile_tests.rs | 30 ++--- tests/integration/info_tests.rs | 21 ++-- tests/integration/install_tests.rs | 16 ++- tests/integration/lsp_tests.rs | 34 ++++-- tests/integration/npm_tests.rs | 107 +++++++++--------- tests/integration/repl_tests.rs | 2 + tests/integration/run_tests.rs | 88 +++++++------- tests/integration/task_tests.rs | 76 +++++++------ tests/integration/test_tests.rs | 21 ++-- tests/integration/vendor_tests.rs | 4 +- tests/integration/watcher_tests.rs | 8 +- tests/specs/bench/package_json/__test__.jsonc | 12 +- tests/specs/bench/package_json/install.out | 3 + tests/specs/bench/package_json/lib.bench.out | 3 - tests/specs/cache/package_json/__test__.jsonc | 2 + .../specs/cert/cafile_install/__test__.jsonc | 1 + .../compile/npmrc_auto_install/deno.json | 2 +- .../future/import_assertions/__test__.jsonc | 26 +---- .../future/import_assertions/success.out | 7 -- .../no_future_install_global/__test__.jsonc | 13 --- .../no_future_install_global/assert.js | 11 -- .../no_future_install_global/install.out | 6 - .../no_future_install_global/pkg/main.js | 3 - .../no_future_install_global/pkg/package.json | 6 - .../lockfile/frozen_lockfile/__test__.jsonc | 2 + .../lockfile/only_package_json/__test__.jsonc | 2 + .../deno.json | 2 +- .../__test__.jsonc | 4 +- .../check_types_in_types_pkg/__test__.jsonc | 4 +- .../__test__.jsonc | 2 +- .../npm/lifecycle_scripts/__test__.jsonc | 4 +- .../all_lifecycles_not_run.out | 4 +- tests/specs/npm/lifecycle_scripts/deno.json | 2 +- .../lifecycle_scripts/node_gyp_not_run.out | 4 +- .../lifecycle_scripts/only_warns_first1.out | 4 +- .../deno.json | 2 +- .../lossy_utf8_script_from_cjs/__test__.jsonc | 2 +- tests/specs/npm/npmrc/__test__.jsonc | 2 +- .../npmrc_tarball_other_server/__test__.jsonc | 4 +- .../specs/npm/workspace_basic/__test__.jsonc | 10 +- .../workspace_sub_deno_json/__test__.jsonc | 4 + .../member_with_deno_json/deno.jsonc | 2 +- .../non_member/deno.json | 2 +- .../npm/workspace_wildcards/__test__.jsonc | 2 +- .../__test__.jsonc | 3 + tests/specs/publish/package_json/deno.json | 2 +- tests/specs/run/no_deno_json/__test__.jsonc | 4 + .../package_json/invalid_value/__test__.jsonc | 2 + .../run/ts_import_assertions/__test__.jsonc | 2 + .../explicit_import_map/__test__.jsonc | 2 + tests/specs/task/bin_package/deno.json | 2 +- .../task/node_modules_dir_false/deno.json | 2 +- .../npx_installed_pkg_non_byonm/deno.jsonc | 2 +- tests/testdata/npm/compare_globals/main.out | 26 ++--- tests/testdata/npm/compare_globals/main.ts | 25 ++-- tests/unit/test_util.ts | 3 +- tests/wpt/runner/expectation.json | 6 +- tests/wpt/runner/runner.ts | 3 + 64 files changed, 406 insertions(+), 377 deletions(-) create mode 100644 tests/specs/bench/package_json/install.out delete mode 100644 tests/specs/future/import_assertions/success.out delete mode 100644 tests/specs/install/no_future_install_global/__test__.jsonc delete mode 100644 tests/specs/install/no_future_install_global/assert.js delete mode 100644 tests/specs/install/no_future_install_global/install.out delete mode 100644 tests/specs/install/no_future_install_global/pkg/main.js delete mode 100644 tests/specs/install/no_future_install_global/pkg/package.json diff --git a/cli/args/flags.rs b/cli/args/flags.rs index 3ac2808694..050d55f4ce 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -8244,8 +8244,12 @@ mod tests { #[test] fn install() { - let r = - flags_from_vec(svec!["deno", "install", "jsr:@std/http/file-server"]); + let r = flags_from_vec(svec![ + "deno", + "install", + "-g", + "jsr:@std/http/file-server" + ]); assert_eq!( r.unwrap(), Flags { @@ -8257,7 +8261,7 @@ mod tests { root: None, force: false, }), - global: false, + global: true, }), ..Flags::default() } @@ -8290,7 +8294,7 @@ mod tests { #[test] fn install_with_flags() { #[rustfmt::skip] - let r = flags_from_vec(svec!["deno", "install", "--import-map", "import_map.json", "--no-remote", "--config", "tsconfig.json", "--no-check", "--unsafely-ignore-certificate-errors", "--reload", "--lock", "lock.json", "--cert", "example.crt", "--cached-only", "--allow-read", "--allow-net", "--v8-flags=--help", "--seed", "1", "--inspect=127.0.0.1:9229", "--name", "file_server", "--root", "/foo", "--force", "--env=.example.env", "jsr:@std/http/file-server", "foo", "bar"]); + let r = flags_from_vec(svec!["deno", "install", "--global", "--import-map", "import_map.json", "--no-remote", "--config", "tsconfig.json", "--no-check", "--unsafely-ignore-certificate-errors", "--reload", "--lock", "lock.json", "--cert", "example.crt", "--cached-only", "--allow-read", "--allow-net", "--v8-flags=--help", "--seed", "1", "--inspect=127.0.0.1:9229", "--name", "file_server", "--root", "/foo", "--force", "--env=.example.env", "jsr:@std/http/file-server", "foo", "bar"]); assert_eq!( r.unwrap(), Flags { @@ -8302,7 +8306,7 @@ mod tests { root: Some("/foo".to_string()), force: true, }), - global: false, + global: true, }), import_map_path: Some("import_map.json".to_string()), no_remote: true, @@ -8682,25 +8686,7 @@ mod tests { watch: None, bare: true, }), - node_modules_dir: Some(true), - code_cache_enabled: true, - ..Flags::default() - } - ); - - let r = flags_from_vec(svec![ - "deno", - "run", - "--node-modules-dir=false", - "script.ts" - ]); - assert_eq!( - r.unwrap(), - Flags { - subcommand: DenoSubcommand::Run(RunFlags::new_default( - "script.ts".to_string(), - )), - node_modules_dir: Some(false), + node_modules_dir: None, code_cache_enabled: true, ..Flags::default() } diff --git a/cli/args/mod.rs b/cli/args/mod.rs index a0888ca581..e339cb7148 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -117,8 +117,8 @@ pub static DENO_DISABLE_PEDANTIC_NODE_WARNINGS: Lazy = Lazy::new(|| { .is_some() }); -pub static DENO_FUTURE: Lazy = - Lazy::new(|| std::env::var("DENO_FUTURE").ok().is_some()); +// TODO(2.0): remove this in a follow up. +pub static DENO_FUTURE: Lazy = Lazy::new(|| true); pub fn jsr_url() -> &'static Url { static JSR_URL: Lazy = Lazy::new(|| { @@ -1680,6 +1680,7 @@ impl CliOptions { } }); + // TODO(2.0): remove this conditional and enable these features in `99_main.js` by default. if *DENO_FUTURE { let future_features = [ deno_runtime::deno_ffi::UNSTABLE_FEATURE_NAME.to_string(), diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs index ec2690506d..4ac9b4d0a8 100644 --- a/cli/lsp/config.rs +++ b/cli/lsp/config.rs @@ -1398,7 +1398,12 @@ impl ConfigData { || ( *DENO_FUTURE && member_dir.workspace.package_jsons().next().is_some() - && member_dir.workspace.node_modules_dir().is_none() + && member_dir + .workspace + .node_modules_mode() + .ok() + .flatten() + .is_none() // TODO(2.0): remove ); if byonm { @@ -1874,13 +1879,28 @@ fn resolve_node_modules_dir( // `nodeModulesDir: true` setting in the deno.json file. This is to // reduce the chance of modifying someone's node_modules directory // without them having asked us to do so. - let explicitly_disabled = workspace.node_modules_dir() == Some(false); + let node_modules_mode = workspace.node_modules_mode().ok().flatten(); + let node_modules_dir_option = workspace.node_modules_dir(); + let explicitly_disabled = if *DENO_FUTURE { + node_modules_mode == Some(NodeModulesMode::GlobalAuto) + } else { + node_modules_dir_option == Some(false) + }; if explicitly_disabled { return None; } - let enabled = byonm - || workspace.node_modules_dir() == Some(true) - || workspace.vendor_dir_path().is_some(); + let enabled = if *DENO_FUTURE { + byonm + || node_modules_mode + .map(|m| m.uses_node_modules_dir()) + .unwrap_or(false) + || workspace.vendor_dir_path().is_some() + } else { + byonm + || workspace.node_modules_dir() == Some(true) + || workspace.vendor_dir_path().is_some() + }; + if !enabled { return None; } diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 37e1aa0be2..05c54dfc67 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -3611,11 +3611,6 @@ impl Inner { .as_ref() .map(|url| url.to_string()) }), - node_modules_dir: Some( - config_data - .and_then(|d| d.node_modules_dir.as_ref()) - .is_some(), - ), // bit of a hack to force the lsp to cache the @types/node package type_check_mode: crate::args::TypeCheckMode::Local, ..Default::default() diff --git a/tests/integration/cache_tests.rs b/tests/integration/cache_tests.rs index 809d10791e..9c6f1f7f18 100644 --- a/tests/integration/cache_tests.rs +++ b/tests/integration/cache_tests.rs @@ -26,6 +26,8 @@ fn xdg_cache_home_dir() { assert!(xdg_cache_home.read_dir().count() > 0); } +// TODO(2.0): reenable +#[ignore] #[test] fn cache_matching_package_json_dep_should_not_install_all() { let context = TestContextBuilder::for_npm().use_temp_cwd().build(); diff --git a/tests/integration/check_tests.rs b/tests/integration/check_tests.rs index ce464135bb..bcc01cf5d0 100644 --- a/tests/integration/check_tests.rs +++ b/tests/integration/check_tests.rs @@ -257,35 +257,38 @@ itest!(check_dts { exit_code: 1, }); -itest!(package_json_basic { - args: "check main.ts", - output: "package_json/basic/main.check.out", - envs: env_vars_for_npm_tests(), - http_server: true, - cwd: Some("package_json/basic"), - copy_temp_dir: Some("package_json/basic"), - exit_code: 0, -}); +// TODO(2.0): this should be rewritten to a spec test and first run `deno install` +// itest!(package_json_basic { +// args: "check main.ts", +// output: "package_json/basic/main.check.out", +// envs: env_vars_for_npm_tests(), +// http_server: true, +// cwd: Some("package_json/basic"), +// copy_temp_dir: Some("package_json/basic"), +// exit_code: 0, +// }); -itest!(package_json_fail_check { - args: "check --quiet fail_check.ts", - output: "package_json/basic/fail_check.check.out", - envs: env_vars_for_npm_tests(), - http_server: true, - cwd: Some("package_json/basic"), - copy_temp_dir: Some("package_json/basic"), - exit_code: 1, -}); +// TODO(2.0): this should be rewritten to a spec test and first run `deno install` +// itest!(package_json_fail_check { +// args: "check --quiet fail_check.ts", +// output: "package_json/basic/fail_check.check.out", +// envs: env_vars_for_npm_tests(), +// http_server: true, +// cwd: Some("package_json/basic"), +// copy_temp_dir: Some("package_json/basic"), +// exit_code: 1, +// }); -itest!(package_json_with_deno_json { - args: "check --quiet main.ts", - output: "package_json/deno_json/main.check.out", - cwd: Some("package_json/deno_json/"), - copy_temp_dir: Some("package_json/deno_json/"), - envs: env_vars_for_npm_tests(), - http_server: true, - exit_code: 1, -}); +// TODO(2.0): this should be rewritten to a spec test and first run `deno install` +// itest!(package_json_with_deno_json { +// args: "check --quiet main.ts", +// output: "package_json/deno_json/main.check.out", +// cwd: Some("package_json/deno_json/"), +// copy_temp_dir: Some("package_json/deno_json/"), +// envs: env_vars_for_npm_tests(), +// http_server: true, +// exit_code: 1, +// }); #[test] fn check_error_in_dep_then_fix() { diff --git a/tests/integration/compile_tests.rs b/tests/integration/compile_tests.rs index 18d34c8627..60451e005f 100644 --- a/tests/integration/compile_tests.rs +++ b/tests/integration/compile_tests.rs @@ -726,7 +726,9 @@ fn dynamic_import_unanalyzable() { .assert_exit_code(0); } +// TODO(2.0): this test should first run `deno install`? #[test] +#[ignore] fn compile_npm_specifiers() { let context = TestContextBuilder::for_npm().use_temp_cwd().build(); @@ -850,7 +852,7 @@ fn compile_npm_file_system() { compile_args: vec!["-A"], run_args: vec![], output_file: "compile/npm_fs/main.out", - node_modules_dir: true, + node_modules_local: true, input_name: Some("binary"), expected_name: "binary", exit_code: 0, @@ -865,7 +867,7 @@ fn compile_npm_bin_esm() { compile_args: vec![], run_args: vec!["this", "is", "a", "test"], output_file: "npm/deno_run_esm.out", - node_modules_dir: false, + node_modules_local: false, input_name: None, expected_name: "cli-esm", exit_code: 0, @@ -880,7 +882,7 @@ fn compile_npm_bin_cjs() { compile_args: vec![], run_args: vec!["this", "is", "a", "test"], output_file: "npm/deno_run_cjs.out", - node_modules_dir: false, + node_modules_local: false, input_name: None, expected_name: "cli-cjs", exit_code: 0, @@ -895,7 +897,7 @@ fn compile_npm_cowsay_main() { compile_args: vec!["--allow-read"], run_args: vec!["Hello"], output_file: "npm/deno_run_cowsay.out", - node_modules_dir: false, + node_modules_local: false, input_name: None, expected_name: "cowsay", exit_code: 0, @@ -910,7 +912,7 @@ fn compile_npm_vfs_implicit_read_permissions() { compile_args: vec![], run_args: vec![], output_file: "compile/vfs_implicit_read_permission/main.out", - node_modules_dir: false, + node_modules_local: false, input_name: Some("binary"), expected_name: "binary", exit_code: 0, @@ -925,7 +927,7 @@ fn compile_npm_no_permissions() { compile_args: vec![], run_args: vec!["Hello"], output_file: "npm/deno_run_cowsay_no_permissions.out", - node_modules_dir: false, + node_modules_local: false, input_name: None, expected_name: "cowsay", exit_code: 1, @@ -940,7 +942,7 @@ fn compile_npm_cowsay_explicit() { compile_args: vec!["--allow-read"], run_args: vec!["Hello"], output_file: "npm/deno_run_cowsay.out", - node_modules_dir: false, + node_modules_local: false, input_name: None, expected_name: "cowsay", exit_code: 0, @@ -955,7 +957,7 @@ fn compile_npm_cowthink() { compile_args: vec!["--allow-read"], run_args: vec!["Hello"], output_file: "npm/deno_run_cowthink.out", - node_modules_dir: false, + node_modules_local: false, input_name: None, expected_name: "cowthink", exit_code: 0, @@ -965,7 +967,7 @@ fn compile_npm_cowthink() { struct RunNpmBinCompileOptions<'a> { input_specifier: &'a str, copy_temp_dir: Option<&'a str>, - node_modules_dir: bool, + node_modules_local: bool, output_file: &'a str, input_name: Option<&'a str>, expected_name: &'a str, @@ -986,8 +988,8 @@ fn run_npm_bin_compile_test(opts: RunNpmBinCompileOptions) { args.extend(opts.compile_args.iter().map(|s| s.to_string())); - if opts.node_modules_dir { - args.push("--node-modules-dir".to_string()); + if opts.node_modules_local { + args.push("--node-modules=local-auto".to_string()); } if let Some(bin_name) = opts.input_name { @@ -1050,7 +1052,7 @@ fn compile_node_modules_symlink_outside() { // compile folder let output = context .new_command() - .args("compile --allow-read --node-modules-dir --output bin main.ts") + .args("compile --allow-read --node-modules=local-auto --output bin main.ts") .run(); output.assert_exit_code(0); output.assert_matches_file( @@ -1073,7 +1075,7 @@ fn compile_node_modules_symlink_outside() { // compile let output = context .new_command() - .args("compile --allow-read --node-modules-dir --output bin main.ts") + .args("compile --allow-read --node-modules=local-auto --output bin main.ts") .run(); output.assert_exit_code(0); output.assert_matches_file( @@ -1103,7 +1105,7 @@ console.log(getValue());"#, // compile folder let output = context .new_command() - .args("compile --allow-read --node-modules-dir --output bin main.ts") + .args("compile --allow-read --node-modules=local-auto --output bin main.ts") .run(); output.assert_exit_code(0); output.assert_matches_text( diff --git a/tests/integration/info_tests.rs b/tests/integration/info_tests.rs index a2e3c2d4f1..b22209a565 100644 --- a/tests/integration/info_tests.rs +++ b/tests/integration/info_tests.rs @@ -2,7 +2,7 @@ use test_util as util; use test_util::itest; -use util::env_vars_for_npm_tests; +// use util::env_vars_for_npm_tests; use util::TestContextBuilder; #[test] @@ -135,15 +135,16 @@ itest!(with_config_override { output: "info/with_config/with_config.out", }); -itest!(package_json_basic { - args: "info --quiet main.ts", - output: "package_json/basic/main.info.out", - envs: env_vars_for_npm_tests(), - http_server: true, - cwd: Some("package_json/basic"), - copy_temp_dir: Some("package_json/basic"), - exit_code: 0, -}); +// TODO(2.0): this test should be a spec test and first run `deno install` +// itest!(package_json_basic { +// args: "info --quiet main.ts", +// output: "package_json/basic/main.info.out", +// envs: env_vars_for_npm_tests(), +// http_server: true, +// cwd: Some("package_json/basic"), +// copy_temp_dir: Some("package_json/basic"), +// exit_code: 0, +// }); itest!(info_import_map { args: "info preact/debug", diff --git a/tests/integration/install_tests.rs b/tests/integration/install_tests.rs index 744f97493d..7d671e0209 100644 --- a/tests/integration/install_tests.rs +++ b/tests/integration/install_tests.rs @@ -20,7 +20,7 @@ fn install_basic() { let output = context .new_command() - .args("install --check --name echo_test http://localhost:4545/echo.ts") + .args("install --check --name echo_test -g http://localhost:4545/echo.ts") .envs([ ("HOME", temp_dir_str.as_str()), ("USERPROFILE", temp_dir_str.as_str()), @@ -30,10 +30,7 @@ fn install_basic() { output.assert_exit_code(0); let output_text = output.combined_output(); - assert_contains!( - output_text, - "`deno install` behavior will change in Deno 2. To preserve the current behavior use the `-g` or `--global` flag." - ); + assert_contains!(output_text, "✅ Successfully installed echo_test"); // no lockfile should be created locally assert!(!temp_dir.path().join("deno.lock").exists()); @@ -167,7 +164,7 @@ fn install_custom_dir_env_var() { context .new_command() .current_dir(util::root_path()) // different cwd - .args("install --check --name echo_test http://localhost:4545/echo.ts") + .args("install --check --name echo_test -g http://localhost:4545/echo.ts") .envs([ ("HOME", temp_dir_str.as_str()), ("USERPROFILE", temp_dir_str.as_str()), @@ -210,6 +207,7 @@ fn installer_test_local_module_run() { .current_dir(util::root_path()) .args_vec([ "install", + "-g", "--name", "echo_test", "--root", @@ -254,7 +252,7 @@ fn installer_test_remote_module_run() { let bin_dir = root_dir.join("bin"); context .new_command() - .args("install --name echo_test --root ./root http://localhost:4545/echo.ts hello") + .args("install --name echo_test --root ./root -g http://localhost:4545/echo.ts hello") .run() .skip_output_check() .assert_exit_code(0); @@ -296,7 +294,7 @@ fn check_local_by_default() { let script_path_str = script_path.to_string_lossy().to_string(); context .new_command() - .args_vec(["install", script_path_str.as_str()]) + .args_vec(["install", "-g", script_path_str.as_str()]) .envs([ ("HOME", temp_dir_str.as_str()), ("USERPROFILE", temp_dir_str.as_str()), @@ -320,7 +318,7 @@ fn check_local_by_default2() { let script_path_str = script_path.to_string_lossy().to_string(); context .new_command() - .args_vec(["install", script_path_str.as_str()]) + .args_vec(["install", "-g", script_path_str.as_str()]) .envs([ ("HOME", temp_dir_str.as_str()), ("NO_COLOR", "1"), diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index 5d4640ce65..f20fbcc9c9 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -8757,9 +8757,9 @@ fn lsp_npm_specifier_unopened_file() { assert_eq!(output.status.code(), Some(0)); let stdout = String::from_utf8(output.stdout).unwrap(); - assert!(stdout.is_empty()); + assert_eq!(stdout.as_str(), ""); let stderr = String::from_utf8(output.stderr).unwrap(); - assert!(stderr.is_empty()); + assert_eq!(stderr.as_str(), ""); // open main.ts, which imports other.ts (unopened) client.did_open(json!({ @@ -9442,7 +9442,7 @@ fn lsp_npmrc() { temp_dir.write( temp_dir.path().join("deno.json"), json!({ - "nodeModulesDir": true, + "nodeModules": "local-auto", }) .to_string(), ); @@ -12369,6 +12369,13 @@ fn lsp_node_modules_dir() { .use_temp_cwd() .build(); let temp_dir = context.temp_dir(); + temp_dir.write( + "deno.json", + json!({ + "nodeModules": "global-auto", + }) + .to_string(), + ); // having a package.json should have no effect on whether // a node_modules dir is created @@ -12406,7 +12413,7 @@ fn lsp_node_modules_dir() { temp_dir.write( temp_dir.path().join("deno.json"), - "{ \"nodeModulesDir\": true, \"lock\": false }\n", + "{ \"nodeModules\": \"local-auto\", \"lock\": false }\n", ); let refresh_config = |client: &mut LspClient| { client.change_configuration(json!({ "deno": { @@ -12442,7 +12449,7 @@ fn lsp_node_modules_dir() { // now add a lockfile and cache temp_dir.write( temp_dir.path().join("deno.json"), - "{ \"nodeModulesDir\": true }\n", + "{ \"nodeModules\": \"local-auto\" }\n", ); refresh_config(&mut client); cache(&mut client); @@ -13049,21 +13056,21 @@ fn lsp_deno_json_scopes_node_modules_dir() { temp_dir.write( "project1/deno.json", json!({ - "nodeModulesDir": true, + "nodeModules": "local-auto", }) .to_string(), ); temp_dir.write( "project2/deno.json", json!({ - "nodeModulesDir": true, + "nodeModules": "local-auto", }) .to_string(), ); temp_dir.write( "project2/project3/deno.json", json!({ - "nodeModulesDir": true, + "nodeModules": "local-auto", }) .to_string(), ); @@ -14240,7 +14247,7 @@ fn lsp_deno_json_workspace_node_modules_dir() { "project1/deno.json", json!({ "workspace": ["project2"], - "nodeModulesDir": true, + "nodeModules": "local-auto", }) .to_string(), ); @@ -14371,6 +14378,15 @@ fn lsp_npm_workspace() { .use_temp_cwd() .build(); let temp_dir = context.temp_dir(); + // TODO(nayeemrmn): Goto definition for local npm package imports should work + // even with byonm. Remove this when fixed. + temp_dir.write( + "deno.json", + json!({ + "nodeModules": "local-auto", + }) + .to_string(), + ); temp_dir.write( "package.json", json!({ diff --git a/tests/integration/npm_tests.rs b/tests/integration/npm_tests.rs index f4bf3d6e9d..b6591c332a 100644 --- a/tests/integration/npm_tests.rs +++ b/tests/integration/npm_tests.rs @@ -140,7 +140,7 @@ itest!(mixed_case_package_name_global_dir { itest!(mixed_case_package_name_local_dir { args: - "run --node-modules-dir -A $TESTDATA/npm/mixed_case_package_name/local.ts", + "run --node-modules=local-auto -A $TESTDATA/npm/mixed_case_package_name/local.ts", output: "npm/mixed_case_package_name/local.out", exit_code: 0, envs: env_vars_for_npm_tests(), @@ -148,15 +148,16 @@ itest!(mixed_case_package_name_local_dir { temp_cwd: true, }); -itest!(local_dir_resolves_symlinks { - args: "run -A index.js", - output: "npm/local_dir_resolves_symlinks/index.out", - exit_code: 0, - envs: env_vars_for_npm_tests(), - cwd: Some("npm/local_dir_resolves_symlinks/"), - copy_temp_dir: Some("npm/local_dir_resolves_symlinks/"), - http_server: true, -}); +// TODO(2.0): this should be rewritten to a spec test and first run `deno install` +// itest!(local_dir_resolves_symlinks { +// args: "run -A index.js", +// output: "npm/local_dir_resolves_symlinks/index.out", +// exit_code: 0, +// envs: env_vars_for_npm_tests(), +// cwd: Some("npm/local_dir_resolves_symlinks/"), +// copy_temp_dir: Some("npm/local_dir_resolves_symlinks/"), +// http_server: true, +// }); // FIXME(bartlomieju): npm: specifiers are not handled in dynamic imports // at the moment @@ -373,7 +374,7 @@ itest!(permissions_outside_package { }); itest!(run_existing_npm_package { - args: "run --allow-read --node-modules-dir npm:@denotest/bin", + args: "run --allow-read --node-modules=local-auto npm:@denotest/bin", output: "npm/run_existing_npm_package/main.out", envs: env_vars_for_npm_tests(), http_server: true, @@ -384,7 +385,7 @@ itest!(run_existing_npm_package { itest!(run_existing_npm_package_with_subpath { args: - "run --allow-read --node-modules-dir npm:@denotest/bin/cli-esm dev --help", + "run --allow-read --node-modules=local-auto npm:@denotest/bin/cli-esm dev --help", output: "npm/run_existing_npm_package_with_subpath/main.out", envs: env_vars_for_npm_tests(), http_server: true, @@ -812,7 +813,7 @@ itest!(builtin_module_module { itest!(node_modules_dir_require_added_node_modules_folder { args: - "run --node-modules-dir -A --quiet $TESTDATA/npm/require_added_nm_folder/main.js", + "run --node-modules=local-auto -A --quiet $TESTDATA/npm/require_added_nm_folder/main.js", output: "npm/require_added_nm_folder/main.out", envs: env_vars_for_npm_tests(), http_server: true, @@ -830,7 +831,7 @@ itest!(node_modules_dir_require_main_entry { }); itest!(node_modules_dir_with_deps { - args: "run --allow-read --allow-env --node-modules-dir $TESTDATA/npm/cjs_with_deps/main.js", + args: "run --allow-read --allow-env --node-modules=local-auto $TESTDATA/npm/cjs_with_deps/main.js", output: "npm/cjs_with_deps/main_node_modules.out", envs: env_vars_for_npm_tests(), http_server: true, @@ -838,7 +839,7 @@ itest!(node_modules_dir_with_deps { }); itest!(node_modules_dir_yargs { - args: "run --allow-read --allow-env --node-modules-dir $TESTDATA/npm/cjs_yargs/main.js", + args: "run --allow-read --allow-env --node-modules=local-auto $TESTDATA/npm/cjs_yargs/main.js", output: "npm/cjs_yargs/main.out", envs: env_vars_for_npm_tests(), http_server: true, @@ -854,7 +855,7 @@ fn node_modules_dir_cache() { let deno = util::deno_cmd_with_deno_dir(&deno_dir) .current_dir(deno_dir.path()) .arg("cache") - .arg("--node-modules-dir") + .arg("--node-modules=local-auto") .arg("--quiet") .arg(util::testdata_path().join("npm/dual_cjs_esm/main.ts")) .envs(env_vars_for_npm_tests()) @@ -887,7 +888,7 @@ fn node_modules_dir_cache() { let deno = util::deno_cmd_with_deno_dir(&deno_dir) .current_dir(deno_dir.path()) .arg("run") - .arg("--node-modules-dir") + .arg("--node-modules=local-auto") .arg("--quiet") .arg("-A") .arg(util::testdata_path().join("npm/dual_cjs_esm/main.ts")) @@ -1495,7 +1496,7 @@ fn peer_deps_with_copied_folders_and_lockfile() { // now run with local node modules let output = context .new_command() - .args("run -A --node-modules-dir main.ts") + .args("run -A --node-modules=local-auto main.ts") .run(); output.assert_exit_code(0); output.assert_matches_file( @@ -1513,7 +1514,7 @@ fn peer_deps_with_copied_folders_and_lockfile() { // now again run with local node modules let output = context .new_command() - .args("run -A --node-modules-dir main.ts") + .args("run -A --node-modules=local-auto main.ts") .run(); output.assert_exit_code(0); output.assert_matches_text("1\n2\n"); @@ -1521,7 +1522,7 @@ fn peer_deps_with_copied_folders_and_lockfile() { // now ensure it works with reloading let output = context .new_command() - .args("run -A --reload --node-modules-dir main.ts") + .args("run -A --reload --node-modules=local-auto main.ts") .run(); output.assert_exit_code(0); output.assert_matches_file( @@ -1531,7 +1532,7 @@ fn peer_deps_with_copied_folders_and_lockfile() { // now ensure it works with reloading and no lockfile let output = context .new_command() - .args("run -A --reload --node-modules-dir --no-lock main.ts") + .args("run -A --reload --node-modules=local-auto --no-lock main.ts") .run(); output.assert_exit_code(0); output.assert_matches_file( @@ -1563,25 +1564,27 @@ itest!(create_require { http_server: true, }); -itest!(node_modules_import_run { - args: "run --quiet main.ts", - output: "npm/node_modules_import/main.out", - http_server: true, - copy_temp_dir: Some("npm/node_modules_import/"), - cwd: Some("npm/node_modules_import/"), - envs: env_vars_for_npm_tests(), - exit_code: 0, -}); +// TODO(2.0): this should be rewritten to a spec test and first run `deno install` +// itest!(node_modules_import_run { +// args: "run --quiet main.ts", +// output: "npm/node_modules_import/main.out", +// http_server: true, +// copy_temp_dir: Some("npm/node_modules_import/"), +// cwd: Some("npm/node_modules_import/"), +// envs: env_vars_for_npm_tests(), +// exit_code: 0, +// }); -itest!(node_modules_import_check { - args: "check --quiet main.ts", - output: "npm/node_modules_import/main_check.out", - envs: env_vars_for_npm_tests(), - http_server: true, - cwd: Some("npm/node_modules_import/"), - copy_temp_dir: Some("npm/node_modules_import/"), - exit_code: 1, -}); +// TODO(2.0): this should be rewritten to a spec test and first run `deno install` +// itest!(node_modules_import_check { +// args: "check --quiet main.ts", +// output: "npm/node_modules_import/main_check.out", +// envs: env_vars_for_npm_tests(), +// http_server: true, +// cwd: Some("npm/node_modules_import/"), +// copy_temp_dir: Some("npm/node_modules_import/"), +// exit_code: 1, +// }); itest!(non_existent_dep { args: "cache npm:@denotest/non-existent-dep", @@ -1611,7 +1614,9 @@ itest!(non_existent_dep_version { )), }); +// TODO(2.0): this should be rewritten to a spec test and first run `deno install` #[test] +#[ignore] fn reload_info_not_found_cache_but_exists_remote() { fn remove_version(registry_json: &mut Value, version: &str) { registry_json @@ -1875,7 +1880,7 @@ fn binary_package_with_optional_dependencies() { let output = context .new_command() - .args("run -A --node-modules-dir main.js") + .args("run -A --node-modules=local-auto main.js") .run(); #[cfg(target_os = "windows")] @@ -1966,7 +1971,7 @@ fn node_modules_dir_config_file() { let node_modules_dir = temp_dir.path().join("node_modules"); let rm_node_modules = || std::fs::remove_dir_all(&node_modules_dir).unwrap(); - temp_dir.write("deno.json", r#"{ "nodeModulesDir": true }"#); + temp_dir.write("deno.json", r#"{ "nodeModules": "local-auto" }"#); temp_dir.write("main.ts", "import 'npm:@denotest/esm-basic';"); let deno_cache_cmd = test_context.new_command().args("cache --quiet main.ts"); @@ -1980,7 +1985,7 @@ fn node_modules_dir_config_file() { assert!(node_modules_dir.exists()); rm_node_modules(); - temp_dir.write("deno.json", r#"{ "nodeModulesDir": false }"#); + temp_dir.write("deno.json", r#"{ "nodeModules": "global-auto" }"#); deno_cache_cmd.run(); assert!(!node_modules_dir.exists()); @@ -1991,7 +1996,7 @@ fn node_modules_dir_config_file() { test_context .new_command() - .args("cache --quiet --node-modules-dir main.ts") + .args("cache --quiet --node-modules=local-auto main.ts") .run(); assert!(node_modules_dir.exists()); @@ -1999,7 +2004,7 @@ fn node_modules_dir_config_file() { rm_node_modules(); test_context .new_command() - .args("cache --quiet --node-modules-dir=false --vendor main.ts") + .args("cache --quiet --node-modules=global-auto --vendor main.ts") .run(); assert!(!node_modules_dir.exists()); } @@ -2016,7 +2021,7 @@ fn top_level_install_package_json_explicit_opt_in() { // when the node_modules_dir is explicitly opted into, we should always // ensure a top level package.json install occurs - temp_dir.write("deno.json", "{ \"nodeModulesDir\": true }"); + temp_dir.write("deno.json", "{ \"nodeModules\": \"local-auto\" }"); temp_dir.write( "package.json", "{ \"dependencies\": { \"@denotest/esm-basic\": \"1.0\" }}", @@ -2105,7 +2110,7 @@ itest!(check_package_file_dts_dmts_dcts { }); itest!(require_resolve_url_paths { - args: "run -A --quiet --node-modules-dir url_paths.ts", + args: "run -A --quiet --node-modules=local-auto url_paths.ts", output: "npm/require_resolve_url/url_paths.out", envs: env_vars_for_npm_tests(), http_server: true, @@ -2776,7 +2781,7 @@ fn cjs_export_analysis_import_cjs_directly_relative_import() { itest!(imports_package_json { args: - "run --no-lock --node-modules-dir=false npm/imports_package_json/main.js", + "run --no-lock --node-modules=global-auto npm/imports_package_json/main.js", output: "npm/imports_package_json/main.out", envs: env_vars_for_npm_tests(), http_server: true, @@ -2784,7 +2789,7 @@ itest!(imports_package_json { itest!(imports_package_json_import_not_defined { args: - "run --no-lock --node-modules-dir=false npm/imports_package_json/import_not_defined.js", + "run --no-lock --node-modules=global-auto npm/imports_package_json/import_not_defined.js", output: "npm/imports_package_json/import_not_defined.out", envs: env_vars_for_npm_tests(), exit_code: 1, @@ -2793,7 +2798,7 @@ itest!(imports_package_json_import_not_defined { itest!(imports_package_json_sub_path_import_not_defined { args: - "run --no-lock --node-modules-dir=false npm/imports_package_json/sub_path_import_not_defined.js", + "run --no-lock --node-modules=global-auto npm/imports_package_json/sub_path_import_not_defined.js", output: "npm/imports_package_json/sub_path_import_not_defined.out", envs: env_vars_for_npm_tests(), exit_code: 1, @@ -2801,7 +2806,7 @@ itest!(imports_package_json_sub_path_import_not_defined { }); itest!(different_nested_dep_node_modules_dir_false { - args: "run --quiet --no-lock --node-modules-dir=false npm/different_nested_dep/main.js", + args: "run --quiet --no-lock --node-modules=global-auto npm/different_nested_dep/main.js", output: "npm/different_nested_dep/main.out", envs: env_vars_for_npm_tests(), exit_code: 0, @@ -2809,7 +2814,7 @@ itest!(different_nested_dep_node_modules_dir_false { }); itest!(different_nested_dep_node_modules_dir_true { - args: "run --no-lock --quiet --node-modules-dir=true main.js", + args: "run --no-lock --quiet --node-modules=local-auto main.js", output: "npm/different_nested_dep/main.out", copy_temp_dir: Some("npm/different_nested_dep/"), cwd: Some("npm/different_nested_dep/"), diff --git a/tests/integration/repl_tests.rs b/tests/integration/repl_tests.rs index 2049990a32..3f137ce7cb 100644 --- a/tests/integration/repl_tests.rs +++ b/tests/integration/repl_tests.rs @@ -1040,7 +1040,9 @@ fn pty_tab_indexable_props() { }); } +// TODO(2.0): this should first run `deno install` #[flaky_test::flaky_test] +#[ignore] fn package_json_uncached_no_error() { let test_context = TestContextBuilder::for_npm() .use_temp_cwd() diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index ade5c45608..4d3374173d 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -946,7 +946,9 @@ fn lock_redirects() { ); } +// TODO(2.0): this should be rewritten to a spec test and first run `deno install` #[test] +#[ignore] fn lock_deno_json_package_json_deps() { let context = TestContextBuilder::new() .use_temp_cwd() @@ -1104,7 +1106,7 @@ fn lock_deno_json_package_json_deps_workspace() { // deno.json let deno_json = temp_dir.join("deno.json"); deno_json.write_json(&json!({ - "nodeModulesDir": true + "nodeModules": "local-auto" })); // package.json @@ -1801,10 +1803,11 @@ itest!(top_level_for_await_ts { output: "run/top_level_await/top_level_for_await.out", }); -itest!(unstable_disabled_js { - args: "run --reload run/unstable.js", - output: "run/unstable_disabled_js.out", -}); +// TODO(2.0): remove, `Deno.umask` is enabled by default with Deno 2. +// itest!(unstable_disabled_js { +// args: "run --reload run/unstable.js", +// output: "run/unstable_disabled_js.out", +// }); itest!(unstable_enabled_js { args: "run --quiet --reload --unstable-fs run/unstable.ts", @@ -1848,25 +1851,29 @@ itest!(unstable_cron_enabled { output: "run/unstable_cron.enabled.out", }); -itest!(unstable_ffi_disabled { - args: "run --quiet --reload --allow-read run/unstable_ffi.js", - output: "run/unstable_ffi.disabled.out", -}); +// TODO(2.0): remove, FFI is stable by default with Deno 2. +// itest!(unstable_ffi_disabled { +// args: "run --quiet --reload --allow-read run/unstable_ffi.js", +// output: "run/unstable_ffi.disabled.out", +// }); -itest!(unstable_ffi_enabled { - args: "run --quiet --reload --allow-read --unstable-ffi run/unstable_ffi.js", - output: "run/unstable_ffi.enabled.out", -}); +// TODO(2.0): remove, FFI is stable by default with Deno 2. +// itest!(unstable_ffi_enabled { +// args: "run --quiet --reload --allow-read --unstable-ffi run/unstable_ffi.js", +// output: "run/unstable_ffi.enabled.out", +// }); -itest!(unstable_fs_disabled { - args: "run --quiet --reload --allow-read run/unstable_fs.js", - output: "run/unstable_fs.disabled.out", -}); +// TODO(2.0): remove, FS APIs are stable by default with Deno 2. +// itest!(unstable_fs_disabled { +// args: "run --quiet --reload --allow-read run/unstable_fs.js", +// output: "run/unstable_fs.disabled.out", +// }); -itest!(unstable_fs_enabled { - args: "run --quiet --reload --allow-read --unstable-fs run/unstable_fs.js", - output: "run/unstable_fs.enabled.out", -}); +// TODO(2.0): remove, FS APIs are stable by default with Deno 2. +// itest!(unstable_fs_enabled { +// args: "run --quiet --reload --allow-read --unstable-fs run/unstable_fs.js", +// output: "run/unstable_fs.enabled.out", +// }); itest!(unstable_http_disabled { args: "run --quiet --reload --allow-read run/unstable_http.js", @@ -1899,16 +1906,18 @@ itest!(unstable_kv_enabled { output: "run/unstable_kv.enabled.out", }); -itest!(unstable_webgpu_disabled { - args: "run --quiet --reload --allow-read run/unstable_webgpu.js", - output: "run/unstable_webgpu.disabled.out", -}); +// TODO(2.0): remove, WebGPU is enabled by default with Deno 2. +// itest!(unstable_webgpu_disabled { +// args: "run --quiet --reload --allow-read run/unstable_webgpu.js", +// output: "run/unstable_webgpu.disabled.out", +// }); -itest!(unstable_webgpu_enabled { - args: - "run --quiet --reload --allow-read --unstable-webgpu run/unstable_webgpu.js", - output: "run/unstable_webgpu.enabled.out", -}); +// TODO(2.0): remove, WebGPU is enabled by default with Deno 2. +// itest!(unstable_webgpu_enabled { +// args: +// "run --quiet --reload --allow-read --unstable-webgpu run/unstable_webgpu.js", +// output: "run/unstable_webgpu.enabled.out", +// }); itest!(import_compression { args: "run --quiet --reload --allow-net run/import_compression/main.ts", @@ -3433,16 +3442,19 @@ itest!( } ); -itest!(package_json_auto_discovered_for_npm_binary { - args: "run -L debug -A npm:@denotest/bin/cli-esm this is a test", - output: "run/with_package_json/npm_binary/main.out", - cwd: Some("run/with_package_json/npm_binary/"), - copy_temp_dir: Some("run/with_package_json/"), - envs: env_vars_for_npm_tests(), - http_server: true, -}); +// TODO(2.0): this should be rewritten to a spec test and first run `deno install` +// itest!(package_json_auto_discovered_for_npm_binary { +// args: "run -L debug -A npm:@denotest/bin/cli-esm this is a test", +// output: "run/with_package_json/npm_binary/main.out", +// cwd: Some("run/with_package_json/npm_binary/"), +// copy_temp_dir: Some("run/with_package_json/"), +// envs: env_vars_for_npm_tests(), +// http_server: true, +// }); +// TODO(2.0): this should be rewritten to a spec test and first run `deno install` #[test] +#[ignore] fn package_json_with_deno_json() { let context = TestContextBuilder::for_npm() .use_copy_temp_dir("package_json/deno_json/") diff --git a/tests/integration/task_tests.rs b/tests/integration/task_tests.rs index 4012081f7a..aba83a66d7 100644 --- a/tests/integration/task_tests.rs +++ b/tests/integration/task_tests.rs @@ -167,27 +167,29 @@ itest!(task_package_json_echo { http_server: true, }); -itest!(task_package_json_npm_bin { - args: "task bin extra", - cwd: Some("task/package_json/"), - output: "task/package_json/bin.out", - copy_temp_dir: Some("task/package_json/"), - envs: env_vars_for_npm_tests(), - exit_code: 0, - http_server: true, -}); +// TODO(2.0): this should first run `deno install` +// itest!(task_package_json_npm_bin { +// args: "task bin extra", +// cwd: Some("task/package_json/"), +// output: "task/package_json/bin.out", +// copy_temp_dir: Some("task/package_json/"), +// envs: env_vars_for_npm_tests(), +// exit_code: 0, +// http_server: true, +// }); +// TODO(2.0): decide what to do with this test // should not auto-install the packages in the package.json // when using nodeModulesDir: false -itest!(task_package_json_node_modules_dir_false { - args: "task echo", - cwd: Some("task/package_json_node_modules_dir_false/"), - output: "task/package_json_node_modules_dir_false/bin.out", - copy_temp_dir: Some("task/package_json_node_modules_dir_false/"), - envs: env_vars_for_npm_tests(), - exit_code: 0, - http_server: true, -}); +// itest!(task_package_json_node_modules_dir_false { +// args: "task echo", +// cwd: Some("task/package_json_node_modules_dir_false/"), +// output: "task/package_json_node_modules_dir_false/bin.out", +// copy_temp_dir: Some("task/package_json_node_modules_dir_false/"), +// envs: env_vars_for_npm_tests(), +// exit_code: 0, +// http_server: true, +// }); itest!(task_both_no_arg { args: "task", @@ -207,15 +209,16 @@ itest!(task_both_deno_json_selected { http_server: true, }); -itest!(task_both_package_json_selected { - args: "task bin asdf", - cwd: Some("task/both/"), - output: "task/both/package_json_selected.out", - copy_temp_dir: Some("task/both/"), - envs: env_vars_for_npm_tests(), - exit_code: 0, - http_server: true, -}); +// TODO(2.0): not entirely clear what's wrong with this test +// itest!(task_both_package_json_selected { +// args: "task bin asdf", +// cwd: Some("task/both/"), +// output: "task/both/package_json_selected.out", +// copy_temp_dir: Some("task/both/"), +// envs: env_vars_for_npm_tests(), +// exit_code: 0, +// http_server: true, +// }); itest!(task_both_prefers_deno { args: "task output some text", @@ -237,15 +240,16 @@ itest!(task_npx_non_existent { http_server: true, }); -itest!(task_npx_on_own { - args: "task on-own", - cwd: Some("task/npx/"), - output: "task/npx/on_own.out", - copy_temp_dir: Some("task/npx/"), - envs: env_vars_for_npm_tests(), - exit_code: 1, - http_server: true, -}); +// TODO(2.0): not entirely clear what's wrong with this test but it hangs for more than 60s +// itest!(task_npx_on_own { +// args: "task on-own", +// cwd: Some("task/npx/"), +// output: "task/npx/on_own.out", +// copy_temp_dir: Some("task/npx/"), +// envs: env_vars_for_npm_tests(), +// exit_code: 1, +// http_server: true, +// }); itest!(task_pre_post { args: "task test", diff --git a/tests/integration/test_tests.rs b/tests/integration/test_tests.rs index 175753f4ad..ed3d9fd426 100644 --- a/tests/integration/test_tests.rs +++ b/tests/integration/test_tests.rs @@ -6,7 +6,7 @@ use test_util as util; use test_util::itest; use util::assert_contains; use util::assert_not_contains; -use util::env_vars_for_npm_tests; +// use util::env_vars_for_npm_tests; use util::wildcard_match; use util::TestContext; use util::TestContextBuilder; @@ -617,15 +617,16 @@ fn sigint_with_hanging_test() { ); } -itest!(package_json_basic { - args: "test", - output: "package_json/basic/lib.test.out", - envs: env_vars_for_npm_tests(), - http_server: true, - cwd: Some("package_json/basic"), - copy_temp_dir: Some("package_json/basic"), - exit_code: 0, -}); +// TODO(2.0): this should be rewritten to a spec test and first run `deno install` +// itest!(package_json_basic { +// args: "test", +// output: "package_json/basic/lib.test.out", +// envs: env_vars_for_npm_tests(), +// http_server: true, +// cwd: Some("package_json/basic"), +// copy_temp_dir: Some("package_json/basic"), +// exit_code: 0, +// }); itest!(test_replace_timers { args: "test test/replace_timers.js", diff --git a/tests/integration/vendor_tests.rs b/tests/integration/vendor_tests.rs index 55ffe8734f..550fbf8b76 100644 --- a/tests/integration/vendor_tests.rs +++ b/tests/integration/vendor_tests.rs @@ -569,7 +569,9 @@ Download http://localhost:4545/vendor/logger.ts\n{}\n\n{}", assert!(output.status.success()); } +// TODO(2.0): decide if this test should be updated or removed #[test] +#[ignore] fn vendor_npm_node_specifiers() { let context = TestContextBuilder::for_npm().use_temp_cwd().build(); let temp_dir = context.temp_dir(); @@ -600,7 +602,7 @@ fn vendor_npm_node_specifiers() { vendored_npm_package_text("1 npm package"), success_text_updated_deno_json("vendor/") )); - let output = context.new_command().args("run -A my_app.ts").run(); + let output = context.new_command().args("run -A -q my_app.ts").run(); output.assert_matches_text("true 5\n"); assert!(temp_dir.path().join("node_modules").exists()); assert!(temp_dir.path().join("deno.lock").exists()); diff --git a/tests/integration/watcher_tests.rs b/tests/integration/watcher_tests.rs index 9685d7ae8b..abc5365b80 100644 --- a/tests/integration/watcher_tests.rs +++ b/tests/integration/watcher_tests.rs @@ -796,11 +796,11 @@ async fn run_watch_load_unload_events() { file_to_watch.write( r#" setInterval(() => {}, 0); - window.addEventListener("load", () => { + globalThis.addEventListener("load", () => { console.log("load"); }); - window.addEventListener("unload", () => { + globalThis.addEventListener("unload", () => { console.log("unload"); }); "#, @@ -827,11 +827,11 @@ async fn run_watch_load_unload_events() { // Change content of the file, this time without an interval to keep it alive. file_to_watch.write( r#" - window.addEventListener("load", () => { + globalThis.addEventListener("load", () => { console.log("load"); }); - window.addEventListener("unload", () => { + globalThis.addEventListener("unload", () => { console.log("unload"); }); "#, diff --git a/tests/specs/bench/package_json/__test__.jsonc b/tests/specs/bench/package_json/__test__.jsonc index 001cc8b54e..f41748ab54 100644 --- a/tests/specs/bench/package_json/__test__.jsonc +++ b/tests/specs/bench/package_json/__test__.jsonc @@ -1,5 +1,13 @@ { "tempDir": true, - "args": "bench", - "output": "lib.bench.out" + "steps": [ + { + "args": "install", + "output": "install.out" + }, + { + "args": "bench", + "output": "lib.bench.out" + } + ] } diff --git a/tests/specs/bench/package_json/install.out b/tests/specs/bench/package_json/install.out new file mode 100644 index 0000000000..b8114c12a0 --- /dev/null +++ b/tests/specs/bench/package_json/install.out @@ -0,0 +1,3 @@ +Download http://localhost:4260/@denotest/esm-basic +Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz +Initialize @denotest/esm-basic@1.0.0 diff --git a/tests/specs/bench/package_json/lib.bench.out b/tests/specs/bench/package_json/lib.bench.out index 24da289a95..066c91169e 100644 --- a/tests/specs/bench/package_json/lib.bench.out +++ b/tests/specs/bench/package_json/lib.bench.out @@ -1,6 +1,3 @@ -Download http://localhost:4260/@denotest/esm-basic -Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz -Initialize @denotest/esm-basic@1.0.0 Check file:///[WILDCARD]/lib.bench.ts CPU | [WILDCARD] Runtime | [WILDCARD] diff --git a/tests/specs/cache/package_json/__test__.jsonc b/tests/specs/cache/package_json/__test__.jsonc index b25ac147d6..803d5ef09a 100644 --- a/tests/specs/cache/package_json/__test__.jsonc +++ b/tests/specs/cache/package_json/__test__.jsonc @@ -1,5 +1,7 @@ { "tempDir": true, + // TODO(2.0): decide if this test should be fixed or removed + "ignore": true, "args": "cache main.ts", "output": "main.cache.out" } diff --git a/tests/specs/cert/cafile_install/__test__.jsonc b/tests/specs/cert/cafile_install/__test__.jsonc index 9591c7769f..67af9be05e 100644 --- a/tests/specs/cert/cafile_install/__test__.jsonc +++ b/tests/specs/cert/cafile_install/__test__.jsonc @@ -9,6 +9,7 @@ "echo_test", "--root", "$PWD", + "-g", "https://localhost:5545/echo.ts" ], "output": "[WILDCARD]" diff --git a/tests/specs/compile/npmrc_auto_install/deno.json b/tests/specs/compile/npmrc_auto_install/deno.json index 176354f98f..b2edaa0354 100644 --- a/tests/specs/compile/npmrc_auto_install/deno.json +++ b/tests/specs/compile/npmrc_auto_install/deno.json @@ -1,3 +1,3 @@ { - "nodeModulesDir": true + "nodeModules": "local-auto" } diff --git a/tests/specs/future/import_assertions/__test__.jsonc b/tests/specs/future/import_assertions/__test__.jsonc index 1c55d2220e..b7356d9244 100644 --- a/tests/specs/future/import_assertions/__test__.jsonc +++ b/tests/specs/future/import_assertions/__test__.jsonc @@ -1,25 +1,5 @@ { - "steps": [ - { - "args": "run main.js", - "output": "error.out", - "exitCode": 1, - "envs": { - "DENO_FUTURE": "1" - } - }, - // Running the same multiple times, should warn each time. - { - "args": "run main.js", - "output": "error.out", - "exitCode": 1, - "envs": { - "DENO_FUTURE": "1" - } - }, - { - "args": "run main.js", - "output": "success.out" - } - ] + "args": "run main.js", + "output": "error.out", + "exitCode": 1 } diff --git a/tests/specs/future/import_assertions/success.out b/tests/specs/future/import_assertions/success.out deleted file mode 100644 index fcf28b9436..0000000000 --- a/tests/specs/future/import_assertions/success.out +++ /dev/null @@ -1,7 +0,0 @@ -⚠️ Import assertions are deprecated. Use `with` keyword, instead of 'assert' keyword. - -import foo from "./main.json" assert { type: "json" }; - - at [WILDCARD]import_assertions/main.js:1:30 - -{ foo: "foo" } diff --git a/tests/specs/install/no_future_install_global/__test__.jsonc b/tests/specs/install/no_future_install_global/__test__.jsonc deleted file mode 100644 index 657cdab803..0000000000 --- a/tests/specs/install/no_future_install_global/__test__.jsonc +++ /dev/null @@ -1,13 +0,0 @@ -{ - "tempDir": true, - "steps": [ - { - "args": "install --root ./bins --name deno-test-bin ./pkg/main.js", - "output": "install.out" - }, - { - "args": "run -A ./assert.js", - "output": "" - } - ] -} diff --git a/tests/specs/install/no_future_install_global/assert.js b/tests/specs/install/no_future_install_global/assert.js deleted file mode 100644 index c7a6a06807..0000000000 --- a/tests/specs/install/no_future_install_global/assert.js +++ /dev/null @@ -1,11 +0,0 @@ -const dirs = Deno.readDir("./bins/bin"); - -let found = false; -for await (const entry of dirs) { - if (entry.name.includes("deno-test-bin")) { - found = true; - } -} -if (!found) { - throw new Error("Failed to find test bin"); -} diff --git a/tests/specs/install/no_future_install_global/install.out b/tests/specs/install/no_future_install_global/install.out deleted file mode 100644 index b1933f536a..0000000000 --- a/tests/specs/install/no_future_install_global/install.out +++ /dev/null @@ -1,6 +0,0 @@ -⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use the `-g` or `--global` flag. -Download http://localhost:4260/@denotest/esm-basic -Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz -[# there shouldn't be a line saying it initialized the node_modules folder here because this is a global install] -✅ Successfully installed deno-test-bin[WILDCARD] -[WILDCARD] diff --git a/tests/specs/install/no_future_install_global/pkg/main.js b/tests/specs/install/no_future_install_global/pkg/main.js deleted file mode 100644 index 6268d71362..0000000000 --- a/tests/specs/install/no_future_install_global/pkg/main.js +++ /dev/null @@ -1,3 +0,0 @@ -import { setValue } from "npm:@denotest/esm-basic"; - -setValue(5); diff --git a/tests/specs/install/no_future_install_global/pkg/package.json b/tests/specs/install/no_future_install_global/pkg/package.json deleted file mode 100644 index 9f465ad503..0000000000 --- a/tests/specs/install/no_future_install_global/pkg/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "deno-test-bin", - "dependencies": { - "@denotest/esm-basic": "*" - } -} diff --git a/tests/specs/lockfile/frozen_lockfile/__test__.jsonc b/tests/specs/lockfile/frozen_lockfile/__test__.jsonc index 0ac69c6bde..0af7363eb9 100644 --- a/tests/specs/lockfile/frozen_lockfile/__test__.jsonc +++ b/tests/specs/lockfile/frozen_lockfile/__test__.jsonc @@ -1,5 +1,7 @@ { "tempDir": true, + // TODO(2.0): re-enable after DENO_FUTURE=1 by default lands + "ignore": true, "tests": { "error_with_new_npm_dep": { "steps": [ diff --git a/tests/specs/lockfile/only_package_json/__test__.jsonc b/tests/specs/lockfile/only_package_json/__test__.jsonc index 6b28a7a924..5d79d7a872 100644 --- a/tests/specs/lockfile/only_package_json/__test__.jsonc +++ b/tests/specs/lockfile/only_package_json/__test__.jsonc @@ -1,5 +1,7 @@ { "tempDir": true, + // TODO(2.0): re-enable after DENO_FUTURE=1 by default lands + "ignore": true, "steps": [ { "args": "cache index.js", diff --git a/tests/specs/npm/adding_npm_dep_in_dynamic_import/deno.json b/tests/specs/npm/adding_npm_dep_in_dynamic_import/deno.json index 38bbf89a0c..27f0b80e78 100644 --- a/tests/specs/npm/adding_npm_dep_in_dynamic_import/deno.json +++ b/tests/specs/npm/adding_npm_dep_in_dynamic_import/deno.json @@ -1,5 +1,5 @@ { - "nodeModulesDir": true, + "nodeModules": "local-auto", "tasks": { "cat": "cat", "rm_node_modules": "rm -rf node_modules" diff --git a/tests/specs/npm/check_prefers_non_types_node_pkg/__test__.jsonc b/tests/specs/npm/check_prefers_non_types_node_pkg/__test__.jsonc index 8c4d0fb206..fc67a5de4a 100644 --- a/tests/specs/npm/check_prefers_non_types_node_pkg/__test__.jsonc +++ b/tests/specs/npm/check_prefers_non_types_node_pkg/__test__.jsonc @@ -15,12 +15,12 @@ }] }, "auto_install": { - "args": "check --node-modules-dir=true --quiet main.ts", + "args": "check --node-modules=local-auto --quiet main.ts", "exitCode": 1, "output": "expected.out" }, "global_folder": { - "args": "check --node-modules-dir=false --quiet main.ts", + "args": "check --node-modules=global-auto --quiet main.ts", "exitCode": 1, "output": "expected.out" } diff --git a/tests/specs/npm/check_types_in_types_pkg/__test__.jsonc b/tests/specs/npm/check_types_in_types_pkg/__test__.jsonc index 7b7a429f4d..9fff273482 100644 --- a/tests/specs/npm/check_types_in_types_pkg/__test__.jsonc +++ b/tests/specs/npm/check_types_in_types_pkg/__test__.jsonc @@ -15,12 +15,12 @@ }] }, "auto_install": { - "args": "check --node-modules-dir=true --quiet main_auto_install.ts", + "args": "check --node-modules=local-auto --quiet main_auto_install.ts", "exitCode": 1, "output": "expected.out" }, "global_folder": { - "args": "check --node-modules-dir=false --quiet main_auto_install.ts", + "args": "check --node-modules=global-auto --quiet main_auto_install.ts", "exitCode": 1, "output": "expected.out" } diff --git a/tests/specs/npm/conditional_exports_node_modules_dir/__test__.jsonc b/tests/specs/npm/conditional_exports_node_modules_dir/__test__.jsonc index 757e1c4e0e..84e26dd470 100644 --- a/tests/specs/npm/conditional_exports_node_modules_dir/__test__.jsonc +++ b/tests/specs/npm/conditional_exports_node_modules_dir/__test__.jsonc @@ -1,5 +1,5 @@ { "tempDir": true, - "args": "run --allow-read --node-modules-dir main.js", + "args": "run --allow-read --node-modules=local-auto main.js", "output": "main.out" } diff --git a/tests/specs/npm/lifecycle_scripts/__test__.jsonc b/tests/specs/npm/lifecycle_scripts/__test__.jsonc index c62bc47b49..3d322504cd 100644 --- a/tests/specs/npm/lifecycle_scripts/__test__.jsonc +++ b/tests/specs/npm/lifecycle_scripts/__test__.jsonc @@ -135,7 +135,7 @@ "output": "" }, { - "args": "cache --allow-scripts --node-modules-dir=true no_deno_json.js", + "args": "cache --allow-scripts --node-modules=local-auto no_deno_json.js", "output": "no_deno_json.out" } ] @@ -148,7 +148,7 @@ "output": "" }, { - "args": "cache --allow-scripts --node-modules-dir=true conflicting_bin.js", + "args": "cache --allow-scripts --node-modules=local-auto conflicting_bin.js", "output": "conflicting_bin.out" } ] diff --git a/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run.out b/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run.out index 0792674145..7d432ead90 100644 --- a/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run.out +++ b/tests/specs/npm/lifecycle_scripts/all_lifecycles_not_run.out @@ -7,6 +7,6 @@ Initialize @denotest/node-lifecycle-scripts@1.0.0 Initialize @denotest/bin@1.0.0 [UNORDERED_END] warning: Packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed. - This may cause the packages to not work correctly. To run them, use the `--allow-scripts` flag with `deno cache` - (e.g. `deno cache --allow-scripts=pkg1,pkg2 `): + This may cause the packages to not work correctly. To run them, use the `--allow-scripts` flag with `deno cache` or `deno install` + (e.g. `deno cache --allow-scripts=pkg1,pkg2 ` or `deno install --allow-scripts=pkg1,pkg2`): npm:@denotest/node-lifecycle-scripts@1.0.0 diff --git a/tests/specs/npm/lifecycle_scripts/deno.json b/tests/specs/npm/lifecycle_scripts/deno.json index 176354f98f..b2edaa0354 100644 --- a/tests/specs/npm/lifecycle_scripts/deno.json +++ b/tests/specs/npm/lifecycle_scripts/deno.json @@ -1,3 +1,3 @@ { - "nodeModulesDir": true + "nodeModules": "local-auto" } diff --git a/tests/specs/npm/lifecycle_scripts/node_gyp_not_run.out b/tests/specs/npm/lifecycle_scripts/node_gyp_not_run.out index c718e7c862..a6315b0ef6 100644 --- a/tests/specs/npm/lifecycle_scripts/node_gyp_not_run.out +++ b/tests/specs/npm/lifecycle_scripts/node_gyp_not_run.out @@ -2,8 +2,8 @@ Download http://localhost:4260/@denotest/node-addon Download http://localhost:4260/node-gyp [WILDCARD] warning: Packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed. - This may cause the packages to not work correctly. To run them, use the `--allow-scripts` flag with `deno cache` - (e.g. `deno cache --allow-scripts=pkg1,pkg2 `): + This may cause the packages to not work correctly. To run them, use the `--allow-scripts` flag with `deno cache` or `deno install` + (e.g. `deno cache --allow-scripts=pkg1,pkg2 ` or `deno install --allow-scripts=pkg1,pkg2`): npm:@denotest/node-addon@1.0.0 error: Uncaught (in promise) Error: Cannot find module './build/Release/node_addon' [WILDCARD] diff --git a/tests/specs/npm/lifecycle_scripts/only_warns_first1.out b/tests/specs/npm/lifecycle_scripts/only_warns_first1.out index 6ebf960289..0d52ae7294 100644 --- a/tests/specs/npm/lifecycle_scripts/only_warns_first1.out +++ b/tests/specs/npm/lifecycle_scripts/only_warns_first1.out @@ -7,8 +7,8 @@ Initialize @denotest/node-lifecycle-scripts@1.0.0 Initialize @denotest/bin@1.0.0 [UNORDERED_END] warning: Packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed. - This may cause the packages to not work correctly. To run them, use the `--allow-scripts` flag with `deno cache` - (e.g. `deno cache --allow-scripts=pkg1,pkg2 `): + This may cause the packages to not work correctly. To run them, use the `--allow-scripts` flag with `deno cache` or `deno install` + (e.g. `deno cache --allow-scripts=pkg1,pkg2 ` or `deno install --allow-scripts=pkg1,pkg2`): npm:@denotest/node-lifecycle-scripts@1.0.0 error: Uncaught SyntaxError: The requested module 'npm:@denotest/node-lifecycle-scripts' does not provide an export named 'value' [WILDCARD] diff --git a/tests/specs/npm/local_dir_no_duplicate_resolution/deno.json b/tests/specs/npm/local_dir_no_duplicate_resolution/deno.json index ae2f9c1ae8..7a51e3d29d 100644 --- a/tests/specs/npm/local_dir_no_duplicate_resolution/deno.json +++ b/tests/specs/npm/local_dir_no_duplicate_resolution/deno.json @@ -1,5 +1,5 @@ { - "nodeModulesDir": true, + "nodeModules": "local-auto", "imports": { "preact": "npm:preact", "preact-render-to-string": "npm:preact-render-to-string" diff --git a/tests/specs/npm/lossy_utf8_script_from_cjs/__test__.jsonc b/tests/specs/npm/lossy_utf8_script_from_cjs/__test__.jsonc index c8d353de00..cfa5a949e1 100644 --- a/tests/specs/npm/lossy_utf8_script_from_cjs/__test__.jsonc +++ b/tests/specs/npm/lossy_utf8_script_from_cjs/__test__.jsonc @@ -1,5 +1,5 @@ { - "args": "run --node-modules-dir --allow-read main.mjs", + "args": "run --node-modules=local-auto --allow-read main.mjs", "output": "main.out", "exitCode": 0, "tempDir": true diff --git a/tests/specs/npm/npmrc/__test__.jsonc b/tests/specs/npm/npmrc/__test__.jsonc index 106842d2b1..6378566ae8 100644 --- a/tests/specs/npm/npmrc/__test__.jsonc +++ b/tests/specs/npm/npmrc/__test__.jsonc @@ -14,7 +14,7 @@ }] }, "run_node_modules_dir": { - "args": "run --node-modules-dir -A --quiet main.js", + "args": "run --node-modules=local-auto -A --quiet main.js", "output": "main.out" } } diff --git a/tests/specs/npm/npmrc_tarball_other_server/__test__.jsonc b/tests/specs/npm/npmrc_tarball_other_server/__test__.jsonc index dfb311c1ec..b20ca90461 100644 --- a/tests/specs/npm/npmrc_tarball_other_server/__test__.jsonc +++ b/tests/specs/npm/npmrc_tarball_other_server/__test__.jsonc @@ -3,13 +3,13 @@ "tests": { "auth_success": { "cwd": "success", - "args": "run --node-modules-dir -A main.js", + "args": "run --node-modules=local-auto -A main.js", "output": "success/main.out", "exitCode": 1 }, "auth_fail": { "cwd": "fail", - "args": "run --node-modules-dir -A main.js", + "args": "run --node-modules=local-auto -A main.js", "output": "fail/main.out", "exitCode": 1 } diff --git a/tests/specs/npm/workspace_basic/__test__.jsonc b/tests/specs/npm/workspace_basic/__test__.jsonc index 7415a9aeb2..768c193fc6 100644 --- a/tests/specs/npm/workspace_basic/__test__.jsonc +++ b/tests/specs/npm/workspace_basic/__test__.jsonc @@ -2,15 +2,15 @@ "tempDir": true, "tests": { "global_cache": { - "args": "run --node-modules-dir=false b/main.ts", + "args": "run --node-modules=global-auto b/main.ts", "output": "b/main_global_cache.out" }, "global_cache_bare_specifier_not_in_pkg": { - "args": "run --node-modules-dir=false main.ts", + "args": "run --node-modules=global-auto main.ts", "output": "main.out" }, "node_modules_dir": { - "args": "run --node-modules-dir=true b/main.ts", + "args": "run --node-modules=local-auto b/main.ts", "output": "b/main_node_modules_dir.out" }, "byonm": { @@ -26,11 +26,15 @@ }] }, "exports_sub_path_not_exists": { + // TODO(2.0): this test appears legitimately broken + "ignore": true, "args": "run b/exports-sub-path-not-exists.ts", "output": "b/exports-sub-path-not-exists.out", "exitCode": 1 }, "no_exports_sub_path_not_exists": { + // TODO(2.0): this test appears legitimately broken + "ignore": true, "args": "run b/no-exports-sub-path-not-exists.ts", "output": "b/no-exports-sub-path-not-exists.out", "exitCode": 1 diff --git a/tests/specs/npm/workspace_sub_deno_json/__test__.jsonc b/tests/specs/npm/workspace_sub_deno_json/__test__.jsonc index c96e91abfb..dbf35dcb0f 100644 --- a/tests/specs/npm/workspace_sub_deno_json/__test__.jsonc +++ b/tests/specs/npm/workspace_sub_deno_json/__test__.jsonc @@ -2,10 +2,14 @@ "tempDir": true, "tests": { "member": { + // TODO(2.0): this test appears legitimately broken + "ignore": true, "args": "run --allow-read member/main.ts", "output": "member.out" }, "member_with_deno_json": { + // TODO(2.0): this test appears legitimately broken + "ignore": true, "args": "run --allow-read member_with_deno_json/main.ts", "output": "member.out" }, diff --git a/tests/specs/npm/workspace_sub_deno_json/member_with_deno_json/deno.jsonc b/tests/specs/npm/workspace_sub_deno_json/member_with_deno_json/deno.jsonc index 99bd145fe7..e246bc65df 100644 --- a/tests/specs/npm/workspace_sub_deno_json/member_with_deno_json/deno.jsonc +++ b/tests/specs/npm/workspace_sub_deno_json/member_with_deno_json/deno.jsonc @@ -1,4 +1,4 @@ { // will cause a warning - "nodeModulesDir": true + "nodeModules": "local-auto" } diff --git a/tests/specs/npm/workspace_sub_deno_json/non_member/deno.json b/tests/specs/npm/workspace_sub_deno_json/non_member/deno.json index 176354f98f..b2edaa0354 100644 --- a/tests/specs/npm/workspace_sub_deno_json/non_member/deno.json +++ b/tests/specs/npm/workspace_sub_deno_json/non_member/deno.json @@ -1,3 +1,3 @@ { - "nodeModulesDir": true + "nodeModules": "local-auto" } diff --git a/tests/specs/npm/workspace_wildcards/__test__.jsonc b/tests/specs/npm/workspace_wildcards/__test__.jsonc index eeb1629ec0..cefc307a61 100644 --- a/tests/specs/npm/workspace_wildcards/__test__.jsonc +++ b/tests/specs/npm/workspace_wildcards/__test__.jsonc @@ -1,4 +1,4 @@ { - "args": "run --node-modules-dir=false main.ts", + "args": "run --node-modules=global-auto main.ts", "output": "main.out" } diff --git a/tests/specs/publish/npm_workspace_jsr_pkg_with_npm_dep/__test__.jsonc b/tests/specs/publish/npm_workspace_jsr_pkg_with_npm_dep/__test__.jsonc index 8819e630dd..cee2fe12d9 100644 --- a/tests/specs/publish/npm_workspace_jsr_pkg_with_npm_dep/__test__.jsonc +++ b/tests/specs/publish/npm_workspace_jsr_pkg_with_npm_dep/__test__.jsonc @@ -1,4 +1,7 @@ { + // TODO(2.0): these tests are actually broken now, some code needs + // to be updated to make them work + "ignore": true, "tests": { "dep_and_workspace_dep": { "args": "publish --dry-run --no-check --log-level=debug", diff --git a/tests/specs/publish/package_json/deno.json b/tests/specs/publish/package_json/deno.json index 6e2826ef5e..00e8db5a89 100644 --- a/tests/specs/publish/package_json/deno.json +++ b/tests/specs/publish/package_json/deno.json @@ -4,5 +4,5 @@ "exports": { ".": "./mod.ts" }, - "nodeModulesDir": false + "nodeModules": "global-auto" } diff --git a/tests/specs/run/no_deno_json/__test__.jsonc b/tests/specs/run/no_deno_json/__test__.jsonc index 5da0209b90..c8e32fa190 100644 --- a/tests/specs/run/no_deno_json/__test__.jsonc +++ b/tests/specs/run/no_deno_json/__test__.jsonc @@ -29,12 +29,16 @@ "cwd": "code" }, "auto_discovered": { + // TODO(2.0): most likely needs to change output to not expect auto-install + "ignore": true, // auto-discovered node_modules relative package.json "args": "run -A main.js", "output": "code/sub_dir/main.out", "cwd": "code/sub_dir" }, "auto_discovered_arg": { + // TODO(2.0): most likely needs to change output to not expect auto-install + "ignore": true, // auto-discovered for local script arg "args": "run -L debug -A code/main.ts", // notice this is not in the sub dir "output": "main.out" diff --git a/tests/specs/run/package_json/invalid_value/__test__.jsonc b/tests/specs/run/package_json/invalid_value/__test__.jsonc index c960dd3027..7f85713cb5 100644 --- a/tests/specs/run/package_json/invalid_value/__test__.jsonc +++ b/tests/specs/run/package_json/invalid_value/__test__.jsonc @@ -1,5 +1,7 @@ { "tempDir": true, + // TODO(2.0): update the tests, should probably run install first + "ignore": true, "tests": { // should run fine when not referencing a failing dep entry "run_ok": { diff --git a/tests/specs/run/ts_import_assertions/__test__.jsonc b/tests/specs/run/ts_import_assertions/__test__.jsonc index 5d8110ae27..6e3ffb044e 100644 --- a/tests/specs/run/ts_import_assertions/__test__.jsonc +++ b/tests/specs/run/ts_import_assertions/__test__.jsonc @@ -1,6 +1,8 @@ { "tests": { "assertion": { + // TODO(2.0): disable import assertion support in TS. + "ignore": true, "steps": [{ "args": "run assertion.ts", "exitCode": 1, diff --git a/tests/specs/run/workspaces/explicit_import_map/__test__.jsonc b/tests/specs/run/workspaces/explicit_import_map/__test__.jsonc index 2bd0d3bcce..b13fde73af 100644 --- a/tests/specs/run/workspaces/explicit_import_map/__test__.jsonc +++ b/tests/specs/run/workspaces/explicit_import_map/__test__.jsonc @@ -1,4 +1,6 @@ { + // TODO(2.0): update the test, should probably call install first + "ignore": true, "args": "run -A --import-map=./import_map.json main.ts", "output": "main.out", "tempDir": true diff --git a/tests/specs/task/bin_package/deno.json b/tests/specs/task/bin_package/deno.json index 176354f98f..b2edaa0354 100644 --- a/tests/specs/task/bin_package/deno.json +++ b/tests/specs/task/bin_package/deno.json @@ -1,3 +1,3 @@ { - "nodeModulesDir": true + "nodeModules": "local-auto" } diff --git a/tests/specs/task/node_modules_dir_false/deno.json b/tests/specs/task/node_modules_dir_false/deno.json index cacff662c6..c11dfbbba3 100644 --- a/tests/specs/task/node_modules_dir_false/deno.json +++ b/tests/specs/task/node_modules_dir_false/deno.json @@ -1,5 +1,5 @@ { - "nodeModulesDir": true, + "nodeModules": "local-auto", "tasks": { "repro": "echo hi" } diff --git a/tests/specs/task/npx_installed_pkg_non_byonm/deno.jsonc b/tests/specs/task/npx_installed_pkg_non_byonm/deno.jsonc index 00303820ba..a21a7745b9 100644 --- a/tests/specs/task/npx_installed_pkg_non_byonm/deno.jsonc +++ b/tests/specs/task/npx_installed_pkg_non_byonm/deno.jsonc @@ -1,6 +1,6 @@ { // not byonm - "nodeModulesDir": true, + "nodeModules": "local-auto", "tasks": { "say": "npx cowsay moo" } diff --git a/tests/testdata/npm/compare_globals/main.out b/tests/testdata/npm/compare_globals/main.out index 9c9c2203aa..5b1d264646 100644 --- a/tests/testdata/npm/compare_globals/main.out +++ b/tests/testdata/npm/compare_globals/main.out @@ -10,21 +10,21 @@ Check file:///[WILDCARD]/npm/compare_globals/main.ts true true [] -false -function -function -function -undefined -false -false -true -true -true -true -true -true +setTimeout 1 false +setTimeout 2 function +setTimeout 3 function +setTimeout 4 function +setTimeout 5 undefined +process 1 false +process 2 false +true +true +window 1 false +window 2 false false false +self 1 true +self 2 true false false bar diff --git a/tests/testdata/npm/compare_globals/main.ts b/tests/testdata/npm/compare_globals/main.ts index 5d082386fe..5019a5fd5c 100644 --- a/tests/testdata/npm/compare_globals/main.ts +++ b/tests/testdata/npm/compare_globals/main.ts @@ -17,36 +17,41 @@ controller.abort("reason"); // in the NodeJS declaration it doesn't have a reaso // Some globals are not the same between Node and Deno. // @ts-expect-error incompatible types between Node and Deno -console.log(globalThis.setTimeout === globals.getSetTimeout()); +console.log("setTimeout 1", globalThis.setTimeout === globals.getSetTimeout()); // Super edge case where some Node code deletes a global where the // Node code has its own global and the Deno code has the same global, // but it's different. Basically if some Node code deletes // one of these globals then we don't want it to suddenly inherit // the Deno global (or touch the Deno global at all). -console.log(typeof globalThis.setTimeout); -console.log(typeof globals.getSetTimeout()); +console.log("setTimeout 2", typeof globalThis.setTimeout); +console.log("setTimeout 3", typeof globals.getSetTimeout()); globals.deleteSetTimeout(); -console.log(typeof globalThis.setTimeout); -console.log(typeof globals.getSetTimeout()); +console.log("setTimeout 4", typeof globalThis.setTimeout); +console.log("setTimeout 5", typeof globals.getSetTimeout()); // In Deno, the process global is not defined, but in Node it is. -console.log("process" in globalThis); +console.log("process 1", "process" in globalThis); console.log( + "process 2", Object.getOwnPropertyDescriptor(globalThis, "process") !== undefined, ); globals.checkProcessGlobal(); -// In Deno, the window and self globals are defined, but in Node they are not. -console.log("window" in globalThis); -console.log("self" in globalThis); +// In Deno 2 and Node.js, the window global is not defined. +console.log("window 1", "window" in globalThis); console.log( + "window 2", Object.getOwnPropertyDescriptor(globalThis, "window") !== undefined, ); +globals.checkWindowGlobal(); + +// In Deno 2 self global is defined, but in Node it is not. +console.log("self 1", "self" in globalThis); console.log( + "self 2", Object.getOwnPropertyDescriptor(globalThis, "self") !== undefined, ); -globals.checkWindowGlobal(); globals.checkSelfGlobal(); // "Non-managed" globals are shared between Node and Deno. diff --git a/tests/unit/test_util.ts b/tests/unit/test_util.ts index 16ca735ace..e78afb828e 100644 --- a/tests/unit/test_util.ts +++ b/tests/unit/test_util.ts @@ -25,7 +25,8 @@ export { delay } from "@std/async/delay"; export { readLines } from "@std/io/read-lines"; export { parseArgs } from "@std/cli/parse-args"; -export const DENO_FUTURE = Deno.env.get("DENO_FUTURE") === "1"; +// TODO(2.0): remove this and all the tests that depend on it. +export const DENO_FUTURE = true; export function pathToAbsoluteFileUrl(path: string): URL { path = resolve(path); diff --git a/tests/wpt/runner/expectation.json b/tests/wpt/runner/expectation.json index 2baf043d53..6dfcccf164 100644 --- a/tests/wpt/runner/expectation.json +++ b/tests/wpt/runner/expectation.json @@ -10323,9 +10323,9 @@ "import() should not drain the microtask queue if it fails during specifier resolution", "import() should not drain the microtask queue when loading an already loaded module" ], - "css-import-in-worker.any.worker.html": true, - "with-import-assertions.any.html": true, - "with-import-assertions.any.worker.html": true + "css-import-in-worker.any.worker.html": false, + "with-import-assertions.any.html": false, + "with-import-assertions.any.worker.html": false } }, "import-meta": { diff --git a/tests/wpt/runner/runner.ts b/tests/wpt/runner/runner.ts index b404f2ad8b..6e654fd334 100644 --- a/tests/wpt/runner/runner.ts +++ b/tests/wpt/runner/runner.ts @@ -214,17 +214,20 @@ async function generateBundle(location: URL): Promise { join(ROOT_PATH, "./tests/wpt/runner/testharnessreport.js"), ); const contents = await Deno.readTextFile(url); + scriptContents.push([url.href, "globalThis.window = globalThis;"]); scriptContents.push([url.href, contents]); } else if (src) { const url = new URL(src, location); const res = await fetch(url); if (res.ok) { const contents = await res.text(); + scriptContents.push([url.href, "globalThis.window = globalThis;"]); scriptContents.push([url.href, contents]); } } else { const url = new URL(`#${inlineScriptCount}`, location); inlineScriptCount++; + scriptContents.push([url.href, "globalThis.window = globalThis;"]); scriptContents.push([url.href, script.textContent]); } }