Skip to content

Commit

Permalink
qt, test: Clean settings after tests
Browse files Browse the repository at this point in the history
A test suite should not leave any artifacts except for those explicitly
expected.

This change is easy to review with `git diff --ignore-all-space`
command.
  • Loading branch information
hebasto committed Mar 5, 2024
1 parent 49cf635 commit 0dcbad3
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions src/qt/test/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,37 +85,45 @@ int main(int argc, char* argv[])
setenv("QT_QPA_PLATFORM", "minimal", 0 /* overwrite */);
#endif

BitcoinApplication app;
app.setOrganizationName(QAPP_ORG_NAME);
app.setApplicationName(QAPP_APP_NAME_DEFAULT "-test");
app.createNode(*init);

QCoreApplication::setOrganizationName(QAPP_ORG_NAME);
QCoreApplication::setApplicationName(QAPP_APP_NAME_DEFAULT "-test");

int num_test_failures{0};

AppTests app_tests(app);
num_test_failures += QTest::qExec(&app_tests);
{
BitcoinApplication app;
app.createNode(*init);

AppTests app_tests(app);
num_test_failures += QTest::qExec(&app_tests);

OptionTests options_tests(app.node());
num_test_failures += QTest::qExec(&options_tests);
OptionTests options_tests(app.node());
num_test_failures += QTest::qExec(&options_tests);

URITests test1;
num_test_failures += QTest::qExec(&test1);
URITests test1;
num_test_failures += QTest::qExec(&test1);

RPCNestedTests test3(app.node());
num_test_failures += QTest::qExec(&test3);
RPCNestedTests test3(app.node());
num_test_failures += QTest::qExec(&test3);

#ifdef ENABLE_WALLET
WalletTests test5(app.node());
num_test_failures += QTest::qExec(&test5);
WalletTests test5(app.node());
num_test_failures += QTest::qExec(&test5);

AddressBookTests test6(app.node());
num_test_failures += QTest::qExec(&test6);
AddressBookTests test6(app.node());
num_test_failures += QTest::qExec(&test6);
#endif

if (num_test_failures) {
qWarning("\nFailed tests: %d\n", num_test_failures);
} else {
qDebug("\nAll tests passed.\n");
if (num_test_failures) {
qWarning("\nFailed tests: %d\n", num_test_failures);
} else {
qDebug("\nAll tests passed.\n");
}
}

QSettings settings;
settings.clear();

return num_test_failures;
}

0 comments on commit 0dcbad3

Please sign in to comment.