summaryrefslogtreecommitdiff
path: root/tests/specs/mod.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-04-27 17:11:57 -0400
committerGitHub <noreply@github.com>2024-04-27 21:11:57 +0000
commit651e3e9e6daf3243dd21b7f66ce9738abdc39a37 (patch)
tree0417415c1a5fa79d0ae5d8f0f75561138275e34e /tests/specs/mod.rs
parente0f849289fdb2c2d86f7fb04182c37012ce2bb69 (diff)
fix(compile): certain jsr specifiers sometimes can't load (#23567)
When returning a jsr specifier for resolve it seems like deno core does not work properly and hangs. Closes https://github.com/denoland/deno/issues/23551 Closes https://github.com/denoland/deno/issues/23139
Diffstat (limited to 'tests/specs/mod.rs')
-rw-r--r--tests/specs/mod.rs25
1 files changed, 22 insertions, 3 deletions
diff --git a/tests/specs/mod.rs b/tests/specs/mod.rs
index 2040eea62..16a9e6f05 100644
--- a/tests/specs/mod.rs
+++ b/tests/specs/mod.rs
@@ -73,6 +73,8 @@ struct StepMetaData {
pub clean_deno_dir: bool,
pub args: VecOrString,
pub cwd: Option<String>,
+ #[serde(rename = "if")]
+ pub if_cond: Option<String>,
pub command_name: Option<String>,
#[serde(default)]
pub envs: HashMap<String, String>,
@@ -152,8 +154,11 @@ fn run_test(test: &CollectedTest, diagnostic_logger: Rc<RefCell<Vec<u8>>>) {
// todo(dsherret): add bases in the future as needed
Some(base) => panic!("Unknown test base: {}", base),
None => {
- // by default add npm and jsr env vars
- builder = builder.add_jsr_env_vars().add_npm_env_vars();
+ // by default add all these
+ builder = builder
+ .add_jsr_env_vars()
+ .add_npm_env_vars()
+ .add_compile_env_vars();
}
}
@@ -167,7 +172,7 @@ fn run_test(test: &CollectedTest, diagnostic_logger: Rc<RefCell<Vec<u8>>>) {
cwd.copy_to_recursive_with_exclusions(temp_dir, &assertion_paths);
}
- for step in &metadata.steps {
+ for step in metadata.steps.iter().filter(|s| should_run_step(s)) {
if step.clean_deno_dir {
context.deno_dir().path().remove_dir_all();
}
@@ -198,6 +203,20 @@ fn run_test(test: &CollectedTest, diagnostic_logger: Rc<RefCell<Vec<u8>>>) {
}
}
+fn should_run_step(step: &StepMetaData) -> bool {
+ if let Some(cond) = &step.if_cond {
+ match cond.as_str() {
+ "windows" => cfg!(windows),
+ "unix" => cfg!(unix),
+ "mac" => cfg!(target_os = "macos"),
+ "linux" => cfg!(target_os = "linux"),
+ value => panic!("Unknown if condition: {}", value),
+ }
+ } else {
+ true
+ }
+}
+
fn resolve_test_and_assertion_files(
dir: &PathRef,
metadata: &MultiTestMetaData,