|
@@ -277,14 +277,20 @@ TEST(DirectoryWatcherTest, InitialScanSync) {
|
|
|
{EventKind::Modified, "c"}}
|
|
|
};
|
|
|
|
|
|
- auto DW = DirectoryWatcher::create(
|
|
|
- fixture.TestWatchedDir,
|
|
|
- [&TestConsumer](llvm::ArrayRef<DirectoryWatcher::Event> Events,
|
|
|
- bool IsInitial) {
|
|
|
- TestConsumer.consume(Events, IsInitial);
|
|
|
- },
|
|
|
- /*waitForInitialSync=*/true);
|
|
|
- if (!DW) return;
|
|
|
+ llvm::Expected<std::unique_ptr<DirectoryWatcher>> DW =
|
|
|
+ DirectoryWatcher::create(
|
|
|
+ fixture.TestWatchedDir,
|
|
|
+ [&TestConsumer](llvm::ArrayRef<DirectoryWatcher::Event> Events,
|
|
|
+ bool IsInitial) {
|
|
|
+ TestConsumer.consume(Events, IsInitial);
|
|
|
+ },
|
|
|
+ /*waitForInitialSync=*/true);
|
|
|
+ if (!DW) {
|
|
|
+ logAllUnhandledErrors(
|
|
|
+ DW.takeError(), llvm::errs(),
|
|
|
+ "DirectoryWatcherTest Failure on DirectoryWatcher::create(): ");
|
|
|
+ exit(EXIT_FAILURE);
|
|
|
+ }
|
|
|
|
|
|
checkEventualResultWithTimeout(TestConsumer);
|
|
|
}
|
|
@@ -309,14 +315,20 @@ TEST(DirectoryWatcherTest, InitialScanAsync) {
|
|
|
{EventKind::Modified, "c"}}
|
|
|
};
|
|
|
|
|
|
- auto DW = DirectoryWatcher::create(
|
|
|
- fixture.TestWatchedDir,
|
|
|
- [&TestConsumer](llvm::ArrayRef<DirectoryWatcher::Event> Events,
|
|
|
- bool IsInitial) {
|
|
|
- TestConsumer.consume(Events, IsInitial);
|
|
|
- },
|
|
|
- /*waitForInitialSync=*/false);
|
|
|
- if (!DW) return;
|
|
|
+ llvm::Expected<std::unique_ptr<DirectoryWatcher>> DW =
|
|
|
+ DirectoryWatcher::create(
|
|
|
+ fixture.TestWatchedDir,
|
|
|
+ [&TestConsumer](llvm::ArrayRef<DirectoryWatcher::Event> Events,
|
|
|
+ bool IsInitial) {
|
|
|
+ TestConsumer.consume(Events, IsInitial);
|
|
|
+ },
|
|
|
+ /*waitForInitialSync=*/false);
|
|
|
+ if (!DW) {
|
|
|
+ logAllUnhandledErrors(
|
|
|
+ DW.takeError(), llvm::errs(),
|
|
|
+ "DirectoryWatcherTest Failure on DirectoryWatcher::create(): ");
|
|
|
+ exit(EXIT_FAILURE);
|
|
|
+ }
|
|
|
|
|
|
checkEventualResultWithTimeout(TestConsumer);
|
|
|
}
|
|
@@ -330,14 +342,20 @@ TEST(DirectoryWatcherTest, AddFiles) {
|
|
|
{EventKind::Modified, "b"},
|
|
|
{EventKind::Modified, "c"}}};
|
|
|
|
|
|
- auto DW = DirectoryWatcher::create(
|
|
|
- fixture.TestWatchedDir,
|
|
|
- [&TestConsumer](llvm::ArrayRef<DirectoryWatcher::Event> Events,
|
|
|
- bool IsInitial) {
|
|
|
- TestConsumer.consume(Events, IsInitial);
|
|
|
- },
|
|
|
- /*waitForInitialSync=*/true);
|
|
|
- if (!DW) return;
|
|
|
+ llvm::Expected<std::unique_ptr<DirectoryWatcher>> DW =
|
|
|
+ DirectoryWatcher::create(
|
|
|
+ fixture.TestWatchedDir,
|
|
|
+ [&TestConsumer](llvm::ArrayRef<DirectoryWatcher::Event> Events,
|
|
|
+ bool IsInitial) {
|
|
|
+ TestConsumer.consume(Events, IsInitial);
|
|
|
+ },
|
|
|
+ /*waitForInitialSync=*/true);
|
|
|
+ if (!DW) {
|
|
|
+ logAllUnhandledErrors(
|
|
|
+ DW.takeError(), llvm::errs(),
|
|
|
+ "DirectoryWatcherTest Failure on DirectoryWatcher::create(): ");
|
|
|
+ exit(EXIT_FAILURE);
|
|
|
+ }
|
|
|
|
|
|
fixture.addFile("a");
|
|
|
fixture.addFile("b");
|
|
@@ -356,14 +374,20 @@ TEST(DirectoryWatcherTest, ModifyFile) {
|
|
|
{{EventKind::Modified, "a"}},
|
|
|
{{EventKind::Modified, "a"}}};
|
|
|
|
|
|
- auto DW = DirectoryWatcher::create(
|
|
|
- fixture.TestWatchedDir,
|
|
|
- [&TestConsumer](llvm::ArrayRef<DirectoryWatcher::Event> Events,
|
|
|
- bool IsInitial) {
|
|
|
- TestConsumer.consume(Events, IsInitial);
|
|
|
- },
|
|
|
- /*waitForInitialSync=*/true);
|
|
|
- if (!DW) return;
|
|
|
+ llvm::Expected<std::unique_ptr<DirectoryWatcher>> DW =
|
|
|
+ DirectoryWatcher::create(
|
|
|
+ fixture.TestWatchedDir,
|
|
|
+ [&TestConsumer](llvm::ArrayRef<DirectoryWatcher::Event> Events,
|
|
|
+ bool IsInitial) {
|
|
|
+ TestConsumer.consume(Events, IsInitial);
|
|
|
+ },
|
|
|
+ /*waitForInitialSync=*/true);
|
|
|
+ if (!DW) {
|
|
|
+ logAllUnhandledErrors(
|
|
|
+ DW.takeError(), llvm::errs(),
|
|
|
+ "DirectoryWatcherTest Failure on DirectoryWatcher::create(): ");
|
|
|
+ exit(EXIT_FAILURE);
|
|
|
+ }
|
|
|
|
|
|
// modify the file
|
|
|
{
|
|
@@ -387,14 +411,20 @@ TEST(DirectoryWatcherTest, DeleteFile) {
|
|
|
{{EventKind::Removed, "a"}},
|
|
|
{{EventKind::Modified, "a"}, {EventKind::Removed, "a"}}};
|
|
|
|
|
|
- auto DW = DirectoryWatcher::create(
|
|
|
- fixture.TestWatchedDir,
|
|
|
- [&TestConsumer](llvm::ArrayRef<DirectoryWatcher::Event> Events,
|
|
|
- bool IsInitial) {
|
|
|
- TestConsumer.consume(Events, IsInitial);
|
|
|
- },
|
|
|
- /*waitForInitialSync=*/true);
|
|
|
- if (!DW) return;
|
|
|
+ llvm::Expected<std::unique_ptr<DirectoryWatcher>> DW =
|
|
|
+ DirectoryWatcher::create(
|
|
|
+ fixture.TestWatchedDir,
|
|
|
+ [&TestConsumer](llvm::ArrayRef<DirectoryWatcher::Event> Events,
|
|
|
+ bool IsInitial) {
|
|
|
+ TestConsumer.consume(Events, IsInitial);
|
|
|
+ },
|
|
|
+ /*waitForInitialSync=*/true);
|
|
|
+ if (!DW) {
|
|
|
+ logAllUnhandledErrors(
|
|
|
+ DW.takeError(), llvm::errs(),
|
|
|
+ "DirectoryWatcherTest Failure on DirectoryWatcher::create(): ");
|
|
|
+ exit(EXIT_FAILURE);
|
|
|
+ }
|
|
|
|
|
|
fixture.deleteFile("a");
|
|
|
|
|
@@ -409,14 +439,20 @@ TEST(DirectoryWatcherTest, DeleteWatchedDir) {
|
|
|
{{EventKind::WatchedDirRemoved, ""},
|
|
|
{EventKind::WatcherGotInvalidated, ""}}};
|
|
|
|
|
|
- auto DW = DirectoryWatcher::create(
|
|
|
- fixture.TestWatchedDir,
|
|
|
- [&TestConsumer](llvm::ArrayRef<DirectoryWatcher::Event> Events,
|
|
|
- bool IsInitial) {
|
|
|
- TestConsumer.consume(Events, IsInitial);
|
|
|
- },
|
|
|
- /*waitForInitialSync=*/true);
|
|
|
- if (!DW) return;
|
|
|
+ llvm::Expected<std::unique_ptr<DirectoryWatcher>> DW =
|
|
|
+ DirectoryWatcher::create(
|
|
|
+ fixture.TestWatchedDir,
|
|
|
+ [&TestConsumer](llvm::ArrayRef<DirectoryWatcher::Event> Events,
|
|
|
+ bool IsInitial) {
|
|
|
+ TestConsumer.consume(Events, IsInitial);
|
|
|
+ },
|
|
|
+ /*waitForInitialSync=*/true);
|
|
|
+ if (!DW) {
|
|
|
+ logAllUnhandledErrors(
|
|
|
+ DW.takeError(), llvm::errs(),
|
|
|
+ "DirectoryWatcherTest Failure on DirectoryWatcher::create(): ");
|
|
|
+ exit(EXIT_FAILURE);
|
|
|
+ }
|
|
|
|
|
|
remove_directories(fixture.TestWatchedDir);
|
|
|
|
|
@@ -430,15 +466,21 @@ TEST(DirectoryWatcherTest, InvalidatedWatcher) {
|
|
|
{}, {{EventKind::WatcherGotInvalidated, ""}}};
|
|
|
|
|
|
{
|
|
|
- auto DW = DirectoryWatcher::create(
|
|
|
- fixture.TestWatchedDir,
|
|
|
- [&TestConsumer](llvm::ArrayRef<DirectoryWatcher::Event> Events,
|
|
|
- bool IsInitial) {
|
|
|
- TestConsumer.consume(Events, IsInitial);
|
|
|
- },
|
|
|
- /*waitForInitialSync=*/true);
|
|
|
- if (!DW) return;
|
|
|
+ llvm::Expected<std::unique_ptr<DirectoryWatcher>> DW =
|
|
|
+ DirectoryWatcher::create(
|
|
|
+ fixture.TestWatchedDir,
|
|
|
+ [&TestConsumer](llvm::ArrayRef<DirectoryWatcher::Event> Events,
|
|
|
+ bool IsInitial) {
|
|
|
+ TestConsumer.consume(Events, IsInitial);
|
|
|
+ },
|
|
|
+ /*waitForInitialSync=*/true);
|
|
|
+ if (!DW) {
|
|
|
+ logAllUnhandledErrors(
|
|
|
+ DW.takeError(), llvm::errs(),
|
|
|
+ "DirectoryWatcherTest Failure on DirectoryWatcher::create(): ");
|
|
|
+ exit(EXIT_FAILURE);
|
|
|
+ }
|
|
|
} // DW is destructed here.
|
|
|
|
|
|
checkEventualResultWithTimeout(TestConsumer);
|
|
|
-}
|
|
|
+}
|