{{EventKind::Modified, "a"},
{EventKind::Modified, "b"},
{EventKind::Modified, "c"}},
- {}};
+ {},
+ // We have to ignore these as it's a race between the test process
+ // which is scanning the directory and kernel which is sending
+ // notification.
+ {{EventKind::Modified, "a"},
+ {EventKind::Modified, "b"},
+ {EventKind::Modified, "c"}}
+ };
auto DW = DirectoryWatcher::create(
fixture.TestWatchedDir,
{{EventKind::Modified, "a"},
{EventKind::Modified, "b"},
{EventKind::Modified, "c"}},
- {}};
+ {},
+ // We have to ignore these as it's a race between the test process
+ // which is scanning the directory and kernel which is sending
+ // notification.
+ {{EventKind::Modified, "a"},
+ {EventKind::Modified, "b"},
+ {EventKind::Modified, "c"}}
+ };
auto DW = DirectoryWatcher::create(
fixture.TestWatchedDir,
fixture.addFile("a");
VerifyingConsumer TestConsumer{
+ {{EventKind::Modified, "a"}},
{{EventKind::Modified, "a"}},
{{EventKind::Modified, "a"}}};
VerifyingConsumer TestConsumer{
{{EventKind::Modified, "a"}},
- {{EventKind::Removed, "a"}}};
+ {{EventKind::Removed, "a"}},
+ {{EventKind::Modified, "a"}}};
auto DW = DirectoryWatcher::create(
fixture.TestWatchedDir,
} // DW is destructed here.
checkEventualResultWithTimeout(TestConsumer);
-}
-
-TEST(DirectoryWatcherTest, ChangeMetadata) {
- DirectoryWatcherTestFixture fixture;
- fixture.addFile("a");
-
- VerifyingConsumer TestConsumer{
- {{DirectoryWatcher::Event::EventKind::Modified, "a"}},
- // We don't expect any notification for file having access file changed.
- {},
- // Given the timing we are ok with receiving the duplicate event.
- {{DirectoryWatcher::Event::EventKind::Modified, "a"}}};
-
- auto DW = DirectoryWatcher::create(
- fixture.TestWatchedDir,
- [&TestConsumer](llvm::ArrayRef<DirectoryWatcher::Event> Events,
- bool IsInitial) {
- TestConsumer.consume(Events, IsInitial);
- },
- /*waitForInitialSync=*/true);
-
- { // Change access and modification time of file a.
- Expected<file_t> HopefullyTheFD = llvm::sys::fs::openNativeFileForWrite(
- fixture.getPathInWatched("a"), CD_OpenExisting, OF_None);
- if (!HopefullyTheFD) {
- llvm::outs() << HopefullyTheFD.takeError();
- }
-
- const int FD = HopefullyTheFD.get();
- const TimePoint<> NewTimePt =
- std::chrono::system_clock::now() - std::chrono::minutes(1);
-#ifndef NDEBUG
- std::error_code setTimeRes =
-#endif
- llvm::sys::fs::setLastAccessAndModificationTime(FD, NewTimePt,
- NewTimePt);
- assert(!setTimeRes);
- }
-
- checkEventualResultWithTimeout(TestConsumer);
-}
+}
\ No newline at end of file