Skip to content

Commit 52da3cc

Browse files
committed
add tests
1 parent d7638e8 commit 52da3cc

File tree

2 files changed

+207
-0
lines changed

2 files changed

+207
-0
lines changed

src/testRunner/unittests/tscWatch/watchEnvironment.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,38 @@ describe("unittests:: tsc-watch:: watchEnvironment:: tsc-watch with different po
725725
verify(/*fsWatchWithTimestamp*/ false);
726726
});
727727

728+
describe("with fsWatch with fsWatchWithTimestamp with useFsEventsOnParentDirectory", () => {
729+
verifyTscWatch({
730+
scenario,
731+
subScenario: "fsWatch/fsWatchWithTimestamp/useFsEventsOnParentDirectory",
732+
commandLineArgs: ["-w", "--watchFile", "usefseventsonparentdirectory", "--extendedDiagnostics"],
733+
sys: () =>
734+
createWatchedSystem(
735+
{
736+
[libFile.path]: libFile.content,
737+
"/user/username/projects/myproject/main.ts": `export const x = 10;`,
738+
"/user/username/projects/myproject/tsconfig.json": jsonToReadableText({ files: ["main.ts"] }),
739+
},
740+
{
741+
currentDirectory: "/user/username/projects/myproject",
742+
fsWatchWithTimestamp: true,
743+
},
744+
),
745+
edits: [
746+
{
747+
caption: "emulate access",
748+
edit: sys => sys.invokeFsWatches("/user/username/projects/myproject/main.ts", "change", /*modifiedTime*/ undefined, /*useTildeSuffix*/ undefined),
749+
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
750+
},
751+
{
752+
caption: "modify file contents",
753+
edit: sys => sys.appendFile("/user/username/projects/myproject/main.ts", "export const y = 10;"),
754+
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
755+
},
756+
],
757+
});
758+
});
759+
728760
verifyTscWatch({
729761
scenario,
730762
subScenario: "fsEvent for change is repeated",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false
2+
Input::
3+
//// [/a/lib/lib.d.ts]
4+
/// <reference no-default-lib="true"/>
5+
interface Boolean {}
6+
interface Function {}
7+
interface CallableFunction {}
8+
interface NewableFunction {}
9+
interface IArguments {}
10+
interface Number { toExponential: any; }
11+
interface Object {}
12+
interface RegExp {}
13+
interface String { charAt: any; }
14+
interface Array<T> { length: number; [n: number]: T; }
15+
16+
//// [/user/username/projects/myproject/main.ts]
17+
export const x = 10;
18+
19+
//// [/user/username/projects/myproject/tsconfig.json]
20+
{
21+
"files": [
22+
"main.ts"
23+
]
24+
}
25+
26+
27+
/a/lib/tsc.js -w --watchFile usefseventsonparentdirectory --extendedDiagnostics
28+
Output::
29+
[12:00:21 AM] Starting compilation in watch mode...
30+
31+
Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false
32+
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 {"watchFile":5} Config file
33+
Synchronizing program
34+
CreatingProgramWith::
35+
roots: ["/user/username/projects/myproject/main.ts"]
36+
options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
37+
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/main.ts 250 {"watchFile":5} Source file
38+
FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 {"watchFile":5} Source file
39+
DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFile":5} Type roots
40+
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 {"watchFile":5} Type roots
41+
DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/node_modules/@types 1 {"watchFile":5} Type roots
42+
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/node_modules/@types 1 {"watchFile":5} Type roots
43+
[12:00:24 AM] Found 0 errors. Watching for file changes.
44+
45+
46+
47+
//// [/user/username/projects/myproject/main.js]
48+
"use strict";
49+
Object.defineProperty(exports, "__esModule", { value: true });
50+
exports.x = void 0;
51+
exports.x = 10;
52+
53+
54+
55+
PolledWatches::
56+
/user/username/projects/myproject/node_modules/@types: *new*
57+
{"pollingInterval":500}
58+
/user/username/projects/node_modules/@types: *new*
59+
{"pollingInterval":500}
60+
61+
FsWatches::
62+
/a/lib: *new*
63+
{}
64+
/user/username/projects/myproject: *new*
65+
{}
66+
67+
Program root files: [
68+
"/user/username/projects/myproject/main.ts"
69+
]
70+
Program options: {
71+
"watch": true,
72+
"extendedDiagnostics": true,
73+
"configFilePath": "/user/username/projects/myproject/tsconfig.json"
74+
}
75+
Program structureReused: Not
76+
Program files::
77+
/a/lib/lib.d.ts
78+
/user/username/projects/myproject/main.ts
79+
80+
Semantic diagnostics in builder refreshed for::
81+
/a/lib/lib.d.ts
82+
/user/username/projects/myproject/main.ts
83+
84+
Shape signatures in builder refreshed for::
85+
/a/lib/lib.d.ts (used version)
86+
/user/username/projects/myproject/main.ts (used version)
87+
88+
exitCode:: ExitStatus.undefined
89+
90+
Change:: emulate access
91+
92+
Input::
93+
94+
Output::
95+
FileWatcher:: Triggered with /user/username/projects/myproject/main.ts 1:: WatchInfo: /user/username/projects/myproject/main.ts 250 {"watchFile":5} Source file
96+
Scheduling update
97+
Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/main.ts 1:: WatchInfo: /user/username/projects/myproject/main.ts 250 {"watchFile":5} Source file
98+
99+
100+
Timeout callback:: count: 1
101+
1: timerToUpdateProgram *new*
102+
103+
Before running Timeout callback:: count: 1
104+
1: timerToUpdateProgram
105+
106+
After running Timeout callback:: count: 0
107+
Output::
108+
Synchronizing program
109+
110+
111+
112+
113+
exitCode:: ExitStatus.undefined
114+
115+
Change:: modify file contents
116+
117+
Input::
118+
//// [/user/username/projects/myproject/main.ts]
119+
export const x = 10;export const y = 10;
120+
121+
122+
Output::
123+
FileWatcher:: Triggered with /user/username/projects/myproject/main.ts 1:: WatchInfo: /user/username/projects/myproject/main.ts 250 {"watchFile":5} Source file
124+
Scheduling update
125+
Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/main.ts 1:: WatchInfo: /user/username/projects/myproject/main.ts 250 {"watchFile":5} Source file
126+
127+
128+
Timeout callback:: count: 1
129+
2: timerToUpdateProgram *new*
130+
131+
Before running Timeout callback:: count: 1
132+
2: timerToUpdateProgram
133+
134+
After running Timeout callback:: count: 0
135+
Output::
136+
Synchronizing program
137+
[12:00:27 AM] File change detected. Starting incremental compilation...
138+
139+
CreatingProgramWith::
140+
roots: ["/user/username/projects/myproject/main.ts"]
141+
options: {"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
142+
[12:00:31 AM] Found 0 errors. Watching for file changes.
143+
144+
145+
146+
//// [/user/username/projects/myproject/main.js]
147+
"use strict";
148+
Object.defineProperty(exports, "__esModule", { value: true });
149+
exports.y = exports.x = void 0;
150+
exports.x = 10;
151+
exports.y = 10;
152+
153+
154+
155+
156+
Program root files: [
157+
"/user/username/projects/myproject/main.ts"
158+
]
159+
Program options: {
160+
"watch": true,
161+
"extendedDiagnostics": true,
162+
"configFilePath": "/user/username/projects/myproject/tsconfig.json"
163+
}
164+
Program structureReused: Completely
165+
Program files::
166+
/a/lib/lib.d.ts
167+
/user/username/projects/myproject/main.ts
168+
169+
Semantic diagnostics in builder refreshed for::
170+
/user/username/projects/myproject/main.ts
171+
172+
Shape signatures in builder refreshed for::
173+
/user/username/projects/myproject/main.ts (computed .d.ts)
174+
175+
exitCode:: ExitStatus.undefined

0 commit comments

Comments
 (0)