From ffeb38456f384ed8899e814ca98f444ae985a6c2 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 12 Mar 2019 13:27:55 -0700 Subject: [PATCH] Set oldestOutputFileName in uptodate status when updating just timestamps of output Fixes #29875 --- src/compiler/tsbuild.ts | 11 ++++-- src/testRunner/unittests/tsbuildWatchMode.ts | 41 ++++++++++++++++++++ src/testRunner/unittests/tscWatch/helpers.ts | 7 +++- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 7afa7eb9730..100dd89fb44 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -1199,7 +1199,7 @@ namespace ts { // Update time stamps for rest of the outputs newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(configFile, newestDeclarationFileContentChangedTime, Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs); - const status: UpToDateStatus = { + const status: Status.UpToDate = { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime, oldestOutputFileName: outputFiles.length ? outputFiles[0].name : getFirstProjectOutput(configFile) @@ -1275,7 +1275,7 @@ namespace ts { // Update timestamps for dts const newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(config, minimumDate, Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs); - const status: UpToDateStatus = { + const status: Status.UpToDate = { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime, oldestOutputFileName: outputFiles[0].name @@ -1292,7 +1292,12 @@ namespace ts { return reportStatus(Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath!); } const priorNewestUpdateTime = updateOutputTimestampsWorker(proj, minimumDate, Diagnostics.Updating_output_timestamps_of_project_0); - projectStatus.setValue(proj.options.configFilePath as ResolvedConfigFilePath, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: priorNewestUpdateTime } as UpToDateStatus); + const status: Status.UpToDate = { + type: UpToDateStatusType.UpToDate, + newestDeclarationFileContentChangedTime: priorNewestUpdateTime, + oldestOutputFileName: getFirstProjectOutput(proj) + }; + projectStatus.setValue(proj.options.configFilePath as ResolvedConfigFilePath, status); } function updateOutputTimestampsWorker(proj: ParsedCommandLine, priorNewestUpdateTime: Date, verboseMessage: DiagnosticMessage, skipOutputs?: FileMap) { diff --git a/src/testRunner/unittests/tsbuildWatchMode.ts b/src/testRunner/unittests/tsbuildWatchMode.ts index 87b3e6d2208..005956a98ad 100644 --- a/src/testRunner/unittests/tsbuildWatchMode.ts +++ b/src/testRunner/unittests/tsbuildWatchMode.ts @@ -1137,5 +1137,46 @@ export function gfoo() { }); }); }); + + it("incremental updates in verbose mode", () => { + const host = createTsBuildWatchSystem(allFiles, { currentDirectory: projectsLocation }); + const solutionBuilder = createSolutionBuilder(host, [`${project}/${SubProject.tests}`], { verbose: true, watch: true }); + solutionBuilder.buildAllProjects(); + solutionBuilder.startWatching(); + checkOutputErrorsInitial(host, emptyArray, /*disableConsoleClears*/ undefined, [ + `Projects in this build: \r\n * sample1/core/tsconfig.json\r\n * sample1/logic/tsconfig.json\r\n * sample1/tests/tsconfig.json\n\n`, + `Project 'sample1/core/tsconfig.json' is out of date because output file 'sample1/core/anotherModule.js' does not exist\n\n`, + `Building project '/user/username/projects/sample1/core/tsconfig.json'...\n\n`, + `Project 'sample1/logic/tsconfig.json' is out of date because output file 'sample1/logic/index.js' does not exist\n\n`, + `Building project '/user/username/projects/sample1/logic/tsconfig.json'...\n\n`, + `Project 'sample1/tests/tsconfig.json' is out of date because output file 'sample1/tests/index.js' does not exist\n\n`, + `Building project '/user/username/projects/sample1/tests/tsconfig.json'...\n\n` + ]); + verifyWatches(host); + + // Make non dts change + host.writeFile(logic[1].path, `${logic[1].content} +function someFn() { }`); + host.checkTimeoutQueueLengthAndRun(1); // build logic + host.checkTimeoutQueueLengthAndRun(1); // build tests + checkOutputErrorsIncremental(host, emptyArray, /*disableConsoleClears*/ undefined, /*logsBeforeWatchDiagnostics*/ undefined, [ + `Project 'sample1/logic/tsconfig.json' is out of date because oldest output 'sample1/logic/index.js' is older than newest input 'sample1/core'\n\n`, + `Building project '/user/username/projects/sample1/logic/tsconfig.json'...\n\n`, + `Project 'sample1/tests/tsconfig.json' is up to date with .d.ts files from its dependencies\n\n`, + `Updating output timestamps of project '/user/username/projects/sample1/tests/tsconfig.json'...\n\n`, + ]); + + // Make dts change + host.writeFile(logic[1].path, `${logic[1].content} +export function someFn() { }`); + host.checkTimeoutQueueLengthAndRun(1); // build logic + host.checkTimeoutQueueLengthAndRun(1); // build tests + checkOutputErrorsIncremental(host, emptyArray, /*disableConsoleClears*/ undefined, /*logsBeforeWatchDiagnostics*/ undefined, [ + `Project 'sample1/logic/tsconfig.json' is out of date because oldest output 'sample1/logic/index.js' is older than newest input 'sample1/core'\n\n`, + `Building project '/user/username/projects/sample1/logic/tsconfig.json'...\n\n`, + `Project 'sample1/tests/tsconfig.json' is out of date because oldest output 'sample1/tests/index.js' is older than newest input 'sample1/logic/tsconfig.json'\n\n`, + `Building project '/user/username/projects/sample1/tests/tsconfig.json'...\n\n`, + ]); + }); }); } diff --git a/src/testRunner/unittests/tscWatch/helpers.ts b/src/testRunner/unittests/tscWatch/helpers.ts index a499e361fb5..98a2d4ffa4b 100644 --- a/src/testRunner/unittests/tscWatch/helpers.ts +++ b/src/testRunner/unittests/tscWatch/helpers.ts @@ -53,6 +53,7 @@ namespace ts.tscWatch { } const elapsedRegex = /^Elapsed:: [0-9]+ms/; + const buildVerboseLogRegEx = /^.+ \- /; function checkOutputErrors( host: WatchedSystem, logsBeforeWatchDiagnostic: string[] | undefined, @@ -87,9 +88,13 @@ namespace ts.tscWatch { index++; } + function getCleanLogString(log: string) { + return log.replace(elapsedRegex, "").replace(buildVerboseLogRegEx, ""); + } + function assertLog(caption: string, expected: string) { const actual = outputs[index]; - assert.equal(actual.replace(elapsedRegex, ""), expected.replace(elapsedRegex, ""), getOutputAtFailedMessage(caption, expected)); + assert.equal(getCleanLogString(actual), getCleanLogString(expected), getOutputAtFailedMessage(caption, expected)); index++; }