summaryrefslogtreecommitdiff
path: root/tests/specs/mod.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-03-15 15:46:51 -0400
committerGitHub <noreply@github.com>2024-03-15 15:46:51 -0400
commite40f9a5c14c51b6d05812e48fa072148fe79c74d (patch)
treee492e91717c7ddda3e31139f870706870449cdde /tests/specs/mod.rs
parent392579b5a673964752e38e1e0d9c2c9ae223a382 (diff)
chore: move more tests away from itest (#22909)
Part of #22907
Diffstat (limited to 'tests/specs/mod.rs')
-rw-r--r--tests/specs/mod.rs27
1 files changed, 10 insertions, 17 deletions
diff --git a/tests/specs/mod.rs b/tests/specs/mod.rs
index d010de43d..feed09871 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<RefCell<Vec<u8>>>) {
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<String, String>,
pub output: String,
#[serde(default)]
pub exit_code: i32,
@@ -283,14 +284,6 @@ fn collect_tests() -> Vec<TestCategory> {
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