Skip to content

Commit 926c6f1

Browse files
authored
Some of the test updates to ensure that it still tests what it is suppose to after we update watch path logic (#53726)
1 parent a97ba98 commit 926c6f1

File tree

69 files changed

+6291
-6158
lines changed

Some content is hidden

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

69 files changed

+6291
-6158
lines changed

src/testRunner/unittests/tscWatch/programUpdates.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -917,28 +917,28 @@ declare const eval: any`
917917
const changeModuleFileToModuleFile1: TscWatchCompileChange = {
918918
caption: "Rename moduleFile to moduleFile1",
919919
edit: sys => {
920-
sys.renameFile("/a/b/moduleFile.ts", "/a/b/moduleFile1.ts");
921-
sys.deleteFile("/a/b/moduleFile.js");
920+
sys.renameFile("/users/username/projects/project/moduleFile.ts", "/users/username/projects/project/moduleFile1.ts");
921+
sys.deleteFile("/users/username/projects/project/moduleFile.js");
922922
},
923923
timeouts: runQueuedTimeoutCallbacksTwice
924924
};
925925
const changeModuleFile1ToModuleFile: TscWatchCompileChange = {
926926
caption: "Rename moduleFile1 back to moduleFile",
927-
edit: sys => sys.renameFile("/a/b/moduleFile1.ts", "/a/b/moduleFile.ts"),
927+
edit: sys => sys.renameFile("/users/username/projects/project/moduleFile1.ts", "/users/username/projects/project/moduleFile.ts"),
928928
timeouts: runQueuedTimeoutCallbacksTwice,
929929
};
930930

931931
verifyTscWatch({
932932
scenario,
933933
subScenario: "rename a module file and rename back should restore the states for inferred projects",
934-
commandLineArgs: ["-w", "/a/b/file1.ts"],
934+
commandLineArgs: ["-w", "/users/username/projects/project/file1.ts"],
935935
sys: () => {
936936
const moduleFile = {
937-
path: "/a/b/moduleFile.ts",
937+
path: "/users/username/projects/project/moduleFile.ts",
938938
content: "export function bar() { };"
939939
};
940940
const file1 = {
941-
path: "/a/b/file1.ts",
941+
path: "/users/username/projects/project/file1.ts",
942942
content: 'import * as T from "./moduleFile"; T.bar();'
943943
};
944944
return createWatchedSystem([moduleFile, file1, libFile]);
@@ -952,16 +952,20 @@ declare const eval: any`
952952
verifyTscWatch({
953953
scenario,
954954
subScenario: "rename a module file and rename back should restore the states for configured projects",
955-
commandLineArgs: ["-w", "-p", configFilePath],
955+
commandLineArgs: ["-w", "-p", "/users/username/projects/project/tsconfig.json"],
956956
sys: () => {
957957
const moduleFile = {
958-
path: "/a/b/moduleFile.ts",
958+
path: "/users/username/projects/project/moduleFile.ts",
959959
content: "export function bar() { };"
960960
};
961961
const file1 = {
962-
path: "/a/b/file1.ts",
962+
path: "/users/username/projects/project/file1.ts",
963963
content: 'import * as T from "./moduleFile"; T.bar();'
964964
};
965+
const configFile = {
966+
path: "/users/username/projects/project/tsconfig.json",
967+
content: `{}`
968+
};
965969
return createWatchedSystem([moduleFile, file1, configFile, libFile]);
966970
},
967971
edits: [
@@ -1005,18 +1009,18 @@ declare const eval: any`
10051009
verifyTscWatch({
10061010
scenario,
10071011
subScenario: "add the missing module file for inferred project-should remove the module not found error",
1008-
commandLineArgs: ["-w", "/a/b/file1.ts"],
1012+
commandLineArgs: ["-w", "/users/username/projects/project/file1.ts"],
10091013
sys: () => {
10101014
const file1 = {
1011-
path: "/a/b/file1.ts",
1015+
path: "/users/username/projects/project/file1.ts",
10121016
content: 'import * as T from "./moduleFile"; T.bar();'
10131017
};
10141018
return createWatchedSystem([file1, libFile]);
10151019
},
10161020
edits: [
10171021
{
10181022
caption: "Create module file",
1019-
edit: sys => sys.writeFile("/a/b/moduleFile.ts", "export function bar() { }"),
1023+
edit: sys => sys.writeFile("/users/username/projects/project/moduleFile.ts", "export function bar() { }"),
10201024
timeouts: runQueuedTimeoutCallbacksTwice,
10211025
}
10221026
]

src/testRunner/unittests/tscWatch/resolutionCache.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -227,25 +227,25 @@ describe("unittests:: tsc-watch:: resolutionCache:: tsc-watch module resolution
227227
verifyTscWatch({
228228
scenario,
229229
subScenario: "works when module resolution changes to ambient module",
230-
commandLineArgs: ["-w", "/a/b/foo.ts"],
230+
commandLineArgs: ["-w", "/users/username/projects/project/foo.ts"],
231231
sys: () => createWatchedSystem([{
232-
path: "/a/b/foo.ts",
232+
path: "/users/username/projects/project/foo.ts",
233233
content: `import * as fs from "fs";`
234-
}, libFile], { currentDirectory: "/a/b" }),
234+
}, libFile], { currentDirectory: "/users/username/projects/project" }),
235235
edits: [
236236
{
237237
caption: "npm install node types",
238238
edit: sys => {
239239
sys.ensureFileOrFolder({
240-
path: "/a/b/node_modules/@types/node/package.json",
240+
path: "/users/username/projects/project/node_modules/@types/node/package.json",
241241
content: `
242242
{
243243
"main": ""
244244
}
245245
`
246246
});
247247
sys.ensureFileOrFolder({
248-
path: "/a/b/node_modules/@types/node/index.d.ts",
248+
path: "/users/username/projects/project/node_modules/@types/node/index.d.ts",
249249
content: `
250250
declare module "fs" {
251251
export interface Stats {
@@ -580,40 +580,40 @@ declare namespace NodeJS {
580580
scenario,
581581
subScenario: "reusing type ref resolution",
582582
sys: () => createWatchedSystem({
583-
"/src/project/tsconfig.json": JSON.stringify({
583+
"/users/username/projects/project/tsconfig.json": JSON.stringify({
584584
compilerOptions: {
585585
composite: true,
586586
traceResolution: true,
587587
outDir: "outDir",
588588
},
589589
}),
590-
"/src/project/fileWithImports.ts": Utils.dedent`
590+
"/users/username/projects/project/fileWithImports.ts": Utils.dedent`
591591
import type { Import0 } from "pkg0";
592592
import type { Import1 } from "pkg1";
593593
`,
594-
"/src/project/node_modules/pkg0/index.d.ts": `export interface Import0 {}`,
595-
"/src/project/fileWithTypeRefs.ts": Utils.dedent`
594+
"/users/username/projects/project/node_modules/pkg0/index.d.ts": `export interface Import0 {}`,
595+
"/users/username/projects/project/fileWithTypeRefs.ts": Utils.dedent`
596596
/// <reference types="pkg2"/>
597597
/// <reference types="pkg3"/>
598598
interface LocalInterface extends Import2, Import3 {}
599599
export {}
600600
`,
601-
"/src/project/node_modules/pkg2/index.d.ts": `interface Import2 {}`,
601+
"/users/username/projects/project/node_modules/pkg2/index.d.ts": `interface Import2 {}`,
602602
[libFile.path]: libFile.content,
603-
}, { currentDirectory: "/src/project" }),
603+
}, { currentDirectory: "/users/username/projects/project" }),
604604
commandLineArgs: ["-w", "--explainFiles", "--extendedDiagnostics"],
605605
edits: [
606606
{
607607
caption: "write file not resolved by import",
608-
edit: sys => sys.ensureFileOrFolder({ path: "/src/project/node_modules/pkg1/index.d.ts", content: `export interface Import1 {}` }),
608+
edit: sys => sys.ensureFileOrFolder({ path: "/users/username/projects/project/node_modules/pkg1/index.d.ts", content: `export interface Import1 {}` }),
609609
timeouts: sys => {
610610
sys.runQueuedTimeoutCallbacks(); // failed lookup
611611
sys.runQueuedTimeoutCallbacks(); // actual update
612612
}
613613
},
614614
{
615615
caption: "write file not resolved by typeRef",
616-
edit: sys => sys.ensureFileOrFolder({ path: "/src/project/node_modules/pkg3/index.d.ts", content: `export interface Import3 {}` }),
616+
edit: sys => sys.ensureFileOrFolder({ path: "/users/username/projects/project/node_modules/pkg3/index.d.ts", content: `export interface Import3 {}` }),
617617
timeouts: sys => {
618618
sys.runQueuedTimeoutCallbacks(); // failed lookup
619619
sys.runQueuedTimeoutCallbacks(); // actual update

src/testRunner/unittests/tsserver/cachingFileSystemInformation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ describe("unittests:: tsserver:: CachingFileSystemInformation:: tsserverProjectS
146146

147147
it("loads missing files from disk", () => {
148148
const root: File = {
149-
path: "/c/foo.ts",
149+
path: "/users/username/projects/project/foo.ts",
150150
content: `import {y} from "bar"`
151151
};
152152

153153
const imported: File = {
154-
path: "/c/bar.d.ts",
154+
path: "/users/username/projects/project/bar.d.ts",
155155
content: `export var y = 1`
156156
};
157157

@@ -318,7 +318,7 @@ describe("unittests:: tsserver:: CachingFileSystemInformation:: tsserverProjectS
318318

319319
describe("Subfolder invalidations correctly include parent folder failed lookup locations", () => {
320320
function runFailedLookupTest(resolution: "Node" | "Classic") {
321-
const projectLocation = "/proj";
321+
const projectLocation = "/users/username/projects/proj";
322322
const file1: File = {
323323
path: `${projectLocation}/foo/boo/app.ts`,
324324
content: `import * as debug from "debug"`

src/testRunner/unittests/tsserver/configuredProjects.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,19 +1054,19 @@ describe("unittests:: tsserver:: ConfiguredProjects:: non-existing directories l
10541054

10551055
it("Changed module resolution reflected when specifying files list", () => {
10561056
const file1: File = {
1057-
path: "/a/b/file1.ts",
1057+
path: "/users/username/projects/project/file1.ts",
10581058
content: 'import classc from "file2"'
10591059
};
10601060
const file2a: File = {
1061-
path: "/a/file2.ts",
1061+
path: "/users/username/projects/file2.ts",
10621062
content: "export classc { method2a() { return 10; } }"
10631063
};
10641064
const file2: File = {
1065-
path: "/a/b/file2.ts",
1065+
path: "/users/username/projects/project/file2.ts",
10661066
content: "export classc { method2() { return 10; } }"
10671067
};
10681068
const configFile: File = {
1069-
path: "/a/b/tsconfig.json",
1069+
path: "/users/username/projects/project/tsconfig.json",
10701070
content: JSON.stringify({ files: [file1.path], compilerOptions: { module: "amd" } })
10711071
};
10721072
const files = [file1, file2a, configFile, libFile];

src/testRunner/unittests/tsserver/events/projectUpdatedInBackground.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ describe("unittests:: tsserver:: events:: ProjectsUpdatedInBackground", () => {
1818
function verifyProjectsUpdatedInBackgroundEvent(scenario: string, createSession: (host: TestServerHost) => TestSession) {
1919
it("when adding new file", () => {
2020
const commonFile1: File = {
21-
path: "/a/b/file1.ts",
21+
path: "/users/username/projects/project/file1.ts",
2222
content: "export var x = 10;"
2323
};
2424
const commonFile2: File = {
25-
path: "/a/b/file2.ts",
25+
path: "/users/username/projects/project/file2.ts",
2626
content: "export var y = 10;"
2727
};
2828
const commonFile3: File = {
29-
path: "/a/b/file3.ts",
29+
path: "/users/username/projects/project/file3.ts",
3030
content: "export var z = 10;"
3131
};
3232
const configFile: File = {
33-
path: "/a/b/tsconfig.json",
33+
path: "/users/username/projects/project/tsconfig.json",
3434
content: `{}`
3535
};
3636
const host = createServerHost([commonFile1, libFile, configFile]);
@@ -49,18 +49,18 @@ describe("unittests:: tsserver:: events:: ProjectsUpdatedInBackground", () => {
4949
function verifyEventWithOutSettings(subScenario: string, compilerOptions: ts.CompilerOptions = {}) {
5050
it(subScenario, () => {
5151
const config: File = {
52-
path: "/a/tsconfig.json",
52+
path: "/users/username/projects/project/tsconfig.json",
5353
content: JSON.stringify({
5454
compilerOptions
5555
})
5656
};
5757

5858
const f1: File = {
59-
path: "/a/a.ts",
59+
path: "/users/username/projects/project/a.ts",
6060
content: "export let x = 1"
6161
};
6262
const f2: File = {
63-
path: "/a/b.ts",
63+
path: "/users/username/projects/project/b.ts",
6464
content: "export let y = 1"
6565
};
6666

@@ -83,9 +83,9 @@ describe("unittests:: tsserver:: events:: ProjectsUpdatedInBackground", () => {
8383
});
8484

8585
describe("with modules and configured project", () => {
86-
const file1Consumer1Path = "/a/b/file1Consumer1.ts";
87-
const moduleFile1Path = "/a/b/moduleFile1.ts";
88-
const configFilePath = "/a/b/tsconfig.json";
86+
const file1Consumer1Path = "/users/username/projects/project/file1Consumer1.ts";
87+
const moduleFile1Path = "/users/username/projects/project/moduleFile1.ts";
88+
const configFilePath = "/users/username/projects/project/tsconfig.json";
8989
interface InitialStateParams {
9090
/** custom config file options */
9191
configObj?: any;
@@ -106,17 +106,17 @@ describe("unittests:: tsserver:: events:: ProjectsUpdatedInBackground", () => {
106106
};
107107

108108
const file1Consumer2: File = {
109-
path: "/a/b/file1Consumer2.ts",
109+
path: "/users/username/projects/project/file1Consumer2.ts",
110110
content: `import {Foo} from "./moduleFile1"; let z = 10;`,
111111
};
112112

113113
const moduleFile2: File = {
114-
path: "/a/b/moduleFile2.ts",
114+
path: "/users/username/projects/project/moduleFile2.ts",
115115
content: `export var Foo4 = 10;`,
116116
};
117117

118118
const globalFile3: File = {
119-
path: "/a/b/globalFile3.ts",
119+
path: "/users/username/projects/project/globalFile3.ts",
120120
content: `interface GlobalFoo { age: number }`
121121
};
122122

@@ -219,7 +219,7 @@ describe("unittests:: tsserver:: events:: ProjectsUpdatedInBackground", () => {
219219
const { host, moduleFile1, session, } = getInitialState();
220220

221221
host.writeFile(moduleFile1.path, `export var T: number;export function Foo() { };`);
222-
host.writeFile("/a/b/file1Consumer3.ts", `import {Foo} from "./moduleFile1"; let y = Foo();`);
222+
host.writeFile("/users/username/projects/project/file1Consumer3.ts", `import {Foo} from "./moduleFile1"; let y = Foo();`);
223223
host.runQueuedTimeoutCallbacks();
224224
baselineTsserverLogs("events/projectUpdatedInBackground", `${scenario} and should be up-to-date with newly created files`, session);
225225
});
@@ -257,7 +257,7 @@ describe("unittests:: tsserver:: events:: ProjectsUpdatedInBackground", () => {
257257
});
258258

259259
it("should always return the file itself if '--out' or '--outFile' is specified", () => {
260-
const outFilePath = "/a/b/out.js";
260+
const outFilePath = "/users/username/projects/project/out.js";
261261
const { host, moduleFile1, session } = getInitialState({
262262
configObj: { compilerOptions: { module: "system", outFile: outFilePath } }
263263
});
@@ -269,7 +269,7 @@ describe("unittests:: tsserver:: events:: ProjectsUpdatedInBackground", () => {
269269

270270
it("should return cascaded affected file list", () => {
271271
const file1Consumer1Consumer1: File = {
272-
path: "/a/b/file1Consumer1Consumer1.ts",
272+
path: "/users/username/projects/project/file1Consumer1Consumer1.ts",
273273
content: `import {y} from "./file1Consumer1";`
274274
};
275275
const { host, moduleFile1, file1Consumer1, updateContentOfOpenFile, session } = getInitialState({
@@ -292,13 +292,13 @@ describe("unittests:: tsserver:: events:: ProjectsUpdatedInBackground", () => {
292292

293293
it("should work fine for files with circular references", () => {
294294
const file1: File = {
295-
path: "/a/b/file1.ts",
295+
path: "/users/username/projects/project/file1.ts",
296296
content: `
297297
/// <reference path="./file2.ts" />
298298
export var t1 = 10;`
299299
};
300300
const file2: File = {
301-
path: "/a/b/file2.ts",
301+
path: "/users/username/projects/project/file2.ts",
302302
content: `
303303
/// <reference path="./file1.ts" />
304304
export var t2 = 10;`
@@ -315,7 +315,7 @@ describe("unittests:: tsserver:: events:: ProjectsUpdatedInBackground", () => {
315315

316316
it("should detect removed code file", () => {
317317
const referenceFile1: File = {
318-
path: "/a/b/referenceFile1.ts",
318+
path: "/users/username/projects/project/referenceFile1.ts",
319319
content: `
320320
/// <reference path="./moduleFile1.ts" />
321321
export var x = Foo();`
@@ -332,7 +332,7 @@ describe("unittests:: tsserver:: events:: ProjectsUpdatedInBackground", () => {
332332

333333
it("should detect non-existing code file", () => {
334334
const referenceFile1: File = {
335-
path: "/a/b/referenceFile1.ts",
335+
path: "/users/username/projects/project/referenceFile1.ts",
336336
content: `
337337
/// <reference path="./moduleFile2.ts" />
338338
export var x = Foo();`

0 commit comments

Comments
 (0)