Skip to content

Commit b846905

Browse files
committed
Add failing test
1 parent a2b785b commit b846905

File tree

3 files changed

+346
-0
lines changed

3 files changed

+346
-0
lines changed

src/testRunner/unittests/config/tsconfigParsing.ts

+9
Original file line numberDiff line numberDiff line change
@@ -421,5 +421,14 @@ namespace ts {
421421
const parsedCommand = parseJsonConfigFileContent(parsed.config, sys, "/foo.bar");
422422
assert.deepEqual(parsedCommand.wildcardDirectories, { "/foo.bar/src": WatchDirectoryFlags.Recursive });
423423
});
424+
425+
it("correctly parses wild card directories from implicit glob when two keys differ only in directory seperator", () => {
426+
const parsed = parseConfigFileTextToJson("/foo.bar/tsconfig.json", JSON.stringify({
427+
include: ["./", "./**/*.json"]
428+
}));
429+
430+
const parsedCommand = parseJsonConfigFileContent(parsed.config, sys, "/foo");
431+
assert.deepEqual(parsedCommand.wildcardDirectories, { "/foo": WatchDirectoryFlags.Recursive });
432+
});
424433
});
425434
}

src/testRunner/unittests/tscWatch/programUpdates.ts

+33
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,39 @@ export class A {
616616
]
617617
});
618618

619+
verifyTscWatch({
620+
scenario,
621+
subScenario: "correctly parses wild card directories from implicit glob when two keys differ only in directory seperator",
622+
commandLineArgs: ["-w", "--extendedDiagnostics"],
623+
sys: () => {
624+
const file1 = {
625+
path: `${projectRoot}/f1.ts`,
626+
content: "export const x = 1"
627+
};
628+
const file2 = {
629+
path: `${projectRoot}/f2.ts`,
630+
content: "export const y = 1"
631+
};
632+
const configFile = {
633+
path: `${projectRoot}/tsconfig.json`,
634+
content: JSON.stringify({ compilerOptions: { composite: true }, include: ["./", "./**/*.json"] })
635+
};
636+
return createWatchedSystem([file1, file2, libFile, configFile], { currentDirectory: projectRoot });
637+
},
638+
changes: [
639+
{
640+
caption: "Add new file",
641+
change: sys => sys.writeFile(`${projectRoot}/new-file.ts`, "export const z = 1;"),
642+
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(0),
643+
},
644+
{
645+
caption: "Import new file",
646+
change: sys => sys.prependFile(`${projectRoot}/f1.ts`, `import { z } from "./new-file";`),
647+
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
648+
}
649+
]
650+
});
651+
619652
verifyTscWatch({
620653
scenario,
621654
subScenario: "can correctly update configured project when set of root files has changed through include",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
Input::
2+
//// [/user/username/projects/myproject/f1.ts]
3+
export const x = 1
4+
5+
//// [/user/username/projects/myproject/f2.ts]
6+
export const y = 1
7+
8+
//// [/a/lib/lib.d.ts]
9+
/// <reference no-default-lib="true"/>
10+
interface Boolean {}
11+
interface Function {}
12+
interface CallableFunction {}
13+
interface NewableFunction {}
14+
interface IArguments {}
15+
interface Number { toExponential: any; }
16+
interface Object {}
17+
interface RegExp {}
18+
interface String { charAt: any; }
19+
interface Array<T> { length: number; [n: number]: T; }
20+
21+
//// [/user/username/projects/myproject/tsconfig.json]
22+
{"compilerOptions":{"composite":true},"include":["./","./**/*.json"]}
23+
24+
25+
/a/lib/tsc.js -w --extendedDiagnostics
26+
Output::
27+
[12:00:23 AM] Starting compilation in watch mode...
28+
29+
Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false
30+
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Config file
31+
Synchronizing program
32+
CreatingProgramWith::
33+
roots: ["/user/username/projects/myproject/f1.ts","/user/username/projects/myproject/f2.ts"]
34+
options: {"composite":true,"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
35+
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/f1.ts 250 undefined Source file
36+
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/f2.ts 250 undefined Source file
37+
FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 undefined Source file
38+
DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Type roots
39+
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Type roots
40+
[12:00:34 AM] Found 0 errors. Watching for file changes.
41+
42+
43+
44+
Program root files: ["/user/username/projects/myproject/f1.ts","/user/username/projects/myproject/f2.ts"]
45+
Program options: {"composite":true,"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
46+
Program structureReused: Not
47+
Program files::
48+
/a/lib/lib.d.ts
49+
/user/username/projects/myproject/f1.ts
50+
/user/username/projects/myproject/f2.ts
51+
52+
Semantic diagnostics in builder refreshed for::
53+
/a/lib/lib.d.ts
54+
/user/username/projects/myproject/f1.ts
55+
/user/username/projects/myproject/f2.ts
56+
57+
Shape signatures in builder refreshed for::
58+
/a/lib/lib.d.ts (used version)
59+
/user/username/projects/myproject/f1.ts (computed .d.ts during emit)
60+
/user/username/projects/myproject/f2.ts (computed .d.ts during emit)
61+
62+
WatchedFiles::
63+
/user/username/projects/myproject/tsconfig.json:
64+
{"fileName":"/user/username/projects/myproject/tsconfig.json","pollingInterval":250}
65+
/user/username/projects/myproject/f1.ts:
66+
{"fileName":"/user/username/projects/myproject/f1.ts","pollingInterval":250}
67+
/user/username/projects/myproject/f2.ts:
68+
{"fileName":"/user/username/projects/myproject/f2.ts","pollingInterval":250}
69+
/a/lib/lib.d.ts:
70+
{"fileName":"/a/lib/lib.d.ts","pollingInterval":250}
71+
72+
FsWatches::
73+
74+
FsWatchesRecursive::
75+
/user/username/projects/myproject/node_modules/@types:
76+
{"directoryName":"/user/username/projects/myproject/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
77+
78+
exitCode:: ExitStatus.undefined
79+
80+
//// [/user/username/projects/myproject/f1.js]
81+
"use strict";
82+
exports.__esModule = true;
83+
exports.x = void 0;
84+
exports.x = 1;
85+
86+
87+
//// [/user/username/projects/myproject/f1.d.ts]
88+
export declare const x = 1;
89+
90+
91+
//// [/user/username/projects/myproject/f2.js]
92+
"use strict";
93+
exports.__esModule = true;
94+
exports.y = void 0;
95+
exports.y = 1;
96+
97+
98+
//// [/user/username/projects/myproject/f2.d.ts]
99+
export declare const y = 1;
100+
101+
102+
//// [/user/username/projects/myproject/tsconfig.tsbuildinfo]
103+
{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./f1.ts","./f2.ts"],"fileInfos":[{"version":"-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }","affectsGlobalScope":true},{"version":"-10906998252-export const x = 1","signature":"-7495133367-export declare const x = 1;\n"},{"version":"-10905812331-export const y = 1","signature":"-6203665398-export declare const y = 1;\n"}],"options":{"composite":true},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"}
104+
105+
//// [/user/username/projects/myproject/tsconfig.tsbuildinfo.readable.baseline.txt]
106+
{
107+
"program": {
108+
"fileNames": [
109+
"../../../../a/lib/lib.d.ts",
110+
"./f1.ts",
111+
"./f2.ts"
112+
],
113+
"fileInfos": {
114+
"../../../../a/lib/lib.d.ts": {
115+
"version": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
116+
"signature": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
117+
"affectsGlobalScope": true
118+
},
119+
"./f1.ts": {
120+
"version": "-10906998252-export const x = 1",
121+
"signature": "-7495133367-export declare const x = 1;\n"
122+
},
123+
"./f2.ts": {
124+
"version": "-10905812331-export const y = 1",
125+
"signature": "-6203665398-export declare const y = 1;\n"
126+
}
127+
},
128+
"options": {
129+
"composite": true
130+
},
131+
"referencedMap": {},
132+
"exportedModulesMap": {},
133+
"semanticDiagnosticsPerFile": [
134+
"../../../../a/lib/lib.d.ts",
135+
"./f1.ts",
136+
"./f2.ts"
137+
]
138+
},
139+
"version": "FakeTSVersion",
140+
"size": 828
141+
}
142+
143+
144+
Change:: Add new file
145+
146+
Input::
147+
//// [/user/username/projects/myproject/new-file.ts]
148+
export const z = 1;
149+
150+
151+
Output::
152+
153+
WatchedFiles::
154+
/user/username/projects/myproject/tsconfig.json:
155+
{"fileName":"/user/username/projects/myproject/tsconfig.json","pollingInterval":250}
156+
/user/username/projects/myproject/f1.ts:
157+
{"fileName":"/user/username/projects/myproject/f1.ts","pollingInterval":250}
158+
/user/username/projects/myproject/f2.ts:
159+
{"fileName":"/user/username/projects/myproject/f2.ts","pollingInterval":250}
160+
/a/lib/lib.d.ts:
161+
{"fileName":"/a/lib/lib.d.ts","pollingInterval":250}
162+
163+
FsWatches::
164+
165+
FsWatchesRecursive::
166+
/user/username/projects/myproject/node_modules/@types:
167+
{"directoryName":"/user/username/projects/myproject/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
168+
169+
exitCode:: ExitStatus.undefined
170+
171+
172+
Change:: Import new file
173+
174+
Input::
175+
//// [/user/username/projects/myproject/f1.ts]
176+
import { z } from "./new-file";export const x = 1
177+
178+
179+
Output::
180+
FileWatcher:: Triggered with /user/username/projects/myproject/f1.ts 1:: WatchInfo: /user/username/projects/myproject/f1.ts 250 undefined Source file
181+
Scheduling update
182+
Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/f1.ts 1:: WatchInfo: /user/username/projects/myproject/f1.ts 250 undefined Source file
183+
Synchronizing program
184+
[12:00:41 AM] File change detected. Starting incremental compilation...
185+
186+
CreatingProgramWith::
187+
roots: ["/user/username/projects/myproject/f1.ts","/user/username/projects/myproject/f2.ts"]
188+
options: {"composite":true,"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
189+
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/new-file.ts 250 undefined Source file
190+
f1.ts:1:19 - error TS6307: File '/user/username/projects/myproject/new-file.ts' is not listed within the file list of project '/user/username/projects/myproject/tsconfig.json'. Projects must list all files or use an 'include' pattern.
191+
192+
1 import { z } from "./new-file";export const x = 1
193+
   ~~~~~~~~~~~~
194+
195+
[12:00:55 AM] Found 1 error. Watching for file changes.
196+
197+
198+
199+
Program root files: ["/user/username/projects/myproject/f1.ts","/user/username/projects/myproject/f2.ts"]
200+
Program options: {"composite":true,"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
201+
Program structureReused: SafeModules
202+
Program files::
203+
/a/lib/lib.d.ts
204+
/user/username/projects/myproject/new-file.ts
205+
/user/username/projects/myproject/f1.ts
206+
/user/username/projects/myproject/f2.ts
207+
208+
Semantic diagnostics in builder refreshed for::
209+
/user/username/projects/myproject/new-file.ts
210+
/user/username/projects/myproject/f1.ts
211+
212+
Shape signatures in builder refreshed for::
213+
/user/username/projects/myproject/new-file.ts (computed .d.ts)
214+
/user/username/projects/myproject/f1.ts (computed .d.ts)
215+
216+
WatchedFiles::
217+
/user/username/projects/myproject/tsconfig.json:
218+
{"fileName":"/user/username/projects/myproject/tsconfig.json","pollingInterval":250}
219+
/user/username/projects/myproject/f1.ts:
220+
{"fileName":"/user/username/projects/myproject/f1.ts","pollingInterval":250}
221+
/user/username/projects/myproject/f2.ts:
222+
{"fileName":"/user/username/projects/myproject/f2.ts","pollingInterval":250}
223+
/a/lib/lib.d.ts:
224+
{"fileName":"/a/lib/lib.d.ts","pollingInterval":250}
225+
/user/username/projects/myproject/new-file.ts:
226+
{"fileName":"/user/username/projects/myproject/new-file.ts","pollingInterval":250}
227+
228+
FsWatches::
229+
230+
FsWatchesRecursive::
231+
/user/username/projects/myproject/node_modules/@types:
232+
{"directoryName":"/user/username/projects/myproject/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
233+
234+
exitCode:: ExitStatus.undefined
235+
236+
//// [/user/username/projects/myproject/f1.js] file written with same contents
237+
//// [/user/username/projects/myproject/f1.d.ts] file written with same contents
238+
//// [/user/username/projects/myproject/tsconfig.tsbuildinfo]
239+
{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./new-file.ts","./f1.ts","./f2.ts"],"fileInfos":[{"version":"-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }","affectsGlobalScope":true},{"version":"-11960320495-export const z = 1;","signature":"-9207164725-export declare const z = 1;\n"},{"version":"1363236232-import { z } from \"./new-file\";export const x = 1","signature":"-7495133367-export declare const x = 1;\n"},{"version":"-10905812331-export const y = 1","signature":"-6203665398-export declare const y = 1;\n"}],"options":{"composite":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,3,4,2]},"version":"FakeTSVersion"}
240+
241+
//// [/user/username/projects/myproject/tsconfig.tsbuildinfo.readable.baseline.txt]
242+
{
243+
"program": {
244+
"fileNames": [
245+
"../../../../a/lib/lib.d.ts",
246+
"./new-file.ts",
247+
"./f1.ts",
248+
"./f2.ts"
249+
],
250+
"fileNamesList": [
251+
[
252+
"./new-file.ts"
253+
]
254+
],
255+
"fileInfos": {
256+
"../../../../a/lib/lib.d.ts": {
257+
"version": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
258+
"signature": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
259+
"affectsGlobalScope": true
260+
},
261+
"./new-file.ts": {
262+
"version": "-11960320495-export const z = 1;",
263+
"signature": "-9207164725-export declare const z = 1;\n"
264+
},
265+
"./f1.ts": {
266+
"version": "1363236232-import { z } from \"./new-file\";export const x = 1",
267+
"signature": "-7495133367-export declare const x = 1;\n"
268+
},
269+
"./f2.ts": {
270+
"version": "-10905812331-export const y = 1",
271+
"signature": "-6203665398-export declare const y = 1;\n"
272+
}
273+
},
274+
"options": {
275+
"composite": true
276+
},
277+
"referencedMap": {
278+
"./f1.ts": [
279+
"./new-file.ts"
280+
]
281+
},
282+
"exportedModulesMap": {},
283+
"semanticDiagnosticsPerFile": [
284+
"../../../../a/lib/lib.d.ts",
285+
"./f1.ts",
286+
"./f2.ts",
287+
"./new-file.ts"
288+
]
289+
},
290+
"version": "FakeTSVersion",
291+
"size": 1005
292+
}
293+
294+
//// [/user/username/projects/myproject/new-file.js]
295+
"use strict";
296+
exports.__esModule = true;
297+
exports.z = void 0;
298+
exports.z = 1;
299+
300+
301+
//// [/user/username/projects/myproject/new-file.d.ts]
302+
export declare const z = 1;
303+
304+

0 commit comments

Comments
 (0)