Skip to content

Commit d27f0fa

Browse files
committed
fix(tasks/prettier_conformance): Skip tests which cannot parse
1 parent bf09033 commit d27f0fa

File tree

4 files changed

+26
-38
lines changed

4 files changed

+26
-38
lines changed

tasks/prettier_conformance/snapshots/prettier.js.snap.md

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
js compatibility: 656/749 (87.58%)
1+
js compatibility: 673/749 (89.85%)
22

33
# Failed
44

@@ -17,27 +17,11 @@ js compatibility: 656/749 (87.58%)
1717
| js/comments/if.js | 💥💥 | 74.83% |
1818
| js/comments/return-statement.js | 💥💥 | 98.28% |
1919
| js/comments/tagged-template-literal.js | 💥💥 | 92.86% |
20-
| js/comments/html-like/comment.js | 💥 | 0.00% |
2120
| js/comments/tagged-template-literal/11662.js | 💥 | 80.00% |
2221
| js/conditional/comments.js | 💥✨ | 23.69% |
2322
| js/conditional/new-ternary-examples.js | 💥✨ | 20.14% |
2423
| js/conditional/new-ternary-spec.js | 💥✨ | 24.35% |
2524
| js/conditional/postfix-ternary-regressions.js | 💥✨ | 20.77% |
26-
| js/discard-binding/array-pattern.js | 💥 | 0.00% |
27-
| js/discard-binding/basic.js | 💥 | 0.00% |
28-
| js/discard-binding/discard-binding-arrow-params.js | 💥 | 0.00% |
29-
| js/discard-binding/discard-binding-assignment.js | 💥 | 0.00% |
30-
| js/discard-binding/discard-binding-async-arrow-params.js | 💥 | 0.00% |
31-
| js/discard-binding/discard-binding-bindings.js | 💥 | 0.00% |
32-
| js/discard-binding/discard-binding-for-await-using-binding.js | 💥 | 0.00% |
33-
| js/discard-binding/discard-binding-for-bindings.js | 💥 | 0.00% |
34-
| js/discard-binding/discard-binding-for-lhs.js | 💥 | 0.00% |
35-
| js/discard-binding/discard-binding-for-using-binding.js | 💥 | 0.00% |
36-
| js/discard-binding/function-parameter.js | 💥 | 0.00% |
37-
| js/discard-binding/object-pattern.js | 💥 | 0.00% |
38-
| js/discard-binding/unary-expression-void.js | 💥 | 0.00% |
39-
| js/discard-binding/using-variable-declarator.js | 💥 | 0.00% |
40-
| js/discard-binding/using.js | 💥 | 0.00% |
4125
| js/explicit-resource-management/for-await-using-of-comments.js | 💥 | 0.00% |
4226
| js/explicit-resource-management/valid-await-using-comments.js | 💥 | 66.67% |
4327
| js/for/9812-unstable.js | 💥 | 45.45% |
@@ -90,7 +74,6 @@ js compatibility: 656/749 (87.58%)
9074
| js/test-declarations/angularjs_inject.js | 💥💥 | 91.53% |
9175
| js/test-declarations/test_declarations.js | 💥💥 | 95.88% |
9276
| js/trailing-comma/dynamic-import.js | 💥💥💥 | 0.00% |
93-
| jsx/expression-with-types/expression.js | 💥💥💥💥 | 0.00% |
9477
| jsx/fbt/test.js | 💥 | 84.06% |
9578
| jsx/jsx/quotes.js | 💥💥💥💥 | 79.41% |
9679
| jsx/jsx/regex.js | 💥💥💥💥 | 75.00% |

tasks/prettier_conformance/snapshots/prettier.ts.snap.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
ts compatibility: 532/598 (88.96%)
1+
ts compatibility: 537/598 (89.80%)
22

33
# Failed
44

55
| Spec path | Failed or Passed | Match ratio |
66
| :-------- | :--------------: | :---------: |
7-
| jsx/expression-with-types/expression.js | 💥💥💥💥 | 0.00% |
87
| jsx/fbt/test.js | 💥 | 84.06% |
98
| jsx/jsx/quotes.js | 💥💥💥💥 | 79.41% |
109
| jsx/jsx/regex.js | 💥💥💥💥 | 75.00% |
@@ -36,9 +35,7 @@ ts compatibility: 532/598 (88.96%)
3635
| typescript/conditional-types/nested-in-condition.ts | 💥✨ | 15.79% |
3736
| typescript/conditional-types/new-ternary-spec.ts | 💥✨ | 10.67% |
3837
| typescript/conditional-types/parentheses.ts | 💥✨ | 15.22% |
39-
| typescript/conformance/types/functions/functionOverloadErrorsSyntax.ts | 💥 | 0.00% |
4038
| typescript/decorators-ts/angular.ts | 💥 | 87.50% |
41-
| typescript/definite/without-annotation.ts | 💥 | 91.67% |
4239
| typescript/import-require/comments.ts | 💥 | 33.33% |
4340
| typescript/import-type/long-module-name/long-module-name2.ts | 💥 | 25.00% |
4441
| typescript/import-type/long-module-name/long-module-name4.ts | 💥 | 89.29% |
@@ -61,8 +58,6 @@ ts compatibility: 532/598 (88.96%)
6158
| typescript/prettier-ignore/mapped-types.ts | 💥 | 96.61% |
6259
| typescript/property-signature/consistent-with-flow/comments.ts | 💥 | 80.00% |
6360
| typescript/property-signature/consistent-with-flow/union.ts | 💥 | 85.71% |
64-
| typescript/type-arguments-bit-shift-left-like/3.ts | 💥 | 0.00% |
65-
| typescript/type-arguments-bit-shift-left-like/5.tsx | 💥 | 0.00% |
6661
| typescript/type-params/18041.ts | 💥 | 43.75% |
6762
| typescript/type-params/constraints-and-default-2.ts | 💥 | 97.60% |
6863
| typescript/type-params/constraints-and-default.ts | 💥 | 87.32% |

tasks/prettier_conformance/src/ignore_list.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ pub const IGNORE_TESTS: &[&str] = &[
7676
// non-standard syntax
7777
"js/deferred-import-evaluation",
7878
"js/bind-expressions",
79-
// Unsupported stage3 features
80-
"tuple-and-record.js",
81-
"js/async-do-expressions",
8279
// Babel plugins (mostly experimental syntaxes)
8380
"js/babel-plugins",
8481
"js/destructuring-private-fields",

tasks/prettier_conformance/src/lib.rs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use similar::TextDiff;
1515
use walkdir::WalkDir;
1616

1717
use oxc_allocator::Allocator;
18-
use oxc_formatter::{FormatOptions, Formatter};
18+
use oxc_formatter::{Formatter, enable_jsx_source_type};
1919
use oxc_parser::{ParseOptions, Parser};
2020
use oxc_span::SourceType;
2121

@@ -240,12 +240,17 @@ impl TestRunner {
240240
)
241241
.unwrap();
242242

243+
let Some(actual) = Self::run_oxc_formatter(path, &source_text, format_options)
244+
else {
245+
// Skip the test if parsing failed
246+
if self.options.debug {
247+
println!(" => Skipped (parsing failed)");
248+
}
249+
continue;
250+
};
251+
243252
let actual = Self::replace_escape_and_eol(
244-
&Self::run_oxc_formatter(
245-
&source_text,
246-
SourceType::from_path(path).unwrap(),
247-
format_options.clone(),
248-
),
253+
&actual,
249254
expected.contains("LF>") || expected.contains("<CR"),
250255
);
251256

@@ -414,12 +419,15 @@ impl TestRunner {
414419
}
415420

416421
fn run_oxc_formatter(
422+
path: &Path,
417423
source_text: &str,
418-
source_type: SourceType,
419-
formatter_options: FormatOptions,
420-
) -> String {
424+
format_options: &oxc_formatter::FormatOptions,
425+
) -> Option<String> {
421426
let allocator = Allocator::default();
422-
let source_type = source_type.with_jsx(source_type.is_javascript());
427+
428+
let source_type = SourceType::from_path(path).unwrap();
429+
let source_type = enable_jsx_source_type(source_type);
430+
423431
let ret = Parser::new(&allocator, source_text, source_type)
424432
.with_options(ParseOptions {
425433
parse_regular_expression: false,
@@ -430,6 +438,11 @@ impl TestRunner {
430438
preserve_parens: false,
431439
})
432440
.parse();
433-
Formatter::new(&allocator, formatter_options).build(&ret.program)
441+
if !ret.errors.is_empty() {
442+
return None;
443+
}
444+
445+
let formatted = Formatter::new(&allocator, format_options.clone()).build(&ret.program);
446+
Some(formatted)
434447
}
435448
}

0 commit comments

Comments
 (0)