Skip to content

Commit 0a01fcb

Browse files
committed
When fsEvent for change is repeated
1 parent 93bd577 commit 0a01fcb

File tree

3 files changed

+189
-1
lines changed

3 files changed

+189
-1
lines changed

src/harness/virtualFileSystemWithWatch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ interface Array<T> { length: number; [n: number]: T; }`
730730
}
731731
}
732732

733-
private invokeFsWatches(fullPath: string, eventName: "rename" | "change", modifiedTime: Date | undefined, useTildeSuffix: boolean | undefined) {
733+
invokeFsWatches(fullPath: string, eventName: "rename" | "change", modifiedTime: Date | undefined, useTildeSuffix: boolean | undefined) {
734734
this.invokeFsWatchesCallbacks(fullPath, eventName, modifiedTime, fullPath, useTildeSuffix);
735735
this.invokeFsWatchesCallbacks(getDirectoryPath(fullPath), eventName, modifiedTime, fullPath, useTildeSuffix);
736736
this.invokeRecursiveFsWatches(fullPath, eventName, modifiedTime, /*entryFullPath*/ undefined, useTildeSuffix);

src/testRunner/unittests/tscWatch/watchEnvironment.ts

+22
Original file line numberDiff line numberDiff line change
@@ -687,5 +687,27 @@ namespace ts.tscWatch {
687687
]
688688
});
689689
});
690+
691+
verifyTscWatch({
692+
scenario,
693+
subScenario: "fsEvent for change is repeated",
694+
commandLineArgs: ["-w", "main.ts", "--extendedDiagnostics"],
695+
sys: () => createWatchedSystem({
696+
"/user/username/projects/project/main.ts": `let a: string = "Hello"`,
697+
[libFile.path]: libFile.content,
698+
}, { currentDirectory: "/user/username/projects/project" }),
699+
changes: [
700+
{
701+
caption: "change main.ts",
702+
change: sys => replaceFileText(sys, "/user/username/projects/project/main.ts", "Hello", "Hello World"),
703+
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
704+
},
705+
{
706+
caption: "receive another change event without modifying the file",
707+
change: sys => sys.invokeFsWatches("/user/username/projects/project/main.ts", "change", /*modifiedTime*/ undefined, /*useTildeSuffix*/ undefined),
708+
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
709+
}
710+
]
711+
});
690712
});
691713
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
Input::
2+
//// [/user/username/projects/project/main.ts]
3+
let a: string = "Hello"
4+
5+
//// [/a/lib/lib.d.ts]
6+
/// <reference no-default-lib="true"/>
7+
interface Boolean {}
8+
interface Function {}
9+
interface CallableFunction {}
10+
interface NewableFunction {}
11+
interface IArguments {}
12+
interface Number { toExponential: any; }
13+
interface Object {}
14+
interface RegExp {}
15+
interface String { charAt: any; }
16+
interface Array<T> { length: number; [n: number]: T; }
17+
18+
19+
/a/lib/tsc.js -w main.ts --extendedDiagnostics
20+
Output::
21+
[12:00:19 AM] Starting compilation in watch mode...
22+
23+
Current directory: /user/username/projects/project CaseSensitiveFileNames: false
24+
Synchronizing program
25+
CreatingProgramWith::
26+
roots: ["main.ts"]
27+
options: {"watch":true,"extendedDiagnostics":true}
28+
FileWatcher:: Added:: WatchInfo: main.ts 250 undefined Source file
29+
FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 undefined Source file
30+
DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@types 1 undefined Type roots
31+
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@types 1 undefined Type roots
32+
[12:00:22 AM] Found 0 errors. Watching for file changes.
33+
34+
35+
36+
Program root files: ["main.ts"]
37+
Program options: {"watch":true,"extendedDiagnostics":true}
38+
Program structureReused: Not
39+
Program files::
40+
/a/lib/lib.d.ts
41+
main.ts
42+
43+
Semantic diagnostics in builder refreshed for::
44+
/a/lib/lib.d.ts
45+
main.ts
46+
47+
Shape signatures in builder refreshed for::
48+
/a/lib/lib.d.ts (used version)
49+
/user/username/projects/project/main.ts (used version)
50+
51+
PolledWatches::
52+
/user/username/projects/project/node_modules/@types:
53+
{"pollingInterval":500}
54+
55+
FsWatches::
56+
/user/username/projects/project/main.ts:
57+
{}
58+
/a/lib/lib.d.ts:
59+
{}
60+
61+
FsWatchesRecursive::
62+
63+
exitCode:: ExitStatus.undefined
64+
65+
//// [/user/username/projects/project/main.js]
66+
var a = "Hello";
67+
68+
69+
70+
Change:: change main.ts
71+
72+
Input::
73+
//// [/user/username/projects/project/main.ts]
74+
let a: string = "Hello World"
75+
76+
77+
Output::
78+
FileWatcher:: Triggered with main.ts 1:: WatchInfo: main.ts 250 undefined Source file
79+
Scheduling update
80+
Elapsed:: *ms FileWatcher:: Triggered with main.ts 1:: WatchInfo: main.ts 250 undefined Source file
81+
Synchronizing program
82+
[12:00:26 AM] File change detected. Starting incremental compilation...
83+
84+
CreatingProgramWith::
85+
roots: ["main.ts"]
86+
options: {"watch":true,"extendedDiagnostics":true}
87+
[12:00:30 AM] Found 0 errors. Watching for file changes.
88+
89+
90+
91+
Program root files: ["main.ts"]
92+
Program options: {"watch":true,"extendedDiagnostics":true}
93+
Program structureReused: Completely
94+
Program files::
95+
/a/lib/lib.d.ts
96+
main.ts
97+
98+
Semantic diagnostics in builder refreshed for::
99+
/a/lib/lib.d.ts
100+
main.ts
101+
102+
Shape signatures in builder refreshed for::
103+
/user/username/projects/project/main.ts (computed .d.ts)
104+
105+
PolledWatches::
106+
/user/username/projects/project/node_modules/@types:
107+
{"pollingInterval":500}
108+
109+
FsWatches::
110+
/user/username/projects/project/main.ts:
111+
{}
112+
/a/lib/lib.d.ts:
113+
{}
114+
115+
FsWatchesRecursive::
116+
117+
exitCode:: ExitStatus.undefined
118+
119+
//// [/user/username/projects/project/main.js]
120+
var a = "Hello World";
121+
122+
123+
124+
Change:: receive another change event without modifying the file
125+
126+
Input::
127+
128+
Output::
129+
FileWatcher:: Triggered with main.ts 1:: WatchInfo: main.ts 250 undefined Source file
130+
Scheduling update
131+
Elapsed:: *ms FileWatcher:: Triggered with main.ts 1:: WatchInfo: main.ts 250 undefined Source file
132+
Synchronizing program
133+
[12:00:31 AM] File change detected. Starting incremental compilation...
134+
135+
CreatingProgramWith::
136+
roots: ["main.ts"]
137+
options: {"watch":true,"extendedDiagnostics":true}
138+
[12:00:32 AM] Found 0 errors. Watching for file changes.
139+
140+
141+
142+
Program root files: ["main.ts"]
143+
Program options: {"watch":true,"extendedDiagnostics":true}
144+
Program structureReused: Completely
145+
Program files::
146+
/a/lib/lib.d.ts
147+
main.ts
148+
149+
Semantic diagnostics in builder refreshed for::
150+
151+
No shapes updated in the builder::
152+
153+
PolledWatches::
154+
/user/username/projects/project/node_modules/@types:
155+
{"pollingInterval":500}
156+
157+
FsWatches::
158+
/user/username/projects/project/main.ts:
159+
{}
160+
/a/lib/lib.d.ts:
161+
{}
162+
163+
FsWatchesRecursive::
164+
165+
exitCode:: ExitStatus.undefined
166+

0 commit comments

Comments
 (0)