watcher - add test for atomic writes

This commit is contained in:
Benjamin Pasero 2021-11-30 09:40:14 +01:00
parent b9cf83f70b
commit 8ce7d13c88
No known key found for this signature in database
GPG key ID: E6380CC4C8219E65

View file

@ -115,7 +115,7 @@ flakySuite('Recursive Watcher (parcel)', () => {
if (failOnEventReason) {
reject(new Error(`Unexpected file event: ${failOnEventReason}`));
} else {
resolve();
setImmediate(() => resolve()); // copied from parcel watcher tests, seems to drop unrelated events on macOS
}
break;
}
@ -272,6 +272,17 @@ flakySuite('Recursive Watcher (parcel)', () => {
await changeFuture;
});
(isMacintosh /* this test seems not possible with fsevents backend */ ? test.skip : test)('basics (atomic writes)', async function () {
await service.watch([{ path: testDir, excludes: [] }]);
// Delete + Recreate file
const newFilePath = join(testDir, 'deep', 'conway.js');
let changeFuture: Promise<unknown> = awaitEvent(service, newFilePath, FileChangeType.UPDATED);
await Promises.unlink(newFilePath);
Promises.writeFile(newFilePath, 'Hello Atomic World');
await changeFuture;
});
(!isLinux /* polling is only used in linux environments (WSL) */ ? test.skip : test)('basics (polling)', async function () {
await service.watch([{ path: testDir, excludes: [], pollingInterval: 100 }]);