Skip to content

Commit 76d49f8

Browse files
committed
test(ast/estree): ignore serde_json errors (#10660)
Related to #9705. Ignore errors from `serde_json` failing to parse JSON AST from `acorn-test262` TS-ESLint parser fixtures. These errors are due to deficiencies in `serde_json` and don't represent real problems. When we switch over to comparing ASTs as JSON strings (as we do in the Acorn and JSX tests), these problems should disappear.
1 parent fd18aaa commit 76d49f8

File tree

2 files changed

+10
-48
lines changed

2 files changed

+10
-48
lines changed

tasks/coverage/snapshots/estree_typescript.snap

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@ commit: 15392346
22

33
estree_typescript Summary:
44
AST Parsed : 6489/6493 (99.94%)
5-
Positive Passed: 6458/6493 (99.46%)
5+
Positive Passed: 6470/6493 (99.65%)
66
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/arrayFromAsync.ts
77
`await` is only allowed within async functions and at the top levels of modules
88

99
Mismatch: tasks/coverage/typescript/tests/cases/compiler/controlFlowInstanceofWithSymbolHasInstance.ts
1010

11-
serde_json::from_str(oxc_json) Error: tasks/coverage/typescript/tests/cases/compiler/deferredConditionalTypes2.ts
12-
number out of range at line 28 column 25
13-
1411
Mismatch: tasks/coverage/typescript/tests/cases/compiler/emitBundleWithShebang1.ts
1512

1613
Mismatch: tasks/coverage/typescript/tests/cases/compiler/emitBundleWithShebang2.ts
@@ -19,17 +16,8 @@ Mismatch: tasks/coverage/typescript/tests/cases/compiler/emitBundleWithShebangAn
1916

2017
Mismatch: tasks/coverage/typescript/tests/cases/compiler/emitBundleWithShebangAndPrologueDirectives2.ts
2118

22-
serde_json::from_str(oxc_json) Error: tasks/coverage/typescript/tests/cases/compiler/fakeInfinity2.ts
23-
number out of range at line 46 column 31
24-
25-
serde_json::from_str(oxc_json) Error: tasks/coverage/typescript/tests/cases/compiler/fakeInfinity3.ts
26-
number out of range at line 46 column 31
27-
2819
Mismatch: tasks/coverage/typescript/tests/cases/compiler/narrowingUnionToUnion.ts
2920

30-
serde_json::from_str(oxc_json) Error: tasks/coverage/typescript/tests/cases/compiler/parsingDeepParenthensizedExpression.ts
31-
recursion limit exceeded at line 3334 column 269
32-
3321
Mismatch: tasks/coverage/typescript/tests/cases/compiler/shebang.ts
3422

3523
Mismatch: tasks/coverage/typescript/tests/cases/compiler/shebangBeforeReferences.ts
@@ -43,32 +31,8 @@ Classes may not have a static property named prototype
4331
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/es2019/importMeta/importMeta.ts
4432
The only valid meta property for import is import.meta
4533

46-
serde_json::from_str(oxc_json) Error: tasks/coverage/typescript/tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/binaryIntegerLiteral.ts
47-
number out of range at line 129 column 27
48-
49-
serde_json::from_str(oxc_json) Error: tasks/coverage/typescript/tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/binaryIntegerLiteralES6.ts
50-
number out of range at line 129 column 27
51-
52-
serde_json::from_str(oxc_json) Error: tasks/coverage/typescript/tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/octalIntegerLiteral.ts
53-
number out of range at line 96 column 27
54-
55-
serde_json::from_str(oxc_json) Error: tasks/coverage/typescript/tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/octalIntegerLiteralES6.ts
56-
number out of range at line 96 column 27
57-
5834
Mismatch: tasks/coverage/typescript/tests/cases/conformance/es6/templates/templateStringMultiline3.ts
5935

60-
serde_json::from_str(oxc_json) Error: tasks/coverage/typescript/tests/cases/conformance/es6/unicodeExtendedEscapes/unicodeExtendedEscapesInStrings10.ts
61-
unexpected end of hex escape at line 30 column 29
62-
63-
serde_json::from_str(oxc_json) Error: tasks/coverage/typescript/tests/cases/conformance/es6/unicodeExtendedEscapes/unicodeExtendedEscapesInStrings11.ts
64-
lone leading surrogate in hex escape at line 30 column 28
65-
66-
serde_json::from_str(oxc_json) Error: tasks/coverage/typescript/tests/cases/conformance/es6/unicodeExtendedEscapes/unicodeExtendedEscapesInTemplates10.ts
67-
unexpected end of hex escape at line 38 column 36
68-
69-
serde_json::from_str(oxc_json) Error: tasks/coverage/typescript/tests/cases/conformance/es6/unicodeExtendedEscapes/unicodeExtendedEscapesInTemplates11.ts
70-
lone leading surrogate in hex escape at line 38 column 35
71-
7236
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/esDecorators/esDecorators-decoratorExpression.1.ts
7337
Expected a semicolon or an implicit semicolon after a statement, but found none
7438

tasks/coverage/src/tools/estree.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,15 @@ impl Case for EstreeTypescriptCase {
322322

323323
let oxc_json = program.to_pretty_estree_ts_json();
324324

325-
// Compare as objects to ignore field order differences for now
325+
// Compare as objects to ignore field order differences for now.
326+
//
327+
// Also ignore failure to parse ESTree JSON. These failures are just due to `serde` being
328+
// unable to handle lone surrogates in strings and numbers which are to big to fit in an `f64`.
329+
// These should match once we switch to comparing ASTs as JSON strings.
330+
let Ok(estree_json_value) = serde_json::from_str::<serde_json::Value>(estree_json)
331+
else {
332+
continue;
333+
};
326334
let mut oxc_json_value = match serde_json::from_str::<serde_json::Value>(&oxc_json) {
327335
Ok(v) => v,
328336
Err(e) => {
@@ -331,16 +339,6 @@ impl Case for EstreeTypescriptCase {
331339
return;
332340
}
333341
};
334-
let estree_json_value = match serde_json::from_str::<serde_json::Value>(estree_json) {
335-
Ok(v) => v,
336-
Err(e) => {
337-
self.base.result = TestResult::GenericError(
338-
"serde_json::from_str(estree_json)",
339-
e.to_string(),
340-
);
341-
return;
342-
}
343-
};
344342
if oxc_json_value == estree_json_value {
345343
continue;
346344
}

0 commit comments

Comments
 (0)