diff --git a/tests/integration/coverage_tests.rs b/tests/integration/coverage_tests.rs index 5353996a0d..1bc3e887a8 100644 --- a/tests/integration/coverage_tests.rs +++ b/tests/integration/coverage_tests.rs @@ -3,7 +3,6 @@ use deno_core::serde_json; use std::fs; use test_util as util; -use test_util::itest; use test_util::TempDir; use util::assert_starts_with; use util::env_vars_for_npm_tests; @@ -631,9 +630,3 @@ File | Branch % | Line % | ", ); } - -itest!(no_files_found { - args: "coverage doesnt_exist.js", - exit_code: 1, - output: "coverage/doesnt_exist.out", -}); diff --git a/tests/integration/flags_tests.rs b/tests/integration/flags_tests.rs index c898c199cc..751f4aafe4 100644 --- a/tests/integration/flags_tests.rs +++ b/tests/integration/flags_tests.rs @@ -1,21 +1,8 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use test_util as util; -use test_util::itest; use util::assert_contains; -#[test] -fn help_flag() { - let status = util::deno_cmd() - .current_dir(util::testdata_path()) - .arg("--help") - .spawn() - .unwrap() - .wait() - .unwrap(); - assert!(status.success()); -} - #[test] fn help_output() { let output = util::deno_cmd() @@ -56,32 +43,3 @@ fn help_output() { assert_contains!(stdout, description); } } - -#[test] -fn version_short_flag() { - let status = util::deno_cmd() - .current_dir(util::testdata_path()) - .arg("-V") - .spawn() - .unwrap() - .wait() - .unwrap(); - assert!(status.success()); -} - -#[test] -fn version_long_flag() { - let status = util::deno_cmd() - .current_dir(util::testdata_path()) - .arg("--version") - .spawn() - .unwrap() - .wait() - .unwrap(); - assert!(status.success()); -} - -itest!(types { - args: "types", - output: "types/types.out", -}); diff --git a/tests/integration/jsr_tests.rs b/tests/integration/jsr_tests.rs index f78bea92d9..307398fc54 100644 --- a/tests/integration/jsr_tests.rs +++ b/tests/integration/jsr_tests.rs @@ -4,87 +4,11 @@ use deno_core::serde_json::json; use deno_core::serde_json::Value; use deno_lockfile::Lockfile; use test_util as util; -use test_util::itest; use url::Url; use util::assert_contains; use util::assert_not_contains; -use util::env_vars_for_jsr_npm_tests; -use util::env_vars_for_jsr_tests; use util::TestContextBuilder; -itest!(no_module_graph_run { - args: "run jsr/no_module_graph/main.ts", - output: "jsr/no_module_graph/main.out", - envs: env_vars_for_jsr_tests(), - http_server: true, -}); - -itest!(no_module_graph_info { - args: "info jsr/no_module_graph/main.ts", - output: "jsr/no_module_graph/main_info.out", - envs: env_vars_for_jsr_tests(), - http_server: true, -}); - -itest!(same_package_multiple_versions { - args: "run --quiet jsr/no_module_graph/multiple.ts", - output: "jsr/no_module_graph/multiple.out", - envs: env_vars_for_jsr_tests(), - http_server: true, -}); - -itest!(module_graph_run { - args: "run jsr/module_graph/main.ts", - output: "jsr/module_graph/main.out", - envs: env_vars_for_jsr_tests(), - http_server: true, -}); - -itest!(module_graph_info { - args: "info jsr/module_graph/main.ts", - output: "jsr/module_graph/main_info.out", - envs: env_vars_for_jsr_tests(), - http_server: true, -}); - -itest!(deps_run { - args: "run jsr/deps/main.ts", - output: "jsr/deps/main.out", - envs: env_vars_for_jsr_tests(), - http_server: true, -}); - -itest!(deps_info { - args: "info jsr/deps/main.ts", - output: "jsr/deps/main_info.out", - envs: env_vars_for_jsr_tests(), - http_server: true, -}); - -itest!(import_https_url_analyzable { - args: "run -A jsr/import_https_url/analyzable.ts", - output: "jsr/import_https_url/analyzable.out", - envs: env_vars_for_jsr_tests(), - http_server: true, - exit_code: 1, -}); - -itest!(import_https_url_unanalyzable { - args: "run -A jsr/import_https_url/unanalyzable.ts", - output: "jsr/import_https_url/unanalyzable.out", - envs: env_vars_for_jsr_tests(), - http_server: true, - exit_code: 1, -}); - -itest!(subset_type_graph { - args: "check --all jsr/subset_type_graph/main.ts", - output: "jsr/subset_type_graph/main.check.out", - envs: env_vars_for_jsr_tests(), - http_server: true, - exit_code: 1, -}); - #[test] fn fast_check_cache() { let test_context = TestContextBuilder::for_jsr().use_temp_cwd().build(); @@ -197,14 +121,6 @@ export function asdf(a: number) { let err: number = ''; return Math.random(); } ); } -itest!(version_not_found { - args: "run jsr/version_not_found/main.ts", - output: "jsr/version_not_found/main.out", - envs: env_vars_for_jsr_tests(), - http_server: true, - exit_code: 1, -}); - #[test] fn specifiers_in_lockfile() { let test_context = TestContextBuilder::for_jsr().use_temp_cwd().build(); @@ -478,19 +394,3 @@ fn set_lockfile_pkg_integrity( .unwrap() .integrity = integrity.to_string(); } - -itest!(jsx_with_no_pragmas { - args: "run jsr/jsx_with_no_pragmas/main.ts", - output: "jsr/jsx_with_no_pragmas/main.out", - envs: env_vars_for_jsr_npm_tests(), - http_server: true, - exit_code: 1, -}); - -itest!(jsx_with_pragmas { - args: "run jsr/jsx_with_pragmas/main.ts", - output: "jsr/jsx_with_pragmas/main.out", - envs: env_vars_for_jsr_npm_tests(), - http_server: true, - exit_code: 0, -}); diff --git a/tests/integration/jupyter_tests.rs b/tests/integration/jupyter_tests.rs deleted file mode 100644 index 5478612585..0000000000 --- a/tests/integration/jupyter_tests.rs +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -use test_util::itest; - -itest!(jupyter_install_command_not_exists { - args: "jupyter --install", - output: "jupyter/install_command_not_exists.out", - envs: vec![("PATH".to_string(), "".to_string())], - exit_code: 1, -}); diff --git a/tests/integration/mod.rs b/tests/integration/mod.rs index 9253cae32e..40dd880b54 100644 --- a/tests/integration/mod.rs +++ b/tests/integration/mod.rs @@ -38,8 +38,6 @@ mod install; mod js_unit_tests; #[path = "jsr_tests.rs"] mod jsr; -#[path = "jupyter_tests.rs"] -mod jupyter; #[path = "lint_tests.rs"] mod lint; #[path = "lsp_tests.rs"] diff --git a/tests/specs/coverage/no_files_found/__test__.jsonc b/tests/specs/coverage/no_files_found/__test__.jsonc new file mode 100644 index 0000000000..3637b41fe3 --- /dev/null +++ b/tests/specs/coverage/no_files_found/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "coverage does_not_exit.js", + "output": "does_not_exist.out", + "exitCode": 1 +} diff --git a/tests/testdata/coverage/doesnt_exist.out b/tests/specs/coverage/no_files_found/does_not_exist.out similarity index 100% rename from tests/testdata/coverage/doesnt_exist.out rename to tests/specs/coverage/no_files_found/does_not_exist.out diff --git a/tests/specs/flags/help_flag/__test__.jsonc b/tests/specs/flags/help_flag/__test__.jsonc new file mode 100644 index 0000000000..4cf04538bc --- /dev/null +++ b/tests/specs/flags/help_flag/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "--help", + "output": "[WILDCARD]" +} diff --git a/tests/specs/flags/types/__test__.jsonc b/tests/specs/flags/types/__test__.jsonc new file mode 100644 index 0000000000..ce0d61d348 --- /dev/null +++ b/tests/specs/flags/types/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "types", + "output": "types.out" +} diff --git a/tests/testdata/types/types.out b/tests/specs/flags/types/types.out similarity index 100% rename from tests/testdata/types/types.out rename to tests/specs/flags/types/types.out diff --git a/tests/specs/flags/version_flag/__test__.jsonc b/tests/specs/flags/version_flag/__test__.jsonc new file mode 100644 index 0000000000..e8c3c16468 --- /dev/null +++ b/tests/specs/flags/version_flag/__test__.jsonc @@ -0,0 +1,9 @@ +{ + "steps": [{ + "args": "-V", + "output": "[WILDCARD]" + }, { + "args": "--version", + "output": "[WILDCARD]" + }] +} diff --git a/tests/specs/jsr/deps/__test__.jsonc b/tests/specs/jsr/deps/__test__.jsonc new file mode 100644 index 0000000000..2528003b51 --- /dev/null +++ b/tests/specs/jsr/deps/__test__.jsonc @@ -0,0 +1,11 @@ +{ + "base": "jsr", + "steps": [{ + "args": "run main.ts", + "output": "main.out" + }, { + "cleanDenoDir": true, + "args": "info main.ts", + "output": "main_info.out" + }] +} diff --git a/tests/testdata/jsr/deps/main.out b/tests/specs/jsr/deps/main.out similarity index 100% rename from tests/testdata/jsr/deps/main.out rename to tests/specs/jsr/deps/main.out diff --git a/tests/testdata/jsr/deps/main.ts b/tests/specs/jsr/deps/main.ts similarity index 100% rename from tests/testdata/jsr/deps/main.ts rename to tests/specs/jsr/deps/main.ts diff --git a/tests/testdata/jsr/deps/main_info.out b/tests/specs/jsr/deps/main_info.out similarity index 100% rename from tests/testdata/jsr/deps/main_info.out rename to tests/specs/jsr/deps/main_info.out diff --git a/tests/specs/jsr/import_https_url/__test__.jsonc b/tests/specs/jsr/import_https_url/__test__.jsonc new file mode 100644 index 0000000000..597b8e009e --- /dev/null +++ b/tests/specs/jsr/import_https_url/__test__.jsonc @@ -0,0 +1,13 @@ +{ + "base": "jsr", + "steps": [{ + "args": "run -A analyzable.ts", + "output": "analyzable.out", + "exitCode": 1 + }, { + "cleanDenoDir": true, + "args": "run -A nonanalyzable.ts", + "output": "nonanalyzable.out", + "exitCode": 1 + }] +} diff --git a/tests/testdata/jsr/import_https_url/analyzable.out b/tests/specs/jsr/import_https_url/analyzable.out similarity index 100% rename from tests/testdata/jsr/import_https_url/analyzable.out rename to tests/specs/jsr/import_https_url/analyzable.out diff --git a/tests/testdata/jsr/import_https_url/analyzable.ts b/tests/specs/jsr/import_https_url/analyzable.ts similarity index 100% rename from tests/testdata/jsr/import_https_url/analyzable.ts rename to tests/specs/jsr/import_https_url/analyzable.ts diff --git a/tests/testdata/jsr/import_https_url/unanalyzable.out b/tests/specs/jsr/import_https_url/nonanalyzable.out similarity index 100% rename from tests/testdata/jsr/import_https_url/unanalyzable.out rename to tests/specs/jsr/import_https_url/nonanalyzable.out diff --git a/tests/testdata/jsr/import_https_url/unanalyzable.ts b/tests/specs/jsr/import_https_url/nonanalyzable.ts similarity index 100% rename from tests/testdata/jsr/import_https_url/unanalyzable.ts rename to tests/specs/jsr/import_https_url/nonanalyzable.ts diff --git a/tests/specs/jsr/jsx_with_no_pragmas/__test__.jsonc b/tests/specs/jsr/jsx_with_no_pragmas/__test__.jsonc new file mode 100644 index 0000000000..c2a269ea64 --- /dev/null +++ b/tests/specs/jsr/jsx_with_no_pragmas/__test__.jsonc @@ -0,0 +1,6 @@ +{ + "base": "jsr", + "args": "run main.ts", + "output": "main.out", + "exitCode": 1 +} diff --git a/tests/testdata/jsr/jsx_with_no_pragmas/main.out b/tests/specs/jsr/jsx_with_no_pragmas/main.out similarity index 100% rename from tests/testdata/jsr/jsx_with_no_pragmas/main.out rename to tests/specs/jsr/jsx_with_no_pragmas/main.out diff --git a/tests/testdata/jsr/jsx_with_no_pragmas/main.ts b/tests/specs/jsr/jsx_with_no_pragmas/main.ts similarity index 100% rename from tests/testdata/jsr/jsx_with_no_pragmas/main.ts rename to tests/specs/jsr/jsx_with_no_pragmas/main.ts diff --git a/tests/specs/jsr/jsx_with_pragmas/__test__.jsonc b/tests/specs/jsr/jsx_with_pragmas/__test__.jsonc new file mode 100644 index 0000000000..a6fa5c7c3f --- /dev/null +++ b/tests/specs/jsr/jsx_with_pragmas/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "base": "jsr", + "args": "run main.ts", + "output": "main.out" +} diff --git a/tests/testdata/jsr/jsx_with_pragmas/main.out b/tests/specs/jsr/jsx_with_pragmas/main.out similarity index 100% rename from tests/testdata/jsr/jsx_with_pragmas/main.out rename to tests/specs/jsr/jsx_with_pragmas/main.out diff --git a/tests/testdata/jsr/jsx_with_pragmas/main.ts b/tests/specs/jsr/jsx_with_pragmas/main.ts similarity index 100% rename from tests/testdata/jsr/jsx_with_pragmas/main.ts rename to tests/specs/jsr/jsx_with_pragmas/main.ts diff --git a/tests/specs/jsr/module_graph/__test__.jsonc b/tests/specs/jsr/module_graph/__test__.jsonc new file mode 100644 index 0000000000..2528003b51 --- /dev/null +++ b/tests/specs/jsr/module_graph/__test__.jsonc @@ -0,0 +1,11 @@ +{ + "base": "jsr", + "steps": [{ + "args": "run main.ts", + "output": "main.out" + }, { + "cleanDenoDir": true, + "args": "info main.ts", + "output": "main_info.out" + }] +} diff --git a/tests/testdata/jsr/module_graph/main.out b/tests/specs/jsr/module_graph/main.out similarity index 100% rename from tests/testdata/jsr/module_graph/main.out rename to tests/specs/jsr/module_graph/main.out diff --git a/tests/testdata/jsr/module_graph/main.ts b/tests/specs/jsr/module_graph/main.ts similarity index 100% rename from tests/testdata/jsr/module_graph/main.ts rename to tests/specs/jsr/module_graph/main.ts diff --git a/tests/testdata/jsr/module_graph/main_info.out b/tests/specs/jsr/module_graph/main_info.out similarity index 100% rename from tests/testdata/jsr/module_graph/main_info.out rename to tests/specs/jsr/module_graph/main_info.out diff --git a/tests/specs/jsr/no_module_graph/__test__.jsonc b/tests/specs/jsr/no_module_graph/__test__.jsonc new file mode 100644 index 0000000000..b3915ecef7 --- /dev/null +++ b/tests/specs/jsr/no_module_graph/__test__.jsonc @@ -0,0 +1,14 @@ +{ + "base": "jsr", + "steps": [{ + "args": "run main.ts", + "output": "main.out" + }, { + "cleanDenoDir": true, + "args": "info main.ts", + "output": "main_info.out" + }, { + "args": "run --quiet multiple.ts", + "output": "multiple.out" + }] +} diff --git a/tests/testdata/jsr/no_module_graph/main.out b/tests/specs/jsr/no_module_graph/main.out similarity index 100% rename from tests/testdata/jsr/no_module_graph/main.out rename to tests/specs/jsr/no_module_graph/main.out diff --git a/tests/testdata/jsr/no_module_graph/main.ts b/tests/specs/jsr/no_module_graph/main.ts similarity index 100% rename from tests/testdata/jsr/no_module_graph/main.ts rename to tests/specs/jsr/no_module_graph/main.ts diff --git a/tests/testdata/jsr/no_module_graph/main_info.out b/tests/specs/jsr/no_module_graph/main_info.out similarity index 100% rename from tests/testdata/jsr/no_module_graph/main_info.out rename to tests/specs/jsr/no_module_graph/main_info.out diff --git a/tests/testdata/jsr/no_module_graph/multiple.out b/tests/specs/jsr/no_module_graph/multiple.out similarity index 100% rename from tests/testdata/jsr/no_module_graph/multiple.out rename to tests/specs/jsr/no_module_graph/multiple.out diff --git a/tests/testdata/jsr/no_module_graph/multiple.ts b/tests/specs/jsr/no_module_graph/multiple.ts similarity index 100% rename from tests/testdata/jsr/no_module_graph/multiple.ts rename to tests/specs/jsr/no_module_graph/multiple.ts diff --git a/tests/specs/jsr/subset_type_graph/__test__.jsonc b/tests/specs/jsr/subset_type_graph/__test__.jsonc new file mode 100644 index 0000000000..85d04ed54d --- /dev/null +++ b/tests/specs/jsr/subset_type_graph/__test__.jsonc @@ -0,0 +1,6 @@ +{ + "base": "jsr", + "args": "check --all main.ts", + "output": "main.check.out", + "exitCode": 1 +} diff --git a/tests/testdata/jsr/subset_type_graph/main.check.out b/tests/specs/jsr/subset_type_graph/main.check.out similarity index 100% rename from tests/testdata/jsr/subset_type_graph/main.check.out rename to tests/specs/jsr/subset_type_graph/main.check.out diff --git a/tests/testdata/jsr/subset_type_graph/main.ts b/tests/specs/jsr/subset_type_graph/main.ts similarity index 100% rename from tests/testdata/jsr/subset_type_graph/main.ts rename to tests/specs/jsr/subset_type_graph/main.ts diff --git a/tests/specs/jsr/version_not_found/__test__.jsonc b/tests/specs/jsr/version_not_found/__test__.jsonc new file mode 100644 index 0000000000..36335985fe --- /dev/null +++ b/tests/specs/jsr/version_not_found/__test__.jsonc @@ -0,0 +1,6 @@ +{ + "base": "jsr", + "args": "run -A main.ts", + "output": "main.out", + "exitCode": 1 +} diff --git a/tests/testdata/jsr/version_not_found/main.out b/tests/specs/jsr/version_not_found/main.out similarity index 100% rename from tests/testdata/jsr/version_not_found/main.out rename to tests/specs/jsr/version_not_found/main.out diff --git a/tests/testdata/jsr/version_not_found/main.ts b/tests/specs/jsr/version_not_found/main.ts similarity index 100% rename from tests/testdata/jsr/version_not_found/main.ts rename to tests/specs/jsr/version_not_found/main.ts diff --git a/tests/specs/jupyter/install_command_not_exists/__test__.jsonc b/tests/specs/jupyter/install_command_not_exists/__test__.jsonc new file mode 100644 index 0000000000..9552157bd4 --- /dev/null +++ b/tests/specs/jupyter/install_command_not_exists/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "args": "jupyter --install", + "output": "install_command_not_exists.out", + "envs": { + "PATH": "" + }, + "exitCode": 1 +} diff --git a/tests/testdata/jupyter/install_command_not_exists.out b/tests/specs/jupyter/install_command_not_exists/install_command_not_exists.out similarity index 100% rename from tests/testdata/jupyter/install_command_not_exists.out rename to tests/specs/jupyter/install_command_not_exists/install_command_not_exists.out diff --git a/tests/specs/mod.rs b/tests/specs/mod.rs index d010de43de..feed098711 100644 --- a/tests/specs/mod.rs +++ b/tests/specs/mod.rs @@ -1,6 +1,7 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use std::cell::RefCell; +use std::collections::HashMap; use std::collections::HashSet; use std::panic::AssertUnwindSafe; use std::rc::Rc; @@ -127,15 +128,13 @@ fn run_test(test: &Test, diagnostic_logger: Rc>>) { context.deno_dir().path().remove_dir_all(); } - let test_output_path = cwd.join(&step.output); - if !test_output_path.to_string_lossy().ends_with(".out") { - panic!( - "Use the .out extension for output files (invalid: {})", - test_output_path - ); - } - let expected_output = test_output_path.read_to_string(); - let command = context.new_command(); + let expected_output = if step.output.ends_with(".out") { + let test_output_path = cwd.join(&step.output); + test_output_path.read_to_string() + } else { + step.output.clone() + }; + let command = context.new_command().envs(&step.envs); let command = match &step.args { VecOrString::Vec(args) => command.args_vec(args), VecOrString::String(text) => command.args(text), @@ -195,6 +194,8 @@ struct StepMetaData { #[serde(default)] pub clean_deno_dir: bool, pub args: VecOrString, + #[serde(default)] + pub envs: HashMap, pub output: String, #[serde(default)] pub exit_code: i32, @@ -283,14 +284,6 @@ fn collect_tests() -> Vec { let test_dir = PathRef::new(entry.path()); let metadata_path = test_dir.join("__test__.jsonc"); - if !metadata_path.is_file() { - let json_path = test_dir.join("__test__.json"); - if json_path.is_file() { - // automatically rename to jsonc - json_path.rename(&metadata_path); - } - } - let metadata_value = metadata_path.read_jsonc_value(); // checking for "steps" leads to a more targeted error message // instead of when deserializing an untagged enum