diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 32b10569fc6..ae3f7cd3c61 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -421,6 +421,7 @@ namespace ts { projectPendingBuild.removeKey(proj); if (!projectPendingBuild.getSize()) { invalidatedProjectQueue.length = 0; + nextIndex = 0; } return proj; } diff --git a/src/testRunner/unittests/tsbuildWatchMode.ts b/src/testRunner/unittests/tsbuildWatchMode.ts index d1405fa9e2c..b7884350061 100644 --- a/src/testRunner/unittests/tsbuildWatchMode.ts +++ b/src/testRunner/unittests/tsbuildWatchMode.ts @@ -98,34 +98,42 @@ namespace ts.tscWatch { for (const stamp of outputFileStamps) { assert.isDefined(stamp[1], `${stamp[0]} expected to be present`); } - return { host, outputFileStamps }; + return host; } it("creates solution in watch mode", () => { createSolutionInWatchMode(); }); it("change builds changes and reports found errors message", () => { - const { host, outputFileStamps } = createSolutionInWatchMode(); - host.writeFile(core[1].path, `${core[1].content} + const host = createSolutionInWatchMode(); + verifyChange(`${core[1].content} export class someClass { }`); - host.checkTimeoutQueueLengthAndRun(1); // Builds core - const changedCore = getOutputFileStamps(host); - verifyChangedFiles(changedCore, outputFileStamps, [ - ...getOutputFileNames(SubProject.core, "anotherModule"), // This should not be written really - ...getOutputFileNames(SubProject.core, "index") - ]); - host.checkTimeoutQueueLengthAndRun(1); // Builds tests - const changedTests = getOutputFileStamps(host); - verifyChangedFiles(changedTests, changedCore, [ - ...getOutputFileNames(SubProject.tests, "index") // Again these need not be written - ]); - host.checkTimeoutQueueLengthAndRun(1); // Builds logic - const changedLogic = getOutputFileStamps(host); - verifyChangedFiles(changedLogic, changedTests, [ - ...getOutputFileNames(SubProject.logic, "index") // Again these need not be written - ]); - host.checkTimeoutQueueLength(0); - checkOutputErrorsIncremental(host, emptyArray); + + // Another change requeues and builds it + verifyChange(core[1].content); + + function verifyChange(coreContent: string) { + const outputFileStamps = getOutputFileStamps(host); + host.writeFile(core[1].path, coreContent); + host.checkTimeoutQueueLengthAndRun(1); // Builds core + const changedCore = getOutputFileStamps(host); + verifyChangedFiles(changedCore, outputFileStamps, [ + ...getOutputFileNames(SubProject.core, "anotherModule"), // This should not be written really + ...getOutputFileNames(SubProject.core, "index") + ]); + host.checkTimeoutQueueLengthAndRun(1); // Builds tests + const changedTests = getOutputFileStamps(host); + verifyChangedFiles(changedTests, changedCore, [ + ...getOutputFileNames(SubProject.tests, "index") // Again these need not be written + ]); + host.checkTimeoutQueueLengthAndRun(1); // Builds logic + const changedLogic = getOutputFileStamps(host); + verifyChangedFiles(changedLogic, changedTests, [ + ...getOutputFileNames(SubProject.logic, "index") // Again these need not be written + ]); + host.checkTimeoutQueueLength(0); + checkOutputErrorsIncremental(host, emptyArray); + } }); // TODO: write tests reporting errors but that will have more involved work since file