Skip to content

Commit 7f9d9e5

Browse files
committed
Baseline before change
1 parent 0ca1973 commit 7f9d9e5

File tree

41 files changed

+92804
-60
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+92804
-60
lines changed

src/testRunner/unittests/canWatch.ts

Lines changed: 64 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -55,71 +55,75 @@ describe("unittests:: canWatch::", () => {
5555
scenario: string,
5656
forPath: "node_modules" | "node_modules/@types" | "",
5757
) {
58-
["file", "dir", "subDir"].forEach(type => {
59-
baselineCanWatch(
60-
`${scenario}In${type}`,
61-
() => `Determines whether to watch given failed lookup location (file that didnt exist) when resolving module.\r\nIt also determines the directory to watch and whether to watch it recursively or not.`,
62-
(paths, longestPathLength, baseline) => {
63-
const recursive = "Recursive";
64-
const maxLength = longestPathLength + ts.combinePaths(forPath, "dir/subdir/somefile.d.ts").length;
65-
const maxLengths = [maxLength, maxLength, recursive.length, maxLength] as const;
66-
baselineCanWatchForRoot(paths, baseline, (rootPathCompoments, root) => {
67-
pushHeader(baseline, ["Location", "getDirectoryToWatchFailedLookupLocation", recursive, "Location if not symlink"], maxLengths);
68-
paths.forEach(path => {
69-
let subPath;
70-
switch (type) {
71-
case "file":
72-
subPath = "somefile.d.ts";
73-
break;
74-
case "dir":
75-
subPath = "dir/somefile.d.ts";
76-
break;
77-
case "subDir":
78-
subPath = "dir/subdir/somefile.d.ts";
79-
break;
80-
}
81-
const testPath = combinePaths(path, forPath, subPath);
82-
const result = ts.getDirectoryToWatchFailedLookupLocation(
83-
testPath,
84-
testPath,
85-
root,
86-
root,
87-
rootPathCompoments,
88-
ts.returnUndefined,
89-
);
90-
pushRow(baseline, [testPath, result ? result.packageDir ?? result.dir : "", result ? `${!result.nonRecursive}` : "", result?.packageDir ? result.dir : ""], maxLengths);
58+
[undefined, true].forEach(preferNonRecursiveWatch => {
59+
["file", "dir", "subDir"].forEach(type => {
60+
baselineCanWatch(
61+
`${scenario}In${type}${preferNonRecursiveWatch ? "NonRecursive" : ""}`,
62+
() => `Determines whether to watch given failed lookup location (file that didnt exist) when resolving module.\r\nIt also determines the directory to watch and whether to watch it recursively or not.`,
63+
(paths, longestPathLength, baseline) => {
64+
const recursive = "Recursive";
65+
const maxLength = longestPathLength + ts.combinePaths(forPath, "dir/subdir/somefile.d.ts").length;
66+
const maxLengths = [maxLength, maxLength, recursive.length, maxLength] as const;
67+
baselineCanWatchForRoot(paths, baseline, (rootPathCompoments, root) => {
68+
pushHeader(baseline, ["Location", "getDirectoryToWatchFailedLookupLocation", recursive, "Location if not symlink"], maxLengths);
69+
paths.forEach(path => {
70+
let subPath;
71+
switch (type) {
72+
case "file":
73+
subPath = "somefile.d.ts";
74+
break;
75+
case "dir":
76+
subPath = "dir/somefile.d.ts";
77+
break;
78+
case "subDir":
79+
subPath = "dir/subdir/somefile.d.ts";
80+
break;
81+
}
82+
const testPath = combinePaths(path, forPath, subPath);
83+
const result = ts.getDirectoryToWatchFailedLookupLocation(
84+
testPath,
85+
testPath,
86+
root,
87+
root,
88+
rootPathCompoments,
89+
ts.returnUndefined,
90+
);
91+
pushRow(baseline, [testPath, result ? result.packageDir ?? result.dir : "", result ? `${!result.nonRecursive}` : "", result?.packageDir ? result.dir : ""], maxLengths);
92+
});
9193
});
92-
});
93-
},
94-
);
94+
},
95+
);
96+
});
9597
});
9698
}
9799

98-
baselineCanWatch(
99-
"getDirectoryToWatchFailedLookupLocationFromTypeRoot",
100-
() => `When watched typeRoot handler is invoked, this method determines the directory for which the failedLookupLocation would need to be invalidated.\r\nSince this is invoked only when watching default typeRoot and is used to handle flaky directory watchers, this is used as a fail safe where if failed lookup starts with returned directory we will invalidate that resolution.`,
101-
(paths, longestPathLength, baseline) => {
102-
const maxLength = longestPathLength + "/node_modules/@types".length;
103-
const maxLengths = [maxLength, maxLength] as const;
104-
baselineCanWatchForRoot(paths, baseline, (rootPathCompoments, root) => {
105-
pushHeader(baseline, ["Directory", "getDirectoryToWatchFailedLookupLocationFromTypeRoot"], maxLengths);
106-
paths.forEach(path => {
107-
path = combinePaths(path, "node_modules/@types");
108-
// This is invoked only on paths that are watched
109-
if (!ts.canWatchAtTypes(path)) return;
110-
const result = ts.getDirectoryToWatchFailedLookupLocationFromTypeRoot(
111-
path,
112-
path,
113-
root,
114-
rootPathCompoments,
115-
ts.returnUndefined,
116-
ts.returnTrue,
117-
);
118-
pushRow(baseline, [path, result !== undefined ? result : ""], maxLengths);
100+
[undefined, true].forEach(preferNonRecursiveWatch => {
101+
baselineCanWatch(
102+
`getDirectoryToWatchFailedLookupLocationFromTypeRoot${preferNonRecursiveWatch ? "NonRecursive" : ""}`,
103+
() => `When watched typeRoot handler is invoked, this method determines the directory for which the failedLookupLocation would need to be invalidated.\r\nSince this is invoked only when watching default typeRoot and is used to handle flaky directory watchers, this is used as a fail safe where if failed lookup starts with returned directory we will invalidate that resolution.`,
104+
(paths, longestPathLength, baseline) => {
105+
const maxLength = longestPathLength + "/node_modules/@types".length;
106+
const maxLengths = [maxLength, maxLength] as const;
107+
baselineCanWatchForRoot(paths, baseline, (rootPathCompoments, root) => {
108+
pushHeader(baseline, ["Directory", "getDirectoryToWatchFailedLookupLocationFromTypeRoot"], maxLengths);
109+
paths.forEach(path => {
110+
path = combinePaths(path, "node_modules/@types");
111+
// This is invoked only on paths that are watched
112+
if (!ts.canWatchAtTypes(path)) return;
113+
const result = ts.getDirectoryToWatchFailedLookupLocationFromTypeRoot(
114+
path,
115+
path,
116+
root,
117+
rootPathCompoments,
118+
ts.returnUndefined,
119+
ts.returnTrue,
120+
);
121+
pushRow(baseline, [path, result !== undefined ? result : ""], maxLengths);
122+
});
119123
});
120-
});
121-
},
122-
);
124+
},
125+
);
126+
});
123127

124128
function baselineCanWatchForRoot(paths: readonly ts.Path[], baseline: string[], baselineForRoot: (rootPathCompoments: Readonly<ts.PathPathComponents>, root: ts.Path) => void) {
125129
paths.forEach(rootDirForResolution => {

0 commit comments

Comments
 (0)