Skip to content

Commit

Permalink
refactor(transform_conformance): correctly handle BABEL_8_BREAKING (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen authored Apr 15, 2024
1 parent 6532799 commit b4bfa2f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
4 changes: 2 additions & 2 deletions tasks/transform_conformance/babel.snap.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Passed: 94/228
Passed: 93/227

# All Passed:
* babel-plugin-transform-react-jsx-source
Expand Down Expand Up @@ -137,7 +137,7 @@ Passed: 94/228
* regression/another-preset-with-custom-jsx-keep-source-self/input.mjs
* regression/runtime-classic-allow-multiple-source-self/input.mjs

# babel-plugin-transform-react-jsx (34/37)
# babel-plugin-transform-react-jsx (33/36)
* autoImport/auto-import-react-source-type-module/input.js
* autoImport/complicated-scope-module/input.js
* autoImport/react-defined/input.js
Expand Down
25 changes: 9 additions & 16 deletions tasks/transform_conformance/src/test_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,16 @@ pub trait TestCase {
return true;
}

let dir = self.path().parent().unwrap();
// Skip Babel 7 specific tests
// https://github.com/babel/babel/issues/10746
// We implement Babel 8 breaking changes under the BABEL_8_BREAKING env flag.
// To test the breaking changes, please duplicate the affected tests with the -babel-7 suffix and add BABEL_8_BREAKING: false to test options.
if dir
.file_name()
.is_some_and(|file_name| file_name.to_string_lossy().ends_with("-babel-7"))
{
return true;
}

// Skip deprecated react options
if options.babel_8_breaking.is_some_and(|b| b) {
if let Ok(options) = self.transform_options() {
if options.react.use_built_ins.is_some() || options.react.use_spread.is_some() {
if let Some(b) = options.babel_8_breaking {
if b {
// Skip deprecated react options
if self.transform_options().as_ref().is_ok_and(|options| {
options.react.use_built_ins.is_some() || options.react.use_spread.is_some()
}) {
return true;
}
} else {
return true;
}
}

Expand All @@ -166,6 +158,7 @@ pub trait TestCase {

// 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
let dir = self.path().parent().unwrap();
if dir.file_name().is_some_and(|n| n.to_string_lossy().starts_with('.')) {
return true;
}
Expand Down

0 comments on commit b4bfa2f

Please sign in to comment.