summaryrefslogtreecommitdiffstats
path: root/src/testlib
Commit message (Collapse)AuthorAgeFilesLines
* testlib: Gracefully handle messages outside of test function in JUnit reporterTor Arne Vestbø2021-09-161-0/+3
| | | | | | | | | Fixes: QTBUG-96543 Task-number: COIN-755 Change-Id: I2334597319f3595f37f48c9811f667e57b99df28 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 8aa1fc6f12858ad6f786a4a971a5758fa28d3686) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QTestJunitStreamer: Include <vector>Mårten Nordheim2021-09-131-0/+1
| | | | | | | | | | The indirect include is not available everywhere Amends b8191f41c65a908d0529d235b0200e6de99c34fb Change-Id: If0abf3b0186594ff5381dab847cbdf13e4fcf448 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit a7bb5b024548c52865fb264367ca38016153f759) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* testlib: Replace custom QTestCoreList with std::vectorTor Arne Vestbø2021-09-1010-209/+70
| | | | | | | | | | | | | | | | | | The custom linked list implementation was implemented using recursion, and as a result didn't handle long lists of test cases, exhausting the stack on e.g. Windows where the default stack is only 1MB. This was the case with e.g. the tst_QChar test that produces 20K test cases. Replacing with a std::vector should do nicely for our use-case. No attempt has been made at further reducing the complexity of QTestElement/QTestCoreElement/QTestElementAttribute. Change-Id: Ie295f7cf937ec6abdc4606b6120818551ad285c7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit b8191f41c65a908d0529d235b0200e6de99c34fb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Make clear why QTestLog::addB?XFail() don't add to countersEdward Welbourne2021-08-271-2/+4
| | | | | | | | | | | | | | This reverts commit 904617dfb83f39a6a379635b64fea6fcd00f241a and makes clear to future readers why that wouldn't be a sensible change. Update the test's data, eliminating a case of duplicate counting that was caused by the reverted commit. Task-number: QTBUG-95661 Change-Id: Ice6d3ab06ca171e0d6eb0fac757f1ab774e229f0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 7af79ba09148dbfe5c1fc8b130d564dcca7ae4b3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add note on selecting the device which is used to run tests on AndroidAssam Boudjelthia2021-08-181-0/+6
| | | | | | | Change-Id: I9bcff18ca11fbbfdff968e29190cae488de56263 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 90d8a7bed6f5e3a27d3a908911d2b80ea83b646f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fix testlib compile definitions not to be overriddenAlexandru Croitor2021-08-131-1/+1
| | | | | | | | | | Amends 70464b355ec1c7007e0b1291f733e2540ba1825f Change-Id: I92424d830afc0aaad9001817be82a06adabd014b Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> (cherry picked from commit ab2669a9fa3a64a43548ace27c510aed3b19072a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* testlib: Remove unused QTestCoreElement and QTestElementAttribute typesTor Arne Vestbø2021-08-123-107/+23
| | | | | | | | | | | The "documentation" has also been removed for all types, as it didn't add anything, and maintaining it to be in sync with the values just adds overhead. Change-Id: Iab1dd7b9804c05559b4674342d6059b68ecf3ecf Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit f0757d2fcdf78e1c0573d8b8e1b3aca88dde6ad1) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* testlib: Don't write redundant log message information in JUnit reporterTor Arne Vestbø2021-08-123-93/+29
| | | | | | | | | | | | | | The separation between <system-out> and <system-err> is sufficient, and we can't expect consumers to interpret our custom comment format. The type of the text node has been renamed to more accurately identify its purpose. Change-Id: I63c8ff17529fc087e1b695698350a6711eb5e68d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 4632be1b4d8c5037c83b7c006850da73b590180e) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* testlib: Let loggers know which test function is being leftTor Arne Vestbø2021-08-121-2/+2
| | | | | | | | | | | | None of the loggers rely on this at the moment, but one could imagine one that does. Plus, doing any sort of debug logging in leaveTestFunction will at the moment be attributed to UnknownTestFunc(). Change-Id: I284b2785a276e028b9f57c26357679fd9e045ca7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit d9fd41a1febfccb25134cbad0c9b72c43ae32853) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* testlib: Document order of QTestResult completion functionsTor Arne Vestbø2021-08-121-0/+39
| | | | | | | | | Change-Id: I34adbcc2bd02887a93cd1e86692401e840afe8bd Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 072e5d2a8f757a0c45d4474075294961ae0e89e2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* testlib: Treat qCritical messages as system-err in JUnit reporterTor Arne Vestbø2021-08-121-0/+1
| | | | | | | Change-Id: Ia34fbc59dc430b7ef39a94bd6836d9675cde58f5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit c08d56be1f833f98549e32d900182c33538d68c0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* testlib: Rename QAbstractTestLogger::QSystem to QCriticalTor Arne Vestbø2021-08-128-13/+13
| | | | | | | | | | | | | | It's used to handle qCritical() messages, and corresponds to QtMsgType's QtCriticalMsg, so change its name to reflect what it really is. In the process, reclassify the -maxwarnings overflow message as a warning, rather than a critical message. Change-Id: I87626117a547ae4498d5dc352b93bd6db8bfb332 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit ca15cc0049c643d58875fd4eddfdae8e3b58c644) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* testlib: Move stdout/stderr reporting into individual <testcase> elementsTor Arne Vestbø2021-08-121-7/+17
| | | | | | | | | | | | | | | | The original Ant JUnit reporter only writes <system-err> and <system-out> to the <testsuite>, but more modern reporters such as Maven Surefire scopes output to each individual <testcase>. This is also handled by both the Jenkins JUnit and xUnit plugins, e.g.: https://github.com/jenkinsci/junit-plugin/commit/145eb5c98 Change-Id: I20c87276004a4e0910fc18e05e6ffa0f5e5a7b7c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 308280e7a9277334c2fd3480c3ddc4971d85b920) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* testlib: Produce <error> elements on fatal errors in JUnit reporterTor Arne Vestbø2021-08-122-53/+54
| | | | | | | | | | Test errors represents unanticipated problems, e.g., an unhandled exception, or a problem with the implementation of the test. Change-Id: I87219e7ffdea56862278f005de44526ad97545f0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 825e4291cd44b82c0566e86e60bb77f434196a44) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* testlib: Don't report blacklisted tests as failures in JUnit reporterTor Arne Vestbø2021-08-111-2/+0
| | | | | | | | | | | | | | We don't produce <failure> elements for them, so we shouldn't include them in the total count of failures. In the future we might produce <skipped> elements instead, but for now remove the incorrect increment. Change-Id: Ia89a5cdaf79f6aa2f92be53180112c40ad6da2c6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit eb4fb9fa32797d48d4779464483230ad92f349a6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* testlib: Fix name of current test case element in JUnit reporterTor Arne Vestbø2021-08-102-10/+10
| | | | | | | | Change-Id: I0bd77e5f1d0540b87568a0c69a4b96442d4000eb Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 1272b60d9eea398c70a7e7803d41e13ad9a1956f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* testlib: Write failure details as <failure> content in JUnit reporterTor Arne Vestbø2021-08-102-7/+25
| | | | | | | | Change-Id: Ica48769e7dfcabdc4bc8f0ed058bc22e29a0b632 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit a2026e4116e325767b899505cf248a75b9647195) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* testlib: Indent CDATA element in JUnit reporterTor Arne Vestbø2021-08-061-1/+1
| | | | | | | | | | | The data itself is not indented, as consumers may read it as verbatim data. Change-Id: Ia934616cea273feadc3a45d7c74726d4f804f0dc Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 0ce70a29b36a43f08ff3c8cdecde7ea75af0840f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: Fix link error to qFuzzyIsNull()Nico Vertriest2021-08-061-4/+5
| | | | | | | Change-Id: I17d890d4d61199dd74598ffa4c670ed65894047c Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit 7d7b484429f2a8a23b0d15e5fbfca18f6553b1bf) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* testlib: Don't report additional 'pass' test point for blacklisted XFailTor Arne Vestbø2021-08-051-3/+3
| | | | | | | | | | | Regression after 9906cc57ed3eed64d534f43c677bb16e08561bb6. Change-Id: I5566f70c66d248426c7a41b6de1cfb92f104cc64 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit c95d7741b74bc617d86297dbfa5cd7d1df98f8c3) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* testlib: Report skipped tests in JUnit reporter as <skipped> elementsTor Arne Vestbø2021-08-054-4/+18
| | | | | | | | | | | | | | | | | | The Apache Ant and Surefire Maven specs document a <skipped> element that can be used to signify skipped test, with a corresponding total skipped test attribute on the <testsuite>. The element includes an optional message attribute, documented in the Surefire spec, and in the Ant source code, but not yet documented in the reverse-engineered Ant spec: https://github.com/windyroad/JUnit-Schema/pull/11 Task-number: QTBUG-95424 Change-Id: Ib6417a41b9c328836f4017e6ebf7f7e9cd91288d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit fb16a66b71250f83a9249a0a04064f56d70c9fd3) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* testlib: Don't report JUnit errors attribute without any <error> elementsTor Arne Vestbø2021-08-051-1/+0
| | | | | | | | | | | | The errors attribute on the <testsuite> element represents the number of <error> elements, but we do not produce any at the moment. Task-number: QTBUG-95424 Change-Id: I7196d622a9a6bbb7e79ed2c2886984d539abb1da Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 58f1c0c146aa678b8140cc17388b5e7f3997fcc6) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* testlib: Sync up QTest::LogElementType with element namesTor Arne Vestbø2021-08-052-3/+5
| | | | | | | | | | | | | | 539553a57216c4ece292ff54fb623807c334cdb6 renamed the LET_Error element enum to LET_Message, without renaming the corresponding "error" element name. This was not an issue in practice, since we never write the actual element in QTestJUnitStreamer, but the two should be in sync to avoid any confusion. Change-Id: I6c29f5303393b5f36b2f9877940bf3f6eaf3b7d2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 5a483656bca949f6c31b5da5339fa5cbe1dfac76) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* testlib: Reduce JUnit test duration reporting to millisecond precisionTor Arne Vestbø2021-08-051-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The original Ant JUnit reporter produced test durations via Double.toString(), supporting arbitrary precisions, and the de-facto schema declared them as xs:decimal. Sadly, the now popular Maven Surefire reporter limited the duration to millisecond precision, and hard-coded this into its schema as SUREFIRE_TIME: https://issues.apache.org/jira/browse/SUREFIRE-1533 Unfortunately this definition spread into tools such as the Jenkins xUnit plugin, which relies on the schema provided by Maven Surefire: https://issues.jenkins.io/browse/JENKINS-52152 As a result, anything that produces higher precision results will not validate in the Jenkins xUnit plugin. Other test frameworks have bitten the bullet and reduced their precision correspondingly, e.g.: https://github.com/catchorg/Catch2/issues/2221 https://github.com/catchorg/Catch2/commit/581c46249acf8389e9 We follow suit, and our JUnit XML output now validates against both the Jenkins JUnit and xUnit plugins, as well as the original Apache Ant de-facto schema. Task-number: QTBUG-95424 Change-Id: I3097d10c03c2a29709960372301b29055d224e10 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit bb74e72aa92b599cb4c80c23161ce9b66639ec01) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* testlib: Improve JUnit XML conformanceTor Arne Vestbø2021-08-054-68/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The JUnit test framework did not initially have any XML reporting facilities built in. Instead, the XML report was generated by the Apache Ant JUnit task: https://github.com/apache/ant/search?q=filename%3AXMLJUnitResultFormatter.java Many users interacted with these reports via the Jenkins JUnit plugin, which provided graphical visualization of the test results: https://plugins.jenkins.io/junit/ Due to the lack of an official XML schema for the Apache Ant JUnit report there was some confusion about what the actual format was. People started documenting the de-facto format, both as produced by Ant, and as consumed by Jenkins: https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd https://github.com/junit-team/junit5/search?q=filename%3Ajenkins-junit.xsd The XML produced by the Qt Test JUnit reporter was far from these schemas, causing issues when importing results into tools such as Jenkins, Allure2, or Test Center. The following changes have been made to improve conformance: - The 'timestamp' attribute on <testsuite> is is now in ISO 8601 local time, without any time zone specified - The 'hostname' attribute on <testsuite> is now included - The 'classname' attribute on <testcase> is now included - The non-standard 'result' attribute on <testcase> has been removed - The non-standard 'result' attribute on <failure> has been renamed to 'type' - The <system-out> element on <testsuite> is always included, even when empty - The non-standard 'tag' attribute on <failure> has been removed. Data-driven tests are now represented as individual <testcase> elements, e.g.: <testcase name="someTest(someData X)" ...> <testcase name="someTest(someData Y)" ...> <testcase name="someTest(someData Z)" ...> The resulting XML validates against both the de-facto Apache Ant 'JUnit 4' schema and the Jenkins JUnit plugin schema. Task-number: QTBUG-95424 Change-Id: I6fc9abedbfb319f2545b99b37d059b18c16776ff Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 973e74399e807fb6f351a7d330c8c8b85b66bc5a) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* testlib: Simplify JUnit test loggerTor Arne Vestbø2021-08-055-74/+26
| | | | | | | | | | | | | | - Use the right name for the attribute (AI_Message), rather than fixing it up in QTestJUnitStreamer. - Don't pretend that we're adding line and file information, only to discard it in QTestJUnitStreamer. - Don't pretend to add benchmark information, only to discard it in QTestJUnitStreamer. Change-Id: Ib6eadc12300157216fe9c6e8bcfebd7eb8a3ea68 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 177d259782f228257a376e3e87b30da6ad96f3fb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* testlib: Pass on file location on failure, but don't assume we have oneTor Arne Vestbø2021-08-044-13/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We try our best to pass on the file location of a failure, including for fatal errors, but the reporting or logging machinery should not assume there is one. By passing on nullptr for the file location we allow the logging backends to decide how to handle the situation, e.g. by not emitting extra fields for failure location. This effectively reverts c25687fa0b6e4be043e1f8c92c093d8b06ca06c4, in favor of relying on the backends to cope with null filename, which they already did. As qFatal uses QMessageLogger, which by default disables file/line information in release builds, we need to explicitly enable this in our self-tests, to get uniform test results. Similarly, we disable file/line info from testlib itself, as reporting Qt internal file and line information for user diagnostics is less useful. The odd one out there is qtestdata.cpp, which still ends up in test output due to using QTEST_ASSERT instead of qFatal for its diagnostics. Cleaning up that, and unifying how we report testlib issues to the user, is left for another day. Change-Id: Ib9451b8eed86fe3ade4a4dcaf0037e1a3450321c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit fa8cffa4c97d2e46de9af6f5e91af9212e372204) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* testlib: Deprecate QWARN() in favor of qWarning()Tor Arne Vestbø2021-08-052-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | The QtTest best practices documentations recommends using output mechanisms such as qDebug() and qWarning() for diagnostic messages, and this is also what most of our own tests do. The QWARN() macro and corresponding internal QTest::qWarn() function was added when QtTest was first implemented, but was likely meant as an internal implementation detail, like its cousin QTestLog::info(), which does not have any corresponding macro. This theory is backed by our own QtTest self-test (tst_silent) describing the output from QWARN() as "an internal testlib warning". The only difference between QWARN() and qWarning(), besides the much richer feature set of the latter, is that qWarning() will not pass on file and line number information in release mode, but QWARN() will. This is an acceptable loss of functionality, considering that the user can override this behavior by defining QT_MESSAGELOGCONTEXT. [ChangeLog][QtTest] QWARN() has been deprecated in favor of qWarning() Change-Id: I5a2431ce48c47392244560dd520953b9fc735c85 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit bef57b317f2efc0e73f2275d594be9d69f5a75d0) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Update QAbstractItemModelTester::FailureReportingMode documentationTor Arne Vestbø2021-08-011-2/+1
| | | | | | | | | | | The key part of FailureReportingMode::QtTest is that it will result in a test failure (via QTest::qVerify); not that it's using the QtTest logging machinery. Change-Id: I18472fba173ce1323748f1f87301a4defa87020e Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> (cherry picked from commit 07d8885cccdb759532715598e18ecbe1c1282d25) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* testlib: Update a few remaining instances of the deprecated -xunitxml formatTor Arne Vestbø2021-07-301-3/+9
| | | | | | | | | The format was renamed in 27db9e458cef512fca3a6b5c9ebbcda7a8172428. Change-Id: I53975c7467d8768dc9dc9ac2d89c42eefa12e22f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 7c14223b1e21a3e19a0f84c772c0c8ca49dfe74f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* testlib: Disable automatic backtrace when test crashes on macOS on ARMTor Arne Vestbø2021-07-191-3/+6
| | | | | | | | | | Take two. f20edffcc8089fe573e03bd5e092dafc9b0ce568 only disabled the backtrace preamble. Change-Id: I972d007af59d13ec6eb11da44fc2b5e25c36e46e Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 0f32703aa5aee46bb2c0bfe9c8e54f05b82cf0f3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Remove old configure-related filesJoerg Bornemann2021-06-181-34/+0
| | | | | | | | | | | | | Remove the configure.json and configure.pri files that were used for the qmake-based configure. Remove the .prev_*.cmake files that were a by-product of configurejson2cmake.py. Task-number: QTBUG-89536 Change-Id: Ie827562f7fd2513d59f69234d77b8b93124ea78e Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 7155e4f62060c3d9f36e748135bd57776f40b4b2)
* Fix MSVC compiler warning in code snippetsKai Köhne2021-06-081-5/+3
| | | | | | | | | Fixes warning C5046: 'testObject::MyTestObject::toString': Symbol involving type with internal linkage not defined Change-Id: I9925eb15e262f29e636c019c87311a6ea2c47505 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* wasm: fix threaded buildsLorn Potter2021-06-081-0/+2
| | | | | | | set the thread pool size default to 4 Change-Id: I038a81610c82ac4d162c044d0e1f58196cffc7b7 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* QTestlib: Add formatting for QObject * in QCOMPAREFriedemann Kleint2021-05-262-0/+40
| | | | | | | | | | | Output object name and class in QCOMPARE(). This should help to debug flaky QWidget tests that for example check on focusWidget(). [ChangeLog][QtTestLib] QCOMPARE() now reports QObject * values by class and objectName(). Task-number: QTBUG-64446 Change-Id: Ife04e89bba04fc78d077c8f0f07af17a17c9cf8c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* testlib: Disable automatic backtrace when test crashes on macOS on ARMTor Arne Vestbø2021-05-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The trick we use by spawning lldb to print the backtrace doesn't work for some reason, and just results in: Process 91619 stopped * thread #1, stop reason = signal SIGSTOP frame #0: 0xffffffffffffffff Target 0: (No executable module.) stopped. Architecture set to: . (lldb) bt all * thread #1, stop reason = signal SIGSTOP frame #0: 0xffffffffffffffff thread #2 frame #0: 0xffffffffffffffff thread #3 frame #0: 0xffffffffffffffff thread #4 frame #0: 0xffffffffffffffff Debugging the stopped process manually with lldb works fine. Change-Id: If5582803a11f1c5c84c31b42d1ae52bdd245bbbb Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QTestAccessible: Clear objects in EventList when deletedFabian Kosmale2021-05-231-1/+10
| | | | | | | | | | | | | | The list persists events, which reference objects. Those objects might get deleted by the time we investigate the objects. We cannot change the event to store a QPointer for BIC reasons, and for normal usage of the events, that doesn't make sense either. Instead, connect the objects destroyed signal to a lambda which clears the events' object member. In order to access the private member, we befriend the test class. Change-Id: I036be7053dccde4bdf862173789564e89d729ee1 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QTestlib: Fix formatting of pointers in QCOMPAREFriedemann Kleint2021-05-232-1/+7
| | | | | | | | | | After 1ed8a7bff503aacf55f7f880ddaad461ea15e5e1, volatile needs to be specified for toString(), else it is not used by compare_ptr_helper(). Add an overload. Pick-to: 6.1 5.15 Change-Id: I3c335f324df346233623272d1014c8360ca33160 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix thread-sanitizer warning about a data raceLars Knoll2021-05-121-9/+10
| | | | | | | | | Not 100% sure if this is a bug in tsan, but turning expected into an atomic variable will avoid the warnings. Change-Id: I6d6a5d58f90258d201ae3880473228638de0a215 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Add a helper method for testing write-once bindable propertiesJuha Vuolle2021-04-301-4/+117
| | | | | | Change-Id: I4f5a2ca983902beccf967e983083cc7a315b8ef6 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Exclude unused functions from WASM buildMorten Sørvig2021-04-301-0/+2
| | | | | | | | Fix “unused function” warnings. Change-Id: I1d8d1de3c181385769bffc094d6c9e3319e1dc98 Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix QAbstractItemModelTester false positiveLuca Beldi2021-04-261-1/+1
| | | | | | | | | When inserting rows to a branch with no columns the tester should not complain about indexes being invalid Pick-to: 6.1 6.0 5.15 Change-Id: I466f4e5140b10f6dcf65a71f109c2d3be7336507 Reviewed-by: David Faure <david.faure@kdab.com>
* Improve error message in bindable property testAndreas Buhr2021-04-231-8/+14
| | | | | | Change-Id: I96a9f36657b49814b540c0b909c4642422d49b35 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* qpropertytesthelper: Check that the types matchFabian Kosmale2021-04-221-0/+11
| | | | | | | | | | | | | | If you have a property myprop of type float, testReadWritePropertyBasics would happily accept testReadWritePropertyBasics(myObject, 1, 2, "myProp") The test would then fail when setting bindings, as we would try to install a binding of type int on a float property, which gets rejected at runtime. To prevent unexpected failures, verify that the types match before doing any further checks. Change-Id: I3893563fce0e11f9e20afa7c6a1e1fe0385382ab Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QTest: improve the read-only property test helperSona Kurazyan2021-04-201-0/+12
| | | | | | | | Add a check that setting a binding on the read-only property has no effect, nor does trying to change its value via such a binding. Change-Id: Id7b55cd53256961faface7ef155225664cdee97a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix QAbstractItemModelTester false positiveLuca Beldi2021-04-191-2/+2
| | | | | | | | | | When rows are removed from a model with no columns, the test should not report a problem if indexes are invalid Fixes: QTBUG-92886 Pick-to: 6.1 6.0 5.15 Change-Id: I7a042dfdb2575f87208a00cbed13db3869807f84 Reviewed-by: David Faure <david.faure@kdab.com>
* QTest: add helper methods to test bindable propertiesIvan Solovev2021-04-162-0/+305
| | | | | | | | | | | | | | | This patch adds helper methods to test bindable properties in the QTest lib. These methods can be useful in many Qt modules, so we decided to have them in qtbase. For now they are in the private header, because we are not sure that they can be useful for the end users. Task-number: QTBUG-89874 Change-Id: I6738728df1bcd895758008ef2ade0d3693802c3e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Specify QT_TESTCASE_BUILDDIR for Qt::Test users implicitlyAlexey Edelev2021-04-082-0/+14
| | | | | | | | | | | | | | | | | | | QT_TESTCASE_BUILDDIR was implicitly defined by Qt::Test target for library users in Qt5. By default, this definition will point to CMAKE_CURRENT_BINARY_DIR. This logic works similarly to qmake logic. From user's perspective it might be useful to not rely on standard search paths, but specify own. This can be done by setting the QT_TESTCASE_BUILDDIR property for the user's target. CMake will substute the value of the QT_TESTCASE_BUILDDIR property into the QT_TESTCASE_BUILDDIR definition. The implicit QT_TESTCASE_SOURCEDIR also seems to be useful. According to the current logic, it points to CMAKE_CURRENT_SOURCE_DIR. Fixes: QTBUG-92079 Change-Id: I8a9065f08e859c713b3c8cc08142a9ced0677770 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Doc: Fix link errors qtbaseNico Vertriest2021-04-061-1/+1
| | | | | | Task-number: QTBUG-90662 Change-Id: I17147d149d9f222c142853805443aff94c5a5ff7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QAbstractItemModelTester: fix false positive when model has zero columnsDavid Faure2021-03-301-1/+1
| | | | | | | | | | Regression introduced by me in commit 72e0d699cec09458ca9325035d477d4899e8e47b Fixes: QTBUG-92220 Change-Id: Ic7dd4eda0a1993f9763933882baf928bfc83b08b Pick-to: 6.1 6.0 5.15 Reviewed-by: Luca Beldi <v.ronin@yahoo.it> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>