Update tests after the merge from master

This commit is contained in:
Sheetal Nandi 2017-10-05 09:54:21 -07:00
parent 03441fe120
commit 2facead886
3 changed files with 14 additions and 16 deletions

View File

@ -352,8 +352,6 @@ namespace ts.projectSystem {
verifyDiagnostics(actual, []);
}
const typeRootFromTsserverLocation = "/node_modules/@types";
export function getTypeRootsFromLocation(currentDirectory: string) {
currentDirectory = normalizePath(currentDirectory);
const result: string[] = [];
@ -401,7 +399,7 @@ namespace ts.projectSystem {
const configFiles = flatMap(configFileLocations, location => [location + "tsconfig.json", location + "jsconfig.json"]);
checkWatchedFiles(host, configFiles.concat(libFile.path, moduleFile.path));
checkWatchedDirectories(host, [], /*recursive*/ false);
checkWatchedDirectories(host, ["/a/b/c", typeRootFromTsserverLocation], /*recursive*/ true);
checkWatchedDirectories(host, ["/a/b/c", ...getTypeRootsFromLocation(getDirectoryPath(appFile.path))], /*recursive*/ true);
});
it("can handle tsconfig file name with difference casing", () => {
@ -4331,7 +4329,7 @@ namespace ts.projectSystem {
function verifyCalledOnEachEntry(callback: CalledMaps, expectedKeys: Map<number>) {
const calledMap = calledMaps[callback];
assert.equal(calledMap.size, expectedKeys.size, `${callback}: incorrect size of map: Actual keys: ${arrayFrom(calledMap.keys())} Expected: ${arrayFrom(expectedKeys.keys())}`);
ts.TestFSWithWatch.verifyMapSize(callback, calledMap, arrayFrom(expectedKeys.keys()));
expectedKeys.forEach((called, name) => {
assert.isTrue(calledMap.has(name), `${callback} is expected to contain ${name}, actual keys: ${arrayFrom(calledMap.keys())}`);
assert.equal(calledMap.get(name).length, called, `${callback} is expected to be called ${called} times with ${name}. Actual entry: ${calledMap.get(name)}`);
@ -4413,6 +4411,7 @@ namespace ts.projectSystem {
}
const f2Lookups = getLocationsForModuleLookup("f2");
callsTrackingHost.verifyCalledOnEachEntryNTimes(CalledMapsWithSingleArg.fileExists, f2Lookups, 1);
const typeRootLocations = getTypeRootsFromLocation(getDirectoryPath(root.path));
const f2DirLookups = getLocationsForDirectoryLookup();
callsTrackingHost.verifyCalledOnEachEntry(CalledMapsWithSingleArg.directoryExists, f2DirLookups);
callsTrackingHost.verifyNoCall(CalledMapsWithSingleArg.getDirectories);
@ -4423,7 +4422,7 @@ namespace ts.projectSystem {
verifyImportedDiagnostics();
const f1Lookups = f2Lookups.map(s => s.replace("f2", "f1"));
f1Lookups.length = f1Lookups.indexOf(imported.path) + 1;
const f1DirLookups = ["/c/d", "/c", typeRootFromTsserverLocation];
const f1DirLookups = ["/c/d", "/c", ...typeRootLocations];
vertifyF1Lookups();
// setting compiler options discards module resolution cache
@ -4475,7 +4474,7 @@ namespace ts.projectSystem {
function getLocationsForDirectoryLookup() {
const result = createMap<number>();
// Type root
result.set(typeRootFromTsserverLocation, 1);
typeRootLocations.forEach(location => result.set(location, 1));
forEachAncestorDirectory(getDirectoryPath(root.path), ancestor => {
// To resolve modules
result.set(ancestor, 2);

View File

@ -95,7 +95,7 @@ namespace ts.TestFSWithWatch {
}
}
function getDiffInKeys(map: Map<any>, expectedKeys: ReadonlyArray<string>) {
function getDiffInKeys<T>(map: Map<T>, expectedKeys: ReadonlyArray<string>) {
if (map.size === expectedKeys.length) {
return "";
}
@ -122,8 +122,12 @@ namespace ts.TestFSWithWatch {
return `\n\nNotInActual: ${notInActual}\nDuplicates: ${duplicates}\nInActualButNotInExpected: ${inActualNotExpected}`;
}
function checkMapKeys(caption: string, map: Map<any>, expectedKeys: ReadonlyArray<string>) {
export function verifyMapSize(caption: string, map: Map<any>, expectedKeys: ReadonlyArray<string>) {
assert.equal(map.size, expectedKeys.length, `${caption}: incorrect size of map: Actual keys: ${arrayFrom(map.keys())} Expected: ${expectedKeys}${getDiffInKeys(map, expectedKeys)}`);
}
function checkMapKeys(caption: string, map: Map<any>, expectedKeys: ReadonlyArray<string>) {
verifyMapSize(caption, map, expectedKeys);
for (const name of expectedKeys) {
assert.isTrue(map.has(name), `${caption} is expected to contain ${name}, actual keys: ${arrayFrom(map.keys())}`);
}
@ -548,7 +552,7 @@ namespace ts.TestFSWithWatch {
const folder = this.toFolder(directoryName);
// base folder has to be present
const base = getDirectoryPath(folder.fullPath);
const base = getDirectoryPath(folder.path);
const baseFolder = this.fs.get(base) as Folder;
Debug.assert(isFolder(baseFolder));
@ -560,7 +564,7 @@ namespace ts.TestFSWithWatch {
const file = this.toFile({ path, content });
// base folder has to be present
const base = getDirectoryPath(file.fullPath);
const base = getDirectoryPath(file.path);
const folder = this.fs.get(base) as Folder;
Debug.assert(isFolder(folder));

View File

@ -7131,7 +7131,6 @@ declare namespace ts.server {
enableLanguageService(): void;
disableLanguageService(): void;
getProjectName(): string;
abstract getProjectRootPath(): string | undefined;
abstract getTypeAcquisition(): TypeAcquisition;
getExternalFiles(): SortedReadonlyArray<string>;
getSourceFile(path: Path): SourceFile;
@ -7184,7 +7183,6 @@ declare namespace ts.server {
addRoot(info: ScriptInfo): void;
removeRoot(info: ScriptInfo): void;
isProjectWithSingleRoot(): boolean;
getProjectRootPath(): string;
close(): void;
getTypeAcquisition(): TypeAcquisition;
}
@ -7211,7 +7209,6 @@ declare namespace ts.server {
enablePlugins(): void;
private enablePlugin(pluginConfigEntry, searchPaths);
private enableProxy(pluginModuleFactory, configEntry);
getProjectRootPath(): string;
/**
* Get the errors that dont have any file name associated
*/
@ -7237,11 +7234,9 @@ declare namespace ts.server {
class ExternalProject extends Project {
externalProjectName: string;
compileOnSaveEnabled: boolean;
private readonly projectFilePath;
excludedFiles: ReadonlyArray<NormalizedPath>;
private typeAcquisition;
getExcludedFiles(): ReadonlyArray<NormalizedPath>;
getProjectRootPath(): string;
getTypeAcquisition(): TypeAcquisition;
setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void;
}
@ -7519,7 +7514,7 @@ declare namespace ts.server {
private updateNonInferredProject<T>(project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave);
private getOrCreateInferredProjectForProjectRootPathIfEnabled(info, projectRootPath);
private getOrCreateSingleInferredProjectIfEnabled();
private createInferredProject(rootDirectoryForResolution, isSingleInferredProject?, projectRootPath?);
private createInferredProject(currentDirectory, isSingleInferredProject?, projectRootPath?);
getScriptInfo(uncheckedFileName: string): ScriptInfo;
private watchClosedScriptInfo(info);
private stopWatchingScriptInfo(info);