From 1d04c84c8f36a88697c82cf98587a5728952314f Mon Sep 17 00:00:00 2001 From: HasanAlrimawi <141642411+HasanAlrimawi@users.noreply.github.com> Date: Tue, 3 Sep 2024 18:14:19 +0300 Subject: [PATCH] chore: deprecate eval itests (#25382) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR serves as a part of #22907 . --------- Signed-off-by: David Sherret Co-authored-by: Bartek IwaƄczuk Co-authored-by: David Sherret --- tests/integration/eval_tests.rs | 63 ------------------- tests/specs/eval/check_local/__test__.jsonc | 4 ++ .../eval/check_local/main.out} | 0 .../check_local_by_default2/__test__.jsonc | 4 ++ .../check_local_by_default2.ts | 0 .../eval/check_local_by_default2/main.out} | 0 .../specs/eval/dyn_import_eval/__test__.jsonc | 4 ++ .../eval/dyn_import_eval/main.out} | 0 tests/specs/eval/dyn_import_eval/mod4.js | 1 + tests/specs/eval/env_file/__test__.jsonc | 4 ++ tests/specs/eval/env_file/env_file | 4 ++ tests/specs/eval/env_file/main.out | 1 + .../eval/env_file_missing/__test__.jsonc | 4 ++ .../eval/env_file_missing/main.out} | 0 .../eval/env_unparsable_file/__test__.jsonc | 2 +- .../eval/env_unparsable_file/env_unparsable | 4 ++ tests/specs/eval/env_unparsable_file/main.out | 2 +- tests/specs/eval/eval_basic/__test__.jsonc | 4 ++ tests/specs/eval/eval_basic/main.out | 1 + tests/specs/eval/eval_p/__test__.jsonc | 4 ++ tests/specs/eval/eval_p/main.out | 1 + tests/specs/eval/eval_ts/__test__.jsonc | 4 ++ tests/specs/eval/eval_ts/main.out | 1 + tests/specs/eval/v8_flags_eval/__test__.jsonc | 4 ++ tests/specs/eval/v8_flags_eval/main.out | 1 + tools/lint.js | 2 +- 26 files changed, 53 insertions(+), 66 deletions(-) create mode 100644 tests/specs/eval/check_local/__test__.jsonc rename tests/{testdata/eval/check_local_by_default.out => specs/eval/check_local/main.out} (100%) create mode 100644 tests/specs/eval/check_local_by_default2/__test__.jsonc rename tests/{testdata/eval => specs/eval/check_local_by_default2}/check_local_by_default2.ts (100%) rename tests/{testdata/eval/check_local_by_default2.out => specs/eval/check_local_by_default2/main.out} (100%) create mode 100644 tests/specs/eval/dyn_import_eval/__test__.jsonc rename tests/{testdata/eval/dyn_import_eval.out => specs/eval/dyn_import_eval/main.out} (100%) create mode 100644 tests/specs/eval/dyn_import_eval/mod4.js create mode 100644 tests/specs/eval/env_file/__test__.jsonc create mode 100644 tests/specs/eval/env_file/env_file create mode 100644 tests/specs/eval/env_file/main.out create mode 100644 tests/specs/eval/env_file_missing/__test__.jsonc rename tests/{testdata/eval/env_file_missing.out => specs/eval/env_file_missing/main.out} (100%) create mode 100644 tests/specs/eval/env_unparsable_file/env_unparsable create mode 100644 tests/specs/eval/eval_basic/__test__.jsonc create mode 100644 tests/specs/eval/eval_basic/main.out create mode 100644 tests/specs/eval/eval_p/__test__.jsonc create mode 100644 tests/specs/eval/eval_p/main.out create mode 100644 tests/specs/eval/eval_ts/__test__.jsonc create mode 100644 tests/specs/eval/eval_ts/main.out create mode 100644 tests/specs/eval/v8_flags_eval/__test__.jsonc create mode 100644 tests/specs/eval/v8_flags_eval/main.out diff --git a/tests/integration/eval_tests.rs b/tests/integration/eval_tests.rs index 3f4c6a3a6d..198be3a4e8 100644 --- a/tests/integration/eval_tests.rs +++ b/tests/integration/eval_tests.rs @@ -1,24 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use test_util as util; -use test_util::itest; - -#[test] -fn eval_p() { - let output = util::deno_cmd() - .arg("eval") - .arg("-p") - .arg("1+2") - .stdout_piped() - .spawn() - .unwrap() - .wait_with_output() - .unwrap(); - assert!(output.status.success()); - let stdout_str = - util::strip_ansi_codes(std::str::from_utf8(&output.stdout).unwrap().trim()); - assert_eq!("3", stdout_str); -} // Make sure that snapshot flags don't affect runtime. #[test] @@ -43,48 +25,3 @@ fn eval_randomness() { numbers.dedup(); assert!(numbers.len() > 1); } - -itest!(eval_basic { - args: "eval console.log(\"hello\")", - output_str: Some("hello\n"), -}); - -// Ugly parentheses due to whitespace delimiting problem. -itest!(eval_ts { - args: "eval --quiet --ext=ts console.log((123)as(number))", // 'as' is a TS keyword only - output_str: Some("123\n"), -}); - -itest!(dyn_import_eval { - args: "eval import('./subdir/mod4.js').then(console.log)", - output: "eval/dyn_import_eval.out", -}); - -// Cannot write the expression to evaluate as "console.log(typeof gc)" -// because itest! splits args on whitespace. -itest!(v8_flags_eval { - args: "eval --v8-flags=--expose-gc console.log(typeof(gc))", - output: "run/v8_flags.js.out", -}); - -itest!(check_local_by_default { - args: "eval --quiet import('http://localhost:4545/subdir/type_error.ts').then(console.log);", - output: "eval/check_local_by_default.out", - http_server: true, -}); - -itest!(check_local_by_default2 { - args: "eval --quiet import('./eval/check_local_by_default2.ts').then(console.log);", - output: "eval/check_local_by_default2.out", - http_server: true, -}); - -itest!(env_file { - args: "eval --env=env console.log(Deno.env.get(\"ANOTHER_FOO\"))", - output_str: Some("ANOTHER_BAR\n"), -}); - -itest!(env_file_missing { - args: "eval --env=missing console.log(Deno.env.get(\"ANOTHER_FOO\"))", - output: "eval/env_file_missing.out", -}); diff --git a/tests/specs/eval/check_local/__test__.jsonc b/tests/specs/eval/check_local/__test__.jsonc new file mode 100644 index 0000000000..e9253803c0 --- /dev/null +++ b/tests/specs/eval/check_local/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "eval --quiet import('http://localhost:4545/subdir/type_error.ts').then(console.log);", + "output": "main.out" +} diff --git a/tests/testdata/eval/check_local_by_default.out b/tests/specs/eval/check_local/main.out similarity index 100% rename from tests/testdata/eval/check_local_by_default.out rename to tests/specs/eval/check_local/main.out diff --git a/tests/specs/eval/check_local_by_default2/__test__.jsonc b/tests/specs/eval/check_local_by_default2/__test__.jsonc new file mode 100644 index 0000000000..b6188b8cee --- /dev/null +++ b/tests/specs/eval/check_local_by_default2/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "eval --quiet import('./check_local_by_default2.ts').then(console.log);", + "output": "main.out" +} diff --git a/tests/testdata/eval/check_local_by_default2.ts b/tests/specs/eval/check_local_by_default2/check_local_by_default2.ts similarity index 100% rename from tests/testdata/eval/check_local_by_default2.ts rename to tests/specs/eval/check_local_by_default2/check_local_by_default2.ts diff --git a/tests/testdata/eval/check_local_by_default2.out b/tests/specs/eval/check_local_by_default2/main.out similarity index 100% rename from tests/testdata/eval/check_local_by_default2.out rename to tests/specs/eval/check_local_by_default2/main.out diff --git a/tests/specs/eval/dyn_import_eval/__test__.jsonc b/tests/specs/eval/dyn_import_eval/__test__.jsonc new file mode 100644 index 0000000000..34e5734936 --- /dev/null +++ b/tests/specs/eval/dyn_import_eval/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "eval import('./mod4.js').then(console.log)", + "output": "main.out" +} diff --git a/tests/testdata/eval/dyn_import_eval.out b/tests/specs/eval/dyn_import_eval/main.out similarity index 100% rename from tests/testdata/eval/dyn_import_eval.out rename to tests/specs/eval/dyn_import_eval/main.out diff --git a/tests/specs/eval/dyn_import_eval/mod4.js b/tests/specs/eval/dyn_import_eval/mod4.js new file mode 100644 index 0000000000..71332dbc42 --- /dev/null +++ b/tests/specs/eval/dyn_import_eval/mod4.js @@ -0,0 +1 @@ +export const isMod4 = true; diff --git a/tests/specs/eval/env_file/__test__.jsonc b/tests/specs/eval/env_file/__test__.jsonc new file mode 100644 index 0000000000..b2e8f87b8a --- /dev/null +++ b/tests/specs/eval/env_file/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "eval --env-file=env_file console.log(Deno.env.get(\"ANOTHER_FOO\"));", + "output": "main.out" +} diff --git a/tests/specs/eval/env_file/env_file b/tests/specs/eval/env_file/env_file new file mode 100644 index 0000000000..c41732d30b --- /dev/null +++ b/tests/specs/eval/env_file/env_file @@ -0,0 +1,4 @@ +FOO=BAR +ANOTHER_FOO=ANOTHER_${FOO} +MULTILINE="First Line +Second Line" \ No newline at end of file diff --git a/tests/specs/eval/env_file/main.out b/tests/specs/eval/env_file/main.out new file mode 100644 index 0000000000..01fcfbd290 --- /dev/null +++ b/tests/specs/eval/env_file/main.out @@ -0,0 +1 @@ +ANOTHER_BAR diff --git a/tests/specs/eval/env_file_missing/__test__.jsonc b/tests/specs/eval/env_file_missing/__test__.jsonc new file mode 100644 index 0000000000..fc4e463807 --- /dev/null +++ b/tests/specs/eval/env_file_missing/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "eval --env-file=missing console.log(Deno.env.get(\"ANOTHER_FOO\"));", + "output": "main.out" +} diff --git a/tests/testdata/eval/env_file_missing.out b/tests/specs/eval/env_file_missing/main.out similarity index 100% rename from tests/testdata/eval/env_file_missing.out rename to tests/specs/eval/env_file_missing/main.out diff --git a/tests/specs/eval/env_unparsable_file/__test__.jsonc b/tests/specs/eval/env_unparsable_file/__test__.jsonc index cf5e9a99b2..8c8dbf5a94 100644 --- a/tests/specs/eval/env_unparsable_file/__test__.jsonc +++ b/tests/specs/eval/env_unparsable_file/__test__.jsonc @@ -1,4 +1,4 @@ { - "args": "eval --env=../../../testdata/env_unparsable console.log(Deno.env.get(\"Another_FOO\"))", + "args": "eval --env-file=env_unparsable console.log(Deno.env.get(\"ANOTHER_FOO\"));", "output": "main.out" } diff --git a/tests/specs/eval/env_unparsable_file/env_unparsable b/tests/specs/eval/env_unparsable_file/env_unparsable new file mode 100644 index 0000000000..5542b80bc3 --- /dev/null +++ b/tests/specs/eval/env_unparsable_file/env_unparsable @@ -0,0 +1,4 @@ +FOO=valid +ANOTHER_FOO=c:\path +MULTILINE="First Line +Second Line" \ No newline at end of file diff --git a/tests/specs/eval/env_unparsable_file/main.out b/tests/specs/eval/env_unparsable_file/main.out index 18d7856b45..1b3f7047a7 100644 --- a/tests/specs/eval/env_unparsable_file/main.out +++ b/tests/specs/eval/env_unparsable_file/main.out @@ -1,2 +1,2 @@ -Warning Parsing failed within the specified environment file: ../../../testdata/env_unparsable at index: 3 of the value: c:\path +Warning Parsing failed within the specified environment file: env_unparsable at index: 3 of the value: c:\path undefined diff --git a/tests/specs/eval/eval_basic/__test__.jsonc b/tests/specs/eval/eval_basic/__test__.jsonc new file mode 100644 index 0000000000..ebc9732361 --- /dev/null +++ b/tests/specs/eval/eval_basic/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "eval console.log(\"hello\")", + "output": "main.out" +} diff --git a/tests/specs/eval/eval_basic/main.out b/tests/specs/eval/eval_basic/main.out new file mode 100644 index 0000000000..ce01362503 --- /dev/null +++ b/tests/specs/eval/eval_basic/main.out @@ -0,0 +1 @@ +hello diff --git a/tests/specs/eval/eval_p/__test__.jsonc b/tests/specs/eval/eval_p/__test__.jsonc new file mode 100644 index 0000000000..bd34d67e3c --- /dev/null +++ b/tests/specs/eval/eval_p/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "eval -p 1+2", + "output": "main.out" +} diff --git a/tests/specs/eval/eval_p/main.out b/tests/specs/eval/eval_p/main.out new file mode 100644 index 0000000000..00750edc07 --- /dev/null +++ b/tests/specs/eval/eval_p/main.out @@ -0,0 +1 @@ +3 diff --git a/tests/specs/eval/eval_ts/__test__.jsonc b/tests/specs/eval/eval_ts/__test__.jsonc new file mode 100644 index 0000000000..4e8b9c2ae2 --- /dev/null +++ b/tests/specs/eval/eval_ts/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "eval --quiet --ext=ts console.log((123)as(number))", + "output": "main.out" +} diff --git a/tests/specs/eval/eval_ts/main.out b/tests/specs/eval/eval_ts/main.out new file mode 100644 index 0000000000..190a18037c --- /dev/null +++ b/tests/specs/eval/eval_ts/main.out @@ -0,0 +1 @@ +123 diff --git a/tests/specs/eval/v8_flags_eval/__test__.jsonc b/tests/specs/eval/v8_flags_eval/__test__.jsonc new file mode 100644 index 0000000000..23b59d482d --- /dev/null +++ b/tests/specs/eval/v8_flags_eval/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "eval --v8-flags=--expose-gc console.log(typeof(gc))", + "output": "main.out" +} diff --git a/tests/specs/eval/v8_flags_eval/main.out b/tests/specs/eval/v8_flags_eval/main.out new file mode 100644 index 0000000000..e2dbde096f --- /dev/null +++ b/tests/specs/eval/v8_flags_eval/main.out @@ -0,0 +1 @@ +function diff --git a/tools/lint.js b/tools/lint.js index 6784ec6300..d40b1b1fd9 100755 --- a/tools/lint.js +++ b/tools/lint.js @@ -202,7 +202,7 @@ async function ensureNoNewITests() { "compile_tests.rs": 0, "coverage_tests.rs": 0, "doc_tests.rs": 15, - "eval_tests.rs": 9, + "eval_tests.rs": 0, "flags_tests.rs": 0, "fmt_tests.rs": 17, "info_tests.rs": 18,