Skip to content

Commit b762d62

Browse files
authored
Merge pull request #30344 from Microsoft/uptoDate
Set oldestOutputFileName in uptodate status when updating just timestamps of output
2 parents 8800cc2 + ffeb384 commit b762d62

File tree

3 files changed

+55
-4
lines changed

3 files changed

+55
-4
lines changed

src/compiler/tsbuild.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ namespace ts {
11991199
// Update time stamps for rest of the outputs
12001200
newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(configFile, newestDeclarationFileContentChangedTime, Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
12011201

1202-
const status: UpToDateStatus = {
1202+
const status: Status.UpToDate = {
12031203
type: UpToDateStatusType.UpToDate,
12041204
newestDeclarationFileContentChangedTime: anyDtsChanged ? maximumDate : newestDeclarationFileContentChangedTime,
12051205
oldestOutputFileName: outputFiles.length ? outputFiles[0].name : getFirstProjectOutput(configFile)
@@ -1275,7 +1275,7 @@ namespace ts {
12751275
// Update timestamps for dts
12761276
const newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(config, minimumDate, Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
12771277

1278-
const status: UpToDateStatus = {
1278+
const status: Status.UpToDate = {
12791279
type: UpToDateStatusType.UpToDate,
12801280
newestDeclarationFileContentChangedTime,
12811281
oldestOutputFileName: outputFiles[0].name
@@ -1292,7 +1292,12 @@ namespace ts {
12921292
return reportStatus(Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath!);
12931293
}
12941294
const priorNewestUpdateTime = updateOutputTimestampsWorker(proj, minimumDate, Diagnostics.Updating_output_timestamps_of_project_0);
1295-
projectStatus.setValue(proj.options.configFilePath as ResolvedConfigFilePath, { type: UpToDateStatusType.UpToDate, newestDeclarationFileContentChangedTime: priorNewestUpdateTime } as UpToDateStatus);
1295+
const status: Status.UpToDate = {
1296+
type: UpToDateStatusType.UpToDate,
1297+
newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
1298+
oldestOutputFileName: getFirstProjectOutput(proj)
1299+
};
1300+
projectStatus.setValue(proj.options.configFilePath as ResolvedConfigFilePath, status);
12961301
}
12971302

12981303
function updateOutputTimestampsWorker(proj: ParsedCommandLine, priorNewestUpdateTime: Date, verboseMessage: DiagnosticMessage, skipOutputs?: FileMap<true>) {

src/testRunner/unittests/tsbuildWatchMode.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,5 +1137,46 @@ export function gfoo() {
11371137
});
11381138
});
11391139
});
1140+
1141+
it("incremental updates in verbose mode", () => {
1142+
const host = createTsBuildWatchSystem(allFiles, { currentDirectory: projectsLocation });
1143+
const solutionBuilder = createSolutionBuilder(host, [`${project}/${SubProject.tests}`], { verbose: true, watch: true });
1144+
solutionBuilder.buildAllProjects();
1145+
solutionBuilder.startWatching();
1146+
checkOutputErrorsInitial(host, emptyArray, /*disableConsoleClears*/ undefined, [
1147+
`Projects in this build: \r\n * sample1/core/tsconfig.json\r\n * sample1/logic/tsconfig.json\r\n * sample1/tests/tsconfig.json\n\n`,
1148+
`Project 'sample1/core/tsconfig.json' is out of date because output file 'sample1/core/anotherModule.js' does not exist\n\n`,
1149+
`Building project '/user/username/projects/sample1/core/tsconfig.json'...\n\n`,
1150+
`Project 'sample1/logic/tsconfig.json' is out of date because output file 'sample1/logic/index.js' does not exist\n\n`,
1151+
`Building project '/user/username/projects/sample1/logic/tsconfig.json'...\n\n`,
1152+
`Project 'sample1/tests/tsconfig.json' is out of date because output file 'sample1/tests/index.js' does not exist\n\n`,
1153+
`Building project '/user/username/projects/sample1/tests/tsconfig.json'...\n\n`
1154+
]);
1155+
verifyWatches(host);
1156+
1157+
// Make non dts change
1158+
host.writeFile(logic[1].path, `${logic[1].content}
1159+
function someFn() { }`);
1160+
host.checkTimeoutQueueLengthAndRun(1); // build logic
1161+
host.checkTimeoutQueueLengthAndRun(1); // build tests
1162+
checkOutputErrorsIncremental(host, emptyArray, /*disableConsoleClears*/ undefined, /*logsBeforeWatchDiagnostics*/ undefined, [
1163+
`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`,
1164+
`Building project '/user/username/projects/sample1/logic/tsconfig.json'...\n\n`,
1165+
`Project 'sample1/tests/tsconfig.json' is up to date with .d.ts files from its dependencies\n\n`,
1166+
`Updating output timestamps of project '/user/username/projects/sample1/tests/tsconfig.json'...\n\n`,
1167+
]);
1168+
1169+
// Make dts change
1170+
host.writeFile(logic[1].path, `${logic[1].content}
1171+
export function someFn() { }`);
1172+
host.checkTimeoutQueueLengthAndRun(1); // build logic
1173+
host.checkTimeoutQueueLengthAndRun(1); // build tests
1174+
checkOutputErrorsIncremental(host, emptyArray, /*disableConsoleClears*/ undefined, /*logsBeforeWatchDiagnostics*/ undefined, [
1175+
`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`,
1176+
`Building project '/user/username/projects/sample1/logic/tsconfig.json'...\n\n`,
1177+
`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`,
1178+
`Building project '/user/username/projects/sample1/tests/tsconfig.json'...\n\n`,
1179+
]);
1180+
});
11401181
});
11411182
}

src/testRunner/unittests/tscWatch/helpers.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ namespace ts.tscWatch {
5353
}
5454

5555
const elapsedRegex = /^Elapsed:: [0-9]+ms/;
56+
const buildVerboseLogRegEx = /^.+ \- /;
5657
function checkOutputErrors(
5758
host: WatchedSystem,
5859
logsBeforeWatchDiagnostic: string[] | undefined,
@@ -87,9 +88,13 @@ namespace ts.tscWatch {
8788
index++;
8889
}
8990

91+
function getCleanLogString(log: string) {
92+
return log.replace(elapsedRegex, "").replace(buildVerboseLogRegEx, "");
93+
}
94+
9095
function assertLog(caption: string, expected: string) {
9196
const actual = outputs[index];
92-
assert.equal(actual.replace(elapsedRegex, ""), expected.replace(elapsedRegex, ""), getOutputAtFailedMessage(caption, expected));
97+
assert.equal(getCleanLogString(actual), getCleanLogString(expected), getOutputAtFailedMessage(caption, expected));
9398
index++;
9499
}
95100

0 commit comments

Comments
 (0)