From 1a75c62ceb077454b3d2e5bd652690da136f54e6 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 19 Apr 2019 15:37:23 -0700 Subject: [PATCH] Remove resetBuildContext --- src/compiler/tsbuild.ts | 29 ++----------------- src/testRunner/unittests/tsbuild/outFile.ts | 14 ++++----- .../unittests/tsbuild/resolveJsonModule.ts | 12 ++++---- src/testRunner/unittests/tsbuild/sample.ts | 9 +++--- 4 files changed, 19 insertions(+), 45 deletions(-) diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 1b298f248f2..5d36be72314 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -260,7 +260,6 @@ namespace ts { // Currently used for testing but can be made public if needed: /*@internal*/ getBuildOrder(): ReadonlyArray; - /*@internal*/ resetBuildContext(opts?: BuildOptions): void; // Testing only /*@internal*/ getUpToDateStatusOfProject(project: string): UpToDateStatus; @@ -337,8 +336,8 @@ namespace ts { const parseConfigFileHost = parseConfigHostFromCompilerHostLike(host); // State of the solution - let options = defaultOptions; - let baseCompilerOptions = getCompilerOptionsOfBuildOptions(options); + const options = defaultOptions; + const baseCompilerOptions = getCompilerOptionsOfBuildOptions(options); const resolvedConfigFilePaths = createMap(); type ConfigFileCacheEntry = ParsedCommandLine | Diagnostic; const configFileCache = createMap() as ConfigFileMap; @@ -380,7 +379,6 @@ namespace ts { buildAllProjects, cleanAllProjects, getBuildOrder, - resetBuildContext, getUpToDateStatusOfProject, invalidateProject, buildInvalidatedProject, @@ -399,29 +397,6 @@ namespace ts { return resolvedPath; } - function resetBuildContext(opts?: BuildOptions) { - options = opts || defaultOptions; - baseCompilerOptions = getCompilerOptionsOfBuildOptions(options); - resolvedConfigFilePaths.clear(); - configFileCache.clear(); - projectStatus.clear(); - buildOrder = undefined; - buildInfoChecked.clear(); - - diagnostics.clear(); - projectPendingBuild.clear(); - projectErrorsReported.clear(); - if (timerToBuildInvalidatedProject) { - clearTimeout(timerToBuildInvalidatedProject); - timerToBuildInvalidatedProject = undefined; - } - reportFileChangeDetected = false; - clearMap(allWatchedWildcardDirectories, wildCardWatches => clearMap(wildCardWatches, closeFileWatcherOf)); - clearMap(allWatchedInputFiles, inputFileWatches => clearMap(inputFileWatches, closeFileWatcher)); - clearMap(allWatchedConfigFiles, closeFileWatcher); - builderPrograms.clear(); - } - function isParsedCommandLine(entry: ConfigFileCacheEntry): entry is ParsedCommandLine { return !!(entry as ParsedCommandLine).options; } diff --git a/src/testRunner/unittests/tsbuild/outFile.ts b/src/testRunner/unittests/tsbuild/outFile.ts index 48beeef4f61..20061c86a7b 100644 --- a/src/testRunner/unittests/tsbuild/outFile.ts +++ b/src/testRunner/unittests/tsbuild/outFile.ts @@ -388,7 +388,7 @@ namespace ts { ...outputFiles[project.third] ]; const host = new fakes.SolutionBuilderHost(fs); - const builder = createSolutionBuilder(host); + let builder = createSolutionBuilder(host); builder.buildAllProjects(); host.assertDiagnosticMessages(...initialExpectedDiagnostics); // Verify they exist @@ -398,7 +398,7 @@ namespace ts { // Delete bundle info host.clearDiagnostics(); host.deleteFile(outputFiles[project.first][ext.buildinfo]); - builder.resetBuildContext(); + builder = createSolutionBuilder(host); builder.buildAllProjects(); host.assertDiagnosticMessages( getExpectedDiagnosticForProjectsInBuild(relSources[project.first][source.config], relSources[project.second][source.config], relSources[project.third][source.config]), @@ -428,11 +428,11 @@ namespace ts { it("rebuilds completely when version in tsbuildinfo doesnt match ts version", () => { const fs = outFileFs.shadow(); const host = new fakes.SolutionBuilderHost(fs); - const builder = createSolutionBuilder(host); + let builder = createSolutionBuilder(host); builder.buildAllProjects(); host.assertDiagnosticMessages(...initialExpectedDiagnostics); host.clearDiagnostics(); - builder.resetBuildContext(); + builder = createSolutionBuilder(host); changeCompilerVersion(host); builder.buildAllProjects(); host.assertDiagnosticMessages( @@ -453,7 +453,7 @@ namespace ts { // Build with command line incremental const host = new fakes.SolutionBuilderHost(fs); - const builder = createSolutionBuilder(host, { incremental: true }); + let builder = createSolutionBuilder(host, { incremental: true }); builder.buildAllProjects(); host.assertDiagnosticMessages(...initialExpectedDiagnostics); host.clearDiagnostics(); @@ -461,7 +461,7 @@ namespace ts { // Make non incremental build with change in file that doesnt affect dts appendText(fs, relSources[project.first][source.ts][part.one], "console.log(s);"); - builder.resetBuildContext({ verbose: true }); + builder = createSolutionBuilder(host, { verbose: true }); builder.buildAllProjects(); host.assertDiagnosticMessages(getExpectedDiagnosticForProjectsInBuild(relSources[project.first][source.config], relSources[project.second][source.config], relSources[project.third][source.config]), [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[project.first][source.config], relOutputFiles[project.first][ext.js], relSources[project.first][source.ts][part.one]], @@ -475,7 +475,7 @@ namespace ts { // Make incremental build with change in file that doesnt affect dts appendText(fs, relSources[project.first][source.ts][part.one], "console.log(s);"); - builder.resetBuildContext({ verbose: true, incremental: true }); + builder = createSolutionBuilder(host, { verbose: true, incremental: true }); builder.buildAllProjects(); // Builds completely because tsbuildinfo is old. host.assertDiagnosticMessages( diff --git a/src/testRunner/unittests/tsbuild/resolveJsonModule.ts b/src/testRunner/unittests/tsbuild/resolveJsonModule.ts index 3fc50d72ea5..d2555a730a2 100644 --- a/src/testRunner/unittests/tsbuild/resolveJsonModule.ts +++ b/src/testRunner/unittests/tsbuild/resolveJsonModule.ts @@ -64,7 +64,7 @@ export default hello.hello`); const configFile = "src/tsconfig_withFiles.json"; replaceText(fs, configFile, `"composite": true,`, `"composite": true, "sourceMap": true,`); const host = new fakes.SolutionBuilderHost(fs); - const builder = createSolutionBuilder(host, [configFile], { verbose: true }); + let builder = createSolutionBuilder(host, [configFile], { verbose: true }); builder.buildAllProjects(); host.assertDiagnosticMessages( getExpectedDiagnosticForProjectsInBuild(configFile), @@ -75,7 +75,7 @@ export default hello.hello`); assert(fs.existsSync(output), `Expect file ${output} to exist`); } host.clearDiagnostics(); - builder.resetBuildContext(); + builder = createSolutionBuilder(host, [configFile], { verbose: true }); tick(); builder.buildAllProjects(); host.assertDiagnosticMessages( @@ -89,7 +89,7 @@ export default hello.hello`); const configFile = "src/tsconfig_withFiles.json"; replaceText(fs, configFile, `"outDir": "dist",`, ""); const host = new fakes.SolutionBuilderHost(fs); - const builder = createSolutionBuilder(host, [configFile], { verbose: true }); + let builder = createSolutionBuilder(host, [configFile], { verbose: true }); builder.buildAllProjects(); host.assertDiagnosticMessages( getExpectedDiagnosticForProjectsInBuild(configFile), @@ -100,7 +100,7 @@ export default hello.hello`); assert(fs.existsSync(output), `Expect file ${output} to exist`); } host.clearDiagnostics(); - builder.resetBuildContext(); + builder = createSolutionBuilder(host, [configFile], { verbose: true }); tick(); builder.buildAllProjects(); host.assertDiagnosticMessages( @@ -128,7 +128,7 @@ export default hello.hello`); const stringsConfigFile = "src/strings/tsconfig.json"; const mainConfigFile = "src/main/tsconfig.json"; const host = new fakes.SolutionBuilderHost(fs); - const builder = createSolutionBuilder(host, [configFile], { verbose: true }); + let builder = createSolutionBuilder(host, [configFile], { verbose: true }); builder.buildAllProjects(); host.assertDiagnosticMessages( getExpectedDiagnosticForProjectsInBuild(stringsConfigFile, mainConfigFile, configFile), @@ -139,7 +139,7 @@ export default hello.hello`); ); assert(fs.existsSync(expectedOutput), `Expect file ${expectedOutput} to exist`); host.clearDiagnostics(); - builder.resetBuildContext(); + builder = createSolutionBuilder(host, [configFile], { verbose: true }); tick(); builder.buildAllProjects(); host.assertDiagnosticMessages( diff --git a/src/testRunner/unittests/tsbuild/sample.ts b/src/testRunner/unittests/tsbuild/sample.ts index c004f53d38e..0682284e1d7 100644 --- a/src/testRunner/unittests/tsbuild/sample.ts +++ b/src/testRunner/unittests/tsbuild/sample.ts @@ -171,11 +171,11 @@ namespace ts { function initializeWithBuild(opts?: BuildOptions) { const fs = projFs.shadow(); const host = new fakes.SolutionBuilderHost(fs); - const builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); + let builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); builder.buildAllProjects(); host.clearDiagnostics(); tick(); - builder.resetBuildContext(opts ? { ...opts, verbose: true } : undefined); + builder = createSolutionBuilder(host, ["/src/tests"], { ...(opts || {}), verbose: true }); return { fs, host, builder }; } @@ -183,7 +183,6 @@ namespace ts { const fs = projFs.shadow(); const host = new fakes.SolutionBuilderHost(fs); const builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); - builder.resetBuildContext(); builder.buildAllProjects(); host.assertDiagnosticMessages( getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"), @@ -288,7 +287,7 @@ namespace ts { fs.writeFileSync("/src/tests/tsconfig.base.json", JSON.stringify({ compilerOptions: { target: "es3" } })); replaceText(fs, "/src/tests/tsconfig.json", `"references": [`, `"extends": "./tsconfig.base.json", "references": [`); const host = new fakes.SolutionBuilderHost(fs); - const builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); + let builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); builder.buildAllProjects(); host.assertDiagnosticMessages( getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"), @@ -301,7 +300,7 @@ namespace ts { ); host.clearDiagnostics(); tick(); - builder.resetBuildContext(); + builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true }); fs.writeFileSync("/src/tests/tsconfig.base.json", JSON.stringify({ compilerOptions: {} })); builder.buildAllProjects(); host.assertDiagnosticMessages(