Skip to content

Commit

Permalink
Updating frequently failing unit test to provide more failure diagnos…
Browse files Browse the repository at this point in the history
…tics
  • Loading branch information
codemercenary committed Jul 31, 2014
1 parent ec81b77 commit 6cb6832
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/autowiring/test/AutoFilterTest.cpp
Expand Up @@ -459,9 +459,26 @@ TEST_F(AutoFilterTest, DeferredRecieptInSubContext)
// Release the preissued packet:
preissued.reset();

// Index of packets that were not expired at the time of detection
std::set<size_t> notExpired;

// Now verify that all of our packets are expired:
for(auto cur : allPackets)
ASSERT_TRUE(cur.expired()) << "Packet did not expire after all recipients went out of scope";
for(size_t i = 0; i < allPackets.size(); i++)
if(!allPackets[i].expired())
notExpired.insert(i);

if(!notExpired.empty()) {
// Delay for a bit, see if they expire later:
std::this_thread::sleep_for(std::chrono::seconds(1));
for(size_t i = 0; i < allPackets.size(); i++)
ASSERT_TRUE(allPackets[i].expired()) << "Packet " << i << " did not expire even after a delay that should have allowed it to expire";

// They did, tell the user what didn't expire the first time around
std::stringstream ss;
for(auto index : notExpired)
ss << index << " ";
FAIL() << "These packets did not expire after all recipients went out of scope: " << ss.str();
}
}

class HasAWeirdAutoFilterMethod {
Expand Down

0 comments on commit 6cb6832

Please sign in to comment.