Skip to content

Commit

Permalink
feat(tasks): skip cases start with dot (#1114)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysteryven authored Oct 30, 2023
1 parent 103268b commit 8105ee5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
9 changes: 3 additions & 6 deletions tasks/transform_conformance/babel.snap.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Passed: 241/1083
Passed: 241/1080

# All Passed:
* babel-plugin-transform-numeric-separator
Expand Down Expand Up @@ -275,7 +275,7 @@ Passed: 241/1083
* regression/T6719/input.js
* regression/T7364/input.mjs

# babel-plugin-transform-class-static-block (6/22)
# babel-plugin-transform-class-static-block (6/21)
* class-static-block/preserve-comments/input.js
* integration/class-binding/input.js
* integration/class-declaration/input.js
Expand All @@ -284,7 +284,6 @@ Passed: 241/1083
* integration/name-conflict/input.js
* integration/new-target/input.js
* integration/preserve-comments/input.js
* integration-loose/.new-target/input.js
* integration-loose/class-binding/input.js
* integration-loose/class-declaration/input.js
* integration-loose/in-class-heritage/input.js
Expand Down Expand Up @@ -804,7 +803,7 @@ Passed: 241/1083
* regression/11061/input.mjs
* variable-declaration/non-null-in-optional-chain/input.ts

# babel-plugin-transform-react-jsx (92/172)
# babel-plugin-transform-react-jsx (92/170)
* autoImport/after-polyfills-compiled-to-cjs/input.mjs
* autoImport/after-polyfills-script-not-supported/input.js
* autoImport/auto-import-react-source-type-module/input.js
Expand All @@ -828,7 +827,6 @@ Passed: 241/1083
* pure/unset-pragma-comment-classic-runtime/input.js
* pure/unset-pragma-option-automatic-runtime/input.js
* pure/unset-pragma-option-classic-runtime/input.js
* react/.should-properly-handle-comments-adjacent-to-children/input.js
* react/adds-appropriate-newlines-when-using-spread-attribute-babel-7/input.js
* react/arrow-functions/input.js
* react/assignment-babel-7/input.js
Expand All @@ -854,7 +852,6 @@ Passed: 241/1083
* react/wraps-props-in-react-spread-for-first-spread-attributes-babel-7/input.js
* react/wraps-props-in-react-spread-for-last-spread-attributes-babel-7/input.js
* react/wraps-props-in-react-spread-for-middle-spread-attributes-babel-7/input.js
* react-automatic/.should-properly-handle-comments-adjacent-to-children/input.js
* react-automatic/arrow-functions/input.js
* react-automatic/does-not-add-source-self-automatic/input.mjs
* react-automatic/handle-nonstatic-children/input.js
Expand Down
2 changes: 1 addition & 1 deletion tasks/transform_conformance/babel_exec.snap.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Passed: 350/409
Passed: 349/408

# All Passed:
* babel-plugin-transform-class-static-block
Expand Down
18 changes: 18 additions & 0 deletions tasks/transform_conformance/src/test_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ pub trait TestCase {

fn test(&self, filter: Option<&str>) -> bool;

fn path(&self) -> &Path;

fn transform_options(&self) -> TransformOptions {
fn get_options<T: Default + DeserializeOwned>(value: Option<Value>) -> T {
value.and_then(|v| serde_json::from_value::<T>(v).ok()).unwrap_or_default()
Expand Down Expand Up @@ -122,6 +124,14 @@ pub trait TestCase {
{
return true;
}

// babel skip test cases that in a directory starting with a dot
// https://github.com/babel/babel/blob/0effd92d886b7135469d23612ceba6414c721673/packages/babel-helper-fixtures/src/index.ts#L223
if self.path().parent().is_some_and(|p| {
p.file_name().is_some_and(|n| n.to_str().map_or(false, |s| s.starts_with('.')))
}) {
return true;
}
false
}

Expand Down Expand Up @@ -161,6 +171,10 @@ impl TestCase for ConformanceTestCase {
&self.options
}

fn path(&self) -> &Path {
&self.path
}

/// Test conformance by comparing the parsed babel code and transformed code.
fn test(&self, filter: Option<&str>) -> bool {
let filtered = filter.is_some_and(|f| self.path.to_string_lossy().as_ref().contains(f));
Expand Down Expand Up @@ -260,6 +274,10 @@ impl TestCase for ExecTestCase {
&self.options
}

fn path(&self) -> &Path {
&self.path
}

fn new<P: Into<PathBuf>>(path: P) -> Self {
let path = path.into();
let options = BabelOptions::from_path(path.parent().unwrap());
Expand Down

0 comments on commit 8105ee5

Please sign in to comment.