Skip to content

Commit 099f4f8

Browse files
committed
test(coverage/typescript): Exclude more non-testable units (#12159)
Part of #11582 The filter logic added in the previous PR was not complete, so I fixed it. Also added more non-testable case. ~~For `parser_typescript.snap`, 2 "Expect Syntax Error" entries are newly reported, but they will be handled in the future task.~~
1 parent d39dde9 commit 099f4f8

File tree

7 files changed

+41
-370
lines changed

7 files changed

+41
-370
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
commit: 81c95189
22

33
codegen_typescript Summary:
4-
AST Parsed : 6700/6700 (100.00%)
5-
Positive Passed: 6700/6700 (100.00%)
4+
AST Parsed : 6835/6835 (100.00%)
5+
Positive Passed: 6835/6835 (100.00%)

tasks/coverage/snapshots/estree_typescript.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
commit: 81c95189
22

33
estree_typescript Summary:
4-
AST Parsed : 6649/6649 (100.00%)
5-
Positive Passed: 6646/6649 (99.95%)
4+
AST Parsed : 6781/6781 (100.00%)
5+
Positive Passed: 6778/6781 (99.96%)
66
Mismatch: tasks/coverage/typescript/tests/cases/conformance/jsx/jsxReactTestSuite.tsx
77

88
Mismatch: tasks/coverage/typescript/tests/cases/conformance/jsx/tsxReactEmitEntities.tsx

tasks/coverage/snapshots/parser_typescript.snap

Lines changed: 3 additions & 347 deletions
Large diffs are not rendered by default.

tasks/coverage/snapshots/semantic_typescript.snap

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ commit: 81c95189
22

33
semantic_typescript Summary:
44
AST Parsed : 6537/6537 (100.00%)
5-
Positive Passed: 2825/6537 (43.22%)
5+
Positive Passed: 2828/6537 (43.26%)
66
semantic Error: tasks/coverage/typescript/tests/cases/compiler/2dArrays.ts
77
Symbol reference IDs mismatch for "Cell":
88
after transform: SymbolId(0): [ReferenceId(1)]
@@ -20988,9 +20988,6 @@ Bindings mismatch:
2098820988
after transform: ScopeId(0): ["jsx"]
2098920989
rebuilt : ScopeId(0): []
2099020990

20991-
semantic Error: tasks/coverage/typescript/tests/cases/compiler/moduleResolutionWithExtensions_unexpected2.ts
20992-
Expected a semicolon or an implicit semicolon after a statement, but found none
20993-
2099420991
semantic Error: tasks/coverage/typescript/tests/cases/compiler/moduleResolutionWithExtensions_withAmbientPresent.ts
2099520992
Bindings mismatch:
2099620993
after transform: ScopeId(0): ["x"]
@@ -21135,10 +21132,14 @@ after transform: ScopeId(0): ["x"]
2113521132
rebuilt : ScopeId(0): []
2113621133

2113721134
semantic Error: tasks/coverage/typescript/tests/cases/compiler/moduleResolution_packageJson_yesAtPackageRoot.ts
21138-
Expected a semicolon or an implicit semicolon after a statement, but found none
21135+
Bindings mismatch:
21136+
after transform: ScopeId(0): ["x"]
21137+
rebuilt : ScopeId(0): []
2113921138

2114021139
semantic Error: tasks/coverage/typescript/tests/cases/compiler/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.ts
21141-
Expected a semicolon or an implicit semicolon after a statement, but found none
21140+
Bindings mismatch:
21141+
after transform: ScopeId(0): ["x"]
21142+
rebuilt : ScopeId(0): []
2114221143

2114321144
semantic Error: tasks/coverage/typescript/tests/cases/compiler/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.ts
2114421145
Bindings mismatch:
@@ -47463,12 +47464,6 @@ Bindings mismatch:
4746347464
after transform: ScopeId(0): ["a"]
4746447465
rebuilt : ScopeId(0): []
4746547466

47466-
semantic Error: tasks/coverage/typescript/tests/cases/conformance/moduleResolution/untypedModuleImport.ts
47467-
Expected a semicolon or an implicit semicolon after a statement, but found none
47468-
47469-
semantic Error: tasks/coverage/typescript/tests/cases/conformance/moduleResolution/untypedModuleImport_vsAmbient.ts
47470-
Expected a semicolon or an implicit semicolon after a statement, but found none
47471-
4747247467
semantic Error: tasks/coverage/typescript/tests/cases/conformance/node/nodeModulesImportAttributesTypeModeDeclarationEmit.ts
4747347468
Scope children mismatch:
4747447469
after transform: ScopeId(0): [ScopeId(1)]

tasks/coverage/snapshots/transformer_typescript.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
commit: 81c95189
22

33
transformer_typescript Summary:
4-
AST Parsed : 6700/6700 (100.00%)
5-
Positive Passed: 6696/6700 (99.94%)
4+
AST Parsed : 6835/6835 (100.00%)
5+
Positive Passed: 6831/6835 (99.94%)
66
Mismatch: tasks/coverage/typescript/tests/cases/compiler/esDecoratorsClassFieldsCrash.ts
77

88
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessor2.ts

tasks/coverage/src/typescript/meta.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,19 @@ impl TestCaseContent {
156156
// e.g. typescript/tests/cases/conformance/moduleResolution/untypedModuleImport.ts
157157
// Based on some config, it's not expected to be read in the first place.
158158
.filter(|unit| {
159-
!(unit.content.starts_with("This file is not ")
160-
|| unit.content.starts_with("Nor is this one."))
159+
// `unit.content.trim().starts_with()` is insufficient when dealing with the first unit.
160+
// This is because the first unit may contain normal comments before the invalid content.
161+
let is_invalid_line = |line: &str| {
162+
[
163+
"This file is not read.",
164+
"This file is not processed.",
165+
"Nor is this one.",
166+
"not read",
167+
]
168+
.iter()
169+
.any(|&invalid| line.starts_with(invalid))
170+
};
171+
!unit.content.lines().any(is_invalid_line)
161172
})
162173
.filter_map(|mut unit| {
163174
let mut source_type = Self::get_source_type(Path::new(&unit.name), &settings)?;

tasks/coverage/src/typescript/mod.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ impl<T: Case> Suite<T> for TypeScriptSuite<T> {
5555
"privateNamesIncompatibleModifiersJs.ts",
5656
// Exporting JSDoc types from `.js`
5757
"importingExportingTypes.ts",
58+
// This is just a binary file
59+
"TransportStream.ts",
5860
]
5961
.iter()
6062
.any(|p| path.to_string_lossy().contains(p));
@@ -135,9 +137,11 @@ impl Case for TypeScriptCase {
135137
// TODO: Filter out more not-supported error codes here
136138
static NOT_SUPPORTED_ERROR_CODES: phf::Set<&'static str> = phf::phf_set![
137139
"2315", // Type 'U' is not generic.
138-
"7005", // Variable 'x' implicitly has an 'any' type.
139-
"7006", // Parameter 'x' implicitly has an 'any' type.
140-
"7008", // Member 'v' implicitly has an 'any' type.
140+
"2665", // Invalid module name in augmentation. Module 'foo' resolves to an untyped module at '/node_modules/foo/index.js', which cannot be augmented.
141+
"6133", // 'Bar' is declared but its value is never read.
142+
"7005", // Variable 'x' implicitly has an 'any' type.
143+
"7006", // Parameter 'x' implicitly has an 'any' type.
144+
"7008", // Member 'v' implicitly has an 'any' type.
141145
"7009", // 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.
142146
"7010", // 'temp', which lacks return-type annotation, implicitly has an 'any' return type.
143147
"7011", // Function expression, which lacks return-type annotation, implicitly has an 'any' return type.
@@ -155,12 +159,17 @@ static NOT_SUPPORTED_ERROR_CODES: phf::Set<&'static str> = phf::phf_set![
155159
"7024", // Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
156160
"7025", // Generator implicitly has yield type 'any'. Consider supplying a return type annotation.
157161
"7026", // JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists.
162+
"7027", // Unreachable code detected.
163+
"7028", // Unused label.
164+
"7029", // Fallthrough case in switch.
165+
"7030", // Not all code paths return a value.
158166
"7031", // Binding element 'a5' implicitly has an 'any' type.
159167
"7032", // Property 'message' implicitly has type 'any', because its set accessor lacks a parameter type annotation.
160168
"7033", // Property 'message' implicitly has type 'any', because its get accessor lacks a return type annotation.
161169
"7034", // Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined.
162170
"7036", // Dynamic import's specifier must be of type 'string', but here has type 'null'.
163171
"7039", // Mapped object type implicitly has an 'any' template type.
172+
"7041", // The containing arrow function captures the global value of 'this'.
164173
"7052", // Element implicitly has an 'any' type because type '{ get: (key: string) => string; }' has no index signature. Did you mean to call 'c.get'?
165174
"7053", // Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'.
166175
"7055", // 'h', which lacks return-type annotation, implicitly has an 'any' yield type.

0 commit comments

Comments
 (0)