testing: avoid aborting client-test due to exception in destructor
The TestingSyncSource destructor ends up calling endSync() for
CalDAV/CardDAV, which must do some real work and may fail with an
exception. If the test has already failed and is getting left via
exception handling, then this extra work can be skipped and, more
importantly, no exceptions are allowed because they would terminate
client-test.
Happened in practice when Google becomes unresponsive with 401 errors,
because then the test fails and the reading of CTag in endSync() is
just going to encounter the same problem, thus raising a second
exception.
(cherry picked from commit 919a45adef
)
Conflicts:
test/ClientTest.cpp
Conflict because of renamed test macros.
This commit is contained in:
parent
81c6d37e1d
commit
d374cd01ba
1 changed files with 10 additions and 1 deletions
|
@ -158,7 +158,16 @@ public:
|
|||
}
|
||||
~TestingSyncSourcePtr()
|
||||
{
|
||||
reset(NULL);
|
||||
// We can skip the full cleanup if the test has already failed.
|
||||
// Also avoids letting an exception escape from the
|
||||
// destructor during exception handling (= program aborted!)
|
||||
// when the endSync() call invoked by reset() needs to
|
||||
// report a proble. CPPUNIT_ASSERT_NO_THROW() itself catches that
|
||||
// exception, but then forwards it, and thus does not
|
||||
// prevent the exception from escaping.
|
||||
if (!std::uncaught_exception()) {
|
||||
CPPUNIT_ASSERT_NO_THROW(reset(NULL));
|
||||
}
|
||||
}
|
||||
|
||||
void reset(TestingSyncSource *source = NULL)
|
||||
|
|
Loading…
Reference in a new issue