summaryrefslogtreecommitdiffstats
path: root/src/testlib
Commit message (Collapse)AuthorAgeFilesLines
* QTest: support initMain() in QTEST_APPLESS_MAINGiuseppe D'Angelo2021-10-051-0/+1
| | | | | | | | | | | | | The various macros that implement a test's main() call a test object initMain() static function, except for QTEST_APPLESS_MAIN. Add it to it. [ChangeLog][QtTest] initMain() is now also supported when using QTEST_APPLESS_MAIN. Change-Id: I46b1eae5ce3bb8c9a5aca525f193c9250e520c6d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Use %.6g rather than %s and QByteArray::number()Edward Welbourne2021-10-011-3/+2
| | | | | | | | | | | | | The comment against the use of this claimed qvsnprintf() lacks 64-bit support, which is probably untrue by now but certainly irrelevant as the value being formatted is a qreal, not a 64-bit integral type. Since %g wants a double, make the value passed explicitly double by casting its denominator. Casting its numerator to qreal was superfluous as that's its type already. Change-Id: I5ff885fbeb9b638b2b0507061e0a19e3b8522143 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Clean up QXmlTestLogger's xmlQuote() and xmlCdata()Edward Welbourne2021-10-012-63/+63
| | | | | | | | | | | | | | | | | | Make the overloads taking a size private (they're only called by the implementation of the others) and have them take qsizetype for the size, rather than size_t. Make the still-public ones consistently return 0 on failure and move the documentation to them. Change some spurious checks (QTestCharBuffer::size() is necessarily positive) to assertions, use '\0' for the nul character to make it visually distinct from the integer 0. Use a do..while loop instead of break-ing out of the tail of a for (;;) loop. Remove spurious extra nul-termination - the function taking size alread did that, so the wrapper to size-expand needn't. Minor style cleanups. Change-Id: I7440f3d9be5e3b2dd88c2aad62bcd1af9fc02278 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Tidy up QTest::qt_asprintf() and remove a spurious declarationEdward Welbourne2021-10-011-18/+11
| | | | | | | | | | | | | | | | The extern declaration for filter_unprintable() was nowhere used and no such function is anywhere defined. The for (;;) loop with lots of reasons to break; was better structured as a do {...} while loop. A comment on -1 as return from qvsprintf() was misplaced. The '\0'-termination after calling qvsprintf() was redundant as vsprintf() reliably '\0'-terminates anyway. Turned a static const into a constexpr. Assert size (a QTestCharBuffer necessarily has size >= 512). Change-Id: I5b7729b9bd66fea0ee7ce3e7cfdde6770f10b36c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Document QTestLog's enumsEdward Welbourne2021-09-271-16/+55
| | | | | | | Task-number: QTBUG-96844 Change-Id: I9af60ef0cf3def699e58b3477b647f2e071afa40 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix various minor documentation errors in QAbstractTestLoggerEdward Welbourne2021-09-271-16/+15
| | | | | Change-Id: I30ad67479b578b00557671cfa25631be0b6e4fb9 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Coding style: correct spacing in XML test loggerEdward Welbourne2021-09-271-32/+32
| | | | | | | Put stars after spaces, not before; indent cases level with switch. Change-Id: I1dc29d0729d5be449b8123e15510177d814d42da Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Document QAbstractTestLogger's virtual method APIEdward Welbourne2021-09-231-3/+209
| | | | | | | | Provide the information an implementor needs in order to be able to implement an logging backend. Change-Id: I7bb522de57149dad843e01a8afa9f8891d011d29 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Deprecate QTest::qWarn() and replace its last useEdward Welbourne2021-09-232-14/+10
| | | | | | | | The one place that actually called it with file and line number was internal to QtTest, so could call QtTestLog::warn(). Change-Id: I8be10fc81996cc3de4d2eea3ecedc59671ffe759 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Replace QTest::qWarn() with qWarning()Edward Welbourne2021-09-232-7/+7
| | | | | | | | | | | | | It's the recommended replacement when file and line aren't known, and simplifies the code in any case, thanks to taking format and varargs. It incidentally also enables tests to tell QtTest's custom message logger to anticipate its warnings, when they arise. Fixes: QTBUG-67702 Change-Id: I10c883f4dd0b69dca6e59e0dbd55ab318f1938f4 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove spurious QTestResult::setCurrentTestData(nullptr);Edward Welbourne2021-09-221-1/+0
| | | | | | | | | Calls to QTestResult::setCurrentTestData() are handled via an RAII class, QTestDataSetter, that ensures this final call passing nullptr was redundant. Change-Id: I7788e3ce898e5628d5590ef9d34182f05e85fe50 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* 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 Pick-to: 6.2 Change-Id: I2334597319f3595f37f48c9811f667e57b99df28 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QTestJunitStreamer: Include <vector>Mårten Nordheim2021-09-131-0/+1
| | | | | | | | | The indirect include is not available everywhere Amends b8191f41c65a908d0529d235b0200e6de99c34fb Pick-to: 6.2 Change-Id: If0abf3b0186594ff5381dab847cbdf13e4fcf448 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* 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. Pick-to: 6.2 Change-Id: Ie295f7cf937ec6abdc4606b6120818551ad285c7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Doc: Remove unsupported customFiltersKai Köhne2021-09-031-4/+0
| | | | | | | | | | | customFilters defined in .qdocconf are not supported anymore by Qt Assistant since Qt 5.13. Therefore remove them from all .qdocconf files, also to avoid cargo-culting them to new help modules. Task-number: QTBUG-95987 Change-Id: I664391460637d2e859348da0338e1a4a3ee9f570 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* 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 Pick-to: 5.12 5.15 6.1 6.2 Change-Id: Ice6d3ab06ca171e0d6eb0fac757f1ab774e229f0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Add note on selecting the device which is used to run tests on AndroidAssam Boudjelthia2021-08-181-0/+6
| | | | | | Pick-to: 6.2 5.15 Change-Id: I9bcff18ca11fbbfdff968e29190cae488de56263 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* CMake: Fix testlib compile definitions not to be overriddenAlexandru Croitor2021-08-121-1/+1
| | | | | | | | | Amends 70464b355ec1c7007e0b1291f733e2540ba1825f Pick-to: 6.2 Change-Id: I92424d830afc0aaad9001817be82a06adabd014b Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* Clarify documentation of QEXPECT_FAIL()'s modeEdward Welbourne2021-08-112-10/+13
| | | | | | | | | Present behavior is to continue or abort, according to the mode, regardless of whether the condition marked does fail. Change-Id: I2eb5eefbbf173326101d08f3bbb378d214e93e71 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Clean up some notes in QtTestLib documentationEdward Welbourne2021-08-111-11/+11
| | | | | | | | | | | Use \note instead of \b{Note:}, don't refer to functions as macros, and don't lie. The data-table set-up functions can delegate their calls to addColumn(), addRow() and newRow() to functions not called directly by the test framework. Change-Id: I3bef22cf1a45df91dc822ac04f07e7d15053825f Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* testlib: Remove unused QTestCoreElement and QTestElementAttribute typesTor Arne Vestbø2021-08-103-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. Pick-to: 6.2 Change-Id: Iab1dd7b9804c05559b4674342d6059b68ecf3ecf Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* testlib: Let loggers know which test function is being leftTor Arne Vestbø2021-08-101-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(). Pick-to: 6.2 Change-Id: I284b2785a276e028b9f57c26357679fd9e045ca7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* testlib: Document order of QTestResult completion functionsTor Arne Vestbø2021-08-101-0/+39
| | | | | | | | Pick-to: 6.2 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>
* testlib: Don't write redundant log message information in JUnit reporterTor Arne Vestbø2021-08-103-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. Pick-to: 6.2 Change-Id: I63c8ff17529fc087e1b695698350a6711eb5e68d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* testlib: Treat qCritical messages as system-err in JUnit reporterTor Arne Vestbø2021-08-101-0/+1
| | | | | | Pick-to: 6.2 Change-Id: Ia34fbc59dc430b7ef39a94bd6836d9675cde58f5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* testlib: Rename QAbstractTestLogger::QSystem to QCriticalTor Arne Vestbø2021-08-108-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. Pick-to: 6.2 Change-Id: I87626117a547ae4498d5dc352b93bd6db8bfb332 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* testlib: Move stdout/stderr reporting into individual <testcase> elementsTor Arne Vestbø2021-08-101-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 Pick-to: 6.2 Change-Id: I20c87276004a4e0910fc18e05e6ffa0f5e5a7b7c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* testlib: Produce <error> elements on fatal errors in JUnit reporterTor Arne Vestbø2021-08-102-53/+54
| | | | | | | | | Test errors represents unanticipated problems, e.g., an unhandled exception, or a problem with the implementation of the test. Pick-to: 6.2 Change-Id: I87219e7ffdea56862278f005de44526ad97545f0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* testlib: Don't report blacklisted tests as failures in JUnit reporterTor Arne Vestbø2021-08-061-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. Pick-to: 6.2 Change-Id: Ia89a5cdaf79f6aa2f92be53180112c40ad6da2c6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* testlib: Fix name of current test case element in JUnit reporterTor Arne Vestbø2021-08-062-10/+10
| | | | | | | Pick-to: 6.2 Change-Id: I0bd77e5f1d0540b87568a0c69a4b96442d4000eb Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* testlib: Write failure details as <failure> content in JUnit reporterTor Arne Vestbø2021-08-062-7/+25
| | | | | | | Pick-to: 6.2 Change-Id: Ica48769e7dfcabdc4bc8f0ed058bc22e29a0b632 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@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. Pick-to: 6.2 Change-Id: Ia934616cea273feadc3a45d7c74726d4f804f0dc Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Fix link error to qFuzzyIsNull()Nico Vertriest2021-08-061-4/+5
| | | | | | Pick-to: 6.1 6.2 Change-Id: I17d890d4d61199dd74598ffa4c670ed65894047c Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* testlib: Don't report additional 'pass' test point for blacklisted XFailTor Arne Vestbø2021-08-051-3/+3
| | | | | | | | | | Regression after 9906cc57ed3eed64d534f43c677bb16e08561bb6. Pick-to: 6.2 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>
* 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 Pick-to: 6.2 Task-number: QTBUG-95424 Change-Id: Ib6417a41b9c328836f4017e6ebf7f7e9cd91288d Reviewed-by: Mårten Nordheim <marten.nordheim@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. Pick-to: 6.2 Task-number: QTBUG-95424 Change-Id: I7196d622a9a6bbb7e79ed2c2886984d539abb1da Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@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. Pick-to: 6.2 Change-Id: I6c29f5303393b5f36b2f9877940bf3f6eaf3b7d2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* 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. Pick-to: 6.2 Task-number: QTBUG-95424 Change-Id: I3097d10c03c2a29709960372301b29055d224e10 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* 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>
* 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. Pick-to: 6.2 Change-Id: Ib6eadc12300157216fe9c6e8bcfebd7eb8a3ea68 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QTestEventLoop: stop when the test failsEdward Welbourne2021-08-052-4/+8
| | | | | | | | | | | | | | | | | | | | | | It makes no sense for the event loop of a test to keep running after a test has failed. This lets test code simply use the usual testlib macros to compare and verify values in asynchronous tests that would otherwise need to hand-test values and send a signal on failure (that the main test can connect to an event-loops quit() or equivalent). For example, QLocalSocket's benchmark simply uses the usual macros, without doing anything to stop its event loop if they fail, with the sad result that, when a test fails, it does so repeatedly and then times out, causing the test program to be killed without running later tests. With this change, that test code (once converted to use QTestEventLoop) is able to exit gracefully on the first failure. [ChangeLog][QtTest][QTestEventLoop] The QTestEventLoop new exits its event loop as soon as the test is known to be failing. Task-number: QTBUG-91713 Change-Id: If0d455741668722034906763025dda496d2afbb4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* 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. Pick-to: 6.2 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>
* testlib: Deprecate QWARN() in favor of qWarning()Tor Arne Vestbø2021-08-042-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() Pick-to: 6.2 Change-Id: I5a2431ce48c47392244560dd520953b9fc735c85 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* 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. Pick-to: 6.2 Change-Id: I18472fba173ce1323748f1f87301a4defa87020e Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* testlib: Update a few remaining instances of the deprecated -xunitxml formatTor Arne Vestbø2021-07-291-3/+9
| | | | | | | | The format was renamed in 27db9e458cef512fca3a6b5c9ebbcda7a8172428. Pick-to: 6.2 Change-Id: I53975c7467d8768dc9dc9ac2d89c42eefa12e22f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDirIterator: add nextFileInfo()Marc Mutz2021-07-281-3/+1
| | | | | | | | | | | | | | | | | | | | | | | Before this change, next() was the only way to advance the iterator, whether the caller was ultimately interested in just the filePath() (good) or not (bad luck, had to call .fileInfo()). Add a new function, nextFileInfo(), with returns fileInfo() instead. Incidentally, the returned object has already been constructed as part of advance()ing the iterator, so the new function is faster than next() even if the result is ignored, because we're not calculating a QString result the caller may not be interested in. Use the new function around the code. Fix a couple of cases of next(); fileInfo().filePath() (just use next()'s return value) as a drive-by. [ChangeLog][QtCore][QDirIterator] Added nextFileInfo(), which is like next(), but returns fileInfo() instead of filePath(). Change-Id: I601220575961169b44139fc55b9eae6c3197afb4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* 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. Pick-to: 6.2 Change-Id: I972d007af59d13ec6eb11da44fc2b5e25c36e46e Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Tidy up qtestcase.cpp's WatchDogEdward Welbourne2021-07-151-6/+11
| | | | | | | | | It now uses QtPrivate::condition_variable, it pulls in the correct header for that, so #include <condition_variable> is no longer needed. Separate opening braces of function bodies onto next line. Change-Id: I08f721c4d52756932bb9409e34e51dcbb3eda104 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QTest: remove unneeded cast in toPrettyUnicode()Marc Mutz2021-07-071-2/+2
| | | | | | | | char16_t, as returned from QStringView::utf16(), is guaranteed to be unsigned, so there's no need to reinterpret_cast to ushort. Change-Id: I7432dd26b4814c61fe70cc33ed307097ef46ce4e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QTest: there's no toString(QImage)Marc Mutz2021-07-071-1/+1
| | | | | | | | | | | ... so don't try to call it. The call resolves to a fall-back implementation of toString() that just returns nullptr, so we might as well pass nullptr directly, like three lines above, and not confuse readers of the code. Change-Id: I85d196aae7a0317050cfe16b206252df3fdffa2d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>