From 0346e597bf2d95f5bfce20d3aadf697e9ee45fe4 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 25 Mar 2024 18:20:15 -0400 Subject: feat(lint): automatically opt-in packages to `jsr` lint tag (#23072) This automatically opts packages (deno.json's with a name, version, and exports field) into the "jsr" lint tag. --- tests/specs/mod.rs | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'tests/specs/mod.rs') diff --git a/tests/specs/mod.rs b/tests/specs/mod.rs index feed09871..3eb8bb386 100644 --- a/tests/specs/mod.rs +++ b/tests/specs/mod.rs @@ -128,19 +128,22 @@ fn run_test(test: &Test, diagnostic_logger: Rc>>) { context.deno_dir().path().remove_dir_all(); } - 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), }; + let command = match &step.cwd { + Some(cwd) => command.current_dir(cwd), + None => command, + }; let output = command.run(); - output.assert_matches_text(expected_output); + if step.output.ends_with(".out") { + let test_output_path = cwd.join(&step.output); + output.assert_matches_file(test_output_path); + } else { + output.assert_matches_text(&step.output); + } output.assert_exit_code(step.exit_code); } } @@ -194,6 +197,7 @@ struct StepMetaData { #[serde(default)] pub clean_deno_dir: bool, pub args: VecOrString, + pub cwd: Option, #[serde(default)] pub envs: HashMap, pub output: String, @@ -299,12 +303,23 @@ fn collect_tests() -> Vec { } .with_context(|| format!("Failed to parse {}", metadata_path)) .unwrap(); + + let test_name = + format!("{}::{}", category.name, entry.file_name().to_string_lossy()); + + // only support characters that work with filtering with `cargo test` + if !test_name + .chars() + .all(|c| c.is_alphanumeric() || matches!(c, '_' | ':')) + { + panic!( + "Invalid test name (only supports alphanumeric and underscore): {}", + test_name + ); + } + category.tests.push(Test { - name: format!( - "{}::{}", - category.name, - entry.file_name().to_string_lossy() - ), + name: test_name, cwd: test_dir, metadata, }); -- cgit v1.2.3