Skip to content

Commit

Permalink
chore: deprecate eval itests (#25382)
Browse files Browse the repository at this point in the history
This PR serves as a part of #22907 .

---------

Signed-off-by: David Sherret <[email protected]>
Co-authored-by: Bartek Iwańczuk <[email protected]>
Co-authored-by: David Sherret <[email protected]>
  • Loading branch information
3 people authored Sep 3, 2024
1 parent b8ed6f8 commit 1d04c84
Show file tree
Hide file tree
Showing 26 changed files with 53 additions and 66 deletions.
63 changes: 0 additions & 63 deletions tests/integration/eval_tests.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -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",
});
4 changes: 4 additions & 0 deletions tests/specs/eval/check_local/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "eval --quiet import('http://localhost:4545/subdir/type_error.ts').then(console.log);",
"output": "main.out"
}
File renamed without changes.
4 changes: 4 additions & 0 deletions tests/specs/eval/check_local_by_default2/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "eval --quiet import('./check_local_by_default2.ts').then(console.log);",
"output": "main.out"
}
4 changes: 4 additions & 0 deletions tests/specs/eval/dyn_import_eval/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "eval import('./mod4.js').then(console.log)",
"output": "main.out"
}
File renamed without changes.
1 change: 1 addition & 0 deletions tests/specs/eval/dyn_import_eval/mod4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const isMod4 = true;
4 changes: 4 additions & 0 deletions tests/specs/eval/env_file/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "eval --env-file=env_file console.log(Deno.env.get(\"ANOTHER_FOO\"));",
"output": "main.out"
}
4 changes: 4 additions & 0 deletions tests/specs/eval/env_file/env_file
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FOO=BAR
ANOTHER_FOO=ANOTHER_${FOO}
MULTILINE="First Line
Second Line"
1 change: 1 addition & 0 deletions tests/specs/eval/env_file/main.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ANOTHER_BAR
4 changes: 4 additions & 0 deletions tests/specs/eval/env_file_missing/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "eval --env-file=missing console.log(Deno.env.get(\"ANOTHER_FOO\"));",
"output": "main.out"
}
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/specs/eval/env_unparsable_file/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -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"
}
4 changes: 4 additions & 0 deletions tests/specs/eval/env_unparsable_file/env_unparsable
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FOO=valid
ANOTHER_FOO=c:\path
MULTILINE="First Line
Second Line"
2 changes: 1 addition & 1 deletion tests/specs/eval/env_unparsable_file/main.out
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions tests/specs/eval/eval_basic/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "eval console.log(\"hello\")",
"output": "main.out"
}
1 change: 1 addition & 0 deletions tests/specs/eval/eval_basic/main.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello
4 changes: 4 additions & 0 deletions tests/specs/eval/eval_p/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "eval -p 1+2",
"output": "main.out"
}
1 change: 1 addition & 0 deletions tests/specs/eval/eval_p/main.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
4 changes: 4 additions & 0 deletions tests/specs/eval/eval_ts/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "eval --quiet --ext=ts console.log((123)as(number))",
"output": "main.out"
}
1 change: 1 addition & 0 deletions tests/specs/eval/eval_ts/main.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
123
4 changes: 4 additions & 0 deletions tests/specs/eval/v8_flags_eval/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "eval --v8-flags=--expose-gc console.log(typeof(gc))",
"output": "main.out"
}
1 change: 1 addition & 0 deletions tests/specs/eval/v8_flags_eval/main.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function
2 changes: 1 addition & 1 deletion tools/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1d04c84

Please sign in to comment.