summaryrefslogtreecommitdiffstats
path: root/src/testlib
Commit message (Collapse)AuthorAgeFilesLines
...
* QTest: add opt-in changing QCOMPARE etc to exit with throw, not returnMarc Mutz2024-01-273-1/+258
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add exception classes and use them to change the control flow for QTEST_{FAIL,SKIP}_ACTION from return'ing from just the immediate function to the full way to the QTestLib infrastructure, here we filter them out. There are three modes: - If QT_NO_EXCEPTION, then we return - If QTEST_THROW_ON_... is also defined, #error out - Otherwise, if QTEST_THROW_ON_... is defined, always throw - Otherwise, the decision is made at runtime (with defaults read from QTEST_THROW_ON_... environment variables). Three selftests depend on the old behavior, as they explicitly check that multiple FAIL SKIP etc emerge, which the new framework, of course, prevents. Locally disable throwing at the test function level. Add initial docs and enable exceptions in all of the selftest subprograms to facilitate switching between the two runtime-selectable modes. [ChangeLog][QtTest] Added QTEST_THROW_ON_FAIL and QTEST_THROW_ON_SKIP C++ macros and environment variables that, when defined, change how QCOMPARE/QVERIFY/QSKIP etc exit the test function on failure. Instead of a return, exiting only the immediately-surrounding function, they throw a special exception instead, thereby exiting from subfunctions of the test function, all the way to QtTestLib. Fixes: QTBUG-66320 Change-Id: I96c38d2a1dcdd9de84942cf448a8bbf3ab6d3679 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QTest: hold WatchDog in optional<> instead of QScopedPointerMarc Mutz2024-01-271-5/+6
| | | | | | | | | | Means we don't need to allocate it on the heap and optional<> fits the semantics of an optional object better. Pick-to: 6.7 Change-Id: Id02c4847c2357c3033dce94b68787ed37d6ca276 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTest: DRY test function invocationMarc Mutz2024-01-261-22/+17
| | | | | | | | | | | | | | Wrap the QMetaMethod::invoke() calls in a helper function in preparation of filtering execeptions as part of QTBUG-66320. Rename the existing helper function to make the old documentation comment redundant. Pick this back to LTS branch in order to avoid needless code divergence going forward. Pick-to: 6.7 6.6 6.5 Change-Id: I34ae24bf23ea21d7063016257908f925fc087298 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QTestLib: prepare QVERIFY_THROWS_EXCEPTION for FAILED_ACTION = throwMarc Mutz2024-01-251-1/+4
| | | | | | | | | | | | | | | | | | | We can't have a QTEST_FAILED_ACTION in a try-block if we intend to allow QTEST_FAILED_ACTION to be a throw statement. We could, of course, add a whitelisting catch-block for the eventual TestFailedException, but as of now, the intent it to give users full control over the definition of QTEST_FAILED_ACTION, and they may have their own idea of what to throw. So add a bool variable to record whether no exception was thrown and use it to drag QTEST_FAILED_ACTION out of the try block. It's ok to be in catch blocks, no action needed there. Change-Id: I0b004e43b1db82cd8b5b12f900ed985e58a56807 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QTest: replace naked returns with QTEST_{FAIL,SKIP}_ACTION macrosMarc Mutz2024-01-252-16/+24
| | | | | | | | | | | | | ... defaulting to "return". This allows customizing these actions, incl. to eventually make them throwing exceptions instead (but that won't work for QVERIFY_THROWS_EXCEPTION, yet). Change-Id: I078a4ce48135bda2cf98fce78318a12d757d7aa5 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* testlib: Remove the "cmake" key from BLACKLIST filesJoerg Bornemann2024-01-241-4/+1
| | | | | | | | | All usages of "cmake" in BLACKLIST files have been removed, and the keyword can be removed. Fixes: QTBUG-90545 Change-Id: Ief1d307490b2673a4e1081d277c1e34264eb3107 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* QTest: Extract Method qCaught() from THROWS_(NO_)EXCEPTIONMarc Mutz2024-01-232-18/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | We've already done a lot in 59600a514ba99ed62b46237d8f160dea84474190, but we can do more: Thanks to std::exception_ptr, we can drag the handling of unexpected exceptions completely to out-of-line code, leaving only the catch(...) as inline. As a nice side-effect, we no longer need the nested try blocks in QVERIFY_THROWS_EXCEPTION to work around GCC -Wexceptions or MSVC C2312 complaining about two handlers for the same exception type (which can happen when exceptiontype is std::exception itself). This may not handle __cxxabi::__forced_unwind correctly, but it doesn't need to: Tests should not need to call THROWS_EXECPTION on code that could emit a pthread cancellation; tests are controlled environments. Keep the old qCaught() function for BC. We don't promise BC in QtTestLib, but it doesn't cost much. Pick-to: 6.7 Change-Id: I1e1627c6341b09197a8a79669fde061c47e6ba47 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QAppleTestLogger: Add source link to failure messagesAxel Spoerl2024-01-221-0/+8
| | | | | | | | | | | | | | The apple test logger did not include the failure location in the log output, because the assumption was that the structured logging would report the file and line separately. Unfortunately we can't do that using the os_log machinery just yet, so we bring in the manual location printing as in the plain text logger. Pick-to: 6.7 Change-Id: Ief0a6a6e04d628c98ed09c09334b694504cbff2c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* SignalDumper: protect access to ignoreClassesMårten Nordheim2024-01-191-6/+17
| | | | | | | | | | | | It's a shared list that, in theory, can be written to by multiple threads. Protect it with a mutex. To make the change in a clean way, move all the .contains() checks into a separate function so we can simply hold the lock in there. Pick-to: 6.7 6.6 6.5 Change-Id: I99ff185346d52e43a3f59f2910a7b2fa6031e3e4 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Introduce macros to simplify testing comparisonIvan Solovev2024-01-191-0/+40
| | | | | | | | | | | | | | | | | | | | | The problem with the QTestPrivate::testAllComparisonOperators() and QTestPrivate::testEqualityOperators() functions is that if they fail, they point into the helper function, but not into the actual test that called the helper function. This is specially annoying when some test calls the helper function multiple times. This patch introduces the helper macros QT_TEST_ALL_COMPARISON_OPS and QT_TEST_EQUALITY_OPS that wrap the respective function calls together with the QTest::currentTestFailed() check. If the test has failed, the macro generates a meaningful debug message with the original file name and line number. This patch also applies the new macros to qtbase. Task-number: QTBUG-119433 Pick-to: 6.7 Change-Id: Iad709de45e5bf53c82e7afa8e9f51e9275c1e619 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* TestLib: consistently wrap comparison helper macros into do {} whileIvan Solovev2024-01-181-38/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | The CHECK_SINGLE_OPERATOR macro is used inside FOR_EACH_CREF macro, which, like all other FOR_EACH_* macros in Qt (see qdebug.h or qmetatype.h), expects its parameter to have a scope or a semicolon. All other CHECK_* macros are *not* used inside FOR_EACH_CREF, so they can follow a more traditional approach with the `do { } while (false)` scope without a trailing semicolon. This allows to use them in the code like: if (condition) MACRO(args); else OTHER_MACRO(args); In the example above, if MACRO ended with the semicolon, adding one more semicolon would have discarded the else part of the conditon, leading to compilation error. Amends bfb237d19a5319bfa020ad0cefaff72e8d94a9be. Task-number: QTBUG-119433 Pick-to: 6.7 Change-Id: I9a7f17416ba7c37a50f022f685b54e2643e4a9e2 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Remove the use of GENERATE_PRIVATE_CPP_EXPORTS argumentAlexey Edelev2024-01-171-1/+0
| | | | | | Task-number: QTBUG-117983 Change-Id: Ic12e6c9daedd56f54cbde20e6bebd19f8420604c Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Make adding new rows to QTestTable more efficientIsak Fyksen2024-01-151-8/+6
| | | | | | | | | | | | | Added QDuplicateTracker to keep track of used tags, rather than looping through QTestTablePrivate::dataList for every added tag. Removed method `hasRow`, instead calling `QDuplicateTracker::hasSeen` directly in `newData`. Pick-to: 6.7 Task-number: QTBUG-118619 Change-Id: Idaab70d8c94227f75620924e0f1ead477f93b27a Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Remove the use of Q_TESTLIB_PRIVATE_EXPORTAlexey Edelev2023-12-221-3/+2
| | | | | | | | | | Q_TESTLIB_PRIVATE_EXPORT is the redefinition of Q_TESTLIB_EXPORT. Keeping the both makes no sense. Task-number: QTBUG-117983 Change-Id: Id909530f1453ad092a45f40c1c85fed1f66e38d7 Reviewed-by: Jason McDonald <macadder1@gmail.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* testlib: Add test function for simulating wheel eventsDoris Verria2023-12-204-0/+85
| | | | | Change-Id: I28fe4dff7db92fb58922948a3eec460df315318c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QTest: Extract Method writePrettyUnicodeChar from toPrettyUnicodeMarc Mutz2023-12-071-38/+46
| | | | | | | | | Easier to reason about by separating the concerns into separate functions. Pick-to: 6.6 6.5 Change-Id: I34666766ac2879577faea17bbd2b700bcb803f51 Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Remove unneeded toString(QPair) declarationMarc Mutz2023-12-062-10/+0
| | | | | | | | | | | | It's literally the same as the std::pair one that immediately follows it, because QPair these days is just a template alias for std::pair. Wasn't flagged as an error because it's just a declaration, not a definition. Pick-to: 6.6 6.5 Change-Id: I5b47572f6e2a71edb47cbe224801a719ff1e060d Reviewed-by: Jason McDonald <macadder1@gmail.com>
* QTest::toPrettyUnicode: remove magic numbersMarc Mutz2023-12-061-4/+8
| | | | | | | | | | Derive them from the chosen output buffer size instead, itself a symbolic constant. Pick-to: 6.6 6.5 Change-Id: I33aa351ba358b106b448f886b92e952e53bc75f9 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Jason McDonald <macadder1@gmail.com>
* QTest: simplify toString(tuple)Marc Mutz2023-12-062-10/+3
| | | | | | | | | | | | | | | | | Use C++14's std::index_sequence instead of our home-brewed QtPrivate::IndexList. I used make_index_sequence<sizeof...(Types)> instead of index_sequence_for<Types...> to avoid having to resolve another type-dependent template alias. Remove the helper's vacuous \internal qdoc block. As a drive-by, rename the helper function to prevent it from participating in QTest::toString() overload resolution, and fix spaces around &. Pick-to: 6.6 6.5 Change-Id: I5981a9b1a99fbe741e75820a6954d066ced9573d Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Silence a warning in release buildJoni Poikelin2023-12-011-1/+1
| | | | | | Pick-to: 6.6 6.5 Change-Id: I6059b560872ebd97874c2dc80e3ad17cf887d8dc Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Rename EINTR_LOOP -> QT_EINTR_LOOPMarc Mutz2023-11-301-1/+1
| | | | | | | | | | | | | | | This non-namespaced macro was defined in a header, and while that header is private, we shouldn't define non-namespaced macros in our headers. The macro also clashed with one of the same name defined in forkfd.c, which broke unity-builds including the forkfd_qt.cpp TU. This rename fixes that, too, so we can now remove forkfd_qt.cpp from NO_UNITY_BUILD_SOURCES. Pick-to: 6.6 6.5 Change-Id: Ic4bb4e4d7a632ca87905e48913db788a7c202314 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Implement checking of op<=> in the compare test helpersIvan Solovev2023-11-281-0/+84
| | | | | | | | The operator<=> is only checked if it is implemented. Task-number: QTBUG-104113 Change-Id: I89396ca5edea7db9e1f9b0459c277cb4268e1f48 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Implement compare helper macrosIvan Solovev2023-11-281-4/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These macros should unwrap into a proper set of equality and ordering operators, depending on the C++ standard being used. For C++17, all 6 operators (==, !=, <, >, <=, >=) are overloaded, while for C++20 only the overloads for opeartor==() and operator<=>() are provided. The macros are documented as internal for now. The macros rely on two helper functions: bool comparesEqual(LeftType lhs, RightType rhs); ReturnType compareThreeWay(LeftType lhs, RightType rhs); The comparesEqual() helper function is used to implement operator==() and operator!=(). The compareThreeWay() helper function is used to implement the four relational operators in C++17, or operator<=>() in C++20. ReturnType must be one of Qt::{partial,weak,strong}_ordering. When possible, the functions should also be declared constexpr and noexcept. It's the user's responsibility to provide the functions before using the macros. Implement a test case which applies the new macros to the dummy classes, and uses the new helper function to verify the comparison results. The MSVC compiler before version 19.36 has a bug, where it fails to correctly generate reverse opeerators in C++20 mode. Introduce a new Q_COMPILER_LACKS_THREE_WAY_COMPARE_SYMMETRY definition for such compiler versions, and use it to manually generate reversed operators when needed. Task-number: QTBUG-104113 Change-Id: Idc19d55df011fd616ff654f35a964e831b8ab93b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QTest: make failOnWarning() functional on temp objects destructionVladimir Belyavsky2023-11-222-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | We need to be able to handle warnings that may occur when temporary objects, that were created in a test function, are destroyed. For example, now we miss all warnings that might be triggered from the object destructor, if the object's deletion was delayed (e.g. via deleteLater()). Also we miss all the warnings that were triggered on the test's cleanup() call. To fix this we need simply move QTestLog::clearFailOnWarnings() from QTestResult::finishedCurrentTestData() to the later stage, i.e. into QTestLog::clearCurrentTestState() which is actually called in appropriate time from QTestResult::finishedCurrentTestDataCleanup(). Same for QTestLog::clearIgnoreMessages(), since they are interrelated, so we need to clear them at the same time. We need this change for QML tests in particularly, to be able fail on warnings that might be triggered from Component.onDestruction() of some temporary test object. Pick-to: 6.6 6.5 Change-Id: I58a57691f20761619f56bd1bea3a862f2c26f569 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* qtestlib: Add option to skip blacklisted testsKalle Viironen2023-11-222-12/+31
| | | | | | | | | | | | | | | Add a command-line option "-skipblacklisted" to testlib to skip blacklisted test cases. Currently, blacklisted test cases are run, but results are ignored. For test code coverage measurements, it's important to see the code coverage of the actually tested code in comparison to the code that was run but not actually tested. The default approach remains unchanged, meaning that blacklisted tests are run with the results ignored. Fixes: QTBUG-112793 Change-Id: I6fe0a6353cb1c021e0232c79bb4f404632fb0bce Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Rename Q*Ordering to Qt::*_orderingMarc Mutz2023-11-211-12/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since we cannot re-use the pre-existing QPartialOrdering type due to binary-compatibility issues (it's not BC to std::partial_ordering), we're no longer bound to copy its API for consistency. So copy std::*_ordering type API for consistency instead, to ease porting for users that can already use C++20 and everyone else come Qt 7. This patch is another step in that direction, renaming classes and their memmbers to std-compatible names. QPartialOrdering cannot change, as it's pre-existing. So add a completely new type Qt::partial_ordering. Adding conversions from QPartialOrdering is left for a follow-up patch. As a drive-by, change `\c Less` to `\l Less` in the \class documentation blocks of the new classes. Amending c6fe64b17c87ec985f17389bf08eee46606862d4, which didn't have a ChangeLog: [ChangeLog][QtCore] Added Qt::{partial,weak,strong}_ordering as drop-in C++17 stand-ins for C++20's std::{partial,weak,strong}_ordering. Task-number: QTBUG-119108 Change-Id: Ib1296de6b708571a6abca8843ba36c114f6fd34f Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Fix a compiler warning (GCC 13.2.1) -Wpessimizing-moveAhmad Samir2023-11-201-2/+2
| | | | | | | | | | | | src/testlib/qpropertytesthelper_p.h:204:38: warning: moving a temporary object prevents copy elision [-Wpessimizing-move] 204 | if (std::unique_ptr<TestedClass> helperObj = std::move(helperConstructor())) { | ^~~~~~~~~ Amends f5a5c59918021b0bf9a43e6130df2a3f02ea5b97. Pick-to: 6.6 6.5 Change-Id: Ie050aa4294289df34347c8f6cbcdce7ff2b784a9 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Move the remaining blacklist setting into TestMethods::invokeTest()Kalle Viironen2023-11-202-3/+4
| | | | | | | | | | Move the remaining QTestResult::setBlacklistCurrentTest() call from checkBlackLists() into TestMethods::invokeTest() Change-Id: I6f0bb26ef612e707ad013d1e42e47b06f40482a0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Jason McDonald <macadder1@gmail.com> Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
* [doc] QBENCHMARK_ONCE: fix typosMarc Mutz2023-11-151-2/+2
| | | | | | | | | ... and remove a prematurely-ending parenthesized remark. Pick-to: 6.6 6.5 6.2 5.15 Change-Id: If0a2f482c45128739ed6cea1d8385ea34f45b094 Reviewed-by: Isak Fyksen <isak.fyksen@qt.io> Reviewed-by: Jason McDonald <macadder1@gmail.com>
* QBENCHMARK: mark loop operations as noexceptMarc Mutz2023-11-153-6/+6
| | | | | | | | | | | | Tell the compiler that next() and isDone() cannot throw, so it doesn't need to create exception handling code. This might yield more faithful benchmark results for micro-benchmarks. As a drive-by, mark isDone() as const, too. Change-Id: Ifac3d9ee2f4df524e780fd07423e26bb5e87dab3 Reviewed-by: Jason McDonald <macadder1@gmail.com> Reviewed-by: Isak Fyksen <isak.fyksen@qt.io>
* Add QTest option for repeating the entire test executionJøger Hansegård2023-11-158-7/+74
| | | | | | | | | | | | | | | | | Repeated test execution can be useful, under a debugger, to catch an intermittent failure or, under memory instrumentation, to make memory leaks easier to recognize. The new -repeat flag allows running the entire test suite multiple times within the same process. It works by executing all tests sequentially before repeating the execution again. This switch is a developer tool, and is not intended for CI. It can only be used with the plain text logger. Change-Id: I2439462c5c44d1c8aa3d3b5656de3eef44898c68 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* TestLib: provide helper functions to test relational operatorsIvan Solovev2023-11-133-0/+262
| | | | | | | | | | | | | | | | | | The patch provides two sets of functions: * functions to perform compile-time check for all cv-ref combinations * functions that actually verify the comparison results for all cv-ref combinations. For now it does not test operator<=>(), even if compiled with C++20, because Qt types do not yet implement it. The patch uses the new helper functions to improve testing of date and time classes, because they already provide a full set of relational operators. Change-Id: I8bd869c489543719ea856d6609cac53cbd4dc122 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Make checkBlackLists() return boolKalle Viironen2023-11-032-2/+4
| | | | | | | | | Make checkBlackLists() return true if the test is blacklisted and false otherwise. Change-Id: Ief400a10a47ec7c21ea1d37fe75c7dc08739e06c Reviewed-by: Dimitrios Apostolou <jimis@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Extend QTestPrivate property tests - actual implementation [2/2]Ivan Solovev2023-11-011-20/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch provides the actual implementation to detect binding loops in property setters. These test will help to catch all the existing binding loops that were introduced when migrating to new bindable properties. The logic of the new tests is taken from tst_QObject::objectNameBinding(), but generalized to be applicable to all bindable properties. The original code from tst_QObject can now be removed. The patch effectively reverts f791570b86ce4a0da45bb6e617701a48ee8189b7 because a lambda returning a nullptr now means that the binding loop test should be skipped, which is not a good default behavior. Now when all the existing bindable properties are fixed, it's fine to give a compilation error when adding new tests, if the class is not default-constructible. Task-number: QTBUG-116345 Pick-to: 6.6 6.5 Change-Id: I059d444d4bb023c050a22e5b1974565e4f581b5c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc: Fix QTest::createTouchDevice docsMichal Klocek2023-11-011-4/+4
| | | | | | | | | | | | | | After the introduction of QInputDevice class the returned QPointingDevice object from QTest::createTouchDevice() call is no longer automatically deleted when the QCoreApplication is deleted. Moreover, this function does not really go thorough qpa but simply registers the device with QWindowSystemInterface::registerInputDevice() (which is actually also used from qpa plugins when new device is plugged) Pick-to: 6.6 6.5 Change-Id: I3a0400288d76b7c95659d6b6ea260eff3233ebf1 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* wasm: Fix test runner for asynchronous testsPiotr Wierciński2023-10-261-0/+12
| | | | | | | | | | | | | | | | | Test runner was not properly handling tests which return the control back to browser event loop. It was treating such tests as if they exited with code 0, marking them as succesfull even if they were eventually failing or hanging. This commit adds a callback to TestCase so the runner is notified when a test truly has finished. As a side effect, two tests need to be disabled for now as they are failing for wasm, which was not properly detected previously. Change-Id: I0eb9383e5bb9cd660431c18747b9e94413629d1e Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Modify copyright format in qt_attribution.jsonLucie Gérard2023-10-231-7/+7
| | | | | | | | | Multiline copyright entries are entered via string array. Task-number: QTBUG-111873 Pick-to: 6.5 6.6 Change-Id: Ib8203163db8d5d579117f402b7a89b59ae1a5169 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Increase QTest failure message limitMitch Curtis2023-10-191-5/+9
| | | | | | | | | | | | | | QPalette specifically has quite a large amount of output (1363 characters) when toString is called on it. We should make sure that we can fit that in our failure messages. This patch does that by increasing the limit from 1024 characters to 4096. Fixes: QTBUG-5903 Fixes: QTBUG-87039 Pick-to: 6.5 6.6 Change-Id: I1dc5078ad05858bb6542c3a06c6b84711af79e4f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* SignalDumper: fix UB (data race on ignoreLevel)Mårten Nordheim2023-10-171-1/+1
| | | | | | | | | | | | ... by making it thread_local. It is written and read by multiple threads at the same time, so it needs to be protected. Since signal emission start and end happens in a single thread, keep it thread_local rather than using an atomic. Pick-to: 6.6 6.5 Change-Id: I98fc5438c512b45f936318be31a6fccbe5b66944 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* SignalDumper: fix UB (data race on indentation level)Mårten Nordheim2023-10-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | ... by making it thread_local. As a natural (and welcome) side-effect, this makes output look sane in multithreaded scenarios. As for why it should be thread_local instead of an atomic: Since signal emissions and slot invocations on one thread are not necessarily correlated with another thread, they should not affect one another's indentation level. As in, emitting QIODevice::readyRead on a background thread should not make QEventLoop::aboutToBlock on the main thread be indented. The only exception to this is BlockingQueued, where one thread is directly tied to another (QTBUG-118145). But slot invocations are anyway not currently printed for Queued connection (see QTBUG-74099.) Pick-to: 6.6 6.5 Change-Id: Iea1fc522d37626df14af419a3455a732729edf74 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Fix warnings and linking issuesTopi Reinio2023-10-091-0/+3
| | | | | | | | | | | | | | | | | | | | Remove or replace links to examples that were removed or moved under manual tests. Replace code snippets that were quoting the now-missing examples. Fix documentation of QSet::removeIf(). Fix typo in documentation macro: Unknown command '\examplecateogry'. Add qtopengl, qtshadertools dependencies to Qt Widgets documentation project to enable correct linking to those topics. Mark all documentation sets in qtbase as free of warnings. Pick-to: 6.6 6.5 Change-Id: I058cd5f2063aa933ea310bceff906f05422a7cb2 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QtTest: block almost all Unix signals in the WatchDog threadThiago Macieira2023-10-011-4/+28
| | | | | | | | | | | | | | Signals delivered via kill(2) are delivered to any thread that is running, so let's make sure the WatchDog thread doesn't get them. This may be hiding bugs in the user's handler code, but in simple unit tests the user may not be expecting there to be multiple threads in the first place. Pick-to: 6.6 Change-Id: I512648fd617741199e67fffd17822cdcdf30926c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QTestPrivate property tests: don't try to create abstract typesVolker Hilsheimer2023-09-281-2/+12
| | | | | | | | | | | | | Amends 5743837a26fce1962c0480bc7536b4c2d0e69997, after which Qt Positioning and Qt SCXML failed to build as some properties operate on abstract classes. Check whether we can instantiate the tested class before trying to do so, otherwise return a default-constructed unique_ptr. Pick-to: 6.6 6.5 Change-Id: Ida9d4375197a93438062b1e1473b4a2a22cc7054 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Extend QTestPrivate property tests - update signatures [1/2]Ivan Solovev2023-09-271-2/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Testing for the binding loops requires a second instance of the TestedClass. In general case, we cannot guarantee that the TestedClass is default-constructible, so we introduce a new parameter - a function that returns an std::unique_ptr holding the properly-constructed instance of TestedClass. The default implementation simply creates a unique_ptr using a default constructor, which is good enough for most cases. The user needs to provide a custom function when TestedClass has no default constructor (for now such usecase exists at least in QtScxml and QtPositioning). This patch introduces new signatures for the helper functions, but does not actually provide new implementation. This is an attempt to simplify the CI integration process. The new arguments have default values, so the existing code will not be affected. The idea is that the merge process goes as follows: * this patch gets merged into qtbase. It should not break leaf modules, because the new parameters have default values -> existing tests are unaffected. * it unblocks all patches to the leaf modules that require the new parameter for the test helper functions. These patches are also supposed to fix all the problems with the binding loops. * once these patches are merged, a follow-up patch to qtbase that actually extends the test coverage can be merged. As it is supposed that all problems in the leaf modules are already fixed, merging this patch should not lead to new problems. The actual implementation of the new tests is provided in a follow-up patch. Task-number: QTBUG-116345 Pick-to: 6.6 6.5 Change-Id: I0dd5c8c60de01aa960d63673b5d7de97950d9490 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* testlib: use const methods moreAnton Kudryavtsev2023-09-081-1/+1
| | | | | | | to avoid implicit detach Change-Id: I8c7de3b7d6a84299714f837da5c9feb39074d0c2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* testlib: use string view types moreAnton Kudryavtsev2023-09-071-1/+1
| | | | | Change-Id: I59886bca9c90cce6aa00e3cbe09a3991b6b4ce79 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Remove redundant QPair includesAhmad Samir2023-09-061-2/+0
| | | | | | | | Nothing in those files uses QPair; and a local build finished fine without them. Task-number: QTBUG-115841 Change-Id: I669cfecaa9129bce6b31e464826287f138b159db Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Mark linux_perf_event with GPL-2.0-onlyKai Köhne2023-09-062-2/+2
| | | | | | | | | | "GPL-2.0" as a SPDX identifier is deprecated in SPDX 3. Use the more explicit GPL-2.0-only instead. Pick-to: 6.2 6.5 6.6 Change-Id: Ie543135ad1d73205f7a94db140189f5132098ea2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Rename Qt::Key_mu to Qt::Key_microEdward Welbourne2023-08-241-2/+2
| | | | | | | | | | | | | | | | | The old name misleadingly identifies it as the Greek letter on which it is based (and to which it case-folds); but U+00B5 is MICRO SIGN, not the Greek letter mu, and pretending it is the latter only leads to confusion. Retain the old name as an alias to the new, prepare to deprecate it from 6.11 and change all uses of it to the new name. [ChangeLog][QtCore][Qt::Key] Qt::Key_mu is now renamed Key_micro, since it is, in fact, the micro sign, not the Greek letter mu. The old name is retained as an alias for the time being. Change-Id: I4deb905f5e59b906710bd092c05a2c0a9b6bba65 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Do not generate the deprecated 'QtTest/qtest_global.h'Alexey Edelev2023-08-241-4/+0
| | | | | | Task-number: QTBUG-115029 Change-Id: I2c0e7979b22c2381049a170f977202d0cd594e4b Reviewed-by: Kai Köhne <kai.koehne@qt.io>