r368399 - Use ASSERT_THAT_ERROR instead of logAllUnhandledErrors/exit
Dmitri Gribenko via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 8 23:14:54 PDT 2019
Author: gribozavr
Date: Thu Aug 8 23:14:54 2019
New Revision: 368399
URL: http://llvm.org/viewvc/llvm-project?rev=368399&view=rev
Log:
Use ASSERT_THAT_ERROR instead of logAllUnhandledErrors/exit
Summary: ASSERT_THAT_ERROR looks like the intended helper for use in tests.
Reviewers: plotfi, jkorous, compnerd
Subscribers: mgorny, dexonsmith, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D65853
Modified:
cfe/trunk/unittests/DirectoryWatcher/CMakeLists.txt
cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
Modified: cfe/trunk/unittests/DirectoryWatcher/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/DirectoryWatcher/CMakeLists.txt?rev=368399&r1=368398&r2=368399&view=diff
==============================================================================
--- cfe/trunk/unittests/DirectoryWatcher/CMakeLists.txt (original)
+++ cfe/trunk/unittests/DirectoryWatcher/CMakeLists.txt Thu Aug 8 23:14:54 2019
@@ -10,8 +10,9 @@ if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "L
target_link_libraries(DirectoryWatcherTests
PRIVATE
+ LLVMTestingSupport
clangDirectoryWatcher
clangBasic
)
-endif()
\ No newline at end of file
+endif()
Modified: cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp?rev=368399&r1=368398&r2=368399&view=diff
==============================================================================
--- cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp (original)
+++ cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp Thu Aug 8 23:14:54 2019
@@ -10,6 +10,7 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"
#include <condition_variable>
#include <future>
@@ -284,12 +285,7 @@ TEST(DirectoryWatcherTest, InitialScanSy
TestConsumer.consume(Events, IsInitial);
},
/*waitForInitialSync=*/true);
- if (!DW) {
- logAllUnhandledErrors(
- DW.takeError(), llvm::errs(),
- "DirectoryWatcherTest Failure on DirectoryWatcher::create(): ");
- exit(EXIT_FAILURE);
- }
+ ASSERT_THAT_ERROR(DW.takeError(), Succeeded());
checkEventualResultWithTimeout(TestConsumer);
}
@@ -322,12 +318,7 @@ TEST(DirectoryWatcherTest, InitialScanAs
TestConsumer.consume(Events, IsInitial);
},
/*waitForInitialSync=*/false);
- if (!DW) {
- logAllUnhandledErrors(
- DW.takeError(), llvm::errs(),
- "DirectoryWatcherTest Failure on DirectoryWatcher::create(): ");
- exit(EXIT_FAILURE);
- }
+ ASSERT_THAT_ERROR(DW.takeError(), Succeeded());
checkEventualResultWithTimeout(TestConsumer);
}
@@ -349,12 +340,7 @@ TEST(DirectoryWatcherTest, AddFiles) {
TestConsumer.consume(Events, IsInitial);
},
/*waitForInitialSync=*/true);
- if (!DW) {
- logAllUnhandledErrors(
- DW.takeError(), llvm::errs(),
- "DirectoryWatcherTest Failure on DirectoryWatcher::create(): ");
- exit(EXIT_FAILURE);
- }
+ ASSERT_THAT_ERROR(DW.takeError(), Succeeded());
fixture.addFile("a");
fixture.addFile("b");
@@ -381,12 +367,7 @@ TEST(DirectoryWatcherTest, ModifyFile) {
TestConsumer.consume(Events, IsInitial);
},
/*waitForInitialSync=*/true);
- if (!DW) {
- logAllUnhandledErrors(
- DW.takeError(), llvm::errs(),
- "DirectoryWatcherTest Failure on DirectoryWatcher::create(): ");
- exit(EXIT_FAILURE);
- }
+ ASSERT_THAT_ERROR(DW.takeError(), Succeeded());
// modify the file
{
@@ -418,12 +399,7 @@ TEST(DirectoryWatcherTest, DeleteFile) {
TestConsumer.consume(Events, IsInitial);
},
/*waitForInitialSync=*/true);
- if (!DW) {
- logAllUnhandledErrors(
- DW.takeError(), llvm::errs(),
- "DirectoryWatcherTest Failure on DirectoryWatcher::create(): ");
- exit(EXIT_FAILURE);
- }
+ ASSERT_THAT_ERROR(DW.takeError(), Succeeded());
fixture.deleteFile("a");
@@ -446,12 +422,7 @@ TEST(DirectoryWatcherTest, DeleteWatched
TestConsumer.consume(Events, IsInitial);
},
/*waitForInitialSync=*/true);
- if (!DW) {
- logAllUnhandledErrors(
- DW.takeError(), llvm::errs(),
- "DirectoryWatcherTest Failure on DirectoryWatcher::create(): ");
- exit(EXIT_FAILURE);
- }
+ ASSERT_THAT_ERROR(DW.takeError(), Succeeded());
remove_directories(fixture.TestWatchedDir);
@@ -473,12 +444,7 @@ TEST(DirectoryWatcherTest, InvalidatedWa
TestConsumer.consume(Events, IsInitial);
},
/*waitForInitialSync=*/true);
- if (!DW) {
- logAllUnhandledErrors(
- DW.takeError(), llvm::errs(),
- "DirectoryWatcherTest Failure on DirectoryWatcher::create(): ");
- exit(EXIT_FAILURE);
- }
+ ASSERT_THAT_ERROR(DW.takeError(), Succeeded());
} // DW is destructed here.
checkEventualResultWithTimeout(TestConsumer);
More information about the cfe-commits
mailing list