diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-12-26 23:16:59 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-12-26 23:16:59 +0000 |
commit | 86dcc235fd56423b50b7bd5d7064bd61d4a71b53 (patch) | |
tree | e1ed2a057ef6142b80fe6443f84291e1e60692a5 /test/bbackupd/testbbackupd.cpp | |
parent | 9d63400fed8960b99f9cffe9a9ceb97f4ce818bd (diff) |
Catch exceptions in individual tests and clean up nicely.
This stops stale daemons from hanging around if a single test fails because
it throws an exception, which otherwise would cause the whole suite to
abort immediately without cleaning up after itself.
Diffstat (limited to 'test/bbackupd/testbbackupd.cpp')
-rw-r--r-- | test/bbackupd/testbbackupd.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp index 21aa7520..190b3930 100644 --- a/test/bbackupd/testbbackupd.cpp +++ b/test/bbackupd/testbbackupd.cpp @@ -472,7 +472,9 @@ int num_tests_selected = 0; if (!setUp(__FUNCTION__)) return true; \ num_tests_selected++; \ int old_failure_count = failures; \ - TEST_THAT(kill_running_daemons()); + TEST_THAT(kill_running_daemons()); \ + try \ + { // left open #define SETUP_WITHOUT_FILES() \ SETUP() \ @@ -508,7 +510,16 @@ bool teardown_test_bbackupd(std::string test_name, int old_failure_count) } #define TEARDOWN() \ - return teardown_test_bbackupd(__FUNCTION__, old_failure_count); + return teardown_test_bbackupd(__FUNCTION__, old_failure_count); \ + } \ + catch (BoxException &e) \ + { \ + BOX_NOTICE(__FUNCTION__ << " errored: " << e.what()); \ + bool status = teardown_test_bbackupd(__FUNCTION__, old_failure_count); \ + s_test_status[__FUNCTION__] = "ERRORED"; \ + return status; \ + } + bool test_basics() { |