./src/qt/test/test_bitcoin-qt
indicating that all tests passed or showing the number of failing tests. It’s currently a bit inconvenient to see this result by eyeballing all of the output.
Add qt unit test runner summary #576
pull jonatack wants to merge 3 commits into bitcoin-core:master from jonatack:gui-test-runner-summary changing 1 files +21 −21-
jonatack commented at 10:03 pm on April 6, 2022: contributorAppend a one-line summary to the output of running
-
gui: add test runner summary ba44aae768
-
gui: count test failures in test runner summary 2489b6fe9c
-
gui, refactor: rename fInvalid to num_test_failures in test_main.cpp d025d7f025
-
jonatack commented at 10:07 pm on April 6, 2022: contributor
A sample patch to generate 3 errors to test the runner output in this case.
0diff --git a/src/qt/test/optiontests.cpp b/src/qt/test/optiontests.cpp 1index 4a943a634..9e6c8a243 100644 2--- a/src/qt/test/optiontests.cpp 3+++ b/src/qt/test/optiontests.cpp 4@@ -28,6 +28,7 @@ void OptionTests::optionTests() 5 gArgs.LockSettings([&](util::Settings& settings) { 6 settings.rw_settings.erase("prune"); 7 }); 8+ QVERIFY(gArgs.IsArgSet("-prune")); 9 gArgs.WriteSettingsFile(); 10 } 11 12@@ -51,7 +52,7 @@ void OptionTests::parametersInteraction() 13 14 OptionsModel{}; 15 16- const bool expected{false}; 17+ const bool expected{true}; 18 19 QVERIFY(gArgs.IsArgSet("-listen")); 20 QCOMPARE(gArgs.GetBoolArg("-listen", !expected), expected); 21diff --git a/src/qt/test/rpcnestedtests.cpp b/src/qt/test/rpcnestedtests.cpp 22index 669a05fe0..4395c20cf 100644 23--- a/src/qt/test/rpcnestedtests.cpp 24+++ b/src/qt/test/rpcnestedtests.cpp 25@@ -73,7 +73,7 @@ void RPCNestedTests::rpcNestedTests() 26 QVERIFY(result.substr(0,1) == "{"); 27 28 RPCConsole::RPCExecuteCommandLine(m_node, result, "getblockchaininfo()[\"chain\"]"); //Quote path identifier are allowed, but look after a child containing the quotes in the key 29- QVERIFY(result == "null"); 30+ QVERIFY(result != "null");
-
in src/qt/test/test_main.cpp:112 in d025d7f025
126+ num_test_failures += QTest::qExec(&test6); 127 #endif 128 129- return fInvalid; 130+ if (num_test_failures) { 131+ qWarning("\nFailed tests: %d\n", num_test_failures);
shaavan commented at 6:16 pm on April 7, 2022:nit: This is less of a suggestion and more of a preference. I don’t think this line needs separate line breaks to make it stand out from other lines. I think we can forgo the “\n"s.
cheetooooo commented at 8:34 pm on April 8, 2022:thanks @shaavanshaavan approvedshaavan commented at 6:16 pm on April 7, 2022: contributorACK d025d7f0251e26b7ab5cf48c236b6b5e46fafe26
It makes sense to give the user an overview of how many tests were failed. Though it won’t wholly communicate the information of which tests failed to the user, it still would make him alert to the situation and allow him to save his efforts of eyeballing in case the “Test failed” message is missing.
I was able to compile the PR and run the
test_bitcoin-qt
file successfully. I have attached the screenshot of the difference in output between the Master and PR branches.Master PR jarolrod approvedjarolrod commented at 1:39 am on April 10, 2022: membertACK https://github.com/bitcoin-core/gui/commit/d025d7f0251e26b7ab5cf48c236b6b5e46fafe26
I have tested and reviewed the code, I agree this can be merged.
in src/qt/test/test_main.cpp:92 in d025d7f025
90+ 91 AppTests app_tests(app); 92- if (QTest::qExec(&app_tests) != 0) { 93- fInvalid = true; 94- } 95+ num_test_failures += QTest::qExec(&app_tests);
hebasto commented at 9:41 pm on April 12, 2022:QTest::qExec
does not guarantee return value1
in case of a test failure, but:a value other than 0 if one or more tests failed or in case of unhandled exceptions.
jonatack commented at 10:06 pm on April 12, 2022:Yes, in my testing it returns the number of failures; if there are two failures for instance, it returns 2. This is desirable.hebasto added the label Tests on Apr 12, 2022hebasto merged this on Apr 12, 2022hebasto closed this on Apr 12, 2022
jonatack deleted the branch on Apr 13, 2022sidhujag referenced this in commit c1b62eb579 on Apr 13, 2022bitcoin-core locked this on Apr 13, 2023
This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-23 07:20 UTC
More mirrored repositories can be found on mirror.b10c.me