1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 08:39:09 -05:00

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 <ashersaupingomez@gmail.com>
Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
Co-authored-by: Nathan Whitaker <nathan@deno.com>
This commit is contained in:
Bartek Iwańczuk 2024-08-30 18:58:58 +01:00 committed by GitHub
parent 4639ae655e
commit b1c6142f74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
64 changed files with 406 additions and 377 deletions

View file

@ -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()
}

View file

@ -117,8 +117,8 @@ pub static DENO_DISABLE_PEDANTIC_NODE_WARNINGS: Lazy<bool> = Lazy::new(|| {
.is_some()
});
pub static DENO_FUTURE: Lazy<bool> =
Lazy::new(|| std::env::var("DENO_FUTURE").ok().is_some());
// TODO(2.0): remove this in a follow up.
pub static DENO_FUTURE: Lazy<bool> = Lazy::new(|| true);
pub fn jsr_url() -> &'static Url {
static JSR_URL: Lazy<Url> = 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(),

View file

@ -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;
}

View file

@ -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()

View file

@ -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();

View file

@ -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() {

View file

@ -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(

View file

@ -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",

View file

@ -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"),

View file

@ -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!({

View file

@ -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/"),

View file

@ -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()

View file

@ -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/")

View file

@ -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",

View file

@ -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",

View file

@ -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());

View file

@ -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");
});
"#,

View file

@ -1,5 +1,13 @@
{
"tempDir": true,
"args": "bench",
"output": "lib.bench.out"
"steps": [
{
"args": "install",
"output": "install.out"
},
{
"args": "bench",
"output": "lib.bench.out"
}
]
}

View file

@ -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

View file

@ -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]

View file

@ -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"
}

View file

@ -9,6 +9,7 @@
"echo_test",
"--root",
"$PWD",
"-g",
"https://localhost:5545/echo.ts"
],
"output": "[WILDCARD]"

View file

@ -1,3 +1,3 @@
{
"nodeModulesDir": true
"nodeModules": "local-auto"
}

View file

@ -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
}

View file

@ -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" }

View file

@ -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": ""
}
]
}

View file

@ -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");
}

View file

@ -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]

View file

@ -1,3 +0,0 @@
import { setValue } from "npm:@denotest/esm-basic";
setValue(5);

View file

@ -1,6 +0,0 @@
{
"name": "deno-test-bin",
"dependencies": {
"@denotest/esm-basic": "*"
}
}

View file

@ -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": [

View file

@ -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",

View file

@ -1,5 +1,5 @@
{
"nodeModulesDir": true,
"nodeModules": "local-auto",
"tasks": {
"cat": "cat",
"rm_node_modules": "rm -rf node_modules"

View file

@ -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"
}

View file

@ -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"
}

View file

@ -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"
}

View file

@ -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"
}
]

View file

@ -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 <entrypoint>`):
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 <entrypoint>` or `deno install --allow-scripts=pkg1,pkg2`):
npm:@denotest/node-lifecycle-scripts@1.0.0

View file

@ -1,3 +1,3 @@
{
"nodeModulesDir": true
"nodeModules": "local-auto"
}

View file

@ -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 <entrypoint>`):
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 <entrypoint>` 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]

View file

@ -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 <entrypoint>`):
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 <entrypoint>` 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]

View file

@ -1,5 +1,5 @@
{
"nodeModulesDir": true,
"nodeModules": "local-auto",
"imports": {
"preact": "npm:preact",
"preact-render-to-string": "npm:preact-render-to-string"

View file

@ -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

View file

@ -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"
}
}

View file

@ -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
}

View file

@ -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

View file

@ -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"
},

View file

@ -1,4 +1,4 @@
{
// will cause a warning
"nodeModulesDir": true
"nodeModules": "local-auto"
}

View file

@ -1,3 +1,3 @@
{
"nodeModulesDir": true
"nodeModules": "local-auto"
}

View file

@ -1,4 +1,4 @@
{
"args": "run --node-modules-dir=false main.ts",
"args": "run --node-modules=global-auto main.ts",
"output": "main.out"
}

View file

@ -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",

View file

@ -4,5 +4,5 @@
"exports": {
".": "./mod.ts"
},
"nodeModulesDir": false
"nodeModules": "global-auto"
}

View file

@ -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"

View file

@ -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": {

View file

@ -1,6 +1,8 @@
{
"tests": {
"assertion": {
// TODO(2.0): disable import assertion support in TS.
"ignore": true,
"steps": [{
"args": "run assertion.ts",
"exitCode": 1,

View file

@ -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

View file

@ -1,3 +1,3 @@
{
"nodeModulesDir": true
"nodeModules": "local-auto"
}

View file

@ -1,5 +1,5 @@
{
"nodeModulesDir": true,
"nodeModules": "local-auto",
"tasks": {
"repro": "echo hi"
}

View file

@ -1,6 +1,6 @@
{
// not byonm
"nodeModulesDir": true,
"nodeModules": "local-auto",
"tasks": {
"say": "npx cowsay moo"
}

View file

@ -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

View file

@ -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.

View file

@ -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);

View file

@ -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": {

View file

@ -214,17 +214,20 @@ async function generateBundle(location: URL): Promise<string> {
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]);
}
}