summaryrefslogtreecommitdiffstats
path: root/tests/auto/testlib/selftests
Commit message (Collapse)AuthorAgeFilesLines
* QTest: rip out qxp::function_ref from reportResult()Thiago Macieira8 days7-14/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is causing huge code bloat because everything is a local lambda. Instead, pass direct type-erased function and data pointers to the replacement function. Testing with tst_qcborvalue, this reduces the compilation time and the output binary size significantly: Before After Compiler Time Size Time Size GCC 13.2 136.99 s 202.3 MB 13.88 s 14.3 MB GCC 14.0 131.49 s 202.7 MB 14.69 s 14.4 MB Clang 17 77.2 s 146.7 MB 13.62 s 12.2 MB Clang 18 141.9 s 187.1 MB 13.62 s 12.4 MB This causes a difference in how toString() overloads are found. Previously it would match far more overloads because the toString() calls were expanded by the macro. Now, we depend on Argument-Dependent Lookup and associated namespaces, so toString() overloads should not be in the QTest namespace any more. With this patch applied, the testlib testcase of tst_selftest started failing, because nullptr is now handled differently. However, I consider it as a bugfix, because previously it was falling back to a default implementation, and now it is using the QTest::toString(std::nullptr_t) overload, which is a desired behavior. Update the reference files for tst_selftest with the new expected output. Task-number: QTBUG-124272 Change-Id: Ie28eadac333c4bcd8c08fffd17c5484186accdf6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Port two tests' QAbstractEventDispatcher overrides to V2Thiago Macieira2024-03-131-8/+5
| | | | | Change-Id: I83dda2d36c904517b3c0fffd17b52c421bf08d5b Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Correct license for tools filesLucie Gérard2024-03-051-1/+1
| | | | | | | | | | | | According to QUIP-18 [1], all tools file should be LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: Icd5d5be2e04819617e68ff142924de1773bebbad Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* QTest: allow passing chrono literal as QTRY_ timeoutMarc Mutz2024-02-071-4/+4
| | | | | | | | | | | | | | | | | | | By wrapping the use of the timeout value in QTRY_IMPL in a lambda that feeds the user input through the std::chrono::milliseconds constructor with std::chrono_literals in-scope, the macros continue to work with raw integral values as well as chrono literals not finer than millisecond granularity. Port all higher-level macros to pass a chrono literal and port some uses in tst_selftests. [ChangeLog][QtTest] The QTRY_*_WITH_TIMEOUT macros now also accept chrono literals (was: int milliseconds). Fixes: QTBUG-121746 Change-Id: Ib38406fc005a0a2c4ae3fd009760f73ad8bed355 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Change license for tests filesLucie Gérard2024-02-0465-65/+65
| | | | | | | | | | | | According to QUIP-18 [1], all tests file should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I9657df5d660820e56c96d511ea49d321c54682e8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* QTest: add -[no]throwon{fail,skip} command line argumentsMarc Mutz2024-01-271-4/+15
| | | | | | | | | | | | ... to complement QTEST_THROW_ON_FAIl/SKIP environment variables. This allows to conveniently test both modes by running each test twice. Task-number: QTBUG-66320 Change-Id: I8b2810e8345061c98472d846017de910a11e0657 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QTest: add opt-in changing QCOMPARE etc to exit with throw, not returnMarc Mutz2024-01-2766-1/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: make failOnWarning() functional on temp objects destructionVladimir Belyavsky2023-11-227-6/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-2211-4/+216
| | | | | | | | | | | | | | | 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>
* Add QTest option for repeating the entire test executionJøger Hansegård2023-11-151-0/+10
| | | | | | | | | | | | | | | | | 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>
* Increase QTest failure message limitMitch Curtis2023-10-197-13/+155
| | | | | | | | | | | | | | 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>
* selftests: document how to run subtests from Windows' cmd.exeMitch Curtis2023-10-171-0/+7
| | | | | | | | | | It deoesn't like single quotes, which must be replaced with doubled-up double quotes. Pick-to: 6.2 6.5 6.6 Change-Id: I8e5f8047e72e4433926a9f4f2044407a4d823682 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* selftests: respect ASAN_OPTIONSMitch Curtis2023-10-162-2/+3
| | | | | | | | | | | | | Ensure that this environment variable is respected, as ASAN errors (e.g. memory leaks) can cause the selftests to fail since they expect no errors in their output. Fix an incorrect function name in a comment, while we're at it. Fixes: QTBUG-118041 Pick-to: 6.5 6.6 Change-Id: I07502101aabd8743df898ae8fe4a693c4733c4af Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_selftests: split the qFatal() test away from tst_SilentThiago Macieira2023-09-068-19/+63
| | | | | | | | | | This allows us to control whether to run this particular test in ASan mode or with specific loggers or not. Adding the expected log output for tst_silent for other loggers is left as an exercise to the reader. Change-Id: Ifa1111900d6945ea8e05fffd177f1548c8c8e714 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Revert "Dodge qFatal() so as to get coverage results despite it"Thiago Macieira2023-09-061-20/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit f20adcde3079227b063b747e6bd91f8fd94c4866. The implementation had the right idea, but this is not expected to work reliably in C++. It's jumping out of several frames without cleaning them out properly and our ASan-based memory leak-checker has started complaining (the next commit will move this test elsewhere). ==19313==ERROR: LeakSanitizer: detected memory leaks Direct leak of 258 byte(s) in 1 object(s) allocated from: #0 0x7ffa505c8e48 in __interceptor_malloc (/usr/lib64/libasan.so.5+0x109e48) #1 0x7ffa4f2d7ff9 (/home/qt/work/install/lib/libQt6Core.so.6+0x896ff9) #2 0x7ffa4f2d834d in QArrayData::allocate(QArrayData**, long long, long long, long long, QArrayData::AllocationOption) (/home/qt/work/install/lib/libQt6Core.so.6+0x89734d) #3 0x7ffa4f23b700 (/home/qt/work/install/lib/libQt6Core.so.6+0x7fa700) #4 0x7ffa4f1f6cc8 in QString::reallocData(long long, QArrayData::AllocationOption) (/home/qt/work/install/lib/libQt6Core.so.6+0x7b5cc8) #5 0x7ffa4f1f68a7 in QString::resize(long long) (/home/qt/work/install/lib/libQt6Core.so.6+0x7b58a7) #6 0x7ffa4f2092ff (/home/qt/work/install/lib/libQt6Core.so.6+0x7c82ff) #7 0x7ffa4f209e09 in QString::vasprintf(char const*, __va_list_tag*) (/home/qt/work/install/lib/libQt6Core.so.6+0x7c8e09) #8 0x7ffa4ed0d83d (/home/qt/work/install/lib/libQt6Core.so.6+0x2cc83d) #9 0x7ffa4ed114a9 in QMessageLogger::fatal(char const*, ...) const (/home/qt/work/install/lib/libQt6Core.so.6+0x2d04a9) #10 0x5641d2604c40 in tst_Silent::messages() /home/qt/work/qt/qtbase/tests/auto/testlib/selftests/silent/tst_silent.cpp:77 #11 0x5641d26050fb in tst_Silent::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) tests/auto/testlib/selftests/silent/silent_autogen/include/tst_silent.moc:118 The restoration of the signal handler (which QtTest now has) is also wrong: this needed to use sigaction() instead. Change-Id: Ifa1111900d6945ea8e05fffd177f14fbc09a1d7d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_selftests: add a way to run a subset of all subprogramsThiago Macieira2023-08-311-0/+2
| | | | | | | This functionality was lost when we switched to Catch2. Change-Id: I2b24e1d3cad44897906efffd177fb4cff641546f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* tst_selftests: deduplicate the Unix/Linux conditionsThiago Macieira2023-08-301-9/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Amends 118f2210c6279803b9a4103a796ce75e88f8beb2. That commit added #ifdef Q_OS_UNIX if (test == "assert" || test == "crashes" || test == "failfetchtype" || test == "faildatatype") return; // Outputs "Received signal 6 (SIGABRT)" #endif Which duplicated 4 out of the 5 tests in the block: #ifdef Q_OS_LINUX // QEMU outputs to stderr about uncaught signals if (QTestPrivate::isRunningArmOnX86() && (test == "assert" || test == "crashes" || test == "faildatatype" || test == "failfetchtype" || test == "silent" )) return; #endif But as Linux is Unix, we never got to that second block for those 4 tests. Pick-to: 6.6 Change-Id: I2b24e1d3cad44897906efffd177fb4b5507d190a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_selftests: compile with QT_NO_FOREACHAhmad Samir2023-08-191-3/+2
| | | | | | | | | | The loop was iterating over a temporary container, so it couldn't have changed it. Use a const auto variable to hold the container and port to ranged-for Task-number: QTBUG-115839 Change-Id: I66e7cbdb811666ca352cdf064b1228caa346d876 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* selftests/badxml/tst_badxml: compile with QT_NO_FOREACHAhmad Samir2023-08-191-14/+10
| | | | | | | | | | | | | | | | | badString(): const'ify the static QList, this is both faster as the compiler doesn't need to check if it has been already initialized, and it means we can use it directly in ranged-for as the method returns const QList&. Drive-by change: don't go the long way around to get a const char*: qPrintable(QString("fail %1").arg(ba)) instead use: QTest::addRow("fail %s", ba.constData()) (thanks to dfaure for pointing it out in review). Task-number: QTBUG-115839 Change-Id: I6e8efa6df47ee94f1d71a63e22ab121647e6bf20 Reviewed-by: David Faure <david.faure@kdab.com>
* Mark all of Qt as free of Q_FOREACH, except where it isn'tMarc Mutz2023-08-193-0/+5
| | | | | | | | | | | | | | | | | | | | | | The density of Q_FOREACH uses in this and some other modules is still extremely high, too high for anyone to tackle in a short amount of time. Even if they're not concentrated in just a few TUs, we need to make progress on a global QT_NO_FOREACH default, so grab the nettle and stick to our strategy: Mark the whole of Qt with QT_NO_FOREACH, to prevent new uses from creeping in, and whitelist the affected TUs by #undef'ing QT_NO_FOREACH locally, at the top of each file. For TUs that are part of a larger executable, this requires these files to be compiled separately, so add them to NO_PCH_SOURCES (which implies NO_UNITY_BUILD_SOURCES, too). In tst_qglobal.cpp and tst_qcollections.cpp change the comment on the #undef QT_NO_FOREACH to indicate that these actually test the macro. Task-number: QTBUG-115839 Change-Id: Iecc444eb7d43d7e4d037f6e155abe0e14a00a5d6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Correct some testlib selftest data: blacklisted does not qFatal()Edward Welbourne2023-07-312-6/+3
| | | | | | | | | The blacklisted test does not crash, as its expected output indeed shows. Pick-to: 6.5 6.6 Change-Id: I07522a7d065b5f39620975a3546bcd156024c41d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_selftests: Fix mistaken early return when checking error outputTor Arne Vestbø2023-07-311-1/+9
| | | | | | | | | | | | | | | | | | In porting the selftest machinery to Catch2 in 24e83de8d192 we accidentally added an unconditional early return when determining whether to check for unexpected stderr output, resulting in not checking error output on any platform. The return statement has now been moved into the Q_CC_MINGW condition, but as we now seem to have similar issues on macOS and Linux with some of the tests outputting "Received signal 6 (SIGABRT)" as we do for QEMU, we need to add a few more explicit early return conditions to the function. Pick-to: 6.5 6.6 Change-Id: I7a25f000843b5f1003a5db883f08285185046b46 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QCOMPARE: restore compatibility with braced-init-listsGiuseppe D'Angelo2023-07-077-37/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a611a9f537f1187825339c2a2214c8ec4a23680f (in Qt 5) added support for mixed-type comparisons through QCOMPARE. That commit added a new overload for qCompare taking two types, T1 and T2; but it also left the same-type qCompare(T, T) overload around, guarded by a Qt 6 version check. The mixed-type version is however not a generalization of the same-type one, because it won't work if one of the arguments doesn't participate in FTAD. Case in point: braced-init-lists. In Qt 5 this worked: QCOMPARE(some_container, {42}); but in Qt 6 it does not work any more. The mixed-type overload fails deduction (can't deduce T2); in Qt 5 the same-type overload deduced T=SomeContainer, and {42} was used to select a constructor for SomeContainer. -- There's a partial, straightforward workaround for this: default T2 to T1 in the mized-type overload. In that case T2 has a "fallback" if it cannot be deduced. This is partial because of course doesn't address the case in which T1 cannot be deduced, but I don't think that is common at all. QList is special here, because it has qCompare overloads that makes it comparable with arrays, initializer lists and more. I don't like that very much -- we should probably have a qCompare(input_range, input_range) overload, but that's an exercise for C++20. Change-Id: I344ba33167829984978cd8d649a1904349a9edab Pick-to: 6.5 6.6 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* CMake: Make qtbase tests standalone projectsAlexandru Croitor2023-07-051-0/+6
| | | | | | | | | | | | | | | | | Add the boilerplate standalone test prelude to each test, so that they can be opened with an IDE without the qt-cmake-standalone-test script, but directly with qt-cmake or cmake. Boilerplate was added using the following scripts: https://git.qt.io/alcroito/cmake_refactor Manual adjustments were made where the code was inserted in the wrong location. Task-number: QTBUG-93020 Change-Id: I77299f990692b4fe4721a9bc35071608d0d23982 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
* selftests: tst_sleep, don't start timer twiceAhmad Samir2023-06-301-1/+0
| | | | | | | Typo from a previous commit. Change-Id: I88cd5c4497d17393615a390428134fd1c710e1f8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTest: add qSleep(std::chrono::milliseconds) overloadAhmad Samir2023-06-302-7/+12
| | | | | | | | | Using chrono means one can write 10s instead of 10'000. [ChangeLog][QTest] Added qSleep(std::chrono::milliseconds) overload. Change-Id: Iac1b12a3fc3f692b557e2d459e6f3bc565f20e93 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTest: port qSleep() to std::this_thread::sleep_forAhmad Samir2023-06-272-7/+18
| | | | | | | | | | | As requested in code review. Big improvement, code-wise. tst_Sleep::wait() was failing on the CI, so be more accurate by using QElapsedTimer::durationElapsed(), which returns nanoseconds. Pick-to: 6.6 Change-Id: I5bed6d6bd768adfdecab2475e6cbe245c20aabd7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Suppress a redundant GCC warningAhmad Samir2023-05-041-0/+4
| | | | | | | The test is accessing an out of bounds index into an array on purpose. Change-Id: I23cce4093fdfabd177eb34639f26fcd6752c8b34 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Rid of 'special case' markersAlexey Edelev2023-04-132-2/+2
| | | | | | | | | | | It's unlikely we will ever use pro2cmake at this project stage, so it doesn't make any sense to keep the 'special case' markers in the CMake scripts. Remove them and replace with TODO where needed. Change-Id: I84290c20679dabbfdec3c5937ce0428fecb3e5a7 Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Testlib: fix the last few s/Q_OS_MAC/Q_OS_DARWIN/wEdward Welbourne2023-03-201-2/+2
| | | | | Change-Id: I6fe6a865aea37c6a2d153bd2c3aace5242362c88 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* Silence some conversion warningsAmir Masoud Abdol2023-03-104-4/+4
| | | | | | Change-Id: I3087bff60e77c0eaa5818a5405c97628ce7f6b79 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QTest: Rename QCOMPARE_XX parameters to add meaningMårten Nordheim2023-03-086-1080/+1080
| | | | | | | | | | | | | | | The parameter names were previously "lhs" and "rhs", which is incredibly abstract for a testing framework. One of the parameters will tend to be a baseline value to compare against while the other is the result of some action we want to test. Thus I suggest they be renamed "computed" and "baseline". This way we can, hopefully, retain the semantic that the 'left'/first argument is the computed ('actual' in QCOMPARE) value while the 'right'/second argument is the baseline ('expected' in QCOMPARE.) Change-Id: I3e0fdce2a3f1faca06fdf7184ef6e0eb9724d990 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Doc: fix link to QTest::failOnWarningVolker Hilsheimer2023-03-051-1/+1
| | | | | | | | | Also fix incorrect failOnWarning*s* elsewhere in comments. Pick-to: 6.5 6.5.0 Change-Id: I0bbc5e71060348153876f3d9a7c77c67f3c2e00d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QTestEventLoop: add enterLoop(std::chrono::milliseconds) overloadAhmad Samir2023-03-031-4/+6
| | | | | | | Task-number: QTBUG-110059 Change-Id: Ibf1d76afd313e390103be4a22e44af7fb41ace1b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_benchlibcallgrind: silence a compiler warningAhmad Samir2023-02-261-1/+1
| | | | | Change-Id: I68cc530fa8eaf941a6ddb7e6987ff37ec270bc4d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tests: Remove remains of qmake conversion from CMakeLists.txt filesFriedemann Kleint2023-02-1757-336/+110
| | | | | | | Pick-to: 6.5 Change-Id: I8d106554bb86ac1ec9bb7a4083de4c376bcbab1d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* tst_Selftests: rewrite this with templates instead of macroThiago Macieira2023-01-121-33/+41
| | | | | | | Otherwise it's undebuggable. Change-Id: I3c79b7e08fa346988dfefffd171ee81fefde63b0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Adapt to QTimeZone replacing Qt::TimeSpec usageEdward Welbourne2022-12-101-2/+5
| | | | | | | | | | | | In the process actually handle all time-spec cases in various places that only handled UTC or LocalTime, or at least note that they don't where that's not practical. Also tidy up header ordering and ensure QDateTime's header is included wherever it's used, while adding the include for QTimeZone where needed. Task-number: QTBUG-108199 Change-Id: Ic1a5cdf0aaf737bf1396aa8ac58ce2004cef7e19 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use QString/QByteArray range erase()Ahmad Samir2022-12-071-5/+7
| | | | | Change-Id: I0fb81306ebe8fc7acd63bb62dc6720c734461da0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Update Catch2 to v2.13.10Marc Mutz2022-10-172-12/+18
| | | | | | | | | | | Two patches applied to upstream release. Pick-to: 6.4 6.2 Fixes: QTBUG-103321 Task-number: QTBUG-99122 Change-Id: Ief451a21e5f61851cb03a9ca94ffe0f864e4b1f8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* testlib: make it possible to test double-clicks with discrete eventsShawn Rutledge2022-10-167-6/+68
| | | | | | | | | | | | | | | | | | | | | | The timestamp will no longer be incremented by 500ms after a mouse release if the delay has been explicitly specified. The default delay is 1 ms since f5010c49a37729375e37e6fe8cea60dd4b880d83 but the running timestamp was unconditionally post-incremented by 500ms after every mouse release, to prevent double-clicks, which were always deemed as unintended (because we have a mouseDClick function for that). Now, we do that 500ms increment only if the user has not provided a delay value in the function argument at all. We have often found it useful in our own tests to generate double-clicks "the hard way", by sending indivdual events, so as to be able to check state in some target object at each step, as shown in the new snippet. [ChangeLog][QtTest] QTest::mouseRelease() and mouseClick() can now be used to test double-clicks, by specifying a realistic timestamp delay. Fixes: QTBUG-102441 Change-Id: I8e8d242061f79efb4c6e02638645e03661a9cd92 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Autotest/Unix: request zero-sized core dumps for crashing codeThiago Macieira2022-10-141-0/+8
| | | | | | | | | | | | | Unix systems have got crash loggers in the past 15-20 years, notably macOS and Linux (abrtd, systemd-coredumpd, etc.). By setting the core dump limit to zero, those tools should be mostly inhibited from running and thus not interfere with the parent process' timeouts. Even for systems without core dump loggers, disabling the writing of a core dump to the filesystem should also help. Pick-to: 6.4 Change-Id: I12a088d1ae424825abd3fffd171d112d0671effe Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* tests: skip tst_selftests on Wayland and XWaylandLiang Qi2022-10-141-0/+5
| | | | | | | | | | | | | QWindow::requestActivate() is not supported. We have one tst_selftests binary, and will test it with both xcb and wayland qpa plugin. A runtime check and skip will have different restult files, which is not implemented in testlib yet. Task-number: QTBUG-107578 Pick-to: 6.4 6.2 Change-Id: Idc8cb24c6f42a9f0f4dc9493e3fd1a5803ba7ce0 Reviewed-by: Liang Qi <liang.qi@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Skip early return from test loops during cleanup()Edward Welbourne2022-09-226-113/+17
| | | | | | | | | | | | | | | | The QTRY_* macros and QTestEventLoop exit early if the test has resolved; however, in the cleanup phase of a test, even if the test has failed, these loops should continue as normal. [ChangeLog][QtTest] During the cleanup() phase of a test, the QTRY_* macros and QTestEventLoop now ignore the test resolution, in contrast to when they are used from the test itself, which (since 6.3.0) exits the loops early if the test has failed. Pick-to: 6.4 6.3 Fixes: QTBUG-104441 Change-Id: I2673161967cbbc57815155af698a9338ab98a686 Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Fix error in TAP test logger's regex to recognize QVERIFY() outputEdward Welbourne2022-09-222-4/+4
| | | | | | | | | | | The regex used a greedy .+ to match an actual dot and a space, preceding an open parenthesis, with the result that if the message contained any parentheses that .+ swallowed everything up to the last of them. Correct the regex so that recently-added tests' error messages show up correctly. Change-Id: I6e52c9b2a6e7959335fcddbb4266f65b589eba68 Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Add test-case for TAP logging glitchEdward Welbourne2022-09-227-7/+11
| | | | | | | | | | | | The recently added test for QTestEventLoop produced a message which the TAP test-logger mis-parses. Since that message shall soon go away (when I fix the bug the new test exists to verify), modify one of cmptest's QVERIFY2() messages to trip up the same bug, so we can spot any regressions on this in future (after the imminent fix to this TAP issue). Change-Id: Ibbe9931c01c75df529c9571e2bbdbd34010dd9ec Reviewed-by: Jason McDonald <macadder1@gmail.com>
* Include global data tags in teamcity's test function namesEdward Welbourne2022-09-132-425/+435
| | | | | | | | | | | | Use the standard mechanism instead of a hand-rolled way of identifying function/data-tag combinations. Adds missing data relevant to identifying test cases, some of which previously had apparently the same name, with no hint at why the test-case was seemingly run repeatedly. Change-Id: I6225c6d1990069c94a1f1c8dbb179993b96076e7 Reviewed-by: Jason McDonald <macadder1@gmail.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix cmake warnings from using deprecated PUBLIC_LIBRARIESVolker Hilsheimer2022-09-051-1/+1
| | | | | | Pick-to: 6.4 Change-Id: I8d4f0d9e98edc4e06dda9f58e62197572b4cbdbc Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>