Skip to content

Commit b25f165

Browse files
committed
merge bitcoin-core/gui#576: Add qt unit test runner summary
1 parent aec2927 commit b25f165

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

src/qt/test/test_main.cpp

+24-24
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
#endif // ENABLE_WALLET
2323

2424
#include <QApplication>
25+
#include <QDebug>
2526
#include <QObject>
2627
#include <QTest>
28+
2729
#include <functional>
2830

2931
#if defined(QT_STATIC)
@@ -67,8 +69,6 @@ int main(int argc, char* argv[])
6769
gArgs.ForceSetArg("-upnp", "0");
6870
gArgs.ForceSetArg("-natpmp", "0");
6971

70-
bool fInvalid = false;
71-
7272
// Prefer the "minimal" platform for the test instead of the normal default
7373
// platform ("xcb", "windows", or "cocoa") so tests can't unintentionally
7474
// interfere with any background GUIs and don't require extra resources.
@@ -83,35 +83,35 @@ int main(int argc, char* argv[])
8383
app.setApplicationName("Dash-Qt-test");
8484

8585
app.node().context()->args = &gArgs; // Make gArgs available in the NodeContext
86+
87+
int num_test_failures{0};
88+
8689
AppTests app_tests(app);
87-
if (QTest::qExec(&app_tests) != 0) {
88-
fInvalid = true;
89-
}
90+
num_test_failures += QTest::qExec(&app_tests);
91+
9092
OptionTests options_tests(app.node());
91-
if (QTest::qExec(&options_tests) != 0) {
92-
fInvalid = true;
93-
}
93+
num_test_failures += QTest::qExec(&options_tests);
94+
9495
URITests test1;
95-
if (QTest::qExec(&test1) != 0) {
96-
fInvalid = true;
97-
}
96+
num_test_failures += QTest::qExec(&test1);
97+
9898
RPCNestedTests test3(app.node());
99-
if (QTest::qExec(&test3) != 0) {
100-
fInvalid = true;
101-
}
99+
num_test_failures += QTest::qExec(&test3);
100+
102101
#ifdef ENABLE_WALLET
103102
WalletTests test5(app.node());
104-
if (QTest::qExec(&test5) != 0) {
105-
fInvalid = true;
106-
}
103+
num_test_failures += QTest::qExec(&test5);
104+
107105
AddressBookTests test6(app.node());
108-
if (QTest::qExec(&test6) != 0) {
109-
fInvalid = true;
110-
}
106+
num_test_failures += QTest::qExec(&test6);
111107
#endif
112-
113108
TrafficGraphDataTests test7;
114-
if (QTest::qExec(&test7) != 0)
115-
fInvalid = true;
116-
return fInvalid;
109+
num_test_failures += QTest::qExec(&test7);
110+
111+
if (num_test_failures) {
112+
qWarning("\nFailed tests: %d\n", num_test_failures);
113+
} else {
114+
qDebug("\nAll tests passed.\n");
115+
}
116+
return num_test_failures;
117117
}

0 commit comments

Comments
 (0)