diff options
author | Tobias Markmann <tm@ayena.de> | 2017-03-31 07:51:56 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2017-03-31 09:49:34 (GMT) |
commit | f4034579f0d4adc6d2e7cb293e91cabd6d598887 (patch) | |
tree | a71ecb84db3d56f724ca795efe9e15012d682fbd | |
parent | 613d66b9847e9e4338a37b22b230d3177872a43c (diff) | |
download | swift-f4034579f0d4adc6d2e7cb293e91cabd6d598887.zip swift-f4034579f0d4adc6d2e7cb293e91cabd6d598887.tar.bz2 |
Fix unhandled Google Test exception in test runner
Coverity raised this issue.
Test-Information:
Unit tests pass on macOS 10.12.4.
Change-Id: I5da68b706feb2f89124777d6153a703dba3bd526
-rw-r--r-- | QA/Checker/checker.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/QA/Checker/checker.cpp b/QA/Checker/checker.cpp index b23e7ff..bcf0f5c 100644 --- a/QA/Checker/checker.cpp +++ b/QA/Checker/checker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -21,11 +21,13 @@ #include <Swiften/Base/Log.h> +using Swift::Log; + int main(int argc, char* argv[]) { bool verbose = false; bool outputXML = false; - Swift::Log::setLogLevel(Swift::Log::error); + Log::setLogLevel(Swift::Log::error); // Parse parameters std::vector<std::string> testsToRun; @@ -69,6 +71,9 @@ int main(int argc, char* argv[]) { ::testing::GTEST_FLAG(output) = gtestOutputFilename; } + // Google Test might throw an exception in an anonymous namespace. Exiting + // due to uncaught execption is fine here. + // coverity[fun_call_w_exception] ::testing::InitGoogleTest(&argc, argv); // Set up the listeners @@ -119,7 +124,13 @@ int main(int argc, char* argv[]) { outputter.write(); } - auto googleTestWasSuccessful = RUN_ALL_TESTS() == 0 ? true : false; + auto googleTestWasSuccessful = false; + try { + googleTestWasSuccessful = RUN_ALL_TESTS() == 0 ? true : false; + } catch (const ::testing::internal::GoogleTestFailureException& e) { + googleTestWasSuccessful = false; + SWIFT_LOG(error) << "GoogleTestFailureException was thrown: " << e.what() << std::endl; + } auto cppUnitWasSuccessful = result.wasSuccessful() ? true : false; |