mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
fix(coverage): match Babel's options.json inheritance for test fixtures (#19002)
## Summary - Fix Babel test fixture options.json inheritance to match `@babel/helper-fixtures` behavior - Babel's hierarchy: task → suite → category. Suite options.json REPLACES (not merges) category plugins - Previously `expect-plugin` tests incorrectly inherited TypeScript plugin from parent category - Fixes 3 tests: `export-interface`, `export-type`, `export-type-named` **Results:** Negative Passed improved from 1660/1689 (98.28%) to 1663/1689 (98.46%) 🤖 Generated with [Claude Code](https://claude.ai/code)
This commit is contained in:
2 files changed
+34
-10
No files matched your search
@@ -117,28 +117,39 @@ fn default_as_true() -> bool {
|
||||
|
||||
impl BabelOptions {
|
||||
/// Read options.json and merge them with options.json from ancestors directories.
|
||||
///
|
||||
/// Babel's fixture hierarchy: task → suite → category.
|
||||
/// Suite options.json REPLACES category plugins (not merge).
|
||||
///
|
||||
/// # Panics
|
||||
pub fn from_test_path(path: &Path) -> Self {
|
||||
let mut babel_options: Option<Self> = None;
|
||||
let mut plugins_json = None;
|
||||
let mut presets_json = None;
|
||||
// Track if suite level (level 1) has options.json - if so, skip category plugins
|
||||
let mut suite_has_options = false;
|
||||
|
||||
for path in path.ancestors().take(3) {
|
||||
for (level, path) in path.ancestors().take(3).enumerate() {
|
||||
let file = path.join("options.json");
|
||||
if !file.exists() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if level == 1 {
|
||||
suite_has_options = true;
|
||||
}
|
||||
|
||||
let content = std::fs::read_to_string(&file).unwrap();
|
||||
let mut new_value = serde_json::from_str::<serde_json::Value>(&content).unwrap();
|
||||
|
||||
let new_plugins = new_value.as_object_mut().unwrap().remove("plugins");
|
||||
if plugins_json.is_none() {
|
||||
// Skip category (level 2) plugins if suite (level 1) has options.json
|
||||
if plugins_json.is_none() && !(level == 2 && suite_has_options) {
|
||||
plugins_json = new_plugins;
|
||||
}
|
||||
|
||||
let new_presets = new_value.as_object_mut().unwrap().remove("presets");
|
||||
if presets_json.is_none() {
|
||||
if presets_json.is_none() && !(level == 2 && suite_has_options) {
|
||||
presets_json = new_presets;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ commit: 92c052dc
|
||||
parser_babel Summary:
|
||||
AST Parsed : 2224/2224 (100.00%)
|
||||
Positive Passed: 2211/2224 (99.42%)
|
||||
Negative Passed: 1665/1689 (98.58%)
|
||||
Negative Passed: 1668/1689 (98.76%)
|
||||
Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2026/explicit-resource-management/invalid-for-using-of-no-initializer/input.js
|
||||
|
||||
Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/cast/unparenthesized-assert-and-assign/input.ts
|
||||
@@ -34,12 +34,6 @@ Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/ty
|
||||
|
||||
Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/dts/invalid-class-initializer/input.ts
|
||||
|
||||
Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-interface/input.js
|
||||
|
||||
Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-type/input.js
|
||||
|
||||
Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-type-named/input.js
|
||||
|
||||
Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/export/equals-in-script/input.ts
|
||||
|
||||
Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/import/equals-in-script/input.ts
|
||||
@@ -13208,6 +13202,25 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc
|
||||
╰────
|
||||
help: Try inserting a semicolon here
|
||||
|
||||
× Unexpected token
|
||||
╭─[babel/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-interface/input.js:1:8]
|
||||
1 │ export interface Foo {}
|
||||
· ─────────
|
||||
╰────
|
||||
|
||||
× Unexpected token
|
||||
╭─[babel/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-type/input.js:1:8]
|
||||
1 │ export type Foo = number;
|
||||
· ────
|
||||
╰────
|
||||
|
||||
× Unexpected token
|
||||
╭─[babel/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-type-named/input.js:2:8]
|
||||
1 │ var Foo;
|
||||
2 │ export type { Foo };
|
||||
· ────
|
||||
╰────
|
||||
|
||||
× Unexpected exponentiation expression
|
||||
╭─[babel/packages/babel-parser/test/fixtures/typescript/exponentiation/await-non-null-before-exponential/input.ts:1:14]
|
||||
1 │ async (a) => await a! ** 6;
|
||||
|
||||
Reference in new issue
Block a user