Skip to content

Commit

Permalink
Use a reliable failure mechanism in test enclosure
Browse files Browse the repository at this point in the history
`assert(false)` gets compiled out in release build unit tests, which prevents this case from properly generating a user warning.  Switching `assert(false)` with the googletest macro `ASSERT_TRUE()` provides more reliability and the added benefit of debug text.
  • Loading branch information
codemercenary committed Mar 25, 2015
1 parent 9047c38 commit 45bd833
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions autowiring/AutowiringEnclosure.h
Expand Up @@ -103,10 +103,7 @@ class AutowiringEnclosure:
ctxt->SignalShutdown();

// Do not allow teardown to take more than 250 milliseconds or so
if(!ctxt->Wait(std::chrono::milliseconds(250))) {
// Critical error--took too long to tear down
assert(false);
}
ASSERT_TRUE(!ctxt->Wait(std::chrono::milliseconds(250))) << "Test case took too long to tear down, unit tests running after this point are untrustworthy";

static const char sc_autothrow [] = "AUTOTHROW_";
if(!strncmp(sc_autothrow, info.name(), sizeof(sc_autothrow) - 1))
Expand Down

0 comments on commit 45bd833

Please sign in to comment.