Skip to content

Commit

Permalink
Merge pull request microsoft#28902 from Microsoft/unitTestsSplit
Browse files Browse the repository at this point in the history
Unittests refactoring
  • Loading branch information
sheetalkamat committed Dec 21, 2018
2 parents a139303 + efc7160 commit b8def16
Show file tree
Hide file tree
Showing 106 changed files with 15,109 additions and 15,019 deletions.
110 changes: 77 additions & 33 deletions src/testRunner/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,64 +36,108 @@

"runner.ts",

"unittests/extractTestHelpers.ts",
"unittests/tsserverProjectSystem.ts",
"unittests/typingsInstaller.ts",
"unittests/services/extract/helpers.ts",
"unittests/tscWatch/helpers.ts",
"unittests/tsserver/helpers.ts",

"unittests/asserts.ts",
"unittests/base64.ts",
"unittests/builder.ts",
"unittests/cancellableLanguageServiceOperations.ts",
"unittests/commandLineParsing.ts",
"unittests/compileOnSave.ts",
"unittests/compilerCore.ts",
"unittests/configurationExtension.ts",
"unittests/convertCompilerOptionsFromJson.ts",
"unittests/convertToAsyncFunction.ts",
"unittests/convertToBase64.ts",
"unittests/convertTypeAcquisitionFromJson.ts",
"unittests/customTransforms.ts",
"unittests/extractConstants.ts",
"unittests/extractFunctions.ts",
"unittests/extractRanges.ts",
"unittests/factory.ts",
"unittests/hostNewLineSupport.ts",
"unittests/incrementalParser.ts",
"unittests/initializeTSConfig.ts",
"unittests/jsDocParsing.ts",
"unittests/languageService.ts",
"unittests/matchFiles.ts",
"unittests/moduleResolution.ts",
"unittests/organizeImports.ts",
"unittests/parsePseudoBigInt.ts",
"unittests/paths.ts",
"unittests/printer.ts",
"unittests/programMissingFiles.ts",
"unittests/programNoParseFalsyFileNames.ts",
"unittests/projectErrors.ts",
"unittests/projectReferences.ts",
"unittests/programApi.ts",
"unittests/publicApi.ts",
"unittests/reuseProgramStructure.ts",
"unittests/session.ts",
"unittests/semver.ts",
"unittests/showConfig.ts",
"unittests/symbolWalker.ts",
"unittests/telemetry.ts",
"unittests/textChanges.ts",
"unittests/textStorage.ts",
"unittests/transform.ts",
"unittests/transpile.ts",
"unittests/tsbuild.ts",
"unittests/tsbuildWatchMode.ts",
"unittests/tsconfigParsing.ts",
"unittests/tscWatchMode.ts",
"unittests/versionCache.ts",
"unittests/config/commandLineParsing.ts",
"unittests/config/configurationExtension.ts",
"unittests/config/convertCompilerOptionsFromJson.ts",
"unittests/config/convertTypeAcquisitionFromJson.ts",
"unittests/config/initializeTSConfig.ts",
"unittests/config/matchFiles.ts",
"unittests/config/projectReferences.ts",
"unittests/config/showConfig.ts",
"unittests/config/tsconfigParsing.ts",
"unittests/evaluation/asyncArrow.ts",
"unittests/evaluation/asyncGenerator.ts",
"unittests/evaluation/forAwaitOf.ts",
"unittests/services/cancellableLanguageServiceOperations.ts",
"unittests/services/colorization.ts",
"unittests/services/convertToAsyncFunction.ts",
"unittests/services/documentRegistry.ts",
"unittests/services/extract/constants.ts",
"unittests/services/extract/functions.ts",
"unittests/services/extract/symbolWalker.ts",
"unittests/services/extract/ranges.ts",
"unittests/services/hostNewLineSupport.ts",
"unittests/services/languageService.ts",
"unittests/services/organizeImports.ts",
"unittests/services/patternMatcher.ts",
"unittests/services/preProcessFile.ts"
"unittests/services/preProcessFile.ts",
"unittests/services/textChanges.ts",
"unittests/services/transpile.ts",
"unittests/tscWatch/consoleClearing.ts",
"unittests/tscWatch/emit.ts",
"unittests/tscWatch/programUpdates.ts",
"unittests/tscWatch/resolutionCache.ts",
"unittests/tscWatch/watchEnvironment.ts",
"unittests/tscWatch/watchApi.ts",
"unittests/tsserver/cachingFileSystemInformation.ts",
"unittests/tsserver/cancellationToken.ts",
"unittests/tsserver/compileOnSave.ts",
"unittests/tsserver/completions.ts",
"unittests/tsserver/configFileSearch.ts",
"unittests/tsserver/configuredProjects.ts",
"unittests/tsserver/declarationFileMaps.ts",
"unittests/tsserver/documentRegistry.ts",
"unittests/tsserver/duplicatePackages.ts",
"unittests/tsserver/events/largeFileReferenced.ts",
"unittests/tsserver/events/projectLanguageServiceState.ts",
"unittests/tsserver/events/projectLoading.ts",
"unittests/tsserver/events/projectUpdatedInBackground.ts",
"unittests/tsserver/events/surveyReady.ts",
"unittests/tsserver/externalProjects.ts",
"unittests/tsserver/forceConsistentCasingInFileNames.ts",
"unittests/tsserver/formatSettings.ts",
"unittests/tsserver/getApplicableRefactors.ts",
"unittests/tsserver/getEditsForFileRename.ts",
"unittests/tsserver/importHelpers.ts",
"unittests/tsserver/inferredProjects.ts",
"unittests/tsserver/languageService.ts",
"unittests/tsserver/maxNodeModuleJsDepth.ts",
"unittests/tsserver/metadataInResponse.ts",
"unittests/tsserver/navTo.ts",
"unittests/tsserver/occurences.ts",
"unittests/tsserver/openFile.ts",
"unittests/tsserver/projectErrors.ts",
"unittests/tsserver/projectReferences.ts",
"unittests/tsserver/projects.ts",
"unittests/tsserver/refactors.ts",
"unittests/tsserver/reload.ts",
"unittests/tsserver/rename.ts",
"unittests/tsserver/resolutionCache.ts",
"unittests/tsserver/session.ts",
"unittests/tsserver/skipLibCheck.ts",
"unittests/tsserver/symLinks.ts",
"unittests/tsserver/syntaxOperations.ts",
"unittests/tsserver/textStorage.ts",
"unittests/tsserver/telemetry.ts",
"unittests/tsserver/typeAquisition.ts",
"unittests/tsserver/typeReferenceDirectives.ts",
"unittests/tsserver/typingsInstaller.ts",
"unittests/tsserver/untitledFiles.ts",
"unittests/tsserver/versionCache.ts",
"unittests/tsserver/watchEnvironment.ts"
]
}
2 changes: 1 addition & 1 deletion src/testRunner/unittests/asserts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace ts {
describe("assert", () => {
describe("unittests:: assert", () => {
it("deepEqual", () => {
assert.throws(() => assert.deepEqual(createNodeArray([createIdentifier("A")]), createNodeArray([createIdentifier("B")])));
assert.throws(() => assert.deepEqual(createNodeArray([], /*hasTrailingComma*/ true), createNodeArray([], /*hasTrailingComma*/ false)));
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/unittests/base64.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace ts {
describe("base64", () => {
describe("unittests:: base64", () => {
describe("base64decode", () => {
it("can decode input strings correctly without needing a host implementation", () => {
const tests = [
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/unittests/builder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace ts {
describe("builder", () => {
describe("unittests:: builder", () => {
it("emits dependent files", () => {
const files: NamedSourceText[] = [
{ name: "/a.ts", text: SourceText.New("", 'import { b } from "./b";', "") },
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/unittests/compilerCore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace ts {
describe("compilerCore", () => {
describe("unittests:: compilerCore", () => {
describe("equalOwnProperties", () => {
it("correctly equates objects", () => {
assert.isTrue(equalOwnProperties({}, {}));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace ts {
describe("parseCommandLine", () => {
describe("unittests:: config:: commandLineParsing:: parseCommandLine", () => {

function assertParseResult(commandLine: string[], expectedParsedCommandLine: ParsedCommandLine) {
const parsed = parseCommandLine(commandLine);
Expand Down Expand Up @@ -367,7 +367,7 @@ namespace ts {
});
});

describe("parseBuildOptions", () => {
describe("unittests:: config:: commandLineParsing:: parseBuildOptions", () => {
function assertParseResult(commandLine: string[], expectedParsedBuildCommand: ParsedBuildCommand) {
const parsed = parseBuildCommand(commandLine);
const parsedBuildOptions = JSON.stringify(parsed.buildOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ namespace ts {
}
}

describe("configurationExtension", () => {
describe("unittests:: config:: configurationExtension", () => {
forEach<[string, string, fakes.ParseConfigHost], void>([
["under a case insensitive host", caseInsensitiveBasePath, caseInsensitiveHost],
["under a case sensitive host", caseSensitiveBasePath, caseSensitiveHost]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace ts {
describe("convertCompilerOptionsFromJson", () => {
describe("unittests:: config:: convertCompilerOptionsFromJson", () => {
const formatDiagnosticHost: FormatDiagnosticsHost = {
getCurrentDirectory: () => "/apath/",
getCanonicalFileName: createGetCanonicalFileName(/*useCaseSensitiveFileNames*/ true),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace ts {
interface ExpectedResult { typeAcquisition: TypeAcquisition; errors: Diagnostic[]; }
describe("convertTypeAcquisitionFromJson", () => {
describe("unittests:: config:: convertTypeAcquisitionFromJson", () => {
function assertTypeAcquisition(json: any, configFileName: string, expectedResult: ExpectedResult) {
assertTypeAcquisitionWithJson(json, configFileName, expectedResult);
assertTypeAcquisitionWithJsonNode(json, configFileName, expectedResult);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace ts {
describe("initTSConfig", () => {
describe("unittests:: config:: initTSConfig", () => {
function initTSConfigCorrectly(name: string, commandLinesArgs: string[]) {
describe(name, () => {
const commandLine = parseCommandLine(commandLinesArgs);
Expand Down Expand Up @@ -30,4 +30,4 @@ namespace ts {

initTSConfigCorrectly("Initialized TSConfig with advanced options", ["--init", "--declaration", "--declarationDir", "lib", "--skipLibCheck", "--noErrorTruncation"]);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ namespace ts {
return createFileDiagnostic(file, start, length, diagnosticMessage, arg0);
}

describe("matchFiles", () => {
describe("unittests:: config:: matchFiles", () => {
it("with defaults", () => {
const json = {};
const expected: ParsedCommandLine = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace ts {
checkResult(prog, host);
}

describe("project-references meta check", () => {
describe("unittests:: config:: project-references meta check", () => {
it("default setup was created correctly", () => {
const spec: TestSpecification = {
"/primary": {
Expand All @@ -118,7 +118,7 @@ namespace ts {
/**
* Validate that we enforce the basic settings constraints for referenced projects
*/
describe("project-references constraint checking for settings", () => {
describe("unittests:: config:: project-references constraint checking for settings", () => {
it("errors when declaration = false", () => {
const spec: TestSpecification = {
"/primary": {
Expand Down Expand Up @@ -248,7 +248,7 @@ namespace ts {
/**
* Path mapping behavior
*/
describe("project-references path mapping", () => {
describe("unittests:: config:: project-references path mapping", () => {
it("redirects to the output .d.ts file", () => {
const spec: TestSpecification = {
"/alpha": {
Expand All @@ -268,7 +268,7 @@ namespace ts {
});
});

describe("project-references nice-behavior", () => {
describe("unittests:: config:: project-references nice-behavior", () => {
it("issues a nice error when the input file is missing", () => {
const spec: TestSpecification = {
"/alpha": {
Expand All @@ -289,7 +289,7 @@ namespace ts {
/**
* 'composite' behavior
*/
describe("project-references behavior changes under composite: true", () => {
describe("unittests:: config:: project-references behavior changes under composite: true", () => {
it("doesn't infer the rootDir from source paths", () => {
const spec: TestSpecification = {
"/alpha": {
Expand All @@ -308,7 +308,7 @@ namespace ts {
});
});

describe("errors when a file in a composite project occurs outside the root", () => {
describe("unittests:: config:: project-references errors when a file in a composite project occurs outside the root", () => {
it("Errors when a file is outside the rootdir", () => {
const spec: TestSpecification = {
"/alpha": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace ts {
describe("showConfig", () => {
describe("unittests:: config:: showConfig", () => {
function showTSConfigCorrectly(name: string, commandLinesArgs: string[], configJson?: object) {
describe(name, () => {
const outputFileName = `showConfig/${name.replace(/[^a-z0-9\-./ ]/ig, "")}/tsconfig.json`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace ts {
describe("parseConfigFileTextToJson", () => {
describe("unittests:: config:: tsconfigParsing:: parseConfigFileTextToJson", () => {
function assertParseResult(jsonText: string, expectedConfigObject: { config?: any; error?: Diagnostic[] }) {
const parsed = parseConfigFileTextToJson("/apath/tsconfig.json", jsonText);
assert.equal(JSON.stringify(parsed), JSON.stringify(expectedConfigObject));
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/unittests/convertToBase64.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace ts {
describe("convertToBase64", () => {
describe("unittests:: convertToBase64", () => {
function runTest(input: string): void {
const actual = convertToBase64(input);
const expected = sys.base64encode!(input);
Expand Down
4 changes: 2 additions & 2 deletions src/testRunner/unittests/customTransforms.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace ts {
describe("customTransforms", () => {
describe("unittests:: customTransforms", () => {
function emitsCorrectly(name: string, sources: { file: string, text: string }[], customTransformers: CustomTransformers, options: CompilerOptions = {}) {
it(name, () => {
const roots = sources.map(source => createSourceFile(source.file, source.text, ScriptTarget.ES2015));
Expand Down Expand Up @@ -97,4 +97,4 @@ namespace ts {
experimentalDecorators: true
});
});
}
}
4 changes: 2 additions & 2 deletions src/testRunner/unittests/evaluation/asyncArrow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe("asyncArrowEvaluation", () => {
describe("unittests:: evaluation:: asyncArrowEvaluation", () => {
// https://github.com/Microsoft/TypeScript/issues/24722
it("this capture (es5)", async () => {
const result = evaluator.evaluateTypeScript(`
Expand All @@ -15,4 +15,4 @@ describe("asyncArrowEvaluation", () => {
await result.main();
assert.instanceOf(result.output[0].a(), result.A);
});
});
});
4 changes: 2 additions & 2 deletions src/testRunner/unittests/evaluation/asyncGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe("asyncGeneratorEvaluation", () => {
describe("unittests:: evaluation:: asyncGeneratorEvaluation", () => {
it("return (es5)", async () => {
const result = evaluator.evaluateTypeScript(`
async function * g() {
Expand Down Expand Up @@ -27,4 +27,4 @@ describe("asyncGeneratorEvaluation", () => {
{ value: 0, done: true }
]);
});
});
});
2 changes: 1 addition & 1 deletion src/testRunner/unittests/evaluation/forAwaitOf.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe("forAwaitOfEvaluation", () => {
describe("unittests:: evaluation:: forAwaitOfEvaluation", () => {
it("sync (es5)", async () => {
const result = evaluator.evaluateTypeScript(`
let i = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/unittests/factory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace ts {
describe("FactoryAPI", () => {
describe("unittests:: FactoryAPI", () => {
function assertSyntaxKind(node: Node, expected: SyntaxKind) {
assert.strictEqual(node.kind, expected, `Actual: ${Debug.showSyntaxKind(node)} Expected: ${(ts as any).SyntaxKind[expected]}`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/unittests/incrementalParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace ts {
}
}

describe("Incremental", () => {
describe("unittests:: Incremental Parser", () => {
it("Inserting into method", () => {
const source = "class C {\r\n" +
" public foo1() { }\r\n" +
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/unittests/jsDocParsing.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace ts {
describe("JSDocParsing", () => {
describe("unittests:: JSDocParsing", () => {
describe("TypeExpressions", () => {
function parsesCorrectly(name: string, content: string) {
it(name, () => {
Expand Down

0 comments on commit b8def16

Please sign in to comment.