summaryrefslogtreecommitdiff
path: root/tests/specs/mod.rs
diff options
context:
space:
mode:
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,