From b92d336d2ad90248937fff348b2931c1eb45bcff Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 28 Sep 2018 20:37:46 +0200 Subject: [PATCH] Try/catch for unit test main --- .../testblacksimpluginfsxp3d.pro | 4 ++-- tests/test.h | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3d.pro b/tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3d.pro index 2f87271f8..ed0d088d6 100644 --- a/tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3d.pro +++ b/tests/blacksimpluginfsxp3d/testblacksimpluginfsxp3d.pro @@ -14,11 +14,11 @@ TEMPLATE = app DEPENDPATH += \ . \ $$SourceRoot/src \ - $$SourceRoot/tests \ + $$SourceRoot/tests INCLUDEPATH += \ $$SourceRoot/src \ - $$SourceRoot/tests \ + $$SourceRoot/tests HEADERS += *.h SOURCES += *.cpp diff --git a/tests/test.h b/tests/test.h index 39f7b1397..3a109d2c1 100644 --- a/tests/test.h +++ b/tests/test.h @@ -49,8 +49,12 @@ args.append({ "-o", resultsFileName + "_testresults.xml,xml" }); \ #define BLACKTEST_APPLESS_MAIN(TestObject) \ int main(int argc, char *argv[]) \ { \ - BLACKTEST_INIT(TestObject) \ - return QTest::qExec(&to, args); \ + try { \ + BLACKTEST_INIT(TestObject) \ + return QTest::qExec(&to, args); \ + } catch (...) { \ + return EXIT_FAILURE; \ + } \ } //! Implements a main() function that executes all tests in TestObject @@ -59,9 +63,13 @@ int main(int argc, char *argv[]) \ #define BLACKTEST_MAIN(TestObject) \ int main(int argc, char *argv[]) \ { \ - QCoreApplication app(argc, argv); \ - BLACKTEST_INIT(TestObject) \ - return QTest::qExec(&to, args); \ + try { \ + QCoreApplication app(argc, argv); \ + BLACKTEST_INIT(TestObject) \ + return QTest::qExec(&to, args); \ + } catch (...) { \ + return EXIT_FAILURE; \ + } \ } //! \endcond