Skip to content

Commit 03fa5b3

Browse files
committed
Add tests for inode watching by making fsWatch part of system function that tests presence before creating fs watch
1 parent 884678e commit 03fa5b3

File tree

337 files changed

+3931
-3576
lines changed

Some content is hidden

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

337 files changed

+3931
-3576
lines changed

Diff for: src/compiler/sys.ts

+160-147
Large diffs are not rendered by default.

Diff for: src/harness/virtualFileSystemWithWatch.ts

+84-69
Large diffs are not rendered by default.

Diff for: src/testRunner/unittests/tscWatch/watchEnvironment.ts

+36
Original file line numberDiff line numberDiff line change
@@ -581,5 +581,41 @@ namespace ts.tscWatch {
581581
verifyWorker("-extendedDiagnostics");
582582
});
583583
});
584+
585+
describe("with fsWatch on inodes", () => {
586+
verifyTscWatch({
587+
scenario,
588+
subScenario: `fsWatch/when using file watching thats on inode`,
589+
commandLineArgs: ["-w", "--extendedDiagnostics"],
590+
sys: () => {
591+
const configFile: File = {
592+
path: `${projectRoot}/tsconfig.json`,
593+
content: JSON.stringify({ watchOptions: { watchFile: "useFsEvents" }, files: ["foo.d.ts", "main.ts"] })
594+
};
595+
const main: File = {
596+
path: `${projectRoot}/main.ts`,
597+
content: `import { foo } from "./foo"; foo();`
598+
};
599+
const foo: File = {
600+
path: `${projectRoot}/foo.d.ts`,
601+
content: `export function foo(): string;`
602+
};
603+
const files = [libFile, main, foo, configFile];
604+
return createWatchedSystem(files, { currentDirectory: projectRoot, inodeWatching: true });
605+
},
606+
changes: [
607+
{
608+
caption: "Replace file with rename event that introduces error",
609+
change: sys => sys.modifyFile(`${projectRoot}/foo.d.ts`, `export function foo2(): string;`, { invokeFileDeleteCreateAsPartInsteadOfChange: true }),
610+
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2),
611+
},
612+
{
613+
caption: "Replace file with rename event that fixes error",
614+
change: sys => sys.modifyFile(`${projectRoot}/foo.d.ts`, `export function foo(): string;`, { invokeFileDeleteCreateAsPartInsteadOfChange: true }),
615+
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2),
616+
},
617+
]
618+
});
619+
});
584620
});
585621
}

Diff for: tests/baselines/reference/tsbuildWatch/demo/updates-with-bad-reference.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,11 @@ FsWatches::
273273

274274
FsWatchesRecursive::
275275
/user/username/projects/demo/core:
276-
{"directoryName":"/user/username/projects/demo/core","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
276+
{"directoryName":"/user/username/projects/demo/core"}
277277
/user/username/projects/demo/animals:
278-
{"directoryName":"/user/username/projects/demo/animals","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
278+
{"directoryName":"/user/username/projects/demo/animals"}
279279
/user/username/projects/demo/zoo:
280-
{"directoryName":"/user/username/projects/demo/zoo","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
280+
{"directoryName":"/user/username/projects/demo/zoo"}
281281

282282
exitCode:: ExitStatus.undefined
283283

@@ -543,11 +543,11 @@ FsWatches::
543543

544544
FsWatchesRecursive::
545545
/user/username/projects/demo/core:
546-
{"directoryName":"/user/username/projects/demo/core","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
546+
{"directoryName":"/user/username/projects/demo/core"}
547547
/user/username/projects/demo/animals:
548-
{"directoryName":"/user/username/projects/demo/animals","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
548+
{"directoryName":"/user/username/projects/demo/animals"}
549549
/user/username/projects/demo/zoo:
550-
{"directoryName":"/user/username/projects/demo/zoo","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
550+
{"directoryName":"/user/username/projects/demo/zoo"}
551551

552552
exitCode:: ExitStatus.undefined
553553

Diff for: tests/baselines/reference/tsbuildWatch/demo/updates-with-circular-reference.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,11 @@ FsWatches::
193193

194194
FsWatchesRecursive::
195195
/user/username/projects/demo/animals:
196-
{"directoryName":"/user/username/projects/demo/animals","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
196+
{"directoryName":"/user/username/projects/demo/animals"}
197197
/user/username/projects/demo/zoo:
198-
{"directoryName":"/user/username/projects/demo/zoo","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
198+
{"directoryName":"/user/username/projects/demo/zoo"}
199199
/user/username/projects/demo/core:
200-
{"directoryName":"/user/username/projects/demo/core","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
200+
{"directoryName":"/user/username/projects/demo/core"}
201201

202202
exitCode:: ExitStatus.undefined
203203

@@ -324,11 +324,11 @@ FsWatches::
324324

325325
FsWatchesRecursive::
326326
/user/username/projects/demo/animals:
327-
{"directoryName":"/user/username/projects/demo/animals","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
327+
{"directoryName":"/user/username/projects/demo/animals"}
328328
/user/username/projects/demo/zoo:
329-
{"directoryName":"/user/username/projects/demo/zoo","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
329+
{"directoryName":"/user/username/projects/demo/zoo"}
330330
/user/username/projects/demo/core:
331-
{"directoryName":"/user/username/projects/demo/core","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
331+
{"directoryName":"/user/username/projects/demo/core"}
332332

333333
exitCode:: ExitStatus.undefined
334334

Diff for: tests/baselines/reference/tsbuildWatch/moduleResolution/build-mode-watches-for-changes-to-package-json-main-fields.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ FsWatches::
168168

169169
FsWatchesRecursive::
170170
/user/username/projects/myproject/packages/pkg2:
171-
{"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
171+
{"directoryName":"/user/username/projects/myproject/packages/pkg2"}
172172
/user/username/projects/myproject/packages/pkg1:
173-
{"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
173+
{"directoryName":"/user/username/projects/myproject/packages/pkg1"}
174174

175175
exitCode:: ExitStatus.undefined
176176

@@ -355,9 +355,9 @@ FsWatches::
355355

356356
FsWatchesRecursive::
357357
/user/username/projects/myproject/packages/pkg2:
358-
{"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
358+
{"directoryName":"/user/username/projects/myproject/packages/pkg2"}
359359
/user/username/projects/myproject/packages/pkg1:
360-
{"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
360+
{"directoryName":"/user/username/projects/myproject/packages/pkg1"}
361361

362362
exitCode:: ExitStatus.undefined
363363

@@ -457,9 +457,9 @@ FsWatches::
457457

458458
FsWatchesRecursive::
459459
/user/username/projects/myproject/packages/pkg2:
460-
{"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
460+
{"directoryName":"/user/username/projects/myproject/packages/pkg2"}
461461
/user/username/projects/myproject/packages/pkg1:
462-
{"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
462+
{"directoryName":"/user/username/projects/myproject/packages/pkg1"}
463463

464464
exitCode:: ExitStatus.undefined
465465

Diff for: tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ FsWatches::
174174

175175
FsWatchesRecursive::
176176
/user/username/projects/myproject/packages/pkg2:
177-
{"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
177+
{"directoryName":"/user/username/projects/myproject/packages/pkg2"}
178178
/user/username/projects/myproject/packages/pkg1:
179-
{"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
179+
{"directoryName":"/user/username/projects/myproject/packages/pkg1"}
180180

181181
exitCode:: ExitStatus.undefined
182182

@@ -374,9 +374,9 @@ FsWatches::
374374

375375
FsWatchesRecursive::
376376
/user/username/projects/myproject/packages/pkg2:
377-
{"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
377+
{"directoryName":"/user/username/projects/myproject/packages/pkg2"}
378378
/user/username/projects/myproject/packages/pkg1:
379-
{"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
379+
{"directoryName":"/user/username/projects/myproject/packages/pkg1"}
380380

381381
exitCode:: ExitStatus.undefined
382382

@@ -483,9 +483,9 @@ FsWatches::
483483

484484
FsWatchesRecursive::
485485
/user/username/projects/myproject/packages/pkg2:
486-
{"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
486+
{"directoryName":"/user/username/projects/myproject/packages/pkg2"}
487487
/user/username/projects/myproject/packages/pkg1:
488-
{"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
488+
{"directoryName":"/user/username/projects/myproject/packages/pkg1"}
489489

490490
exitCode:: ExitStatus.undefined
491491

@@ -604,9 +604,9 @@ FsWatches::
604604

605605
FsWatchesRecursive::
606606
/user/username/projects/myproject/packages/pkg2:
607-
{"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
607+
{"directoryName":"/user/username/projects/myproject/packages/pkg2"}
608608
/user/username/projects/myproject/packages/pkg1:
609-
{"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
609+
{"directoryName":"/user/username/projects/myproject/packages/pkg1"}
610610

611611
exitCode:: ExitStatus.undefined
612612

@@ -692,9 +692,9 @@ FsWatches::
692692

693693
FsWatchesRecursive::
694694
/user/username/projects/myproject/packages/pkg2:
695-
{"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
695+
{"directoryName":"/user/username/projects/myproject/packages/pkg2"}
696696
/user/username/projects/myproject/packages/pkg1:
697-
{"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
697+
{"directoryName":"/user/username/projects/myproject/packages/pkg1"}
698698

699699
exitCode:: ExitStatus.undefined
700700

Diff for: tests/baselines/reference/tsbuildWatch/noEmit/does-not-go-in-loop-when-watching-when-no-files-are-emitted-with-incremental.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ FsWatches::
7070

7171
FsWatchesRecursive::
7272
/user/username/projects/myproject:
73-
{"directoryName":"/user/username/projects/myproject","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
73+
{"directoryName":"/user/username/projects/myproject"}
7474

7575
exitCode:: ExitStatus.undefined
7676

@@ -164,7 +164,7 @@ FsWatches::
164164

165165
FsWatchesRecursive::
166166
/user/username/projects/myproject:
167-
{"directoryName":"/user/username/projects/myproject","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
167+
{"directoryName":"/user/username/projects/myproject"}
168168

169169
exitCode:: ExitStatus.undefined
170170

@@ -217,7 +217,7 @@ FsWatches::
217217

218218
FsWatchesRecursive::
219219
/user/username/projects/myproject:
220-
{"directoryName":"/user/username/projects/myproject","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
220+
{"directoryName":"/user/username/projects/myproject"}
221221

222222
exitCode:: ExitStatus.undefined
223223

Diff for: tests/baselines/reference/tsbuildWatch/noEmit/does-not-go-in-loop-when-watching-when-no-files-are-emitted.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ FsWatches::
7070

7171
FsWatchesRecursive::
7272
/user/username/projects/myproject:
73-
{"directoryName":"/user/username/projects/myproject","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
73+
{"directoryName":"/user/username/projects/myproject"}
7474

7575
exitCode:: ExitStatus.undefined
7676

@@ -116,7 +116,7 @@ FsWatches::
116116

117117
FsWatchesRecursive::
118118
/user/username/projects/myproject:
119-
{"directoryName":"/user/username/projects/myproject","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
119+
{"directoryName":"/user/username/projects/myproject"}
120120

121121
exitCode:: ExitStatus.undefined
122122

@@ -169,7 +169,7 @@ FsWatches::
169169

170170
FsWatchesRecursive::
171171
/user/username/projects/myproject:
172-
{"directoryName":"/user/username/projects/myproject","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
172+
{"directoryName":"/user/username/projects/myproject"}
173173

174174
exitCode:: ExitStatus.undefined
175175

Diff for: tests/baselines/reference/tsbuildWatch/noEmitOnError/does-not-emit-any-files-on-error-with-incremental.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ FsWatches::
8787

8888
FsWatchesRecursive::
8989
/user/username/projects/noemitonerror:
90-
{"directoryName":"/user/username/projects/noemitonerror","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
90+
{"directoryName":"/user/username/projects/noemitonerror"}
9191

9292
exitCode:: ExitStatus.undefined
9393

@@ -141,7 +141,7 @@ FsWatches::
141141

142142
FsWatchesRecursive::
143143
/user/username/projects/noemitonerror:
144-
{"directoryName":"/user/username/projects/noemitonerror","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
144+
{"directoryName":"/user/username/projects/noemitonerror"}
145145

146146
exitCode:: ExitStatus.undefined
147147

@@ -203,7 +203,7 @@ FsWatches::
203203

204204
FsWatchesRecursive::
205205
/user/username/projects/noemitonerror:
206-
{"directoryName":"/user/username/projects/noemitonerror","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
206+
{"directoryName":"/user/username/projects/noemitonerror"}
207207

208208
exitCode:: ExitStatus.undefined
209209

@@ -338,7 +338,7 @@ FsWatches::
338338

339339
FsWatchesRecursive::
340340
/user/username/projects/noemitonerror:
341-
{"directoryName":"/user/username/projects/noemitonerror","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
341+
{"directoryName":"/user/username/projects/noemitonerror"}
342342

343343
exitCode:: ExitStatus.undefined
344344

@@ -467,7 +467,7 @@ FsWatches::
467467

468468
FsWatchesRecursive::
469469
/user/username/projects/noemitonerror:
470-
{"directoryName":"/user/username/projects/noemitonerror","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
470+
{"directoryName":"/user/username/projects/noemitonerror"}
471471

472472
exitCode:: ExitStatus.undefined
473473

@@ -523,7 +523,7 @@ FsWatches::
523523

524524
FsWatchesRecursive::
525525
/user/username/projects/noemitonerror:
526-
{"directoryName":"/user/username/projects/noemitonerror","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
526+
{"directoryName":"/user/username/projects/noemitonerror"}
527527

528528
exitCode:: ExitStatus.undefined
529529

@@ -639,7 +639,7 @@ FsWatches::
639639

640640
FsWatchesRecursive::
641641
/user/username/projects/noemitonerror:
642-
{"directoryName":"/user/username/projects/noemitonerror","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
642+
{"directoryName":"/user/username/projects/noemitonerror"}
643643

644644
exitCode:: ExitStatus.undefined
645645

Diff for: tests/baselines/reference/tsbuildWatch/noEmitOnError/does-not-emit-any-files-on-error.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ FsWatches::
8787

8888
FsWatchesRecursive::
8989
/user/username/projects/noemitonerror:
90-
{"directoryName":"/user/username/projects/noemitonerror","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
90+
{"directoryName":"/user/username/projects/noemitonerror"}
9191

9292
exitCode:: ExitStatus.undefined
9393

@@ -141,7 +141,7 @@ FsWatches::
141141

142142
FsWatchesRecursive::
143143
/user/username/projects/noemitonerror:
144-
{"directoryName":"/user/username/projects/noemitonerror","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
144+
{"directoryName":"/user/username/projects/noemitonerror"}
145145

146146
exitCode:: ExitStatus.undefined
147147

@@ -203,7 +203,7 @@ FsWatches::
203203

204204
FsWatchesRecursive::
205205
/user/username/projects/noemitonerror:
206-
{"directoryName":"/user/username/projects/noemitonerror","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
206+
{"directoryName":"/user/username/projects/noemitonerror"}
207207

208208
exitCode:: ExitStatus.undefined
209209

@@ -281,7 +281,7 @@ FsWatches::
281281

282282
FsWatchesRecursive::
283283
/user/username/projects/noemitonerror:
284-
{"directoryName":"/user/username/projects/noemitonerror","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
284+
{"directoryName":"/user/username/projects/noemitonerror"}
285285

286286
exitCode:: ExitStatus.undefined
287287

@@ -335,7 +335,7 @@ FsWatches::
335335

336336
FsWatchesRecursive::
337337
/user/username/projects/noemitonerror:
338-
{"directoryName":"/user/username/projects/noemitonerror","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
338+
{"directoryName":"/user/username/projects/noemitonerror"}
339339

340340
exitCode:: ExitStatus.undefined
341341

@@ -391,7 +391,7 @@ FsWatches::
391391

392392
FsWatchesRecursive::
393393
/user/username/projects/noemitonerror:
394-
{"directoryName":"/user/username/projects/noemitonerror","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
394+
{"directoryName":"/user/username/projects/noemitonerror"}
395395

396396
exitCode:: ExitStatus.undefined
397397

@@ -450,7 +450,7 @@ FsWatches::
450450

451451
FsWatchesRecursive::
452452
/user/username/projects/noemitonerror:
453-
{"directoryName":"/user/username/projects/noemitonerror","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
453+
{"directoryName":"/user/username/projects/noemitonerror"}
454454

455455
exitCode:: ExitStatus.undefined
456456

Diff for: tests/baselines/reference/tsbuildWatch/programUpdates/creates-solution-in-watch-mode.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ FsWatches::
194194

195195
FsWatchesRecursive::
196196
/user/username/projects/sample1/core:
197-
{"directoryName":"/user/username/projects/sample1/core","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
197+
{"directoryName":"/user/username/projects/sample1/core"}
198198
/user/username/projects/sample1/logic:
199-
{"directoryName":"/user/username/projects/sample1/logic","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
199+
{"directoryName":"/user/username/projects/sample1/logic"}
200200

201201
exitCode:: ExitStatus.undefined
202202

0 commit comments

Comments
 (0)