Remove getUpToDateStatusOfFile from solution builder since that test anyways is tested with the --watch mode

This commit is contained in:
Sheetal Nandi 2019-04-18 16:22:13 -07:00
parent e9d4e0b104
commit 92365027a1
2 changed files with 7 additions and 68 deletions

View file

@ -306,10 +306,13 @@ namespace ts {
buildAllProjects(): ExitStatus;
cleanAllProjects(): ExitStatus;
// Currently used for testing but can be made public if needed:
/*@internal*/ getBuildOrder(): ReadonlyArray<ResolvedConfigFileName>;
// Testing only
// TODO:: All the below ones should technically only be in watch mode. but thats for later time
/*@internal*/ resolveProjectName(name: string): ResolvedConfigFileName;
/*@internal*/ getUpToDateStatusOfFile(configFileName: ResolvedConfigFileName): UpToDateStatus;
/*@internal*/ getBuildOrder(): ReadonlyArray<ResolvedConfigFileName>;
/*@internal*/ invalidateProject(configFileName: string, reloadLevel?: ConfigFileProgramReloadLevel): void;
/*@internal*/ buildInvalidatedProject(): void;
@ -413,7 +416,6 @@ namespace ts {
return {
buildAllProjects,
getUpToDateStatusOfFile,
cleanAllProjects,
resetBuildContext,
getBuildOrder,
@ -603,12 +605,8 @@ namespace ts {
scheduleBuildInvalidatedProject();
}
function getUpToDateStatusOfFile(configFileName: ResolvedConfigFileName): UpToDateStatus {
return getUpToDateStatus(parseConfigFile(configFileName));
}
function getBuildOrder() {
return buildOrder || (buildOrder = createBuildOrder(resolveProjectNames(rootNames)));
return buildOrder || (buildOrder = createBuildOrder(rootNames.map(resolveProjectName)));
}
function getUpToDateStatus(project: ParsedCommandLine | undefined): UpToDateStatus {
@ -1004,7 +1002,7 @@ namespace ts {
}
}
function createBuildOrder(roots: ResolvedConfigFileName[]): readonly ResolvedConfigFileName[] {
function createBuildOrder(roots: readonly ResolvedConfigFileName[]): readonly ResolvedConfigFileName[] {
const temporaryMarks = createFileMap<true>(toPath);
const permanentMarks = createFileMap<true>(toPath);
const circularityReportStack: string[] = [];
@ -1344,10 +1342,6 @@ namespace ts {
return resolveConfigFileProjectName(resolvePath(host.getCurrentDirectory(), name));
}
function resolveProjectNames(configFileNames: ReadonlyArray<string>): ResolvedConfigFileName[] {
return configFileNames.map(resolveProjectName);
}
function buildAllProjects(): ExitStatus {
if (options.watch) { reportWatchStatus(Diagnostics.Starting_compilation_in_watch_mode); }
// TODO:: In watch mode as well to use caches for incremental build once we can invalidate caches correctly and have right api

View file

@ -337,61 +337,6 @@ namespace ts {
});
});
describe("project invalidation", () => {
it("invalidates projects correctly", () => {
const fs = projFs.shadow();
const host = new fakes.SolutionBuilderHost(fs);
const builder = createSolutionBuilder(host, ["/src/tests"], { dry: false, force: false, verbose: false });
builder.buildAllProjects();
host.assertDiagnosticMessages(/*empty*/);
// Update a timestamp in the middle project
tick();
appendText(fs, "/src/logic/index.ts", "function foo() {}");
const originalWriteFile = fs.writeFileSync;
const writtenFiles = createMap<true>();
fs.writeFileSync = (path, data, encoding) => {
writtenFiles.set(path, true);
originalWriteFile.call(fs, path, data, encoding);
};
// Because we haven't reset the build context, the builder should assume there's nothing to do right now
const status = builder.getUpToDateStatusOfFile(builder.resolveProjectName("/src/logic"));
assert.equal(status.type, UpToDateStatusType.UpToDate, "Project should be assumed to be up-to-date");
verifyInvalidation(/*expectedToWriteTests*/ false);
// Rebuild this project
fs.writeFileSync("/src/logic/index.ts", `${fs.readFileSync("/src/logic/index.ts")}
export class cNew {}`);
verifyInvalidation(/*expectedToWriteTests*/ true);
function verifyInvalidation(expectedToWriteTests: boolean) {
// Rebuild this project
tick();
builder.invalidateProject("/src/logic");
builder.buildInvalidatedProject();
// The file should be updated
assert.isTrue(writtenFiles.has("/src/logic/index.js"), "JS file should have been rebuilt");
assert.equal(fs.statSync("/src/logic/index.js").mtimeMs, time(), "JS file should have been rebuilt");
assert.isFalse(writtenFiles.has("/src/tests/index.js"), "Downstream JS file should *not* have been rebuilt");
assert.isBelow(fs.statSync("/src/tests/index.js").mtimeMs, time(), "Downstream JS file should *not* have been rebuilt");
writtenFiles.clear();
// Build downstream projects should update 'tests', but not 'core'
tick();
builder.buildInvalidatedProject();
if (expectedToWriteTests) {
assert.isTrue(writtenFiles.has("/src/tests/index.js"), "Downstream JS file should have been rebuilt");
}
else {
assert.equal(writtenFiles.size, 0, "Should not write any new files");
}
assert.equal(fs.statSync("/src/tests/index.js").mtimeMs, time(), "Downstream JS file should have new timestamp");
assert.isBelow(fs.statSync("/src/core/index.js").mtimeMs, time(), "Upstream JS file should not have been rebuilt");
}
});
});
describe("lists files", () => {
it("listFiles", () => {
const fs = projFs.shadow();