Set oldestOutputFileName in uptodate status when updating just timestamps of output

Fixes #29875
This commit is contained in:
Sheetal Nandi 2019-03-12 13:27:55 -07:00
parent ba95fcac87
commit ffeb38456f
3 changed files with 55 additions and 4 deletions

View File

@ -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<true>) {

View File

@ -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`,
]);
});
});
}

View File

@ -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++;
}