qt6, test: Handle deprecated code #839

pull hebasto wants to merge 2 commits into bitcoin-core:master from hebasto:240929-qt6-test changing 5 files +12 −7
  1. hebasto commented at 1:22 pm on September 29, 2024: member

    Split from https://github.com/bitcoin/bitcoin/pull/30997.

    This PR ensures compatibility across all supported Qt versions.


    This PR can be tested on macOS using the first commit from https://github.com/bitcoin/bitcoin/pull/30997 and Homebrew’s qt package.

  2. qt6, test: Use `qWarning()` instead of `QWARN()` macro
    The `QWARN()` macro internally uses `QTest::qWarn()`, which has been
    deprecated since Qt 6.3. Replacing it with `qWarning()` ensures
    compatibility across all Qt versions.
    cb750b4b40
  3. hebasto added the label Tests on Sep 29, 2024
  4. hebasto added the label Qt 6 on Sep 29, 2024
  5. DrahtBot commented at 1:22 pm on September 29, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK promag, Sjors

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  6. hebasto commented at 11:57 am on October 2, 2024: member
    Friendly ping @Sjors @furszy @ryanofsky @jarolrod ;)
  7. in src/qt/test/rpcnestedtests.cpp:131 in 2b5fd8fd24 outdated
    126@@ -127,13 +127,26 @@ void RPCNestedTests::rpcNestedTests()
    127     RPCConsole::RPCExecuteCommandLine(m_node, result, "rpcNestedTest(   abc   ,   cba )");
    128     QVERIFY(result == "[\"abc\",\"cba\"]");
    129 
    130+#if (QT_VERSION >= QT_VERSION_CHECK(6, 3, 0))
    131+    QVERIFY_THROWS_EXCEPTION(std::runtime_error, RPCConsole::RPCExecuteCommandLine(m_node, result, "getblockchaininfo() .\n")); //invalid syntax
    


    promag commented at 6:26 pm on October 3, 2024:

    2b5fd8fd24026ecf2fac7af6657e2363bfe3706c

    An alternative to reduce duplicate code and the diff is to define QVERIFY_EXCEPTION_THROWN, something like?

    0// handle deprecated macro, can be removed once minimum Qt is at least 6.3.0
    1#if (QT_VERSION >= QT_VERSION_CHECK(6, 3, 0))
    2#define QVERIFY_EXCEPTION_THROWN(a, b) QVERIFY_THROWS_EXCEPTION(b, a)
    3#endif
    

    hebasto commented at 7:01 pm on October 3, 2024:
    Thanks! Reworked per your feedback.
  8. promag commented at 6:30 pm on October 3, 2024: contributor
    Concept ACK
  9. qt6, test: Handle deprecated `QVERIFY_EXCEPTION_THROWN`
    This change ensures compatibility across all supported Qt versions.
    
    Co-Authored-By: João Barbosa <joao.paulo.barbosa@gmail.com>
    5625840c11
  10. hebasto force-pushed on Oct 3, 2024
  11. promag commented at 11:00 pm on October 3, 2024: contributor
    Code review ACK 5625840c11db2065a1c8d8de3babb6466eda04d4.
  12. in src/qt/test/rpcnestedtests.cpp:133 in 5625840c11
    126@@ -127,6 +127,11 @@ void RPCNestedTests::rpcNestedTests()
    127     RPCConsole::RPCExecuteCommandLine(m_node, result, "rpcNestedTest(   abc   ,   cba )");
    128     QVERIFY(result == "[\"abc\",\"cba\"]");
    129 
    130+// Handle deprecated macro, can be removed once minimum Qt is at least 6.3.0.
    131+#if (QT_VERSION >= QT_VERSION_CHECK(6, 3, 0))
    132+#undef QVERIFY_EXCEPTION_THROWN
    133+#define QVERIFY_EXCEPTION_THROWN(expression, exceptiontype) QVERIFY_THROWS_EXCEPTION(exceptiontype, expression)
    


    Sjors commented at 8:10 am on October 4, 2024:
    5625840c11db2065a1c8d8de3babb6466eda04d4: note to other reviewers: https://doc.qt.io/qt-6/qtest.html#QVERIFY_THROWS_EXCEPTION
  13. Sjors approved
  14. Sjors commented at 8:16 am on October 4, 2024: member

    tACK 5625840c11db2065a1c8d8de3babb6466eda04d4

    I only tested on Intel macOS 15.0 with Homebrew qt@5. Checked that the warnings still appear with build/src/qt/test/test_bitcoin-qt.

  15. hebasto merged this on Oct 4, 2024
  16. hebasto closed this on Oct 4, 2024

  17. hebasto deleted the branch on Oct 4, 2024
  18. in src/qt/test/test_main.cpp:61 in 5625840c11
    57@@ -58,7 +58,7 @@ int main(int argc, char* argv[])
    58     gArgs.ForceSetArg("-natpmp", "0");
    59 
    60     std::string error;
    61-    if (!gArgs.ReadConfigFiles(error, true)) QWARN(error.c_str());
    62+    if (!gArgs.ReadConfigFiles(error, true)) qWarning() << error.c_str();
    


    maflcko commented at 7:56 am on October 7, 2024:
    Is the c_str() still needed?

github-metadata-mirror

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-12-21 15:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me