Skip to content

Commit 3a6e8c7

Browse files
committed
test(formatter): treat tests with syntax errors as passed (#15936)
Skip tests with syntax errors, since it's not the formatter's fault
1 parent a280187 commit 3a6e8c7

File tree

4 files changed

+5
-71
lines changed

4 files changed

+5
-71
lines changed

tasks/coverage/snapshots/formatter_babel.snap

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,4 @@ commit: c92c4919
22

33
formatter_babel Summary:
44
AST Parsed : 2440/2440 (100.00%)
5-
Positive Passed: 2421/2440 (99.22%)
6-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/annex-b/enabled/valid-assignment-target-type/input.js
7-
Cannot assign to this expression
8-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/annex-b/enabled/valid-assignment-target-type-createParenthesizedExpressions/input.js
9-
Cannot assign to this expression
10-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2022/top-level-await-unambiguous/module/input.js
11-
`await` is only allowed within async functions and at the top levels of modules
12-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2026/async-explicit-resource-management/valid-module-block-top-level-using-binding/input.js
13-
Expected a semicolon or an implicit semicolon after a statement, but found none
14-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2026/explicit-resource-management/valid-for-await-using-binding-escaped-of-of/input.mjs
15-
Keywords cannot contain escape charactersExpected `)` but found `of`
16-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2026/explicit-resource-management/valid-for-using-binding-escaped-of-of/input.js
17-
Keywords cannot contain escape charactersExpected `)` but found `of`
18-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2026/explicit-resource-management/valid-for-using-declaration-binding-of/input.js
19-
Unexpected token
20-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2026/explicit-resource-management/valid-module-block-top-level-using-binding/input.js
21-
Expected a semicolon or an implicit semicolon after a statement, but found none
22-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/arrow-function/generic-tsx-babel-7/input.ts
23-
Unexpected token. Did you mean `{'>'}` or `>`?
24-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/explicit-resource-management/valid-for-using-declaration-binding-of/input.js
25-
Unexpected token
26-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-param/input.ts
27-
Expected `,` or `)` but found `extends`
28-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/regression/nested-extends-in-arrow-type-param-babel-7/input.ts
29-
Expected `,` or `)` but found `extends`
30-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/type-arguments-bit-shift-left-like/class-heritage/input.ts
31-
Expected `{` but found `<<`
32-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/type-arguments-bit-shift-left-like/class-heritage-babel-7/input.ts
33-
Expected `{` but found `<<`
34-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/type-arguments-bit-shift-left-like/interface-heritage/input.ts
35-
Expected `{` but found `<<`
36-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/type-arguments-bit-shift-left-like/jsx-opening-element/input.tsx
37-
Unexpected token
38-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/type-arguments-bit-shift-left-like/jsx-opening-element-babel-7/input.tsx
39-
Unexpected token
40-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/type-arguments-bit-shift-left-like-babel-7/class-heritage/input.ts
41-
Expected `{` but found `<<`
42-
Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/type-arguments-bit-shift-left-like-babel-7/jsx-opening-element/input.tsx
43-
Unexpected token
5+
Positive Passed: 2440/2440 (100.00%)

tasks/coverage/snapshots/formatter_test262.snap

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,10 @@ commit: c125a8dc
22

33
formatter_test262 Summary:
44
AST Parsed : 44973/44973 (100.00%)
5-
Positive Passed: 44962/44973 (99.98%)
6-
Expect to Parse: tasks/coverage/test262/test/annexB/language/expressions/assignmenttargettype/callexpression-as-for-in-lhs.js
7-
Cannot assign to this expression
8-
Expect to Parse: tasks/coverage/test262/test/annexB/language/expressions/assignmenttargettype/callexpression-as-for-of-lhs.js
9-
Cannot assign to this expression
10-
Expect to Parse: tasks/coverage/test262/test/annexB/language/expressions/assignmenttargettype/callexpression-in-compound-assignment.js
11-
Cannot assign to this expression
12-
Expect to Parse: tasks/coverage/test262/test/annexB/language/expressions/assignmenttargettype/callexpression-in-postfix-update.js
13-
Cannot assign to this expression
14-
Expect to Parse: tasks/coverage/test262/test/annexB/language/expressions/assignmenttargettype/callexpression-in-prefix-update.js
15-
Cannot assign to this expression
16-
Expect to Parse: tasks/coverage/test262/test/annexB/language/expressions/assignmenttargettype/callexpression.js
17-
Cannot assign to this expression
18-
Expect to Parse: tasks/coverage/test262/test/annexB/language/expressions/assignmenttargettype/cover-callexpression-and-asyncarrowhead.js
19-
Cannot assign to this expression
5+
Positive Passed: 44970/44973 (99.99%)
206
Mismatch: tasks/coverage/test262/test/built-ins/Function/prototype/toString/line-terminator-normalisation-CR-LF.js
217

228
Mismatch: tasks/coverage/test262/test/built-ins/Function/prototype/toString/line-terminator-normalisation-CR.js
239

2410
Mismatch: tasks/coverage/test262/test/built-ins/Function/prototype/toString/line-terminator-normalisation-LF.js
2511

26-
Expect to Parse: tasks/coverage/test262/test/language/statements/using/syntax/using-for-statement.js
27-
Unexpected token

tasks/coverage/snapshots/formatter_typescript.snap

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,11 @@ commit: cc2610fd
22

33
formatter_typescript Summary:
44
AST Parsed : 9822/9822 (100.00%)
5-
Positive Passed: 9810/9822 (99.88%)
5+
Positive Passed: 9815/9822 (99.93%)
66
Mismatch: tasks/coverage/typescript/tests/cases/compiler/amdLikeInputDeclarationEmit.ts
77

8-
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/arrayFromAsync.ts
9-
`await` is only allowed within async functions and at the top levels of modules`await` is only allowed within async functions and at the top levels of modules`await` is only allowed within async functions and at the top levels of modules`await` is only allowed within async functions and at the top levels of modules`await` is only allowed within async functions and at the top levels of modules`await` is only allowed within async functions and at the top levels of modules`await` is only allowed within async functions and at the top levels of modules`await` is only allowed within async functions and at the top levels of modules`await` is only allowed within async functions and at the top levels of modules`await` is only allowed within async functions and at the top levels of modules`await` is only allowed within async functions and at the top levels of modules
108
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/genericTypeAssertions3.ts
119
Unexpected token
12-
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/modulePreserveTopLevelAwait1.ts
13-
`await` is only allowed within async functions and at the top levels of modules`await` is only allowed within async functions and at the top levels of modules
14-
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/sourceMapValidationDecorators.ts
15-
Unexpected token
1610
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/typeAssertionToGenericFunctionType.ts
1711
Unexpected token
1812
Mismatch: tasks/coverage/typescript/tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts
@@ -21,9 +15,5 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/expressions/e
2115
Unexpected token
2216
Mismatch: tasks/coverage/typescript/tests/cases/conformance/generators/yieldStatementNoAsiAfterTransform.ts
2317

24-
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.1.ts
25-
Using declaration cannot appear in the bare case statement.Using declaration cannot appear in the bare case statement.Using declaration cannot appear in the bare case statement.
26-
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.1.ts
27-
Using declaration cannot appear in the bare case statement.Using declaration cannot appear in the bare case statement.Using declaration cannot appear in the bare case statement.
2818
Mismatch: tasks/coverage/typescript/tests/cases/conformance/statements/returnStatements/returnStatementNoAsiAfterTransform.ts
2919

tasks/coverage/src/tools/formatter.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ fn get_result(source_text: &str, source_type: SourceType) -> TestResult {
2424
Parser::new(&allocator, source_text, source_type).with_options(get_parse_options()).parse();
2525

2626
if !errors.is_empty() {
27-
return TestResult::ParseError(
28-
errors.iter().map(std::string::ToString::to_string).collect(),
29-
false,
30-
);
27+
// Skip test if input source code has parse errors
28+
return TestResult::Passed;
3129
}
3230

3331
let source_text1 = Formatter::new(&allocator, options.clone()).build(&program);

0 commit comments

Comments
 (0)