Skip to content

Commit 90abaa1

Browse files
committed
Reset the build queue correctly
Fixes issue reported in microsoft#26545#issuecomment-416961260
1 parent d6ff1a7 commit 90abaa1

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

src/compiler/tsbuild.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ namespace ts {
429429
projectPendingBuild.removeKey(proj);
430430
if (!projectPendingBuild.getSize()) {
431431
invalidatedProjectQueue.length = 0;
432+
nextIndex = 0;
432433
}
433434
return proj;
434435
}

src/testRunner/unittests/tsbuildWatchMode.ts

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -98,34 +98,42 @@ namespace ts.tscWatch {
9898
for (const stamp of outputFileStamps) {
9999
assert.isDefined(stamp[1], `${stamp[0]} expected to be present`);
100100
}
101-
return { host, outputFileStamps };
101+
return host;
102102
}
103103
it("creates solution in watch mode", () => {
104104
createSolutionInWatchMode();
105105
});
106106

107107
it("change builds changes and reports found errors message", () => {
108-
const { host, outputFileStamps } = createSolutionInWatchMode();
109-
host.writeFile(core[1].path, `${core[1].content}
108+
const host = createSolutionInWatchMode();
109+
verifyChange(`${core[1].content}
110110
export class someClass { }`);
111-
host.checkTimeoutQueueLengthAndRun(1); // Builds core
112-
const changedCore = getOutputFileStamps(host);
113-
verifyChangedFiles(changedCore, outputFileStamps, [
114-
...getOutputFileNames(SubProject.core, "anotherModule"), // This should not be written really
115-
...getOutputFileNames(SubProject.core, "index")
116-
]);
117-
host.checkTimeoutQueueLengthAndRun(1); // Builds tests
118-
const changedTests = getOutputFileStamps(host);
119-
verifyChangedFiles(changedTests, changedCore, [
120-
...getOutputFileNames(SubProject.tests, "index") // Again these need not be written
121-
]);
122-
host.checkTimeoutQueueLengthAndRun(1); // Builds logic
123-
const changedLogic = getOutputFileStamps(host);
124-
verifyChangedFiles(changedLogic, changedTests, [
125-
...getOutputFileNames(SubProject.logic, "index") // Again these need not be written
126-
]);
127-
host.checkTimeoutQueueLength(0);
128-
checkOutputErrorsIncremental(host, emptyArray);
111+
112+
// Another change requeues and builds it
113+
verifyChange(core[1].content);
114+
115+
function verifyChange(coreContent: string) {
116+
const outputFileStamps = getOutputFileStamps(host);
117+
host.writeFile(core[1].path, coreContent);
118+
host.checkTimeoutQueueLengthAndRun(1); // Builds core
119+
const changedCore = getOutputFileStamps(host);
120+
verifyChangedFiles(changedCore, outputFileStamps, [
121+
...getOutputFileNames(SubProject.core, "anotherModule"), // This should not be written really
122+
...getOutputFileNames(SubProject.core, "index")
123+
]);
124+
host.checkTimeoutQueueLengthAndRun(1); // Builds tests
125+
const changedTests = getOutputFileStamps(host);
126+
verifyChangedFiles(changedTests, changedCore, [
127+
...getOutputFileNames(SubProject.tests, "index") // Again these need not be written
128+
]);
129+
host.checkTimeoutQueueLengthAndRun(1); // Builds logic
130+
const changedLogic = getOutputFileStamps(host);
131+
verifyChangedFiles(changedLogic, changedTests, [
132+
...getOutputFileNames(SubProject.logic, "index") // Again these need not be written
133+
]);
134+
host.checkTimeoutQueueLength(0);
135+
checkOutputErrorsIncremental(host, emptyArray);
136+
}
129137
});
130138

131139
// TODO: write tests reporting errors but that will have more involved work since file

0 commit comments

Comments
 (0)