Skip to content

Commit b8def16

Browse files
authored
Merge pull request microsoft#28902 from Microsoft/unitTestsSplit
Unittests refactoring
2 parents a139303 + efc7160 commit b8def16

File tree

106 files changed

+15109
-15019
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+15109
-15019
lines changed

src/testRunner/tsconfig.json

Lines changed: 77 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -36,64 +36,108 @@
3636

3737
"runner.ts",
3838

39-
"unittests/extractTestHelpers.ts",
40-
"unittests/tsserverProjectSystem.ts",
41-
"unittests/typingsInstaller.ts",
39+
"unittests/services/extract/helpers.ts",
40+
"unittests/tscWatch/helpers.ts",
41+
"unittests/tsserver/helpers.ts",
4242

4343
"unittests/asserts.ts",
4444
"unittests/base64.ts",
4545
"unittests/builder.ts",
46-
"unittests/cancellableLanguageServiceOperations.ts",
47-
"unittests/commandLineParsing.ts",
48-
"unittests/compileOnSave.ts",
4946
"unittests/compilerCore.ts",
50-
"unittests/configurationExtension.ts",
51-
"unittests/convertCompilerOptionsFromJson.ts",
52-
"unittests/convertToAsyncFunction.ts",
5347
"unittests/convertToBase64.ts",
54-
"unittests/convertTypeAcquisitionFromJson.ts",
5548
"unittests/customTransforms.ts",
56-
"unittests/extractConstants.ts",
57-
"unittests/extractFunctions.ts",
58-
"unittests/extractRanges.ts",
5949
"unittests/factory.ts",
60-
"unittests/hostNewLineSupport.ts",
6150
"unittests/incrementalParser.ts",
62-
"unittests/initializeTSConfig.ts",
6351
"unittests/jsDocParsing.ts",
64-
"unittests/languageService.ts",
65-
"unittests/matchFiles.ts",
6652
"unittests/moduleResolution.ts",
67-
"unittests/organizeImports.ts",
6853
"unittests/parsePseudoBigInt.ts",
6954
"unittests/paths.ts",
7055
"unittests/printer.ts",
71-
"unittests/programMissingFiles.ts",
72-
"unittests/programNoParseFalsyFileNames.ts",
73-
"unittests/projectErrors.ts",
74-
"unittests/projectReferences.ts",
56+
"unittests/programApi.ts",
7557
"unittests/publicApi.ts",
7658
"unittests/reuseProgramStructure.ts",
77-
"unittests/session.ts",
7859
"unittests/semver.ts",
79-
"unittests/showConfig.ts",
80-
"unittests/symbolWalker.ts",
81-
"unittests/telemetry.ts",
82-
"unittests/textChanges.ts",
83-
"unittests/textStorage.ts",
8460
"unittests/transform.ts",
85-
"unittests/transpile.ts",
8661
"unittests/tsbuild.ts",
8762
"unittests/tsbuildWatchMode.ts",
88-
"unittests/tsconfigParsing.ts",
89-
"unittests/tscWatchMode.ts",
90-
"unittests/versionCache.ts",
63+
"unittests/config/commandLineParsing.ts",
64+
"unittests/config/configurationExtension.ts",
65+
"unittests/config/convertCompilerOptionsFromJson.ts",
66+
"unittests/config/convertTypeAcquisitionFromJson.ts",
67+
"unittests/config/initializeTSConfig.ts",
68+
"unittests/config/matchFiles.ts",
69+
"unittests/config/projectReferences.ts",
70+
"unittests/config/showConfig.ts",
71+
"unittests/config/tsconfigParsing.ts",
9172
"unittests/evaluation/asyncArrow.ts",
9273
"unittests/evaluation/asyncGenerator.ts",
9374
"unittests/evaluation/forAwaitOf.ts",
75+
"unittests/services/cancellableLanguageServiceOperations.ts",
9476
"unittests/services/colorization.ts",
77+
"unittests/services/convertToAsyncFunction.ts",
9578
"unittests/services/documentRegistry.ts",
79+
"unittests/services/extract/constants.ts",
80+
"unittests/services/extract/functions.ts",
81+
"unittests/services/extract/symbolWalker.ts",
82+
"unittests/services/extract/ranges.ts",
83+
"unittests/services/hostNewLineSupport.ts",
84+
"unittests/services/languageService.ts",
85+
"unittests/services/organizeImports.ts",
9686
"unittests/services/patternMatcher.ts",
97-
"unittests/services/preProcessFile.ts"
87+
"unittests/services/preProcessFile.ts",
88+
"unittests/services/textChanges.ts",
89+
"unittests/services/transpile.ts",
90+
"unittests/tscWatch/consoleClearing.ts",
91+
"unittests/tscWatch/emit.ts",
92+
"unittests/tscWatch/programUpdates.ts",
93+
"unittests/tscWatch/resolutionCache.ts",
94+
"unittests/tscWatch/watchEnvironment.ts",
95+
"unittests/tscWatch/watchApi.ts",
96+
"unittests/tsserver/cachingFileSystemInformation.ts",
97+
"unittests/tsserver/cancellationToken.ts",
98+
"unittests/tsserver/compileOnSave.ts",
99+
"unittests/tsserver/completions.ts",
100+
"unittests/tsserver/configFileSearch.ts",
101+
"unittests/tsserver/configuredProjects.ts",
102+
"unittests/tsserver/declarationFileMaps.ts",
103+
"unittests/tsserver/documentRegistry.ts",
104+
"unittests/tsserver/duplicatePackages.ts",
105+
"unittests/tsserver/events/largeFileReferenced.ts",
106+
"unittests/tsserver/events/projectLanguageServiceState.ts",
107+
"unittests/tsserver/events/projectLoading.ts",
108+
"unittests/tsserver/events/projectUpdatedInBackground.ts",
109+
"unittests/tsserver/events/surveyReady.ts",
110+
"unittests/tsserver/externalProjects.ts",
111+
"unittests/tsserver/forceConsistentCasingInFileNames.ts",
112+
"unittests/tsserver/formatSettings.ts",
113+
"unittests/tsserver/getApplicableRefactors.ts",
114+
"unittests/tsserver/getEditsForFileRename.ts",
115+
"unittests/tsserver/importHelpers.ts",
116+
"unittests/tsserver/inferredProjects.ts",
117+
"unittests/tsserver/languageService.ts",
118+
"unittests/tsserver/maxNodeModuleJsDepth.ts",
119+
"unittests/tsserver/metadataInResponse.ts",
120+
"unittests/tsserver/navTo.ts",
121+
"unittests/tsserver/occurences.ts",
122+
"unittests/tsserver/openFile.ts",
123+
"unittests/tsserver/projectErrors.ts",
124+
"unittests/tsserver/projectReferences.ts",
125+
"unittests/tsserver/projects.ts",
126+
"unittests/tsserver/refactors.ts",
127+
"unittests/tsserver/reload.ts",
128+
"unittests/tsserver/rename.ts",
129+
"unittests/tsserver/resolutionCache.ts",
130+
"unittests/tsserver/session.ts",
131+
"unittests/tsserver/skipLibCheck.ts",
132+
"unittests/tsserver/symLinks.ts",
133+
"unittests/tsserver/syntaxOperations.ts",
134+
"unittests/tsserver/textStorage.ts",
135+
"unittests/tsserver/telemetry.ts",
136+
"unittests/tsserver/typeAquisition.ts",
137+
"unittests/tsserver/typeReferenceDirectives.ts",
138+
"unittests/tsserver/typingsInstaller.ts",
139+
"unittests/tsserver/untitledFiles.ts",
140+
"unittests/tsserver/versionCache.ts",
141+
"unittests/tsserver/watchEnvironment.ts"
98142
]
99143
}

src/testRunner/unittests/asserts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
namespace ts {
2-
describe("assert", () => {
2+
describe("unittests:: assert", () => {
33
it("deepEqual", () => {
44
assert.throws(() => assert.deepEqual(createNodeArray([createIdentifier("A")]), createNodeArray([createIdentifier("B")])));
55
assert.throws(() => assert.deepEqual(createNodeArray([], /*hasTrailingComma*/ true), createNodeArray([], /*hasTrailingComma*/ false)));

src/testRunner/unittests/base64.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
namespace ts {
2-
describe("base64", () => {
2+
describe("unittests:: base64", () => {
33
describe("base64decode", () => {
44
it("can decode input strings correctly without needing a host implementation", () => {
55
const tests = [

src/testRunner/unittests/builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
namespace ts {
2-
describe("builder", () => {
2+
describe("unittests:: builder", () => {
33
it("emits dependent files", () => {
44
const files: NamedSourceText[] = [
55
{ name: "/a.ts", text: SourceText.New("", 'import { b } from "./b";', "") },

src/testRunner/unittests/compilerCore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
namespace ts {
2-
describe("compilerCore", () => {
2+
describe("unittests:: compilerCore", () => {
33
describe("equalOwnProperties", () => {
44
it("correctly equates objects", () => {
55
assert.isTrue(equalOwnProperties({}, {}));

src/testRunner/unittests/commandLineParsing.ts renamed to src/testRunner/unittests/config/commandLineParsing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
namespace ts {
2-
describe("parseCommandLine", () => {
2+
describe("unittests:: config:: commandLineParsing:: parseCommandLine", () => {
33

44
function assertParseResult(commandLine: string[], expectedParsedCommandLine: ParsedCommandLine) {
55
const parsed = parseCommandLine(commandLine);
@@ -367,7 +367,7 @@ namespace ts {
367367
});
368368
});
369369

370-
describe("parseBuildOptions", () => {
370+
describe("unittests:: config:: commandLineParsing:: parseBuildOptions", () => {
371371
function assertParseResult(commandLine: string[], expectedParsedBuildCommand: ParsedBuildCommand) {
372372
const parsed = parseBuildCommand(commandLine);
373373
const parsedBuildOptions = JSON.stringify(parsed.buildOptions);

src/testRunner/unittests/configurationExtension.ts renamed to src/testRunner/unittests/config/configurationExtension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ namespace ts {
208208
}
209209
}
210210

211-
describe("configurationExtension", () => {
211+
describe("unittests:: config:: configurationExtension", () => {
212212
forEach<[string, string, fakes.ParseConfigHost], void>([
213213
["under a case insensitive host", caseInsensitiveBasePath, caseInsensitiveHost],
214214
["under a case sensitive host", caseSensitiveBasePath, caseSensitiveHost]

src/testRunner/unittests/convertCompilerOptionsFromJson.ts renamed to src/testRunner/unittests/config/convertCompilerOptionsFromJson.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
namespace ts {
2-
describe("convertCompilerOptionsFromJson", () => {
2+
describe("unittests:: config:: convertCompilerOptionsFromJson", () => {
33
const formatDiagnosticHost: FormatDiagnosticsHost = {
44
getCurrentDirectory: () => "/apath/",
55
getCanonicalFileName: createGetCanonicalFileName(/*useCaseSensitiveFileNames*/ true),

src/testRunner/unittests/convertTypeAcquisitionFromJson.ts renamed to src/testRunner/unittests/config/convertTypeAcquisitionFromJson.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace ts {
22
interface ExpectedResult { typeAcquisition: TypeAcquisition; errors: Diagnostic[]; }
3-
describe("convertTypeAcquisitionFromJson", () => {
3+
describe("unittests:: config:: convertTypeAcquisitionFromJson", () => {
44
function assertTypeAcquisition(json: any, configFileName: string, expectedResult: ExpectedResult) {
55
assertTypeAcquisitionWithJson(json, configFileName, expectedResult);
66
assertTypeAcquisitionWithJsonNode(json, configFileName, expectedResult);

src/testRunner/unittests/initializeTSConfig.ts renamed to src/testRunner/unittests/config/initializeTSConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
namespace ts {
2-
describe("initTSConfig", () => {
2+
describe("unittests:: config:: initTSConfig", () => {
33
function initTSConfigCorrectly(name: string, commandLinesArgs: string[]) {
44
describe(name, () => {
55
const commandLine = parseCommandLine(commandLinesArgs);
@@ -30,4 +30,4 @@ namespace ts {
3030

3131
initTSConfigCorrectly("Initialized TSConfig with advanced options", ["--init", "--declaration", "--declarationDir", "lib", "--skipLibCheck", "--noErrorTruncation"]);
3232
});
33-
}
33+
}

src/testRunner/unittests/matchFiles.ts renamed to src/testRunner/unittests/config/matchFiles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ namespace ts {
143143
return createFileDiagnostic(file, start, length, diagnosticMessage, arg0);
144144
}
145145

146-
describe("matchFiles", () => {
146+
describe("unittests:: config:: matchFiles", () => {
147147
it("with defaults", () => {
148148
const json = {};
149149
const expected: ParsedCommandLine = {

src/testRunner/unittests/projectReferences.ts renamed to src/testRunner/unittests/config/projectReferences.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ namespace ts {
9696
checkResult(prog, host);
9797
}
9898

99-
describe("project-references meta check", () => {
99+
describe("unittests:: config:: project-references meta check", () => {
100100
it("default setup was created correctly", () => {
101101
const spec: TestSpecification = {
102102
"/primary": {
@@ -118,7 +118,7 @@ namespace ts {
118118
/**
119119
* Validate that we enforce the basic settings constraints for referenced projects
120120
*/
121-
describe("project-references constraint checking for settings", () => {
121+
describe("unittests:: config:: project-references constraint checking for settings", () => {
122122
it("errors when declaration = false", () => {
123123
const spec: TestSpecification = {
124124
"/primary": {
@@ -248,7 +248,7 @@ namespace ts {
248248
/**
249249
* Path mapping behavior
250250
*/
251-
describe("project-references path mapping", () => {
251+
describe("unittests:: config:: project-references path mapping", () => {
252252
it("redirects to the output .d.ts file", () => {
253253
const spec: TestSpecification = {
254254
"/alpha": {
@@ -268,7 +268,7 @@ namespace ts {
268268
});
269269
});
270270

271-
describe("project-references nice-behavior", () => {
271+
describe("unittests:: config:: project-references nice-behavior", () => {
272272
it("issues a nice error when the input file is missing", () => {
273273
const spec: TestSpecification = {
274274
"/alpha": {
@@ -289,7 +289,7 @@ namespace ts {
289289
/**
290290
* 'composite' behavior
291291
*/
292-
describe("project-references behavior changes under composite: true", () => {
292+
describe("unittests:: config:: project-references behavior changes under composite: true", () => {
293293
it("doesn't infer the rootDir from source paths", () => {
294294
const spec: TestSpecification = {
295295
"/alpha": {
@@ -308,7 +308,7 @@ namespace ts {
308308
});
309309
});
310310

311-
describe("errors when a file in a composite project occurs outside the root", () => {
311+
describe("unittests:: config:: project-references errors when a file in a composite project occurs outside the root", () => {
312312
it("Errors when a file is outside the rootdir", () => {
313313
const spec: TestSpecification = {
314314
"/alpha": {

src/testRunner/unittests/showConfig.ts renamed to src/testRunner/unittests/config/showConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
namespace ts {
2-
describe("showConfig", () => {
2+
describe("unittests:: config:: showConfig", () => {
33
function showTSConfigCorrectly(name: string, commandLinesArgs: string[], configJson?: object) {
44
describe(name, () => {
55
const outputFileName = `showConfig/${name.replace(/[^a-z0-9\-./ ]/ig, "")}/tsconfig.json`;

src/testRunner/unittests/tsconfigParsing.ts renamed to src/testRunner/unittests/config/tsconfigParsing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
namespace ts {
2-
describe("parseConfigFileTextToJson", () => {
2+
describe("unittests:: config:: tsconfigParsing:: parseConfigFileTextToJson", () => {
33
function assertParseResult(jsonText: string, expectedConfigObject: { config?: any; error?: Diagnostic[] }) {
44
const parsed = parseConfigFileTextToJson("/apath/tsconfig.json", jsonText);
55
assert.equal(JSON.stringify(parsed), JSON.stringify(expectedConfigObject));

src/testRunner/unittests/convertToBase64.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
namespace ts {
2-
describe("convertToBase64", () => {
2+
describe("unittests:: convertToBase64", () => {
33
function runTest(input: string): void {
44
const actual = convertToBase64(input);
55
const expected = sys.base64encode!(input);

src/testRunner/unittests/customTransforms.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
namespace ts {
2-
describe("customTransforms", () => {
2+
describe("unittests:: customTransforms", () => {
33
function emitsCorrectly(name: string, sources: { file: string, text: string }[], customTransformers: CustomTransformers, options: CompilerOptions = {}) {
44
it(name, () => {
55
const roots = sources.map(source => createSourceFile(source.file, source.text, ScriptTarget.ES2015));
@@ -97,4 +97,4 @@ namespace ts {
9797
experimentalDecorators: true
9898
});
9999
});
100-
}
100+
}

src/testRunner/unittests/evaluation/asyncArrow.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe("asyncArrowEvaluation", () => {
1+
describe("unittests:: evaluation:: asyncArrowEvaluation", () => {
22
// https://github.com/Microsoft/TypeScript/issues/24722
33
it("this capture (es5)", async () => {
44
const result = evaluator.evaluateTypeScript(`
@@ -15,4 +15,4 @@ describe("asyncArrowEvaluation", () => {
1515
await result.main();
1616
assert.instanceOf(result.output[0].a(), result.A);
1717
});
18-
});
18+
});

src/testRunner/unittests/evaluation/asyncGenerator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe("asyncGeneratorEvaluation", () => {
1+
describe("unittests:: evaluation:: asyncGeneratorEvaluation", () => {
22
it("return (es5)", async () => {
33
const result = evaluator.evaluateTypeScript(`
44
async function * g() {
@@ -27,4 +27,4 @@ describe("asyncGeneratorEvaluation", () => {
2727
{ value: 0, done: true }
2828
]);
2929
});
30-
});
30+
});

src/testRunner/unittests/evaluation/forAwaitOf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe("forAwaitOfEvaluation", () => {
1+
describe("unittests:: evaluation:: forAwaitOfEvaluation", () => {
22
it("sync (es5)", async () => {
33
const result = evaluator.evaluateTypeScript(`
44
let i = 0;

src/testRunner/unittests/factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
namespace ts {
2-
describe("FactoryAPI", () => {
2+
describe("unittests:: FactoryAPI", () => {
33
function assertSyntaxKind(node: Node, expected: SyntaxKind) {
44
assert.strictEqual(node.kind, expected, `Actual: ${Debug.showSyntaxKind(node)} Expected: ${(ts as any).SyntaxKind[expected]}`);
55
}

src/testRunner/unittests/incrementalParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ namespace ts {
120120
}
121121
}
122122

123-
describe("Incremental", () => {
123+
describe("unittests:: Incremental Parser", () => {
124124
it("Inserting into method", () => {
125125
const source = "class C {\r\n" +
126126
" public foo1() { }\r\n" +

src/testRunner/unittests/jsDocParsing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
namespace ts {
2-
describe("JSDocParsing", () => {
2+
describe("unittests:: JSDocParsing", () => {
33
describe("TypeExpressions", () => {
44
function parsesCorrectly(name: string, content: string) {
55
it(name, () => {

0 commit comments

Comments
 (0)