summaryrefslogtreecommitdiffstats
path: root/clang/unittests/DirectoryWatcher
diff options
context:
space:
mode:
authorJan Korous <jkorous@apple.com>2019-07-13 00:09:04 +0000
committerJan Korous <jkorous@apple.com>2019-07-13 00:09:04 +0000
commit4765aa14ff429db9301047296c9bd8e201bcb3a2 (patch)
tree0d27e2894b3054b1b281723f8189975a62ae15f6 /clang/unittests/DirectoryWatcher
parent5d9d7c59ee3353675ec89653c3a2b0175305d59a (diff)
downloadbcm5719-llvm-4765aa14ff429db9301047296c9bd8e201bcb3a2.tar.gz
bcm5719-llvm-4765aa14ff429db9301047296c9bd8e201bcb3a2.zip
[DirectoryWatcher][test][NFC] Add information to test failure reports
llvm-svn: 365976
Diffstat (limited to 'clang/unittests/DirectoryWatcher')
-rw-r--r--clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp b/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
index 0808ff47dee..72bc86d4493 100644
--- a/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
+++ b/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -97,7 +97,9 @@ std::string eventKindToString(const DirectoryWatcher::Event::EventKind K) {
struct VerifyingConsumer {
std::vector<DirectoryWatcher::Event> ExpectedInitial;
+ const std::vector<DirectoryWatcher::Event> ExpectedInitialCopy;
std::vector<DirectoryWatcher::Event> ExpectedNonInitial;
+ const std::vector<DirectoryWatcher::Event> ExpectedNonInitialCopy;
std::vector<DirectoryWatcher::Event> OptionalNonInitial;
std::vector<DirectoryWatcher::Event> UnexpectedInitial;
std::vector<DirectoryWatcher::Event> UnexpectedNonInitial;
@@ -108,8 +110,8 @@ struct VerifyingConsumer {
const std::vector<DirectoryWatcher::Event> &ExpectedInitial,
const std::vector<DirectoryWatcher::Event> &ExpectedNonInitial,
const std::vector<DirectoryWatcher::Event> &OptionalNonInitial = {})
- : ExpectedInitial(ExpectedInitial),
- ExpectedNonInitial(ExpectedNonInitial),
+ : ExpectedInitial(ExpectedInitial), ExpectedInitialCopy(ExpectedInitial),
+ ExpectedNonInitial(ExpectedNonInitial), ExpectedNonInitialCopy(ExpectedNonInitial),
OptionalNonInitial(OptionalNonInitial) {}
// This method is used by DirectoryWatcher.
@@ -181,6 +183,26 @@ struct VerifyingConsumer {
}
void printUnmetExpectations(llvm::raw_ostream &OS) {
+ // If there was any issue, print the expected state
+ if (
+ !ExpectedInitial.empty()
+ ||
+ !ExpectedNonInitial.empty()
+ ||
+ !UnexpectedInitial.empty()
+ ||
+ !UnexpectedNonInitial.empty()
+ ) {
+ OS << "Expected initial events: \n";
+ for (const auto &E : ExpectedInitialCopy) {
+ OS << eventKindToString(E.Kind) << " " << E.Filename << "\n";
+ }
+ OS << "Expected non-initial events: \n";
+ for (const auto &E : ExpectedNonInitialCopy) {
+ OS << eventKindToString(E.Kind) << " " << E.Filename << "\n";
+ }
+ }
+
if (!ExpectedInitial.empty()) {
OS << "Expected but not seen initial events: \n";
for (const auto &E : ExpectedInitial) {
@@ -218,6 +240,7 @@ void checkEventualResultWithTimeout(VerifyingConsumer &TestConsumer) {
EXPECT_TRUE(WaitForExpectedStateResult.wait_for(std::chrono::seconds(3)) ==
std::future_status::ready)
<< "The expected result state wasn't reached before the time-out.";
+ std::unique_lock<std::mutex> L(TestConsumer.Mtx);
EXPECT_TRUE(TestConsumer.result().hasValue());
if (TestConsumer.result().hasValue()) {
EXPECT_TRUE(*TestConsumer.result());
OpenPOWER on IntegriCloud