Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions rust/execution/counterfactual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,34 @@ pub(crate) async fn run_one(
} else {
approval.timeout()
};
let mut args = Vec::new();
if target.file.ends_with(".ts")
let ts_mode = target.file.ends_with(".ts")
|| target.file.ends_with(".mts")
|| target.file.ends_with(".cts")
{
|| owner.root().join("tsconfig.json").is_file();
let run_node = if ts_mode {
tools::find_modern_node(node)
} else {
node.to_path_buf()
};
let mut args = Vec::new();
if ts_mode {
for cand in [
Some(owner.root().join("node_modules")),
owner
.root()
.parent()
.and_then(Path::parent)
.map(|p| p.join("node_modules")),
]
.into_iter()
.flatten()
{
if cand.is_dir() {
env.insert("ROSTER_NODE_MODULES".to_owned(), cand.display().to_string());
break;
}
}
args.push("--experimental-transform-types".to_owned());
args.push("--import".to_owned());
args.push(tools::TS_IMPORT_HOOK.to_owned());
}
Expand All @@ -217,7 +240,7 @@ pub(crate) async fn run_one(
return owner
.run(
directory,
node,
&run_node,
&args,
&env,
approval.timeout(),
Expand Down
7 changes: 5 additions & 2 deletions rust/execution/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub fn relevant_tests(files: &[String]) -> Result<Vec<String>, Error> {
return Ok(Vec::new());
}
let pattern = regex(
r"(?:^tests?/.+\.[cm]?[jt]s$|(?:^|/)(?:test(?:[._-][^/]+)?|[^/]+[._-](?:test|spec))\.[cm]?[jt]s$)",
r"(?:^(?:tests?|__tests__)/.+\.[cm]?[jt]s$|(?:^|/)__tests__/.+\.[cm]?[jt]s$|(?:^|/)(?:test(?:[._-][^/]+)?|[^/]+[._-](?:test|spec))\.[cm]?[jt]s$)",
)?;
let extension = regex(r"\.[cm]?[jt]s$")?;
let mut tests = Vec::new();
Expand Down Expand Up @@ -240,7 +240,10 @@ pub fn verification_decision(files: &[String]) -> Result<Value, Error> {
let update = relevant_tests(files)?
.into_iter()
.filter(|file| {
files.contains(file) || file.starts_with("tests/") || file.starts_with("test/")
files.contains(file)
|| file.starts_with("tests/")
|| file.starts_with("test/")
|| file.starts_with("__tests__/")
})
.collect::<Vec<_>>();
Ok(Value::object(vec![
Expand Down
Loading
Loading