From e40f9a5c14c51b6d05812e48fa072148fe79c74d Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 15 Mar 2024 15:46:51 -0400 Subject: [PATCH] chore: move more tests away from itest (#22909) Part of #22907 --- tests/integration/coverage_tests.rs | 7 -- tests/integration/flags_tests.rs | 42 -------- tests/integration/jsr_tests.rs | 100 ------------------ tests/integration/jupyter_tests.rs | 10 -- tests/integration/mod.rs | 2 - .../coverage/no_files_found/__test__.jsonc | 5 + .../no_files_found/does_not_exist.out} | 0 tests/specs/flags/help_flag/__test__.jsonc | 4 + tests/specs/flags/types/__test__.jsonc | 4 + .../{testdata => specs/flags}/types/types.out | 0 tests/specs/flags/version_flag/__test__.jsonc | 9 ++ tests/specs/jsr/deps/__test__.jsonc | 11 ++ tests/{testdata => specs}/jsr/deps/main.out | 0 tests/{testdata => specs}/jsr/deps/main.ts | 0 .../jsr/deps/main_info.out | 0 .../specs/jsr/import_https_url/__test__.jsonc | 13 +++ .../jsr/import_https_url/analyzable.out | 0 .../jsr/import_https_url/analyzable.ts | 0 .../jsr/import_https_url/nonanalyzable.out} | 0 .../jsr/import_https_url/nonanalyzable.ts} | 0 .../jsr/jsx_with_no_pragmas/__test__.jsonc | 6 ++ .../jsr/jsx_with_no_pragmas/main.out | 0 .../jsr/jsx_with_no_pragmas/main.ts | 0 .../specs/jsr/jsx_with_pragmas/__test__.jsonc | 5 + .../jsr/jsx_with_pragmas/main.out | 0 .../jsr/jsx_with_pragmas/main.ts | 0 tests/specs/jsr/module_graph/__test__.jsonc | 11 ++ .../jsr/module_graph/main.out | 0 .../jsr/module_graph/main.ts | 0 .../jsr/module_graph/main_info.out | 0 .../specs/jsr/no_module_graph/__test__.jsonc | 14 +++ .../jsr/no_module_graph/main.out | 0 .../jsr/no_module_graph/main.ts | 0 .../jsr/no_module_graph/main_info.out | 0 .../jsr/no_module_graph/multiple.out | 0 .../jsr/no_module_graph/multiple.ts | 0 .../jsr/subset_type_graph/__test__.jsonc | 6 ++ .../jsr/subset_type_graph/main.check.out | 0 .../jsr/subset_type_graph/main.ts | 0 .../jsr/version_not_found/__test__.jsonc | 6 ++ .../jsr/version_not_found/main.out | 0 .../jsr/version_not_found/main.ts | 0 .../install_command_not_exists/__test__.jsonc | 8 ++ .../install_command_not_exists.out | 0 tests/specs/mod.rs | 27 ++--- 45 files changed, 112 insertions(+), 178 deletions(-) delete mode 100644 tests/integration/jupyter_tests.rs create mode 100644 tests/specs/coverage/no_files_found/__test__.jsonc rename tests/{testdata/coverage/doesnt_exist.out => specs/coverage/no_files_found/does_not_exist.out} (100%) create mode 100644 tests/specs/flags/help_flag/__test__.jsonc create mode 100644 tests/specs/flags/types/__test__.jsonc rename tests/{testdata => specs/flags}/types/types.out (100%) create mode 100644 tests/specs/flags/version_flag/__test__.jsonc create mode 100644 tests/specs/jsr/deps/__test__.jsonc rename tests/{testdata => specs}/jsr/deps/main.out (100%) rename tests/{testdata => specs}/jsr/deps/main.ts (100%) rename tests/{testdata => specs}/jsr/deps/main_info.out (100%) create mode 100644 tests/specs/jsr/import_https_url/__test__.jsonc rename tests/{testdata => specs}/jsr/import_https_url/analyzable.out (100%) rename tests/{testdata => specs}/jsr/import_https_url/analyzable.ts (100%) rename tests/{testdata/jsr/import_https_url/unanalyzable.out => specs/jsr/import_https_url/nonanalyzable.out} (100%) rename tests/{testdata/jsr/import_https_url/unanalyzable.ts => specs/jsr/import_https_url/nonanalyzable.ts} (100%) create mode 100644 tests/specs/jsr/jsx_with_no_pragmas/__test__.jsonc rename tests/{testdata => specs}/jsr/jsx_with_no_pragmas/main.out (100%) rename tests/{testdata => specs}/jsr/jsx_with_no_pragmas/main.ts (100%) create mode 100644 tests/specs/jsr/jsx_with_pragmas/__test__.jsonc rename tests/{testdata => specs}/jsr/jsx_with_pragmas/main.out (100%) rename tests/{testdata => specs}/jsr/jsx_with_pragmas/main.ts (100%) create mode 100644 tests/specs/jsr/module_graph/__test__.jsonc rename tests/{testdata => specs}/jsr/module_graph/main.out (100%) rename tests/{testdata => specs}/jsr/module_graph/main.ts (100%) rename tests/{testdata => specs}/jsr/module_graph/main_info.out (100%) create mode 100644 tests/specs/jsr/no_module_graph/__test__.jsonc rename tests/{testdata => specs}/jsr/no_module_graph/main.out (100%) rename tests/{testdata => specs}/jsr/no_module_graph/main.ts (100%) rename tests/{testdata => specs}/jsr/no_module_graph/main_info.out (100%) rename tests/{testdata => specs}/jsr/no_module_graph/multiple.out (100%) rename tests/{testdata => specs}/jsr/no_module_graph/multiple.ts (100%) create mode 100644 tests/specs/jsr/subset_type_graph/__test__.jsonc rename tests/{testdata => specs}/jsr/subset_type_graph/main.check.out (100%) rename tests/{testdata => specs}/jsr/subset_type_graph/main.ts (100%) create mode 100644 tests/specs/jsr/version_not_found/__test__.jsonc rename tests/{testdata => specs}/jsr/version_not_found/main.out (100%) rename tests/{testdata => specs}/jsr/version_not_found/main.ts (100%) create mode 100644 tests/specs/jupyter/install_command_not_exists/__test__.jsonc rename tests/{testdata/jupyter => specs/jupyter/install_command_not_exists}/install_command_not_exists.out (100%) diff --git a/tests/integration/coverage_tests.rs b/tests/integration/coverage_tests.rs index 5353996a0de503..1bc3e887a8d30f 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 c898c199cc51d2..751f4aafe423ae 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 f78bea92d93015..307398fc5475da 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 54786125854ea5..00000000000000 --- 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 9253cae32ed2c8..40dd880b54a7b4 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 00000000000000..3637b41fe356e0 --- /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 00000000000000..4cf04538bc4e04 --- /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 00000000000000..ce0d61d3486fd6 --- /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 00000000000000..e8c3c164689e9a --- /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 00000000000000..2528003b511a19 --- /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 00000000000000..597b8e009efaac --- /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 00000000000000..c2a269ea648bc7 --- /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 00000000000000..a6fa5c7c3f3ee6 --- /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 00000000000000..2528003b511a19 --- /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 00000000000000..b3915ecef7d48d --- /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 00000000000000..85d04ed54ddf23 --- /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 00000000000000..36335985fe50c4 --- /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 00000000000000..9552157bd429cd --- /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 d010de43de9c96..feed098711ba65 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