Skip to content

Commit

Permalink
fix(transform_conformance): only run exec tests when specified
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Nov 19, 2024
1 parent d608012 commit ecf4bbf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 4 additions & 4 deletions tasks/transform_conformance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl TestRunner {
let _ = fs::remove_dir_all(&fixture_root);
let _ = fs::create_dir(&fixture_root);
}
let transform_paths = Self::generate_test_cases(root, self.options.filter.as_ref());
let transform_paths = Self::generate_test_cases(root, &self.options);
self.generate_snapshot(root, &snap_root().join(snapshot), transform_paths);
if self.options.exec {
self.run_vitest(&snap_root().join(exec_snapshot));
Expand All @@ -90,7 +90,7 @@ impl TestRunner {

fn generate_test_cases(
root: &Path,
filter: Option<&String>,
options: &TestRunnerOptions,
) -> IndexMap<String, Vec<TestCase>> {
let cwd = root.parent().unwrap_or(root);
// use `IndexMap` to keep the order of the test cases the same in insert order.
Expand All @@ -103,7 +103,7 @@ impl TestRunner {
.into_iter()
.filter_map(Result::ok)
.filter(|e| {
if let Some(filter) = filter {
if let Some(filter) = &options.filter {
if !e.path().to_string_lossy().contains(filter) {
return false;
}
Expand All @@ -113,7 +113,7 @@ impl TestRunner {
.filter_map(|e| TestCase::new(cwd, e.path()))
.filter(|test_case| !test_case.skip_test_case())
.map(|mut case| {
case.test(filter.is_some());
case.test(options);
case
})
.collect::<Vec<_>>();
Expand Down
11 changes: 8 additions & 3 deletions tasks/transform_conformance/src/test_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use oxc_tasks_common::{normalize_path, print_diff_in_terminal, project_root};
use crate::{
constants::{PLUGINS_NOT_SUPPORTED_YET, SKIP_TESTS, SNAPSHOT_TESTS},
driver::Driver,
fixture_root, oxc_test_root, packages_root, snap_root,
fixture_root, oxc_test_root, packages_root, snap_root, TestRunnerOptions,
};

#[derive(Debug)]
Expand Down Expand Up @@ -190,10 +190,15 @@ impl TestCase {
Ok(driver.printed())
}

pub fn test(&mut self, filtered: bool) {
pub fn test(&mut self, options: &TestRunnerOptions) {
let filtered = options.filter.is_some();
match self.kind {
TestCaseKind::Conformance => self.test_conformance(filtered),
TestCaseKind::Exec => self.test_exec(filtered),
TestCaseKind::Exec => {
if options.exec {
self.test_exec(filtered);
}
}
TestCaseKind::Snapshot => self.test_snapshot(filtered),
}
}
Expand Down

0 comments on commit ecf4bbf

Please sign in to comment.