Skip to content

Commit 2facead

Browse files
committed
Update tests after the merge from master
1 parent 03441fe commit 2facead

3 files changed

Lines changed: 14 additions & 16 deletions

File tree

‎src/harness/unittests/tsserverProjectSystem.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,6 @@ namespace ts.projectSystem {
352352
verifyDiagnostics(actual, []);
353353
}
354354

355-
const typeRootFromTsserverLocation = "/node_modules/@types";
356-
357355
export function getTypeRootsFromLocation(currentDirectory: string) {
358356
currentDirectory = normalizePath(currentDirectory);
359357
const result: string[] = [];
@@ -401,7 +399,7 @@ namespace ts.projectSystem {
401399
const configFiles = flatMap(configFileLocations, location => [location + "tsconfig.json", location + "jsconfig.json"]);
402400
checkWatchedFiles(host, configFiles.concat(libFile.path, moduleFile.path));
403401
checkWatchedDirectories(host, [], /*recursive*/ false);
404-
checkWatchedDirectories(host, ["/a/b/c", typeRootFromTsserverLocation], /*recursive*/ true);
402+
checkWatchedDirectories(host, ["/a/b/c", ...getTypeRootsFromLocation(getDirectoryPath(appFile.path))], /*recursive*/ true);
405403
});
406404

407405
it("can handle tsconfig file name with difference casing", () => {
@@ -4331,7 +4329,7 @@ namespace ts.projectSystem {
43314329

43324330
function verifyCalledOnEachEntry(callback: CalledMaps, expectedKeys: Map<number>) {
43334331
const calledMap = calledMaps[callback];
4334-
assert.equal(calledMap.size, expectedKeys.size, `${callback}: incorrect size of map: Actual keys: ${arrayFrom(calledMap.keys())} Expected: ${arrayFrom(expectedKeys.keys())}`);
4332+
ts.TestFSWithWatch.verifyMapSize(callback, calledMap, arrayFrom(expectedKeys.keys()));
43354333
expectedKeys.forEach((called, name) => {
43364334
assert.isTrue(calledMap.has(name), `${callback} is expected to contain ${name}, actual keys: ${arrayFrom(calledMap.keys())}`);
43374335
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 {
44134411
}
44144412
const f2Lookups = getLocationsForModuleLookup("f2");
44154413
callsTrackingHost.verifyCalledOnEachEntryNTimes(CalledMapsWithSingleArg.fileExists, f2Lookups, 1);
4414+
const typeRootLocations = getTypeRootsFromLocation(getDirectoryPath(root.path));
44164415
const f2DirLookups = getLocationsForDirectoryLookup();
44174416
callsTrackingHost.verifyCalledOnEachEntry(CalledMapsWithSingleArg.directoryExists, f2DirLookups);
44184417
callsTrackingHost.verifyNoCall(CalledMapsWithSingleArg.getDirectories);
@@ -4423,7 +4422,7 @@ namespace ts.projectSystem {
44234422
verifyImportedDiagnostics();
44244423
const f1Lookups = f2Lookups.map(s => s.replace("f2", "f1"));
44254424
f1Lookups.length = f1Lookups.indexOf(imported.path) + 1;
4426-
const f1DirLookups = ["/c/d", "/c", typeRootFromTsserverLocation];
4425+
const f1DirLookups = ["/c/d", "/c", ...typeRootLocations];
44274426
vertifyF1Lookups();
44284427

44294428
// setting compiler options discards module resolution cache
@@ -4475,7 +4474,7 @@ namespace ts.projectSystem {
44754474
function getLocationsForDirectoryLookup() {
44764475
const result = createMap<number>();
44774476
// Type root
4478-
result.set(typeRootFromTsserverLocation, 1);
4477+
typeRootLocations.forEach(location => result.set(location, 1));
44794478
forEachAncestorDirectory(getDirectoryPath(root.path), ancestor => {
44804479
// To resolve modules
44814480
result.set(ancestor, 2);

‎src/harness/virtualFileSystemWithWatch.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ namespace ts.TestFSWithWatch {
9595
}
9696
}
9797

98-
function getDiffInKeys(map: Map<any>, expectedKeys: ReadonlyArray<string>) {
98+
function getDiffInKeys<T>(map: Map<T>, expectedKeys: ReadonlyArray<string>) {
9999
if (map.size === expectedKeys.length) {
100100
return "";
101101
}
@@ -122,8 +122,12 @@ namespace ts.TestFSWithWatch {
122122
return `\n\nNotInActual: ${notInActual}\nDuplicates: ${duplicates}\nInActualButNotInExpected: ${inActualNotExpected}`;
123123
}
124124

125-
function checkMapKeys(caption: string, map: Map<any>, expectedKeys: ReadonlyArray<string>) {
125+
export function verifyMapSize(caption: string, map: Map<any>, expectedKeys: ReadonlyArray<string>) {
126126
assert.equal(map.size, expectedKeys.length, `${caption}: incorrect size of map: Actual keys: ${arrayFrom(map.keys())} Expected: ${expectedKeys}${getDiffInKeys(map, expectedKeys)}`);
127+
}
128+
129+
function checkMapKeys(caption: string, map: Map<any>, expectedKeys: ReadonlyArray<string>) {
130+
verifyMapSize(caption, map, expectedKeys);
127131
for (const name of expectedKeys) {
128132
assert.isTrue(map.has(name), `${caption} is expected to contain ${name}, actual keys: ${arrayFrom(map.keys())}`);
129133
}
@@ -548,7 +552,7 @@ namespace ts.TestFSWithWatch {
548552
const folder = this.toFolder(directoryName);
549553

550554
// base folder has to be present
551-
const base = getDirectoryPath(folder.fullPath);
555+
const base = getDirectoryPath(folder.path);
552556
const baseFolder = this.fs.get(base) as Folder;
553557
Debug.assert(isFolder(baseFolder));
554558

@@ -560,7 +564,7 @@ namespace ts.TestFSWithWatch {
560564
const file = this.toFile({ path, content });
561565

562566
// base folder has to be present
563-
const base = getDirectoryPath(file.fullPath);
567+
const base = getDirectoryPath(file.path);
564568
const folder = this.fs.get(base) as Folder;
565569
Debug.assert(isFolder(folder));
566570

‎tests/baselines/reference/api/tsserverlibrary.d.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7131,7 +7131,6 @@ declare namespace ts.server {
71317131
enableLanguageService(): void;
71327132
disableLanguageService(): void;
71337133
getProjectName(): string;
7134-
abstract getProjectRootPath(): string | undefined;
71357134
abstract getTypeAcquisition(): TypeAcquisition;
71367135
getExternalFiles(): SortedReadonlyArray<string>;
71377136
getSourceFile(path: Path): SourceFile;
@@ -7184,7 +7183,6 @@ declare namespace ts.server {
71847183
addRoot(info: ScriptInfo): void;
71857184
removeRoot(info: ScriptInfo): void;
71867185
isProjectWithSingleRoot(): boolean;
7187-
getProjectRootPath(): string;
71887186
close(): void;
71897187
getTypeAcquisition(): TypeAcquisition;
71907188
}
@@ -7211,7 +7209,6 @@ declare namespace ts.server {
72117209
enablePlugins(): void;
72127210
private enablePlugin(pluginConfigEntry, searchPaths);
72137211
private enableProxy(pluginModuleFactory, configEntry);
7214-
getProjectRootPath(): string;
72157212
/**
72167213
* Get the errors that dont have any file name associated
72177214
*/
@@ -7237,11 +7234,9 @@ declare namespace ts.server {
72377234
class ExternalProject extends Project {
72387235
externalProjectName: string;
72397236
compileOnSaveEnabled: boolean;
7240-
private readonly projectFilePath;
72417237
excludedFiles: ReadonlyArray<NormalizedPath>;
72427238
private typeAcquisition;
72437239
getExcludedFiles(): ReadonlyArray<NormalizedPath>;
7244-
getProjectRootPath(): string;
72457240
getTypeAcquisition(): TypeAcquisition;
72467241
setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void;
72477242
}
@@ -7519,7 +7514,7 @@ declare namespace ts.server {
75197514
private updateNonInferredProject<T>(project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave);
75207515
private getOrCreateInferredProjectForProjectRootPathIfEnabled(info, projectRootPath);
75217516
private getOrCreateSingleInferredProjectIfEnabled();
7522-
private createInferredProject(rootDirectoryForResolution, isSingleInferredProject?, projectRootPath?);
7517+
private createInferredProject(currentDirectory, isSingleInferredProject?, projectRootPath?);
75237518
getScriptInfo(uncheckedFileName: string): ScriptInfo;
75247519
private watchClosedScriptInfo(info);
75257520
private stopWatchingScriptInfo(info);

0 commit comments

Comments
 (0)