]> granicus.if.org Git - clang/commitdiff
[DirectoryWatcher] Relax assumption to prevent test flakiness
authorJan Korous <jkorous@apple.com>
Thu, 1 Aug 2019 23:24:30 +0000 (23:24 +0000)
committerJan Korous <jkorous@apple.com>
Thu, 1 Aug 2019 23:24:30 +0000 (23:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@367632 91177308-0d34-0410-b5e6-96231b3b80d8

lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

index 3df79ac48a4ac09167b0188dd2fccf1e5e15036c..ae3cb6141636b4128d1348a743d647c19f7719b1 100644 (file)
@@ -25,6 +25,24 @@ static void stopFSEventStream(FSEventStreamRef);
 
 namespace {
 
+/// This implementation is based on FSEvents API which implementation is
+/// aggressively coallescing events. This can manifest as duplicate events.
+///
+/// For example this scenario has been observed:
+///
+/// create foo/bar
+/// sleep 5 s
+/// create DirectoryWatcherMac for dir foo
+/// receive notification: bar EventKind::Modified
+/// sleep 5 s
+/// modify foo/bar
+/// receive notification: bar EventKind::Modified
+/// receive notification: bar EventKind::Modified
+/// sleep 5 s
+/// delete foo/bar
+/// receive notification: bar EventKind::Modified
+/// receive notification: bar EventKind::Modified
+/// receive notification: bar EventKind::Removed
 class DirectoryWatcherMac : public clang::DirectoryWatcher {
 public:
   DirectoryWatcherMac(
index a6b48e5623675693cf6f0dc396ea6b2077fb0bd1..c26ba57354fc4d73c178061e6f0e5a66428462e2 100644 (file)
@@ -377,7 +377,7 @@ TEST(DirectoryWatcherTest, DeleteFile) {
   VerifyingConsumer TestConsumer{
       {{EventKind::Modified, "a"}},
       {{EventKind::Removed, "a"}},
-      {{EventKind::Modified, "a"}}};
+      {{EventKind::Modified, "a"}, {EventKind::Removed, "a"}}};
 
   auto DW = DirectoryWatcher::create(
       fixture.TestWatchedDir,