diff options
Diffstat (limited to 'tests/auto/testlib')
23 files changed, 502 insertions, 96 deletions
diff --git a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp index ac7336e8e3..8b0319679f 100644 --- a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp +++ b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp @@ -79,15 +79,15 @@ void tst_QSignalSpy::spyWithoutArgs() QtTestObject obj; QSignalSpy spy(&obj, SIGNAL(sig0())); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); emit obj.sig0(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); emit obj.sig0(); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QList<QVariant> args = spy.takeFirst(); - QCOMPARE(args.count(), 0); + QCOMPARE(args.size(), 0); } void tst_QSignalSpy::spyWithBasicArgs() @@ -96,10 +96,10 @@ void tst_QSignalSpy::spyWithBasicArgs() QSignalSpy spy(&obj, SIGNAL(sig1(int,int))); emit obj.sig1(1, 2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QList<QVariant> args = spy.takeFirst(); - QCOMPARE(args.count(), 2); + QCOMPARE(args.size(), 2); QCOMPARE(args.at(0).toInt(), 1); QCOMPARE(args.at(1).toInt(), 2); @@ -107,7 +107,7 @@ void tst_QSignalSpy::spyWithBasicArgs() emit obj.sigLong(1l, 2l); args = spyl.takeFirst(); - QCOMPARE(args.count(), 2); + QCOMPARE(args.size(), 2); QCOMPARE(qvariant_cast<long>(args.at(0)), 1l); QCOMPARE(qvariant_cast<long>(args.at(1)), 2l); } @@ -124,10 +124,10 @@ void tst_QSignalSpy::spyWithPointers() int i2 = 2; emit obj.sig2(&i1, &i2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QList<QVariant> args = spy.takeFirst(); - QCOMPARE(args.count(), 2); + QCOMPARE(args.size(), 2); QCOMPARE(*static_cast<int * const *>(args.at(0).constData()), &i1); QCOMPARE(*static_cast<int * const *>(args.at(1).constData()), &i2); } @@ -155,15 +155,15 @@ void tst_QSignalSpy::spyWithBasicQtClasses() QSignalSpy spy(&obj, SIGNAL(sig(QString))); emit obj.sig(QString("bubu")); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).count(), 1); + QCOMPARE(spy.size(), 1); + QCOMPARE(spy.at(0).size(), 1); QCOMPARE(spy.at(0).at(0).toString(), QString("bubu")); QSignalSpy spy2(&obj, SIGNAL(sig5(QVariant))); QVariant val(45); emit obj.sig5(val); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy2.at(0).count(), 1); + QCOMPARE(spy2.size(), 1); + QCOMPARE(spy2.at(0).size(), 1); QCOMPARE(spy2.at(0).at(0), val); QCOMPARE(qvariant_cast<QVariant>(spy2.at(0).at(0)), val); } @@ -176,8 +176,8 @@ void tst_QSignalSpy::spyWithQtClasses() QSignalSpy spy(&obj, SIGNAL(sig2(QDateTime))); QDateTime dt = QDateTime::currentDateTime(); emit obj.sig2(dt); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).count(), 1); + QCOMPARE(spy.size(), 1); + QCOMPARE(spy.at(0).size(), 1); QCOMPARE(spy.at(0).at(0).typeName(), "QDateTime"); QCOMPARE(*static_cast<const QDateTime *>(spy.at(0).at(0).constData()), dt); QCOMPARE(spy.at(0).at(0).toDateTime(), dt); @@ -248,7 +248,7 @@ void tst_QSignalSpy::wait_signalEmittedTooLate() QTimer::singleShot(500, this, SIGNAL(sigFoo())); QSignalSpy spy(this, SIGNAL(sigFoo())); QVERIFY(!spy.wait(200)); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE(spy.size(), 1); } void tst_QSignalSpy::wait_signalEmittedMultipleTimes() @@ -257,13 +257,13 @@ void tst_QSignalSpy::wait_signalEmittedMultipleTimes() QTimer::singleShot(800, this, SIGNAL(sigFoo())); QSignalSpy spy(this, SIGNAL(sigFoo())); QVERIFY(spy.wait()); - QCOMPARE(spy.count(), 1); // we don't wait for the second signal... + QCOMPARE(spy.size(), 1); // we don't wait for the second signal... QVERIFY(spy.wait()); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QVERIFY(!spy.wait(1)); QTimer::singleShot(10, this, SIGNAL(sigFoo())); QVERIFY(spy.wait()); - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.size(), 3); } void tst_QSignalSpy::spyFunctionPointerWithoutArgs() @@ -271,15 +271,15 @@ void tst_QSignalSpy::spyFunctionPointerWithoutArgs() QtTestObject obj; QSignalSpy spy(&obj, &QtTestObject::sig0); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); emit obj.sig0(); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); emit obj.sig0(); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QList<QVariant> args = spy.takeFirst(); - QCOMPARE(args.count(), 0); + QCOMPARE(args.size(), 0); } void tst_QSignalSpy::spyFunctionPointerWithBasicArgs() @@ -288,10 +288,10 @@ void tst_QSignalSpy::spyFunctionPointerWithBasicArgs() QSignalSpy spy(&obj, &QtTestObject::sig1); emit obj.sig1(1, 2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QList<QVariant> args = spy.takeFirst(); - QCOMPARE(args.count(), 2); + QCOMPARE(args.size(), 2); QCOMPARE(args.at(0).toInt(), 1); QCOMPARE(args.at(1).toInt(), 2); @@ -299,7 +299,7 @@ void tst_QSignalSpy::spyFunctionPointerWithBasicArgs() emit obj.sigLong(1l, 2l); args = spyl.takeFirst(); - QCOMPARE(args.count(), 2); + QCOMPARE(args.size(), 2); QCOMPARE(qvariant_cast<long>(args.at(0)), 1l); QCOMPARE(qvariant_cast<long>(args.at(1)), 2l); } @@ -316,10 +316,10 @@ void tst_QSignalSpy::spyFunctionPointerWithPointers() int i2 = 2; emit obj.sig2(&i1, &i2); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); QList<QVariant> args = spy.takeFirst(); - QCOMPARE(args.count(), 2); + QCOMPARE(args.size(), 2); QCOMPARE(*static_cast<int * const *>(args.at(0).constData()), &i1); QCOMPARE(*static_cast<int * const *>(args.at(1).constData()), &i2); } @@ -330,15 +330,15 @@ void tst_QSignalSpy::spyFunctionPointerWithBasicQtClasses() QSignalSpy spy(&obj, &QtTestObject2::sig); emit obj.sig(QString("bubu")); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).count(), 1); + QCOMPARE(spy.size(), 1); + QCOMPARE(spy.at(0).size(), 1); QCOMPARE(spy.at(0).at(0).toString(), QString("bubu")); QSignalSpy spy2(&obj, &QtTestObject2::sig5); QVariant val(45); emit obj.sig5(val); - QCOMPARE(spy2.count(), 1); - QCOMPARE(spy2.at(0).count(), 1); + QCOMPARE(spy2.size(), 1); + QCOMPARE(spy2.at(0).size(), 1); QCOMPARE(spy2.at(0).at(0), val); QCOMPARE(qvariant_cast<QVariant>(spy2.at(0).at(0)), val); } @@ -350,8 +350,8 @@ void tst_QSignalSpy::spyFunctionPointerWithQtClasses() QSignalSpy spy(&obj, &QtTestObject2::sig2); QDateTime dt = QDateTime::currentDateTime(); emit obj.sig2(dt); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).count(), 1); + QCOMPARE(spy.size(), 1); + QCOMPARE(spy.at(0).size(), 1); QCOMPARE(spy.at(0).at(0).typeName(), "QDateTime"); QCOMPARE(*static_cast<const QDateTime *>(spy.at(0).at(0).constData()), dt); QCOMPARE(spy.at(0).at(0).toDateTime(), dt); @@ -373,8 +373,8 @@ void tst_QSignalSpy::spyFunctionPointerWithCustomClass() { QSignalSpy spy(&obj, &QtTestObject2::sig6); emit obj.sig6({}); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.at(0).count(), 1); + QCOMPARE(spy.size(), 1); + QCOMPARE(spy.at(0).size(), 1); QCOMPARE(spy.at(0).at(0).typeName(), "CustomType"); } @@ -420,7 +420,7 @@ void tst_QSignalSpy::waitFunctionPointer_signalEmittedTooLate() QSignalSpy spy(this, &tst_QSignalSpy::sigFoo); QVERIFY(!spy.wait(200)); QTest::qWait(400); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_QSignalSpy::waitFunctionPointer_signalEmittedMultipleTimes() @@ -429,13 +429,13 @@ void tst_QSignalSpy::waitFunctionPointer_signalEmittedMultipleTimes() QTimer::singleShot(800, this, SIGNAL(sigFoo())); QSignalSpy spy(this, &tst_QSignalSpy::sigFoo); QVERIFY(spy.wait()); - QCOMPARE(spy.count(), 1); // we don't wait for the second signal... + QCOMPARE(spy.size(), 1); // we don't wait for the second signal... QVERIFY(spy.wait()); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); QVERIFY(!spy.wait(1)); QTimer::singleShot(10, this, SIGNAL(sigFoo())); QVERIFY(spy.wait()); - QCOMPARE(spy.count(), 3); + QCOMPARE(spy.size(), 3); } void tst_QSignalSpy::spyOnMetaMethod() @@ -454,7 +454,7 @@ void tst_QSignalSpy::spyOnMetaMethod() QVERIFY(spy.isValid()); obj.setObjectName("A new object name"); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } Q_DECLARE_METATYPE(QMetaMethod); diff --git a/tests/auto/testlib/selftests/CMakeLists.txt b/tests/auto/testlib/selftests/CMakeLists.txt index ceea1226f8..c3f428d110 100644 --- a/tests/auto/testlib/selftests/CMakeLists.txt +++ b/tests/auto/testlib/selftests/CMakeLists.txt @@ -56,6 +56,7 @@ set(subprograms deleteLater deleteLater_noApp differentexec + eventloop exceptionthrow expectfail extendedcompare diff --git a/tests/auto/testlib/selftests/badxml/tst_badxml.cpp b/tests/auto/testlib/selftests/badxml/tst_badxml.cpp index cb69905c34..ec54f786d9 100644 --- a/tests/auto/testlib/selftests/badxml/tst_badxml.cpp +++ b/tests/auto/testlib/selftests/badxml/tst_badxml.cpp @@ -180,16 +180,16 @@ int main(int argc, char** argv) if (badstring == -1) { tst_BadXml test; - return QTest::qExec(&test, args.count(), const_cast<char**>(args.data())); + return QTest::qExec(&test, args.size(), const_cast<char**>(args.data())); } QList<QByteArray> badstrings = tst_BadXml::badStrings(); - if (badstring >= badstrings.count()) + if (badstring >= badstrings.size()) qFatal("`-badstring %d' is out of range", badstring); tst_BadXmlSub test; test.className = badstrings[badstring].constData(); - return QTest::qExec(&test, args.count(), const_cast<char**>(args.data())); + return QTest::qExec(&test, args.size(), const_cast<char**>(args.data())); } #include "tst_badxml.moc" diff --git a/tests/auto/testlib/selftests/catch_p_p.h b/tests/auto/testlib/selftests/catch_p_p.h index 9034ac2204..f22183557d 100644 --- a/tests/auto/testlib/selftests/catch_p_p.h +++ b/tests/auto/testlib/selftests/catch_p_p.h @@ -1,6 +1,6 @@ /* - * Catch v2.13.9 - * Generated: 2022-04-12 22:37:23.260201 + * Catch v2.13.10 + * Generated: 2022-10-16 11:01:23.452308 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2022 Two Blue Cubes Ltd. All rights reserved. @@ -15,7 +15,7 @@ #define CATCH_VERSION_MAJOR 2 #define CATCH_VERSION_MINOR 13 -#define CATCH_VERSION_PATCH 9 +#define CATCH_VERSION_PATCH 10 #ifdef __clang__ # pragma clang system_header @@ -7395,8 +7395,6 @@ namespace Catch { template <typename T, bool Destruct> struct ObjectStorage { - using TStorage = typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type; - ObjectStorage() : data() {} ObjectStorage(const ObjectStorage& other) @@ -7439,7 +7437,7 @@ namespace Catch { return *static_cast<T*>(static_cast<void*>(&data)); } - TStorage data; + struct { alignas(T) unsigned char data[sizeof(T)]; } data; }; } @@ -7949,7 +7947,7 @@ namespace Catch { #if defined(__i386__) || defined(__x86_64__) #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */ #elif defined(__aarch64__) - #define CATCH_TRAP() __asm__(".inst 0xd4200000") + #define CATCH_TRAP() __asm__(".inst 0xd43e0000") #endif #elif defined(CATCH_PLATFORM_IPHONE) @@ -13560,7 +13558,7 @@ namespace Catch { // Handle list request if( Option<std::size_t> listed = list( m_config ) ) - return static_cast<int>( *listed ); + return (std::min) (MaxExitCode, static_cast<int>(*listed)); TestGroup tests { m_config }; auto const totals = tests.execute(); @@ -15393,7 +15391,7 @@ namespace Catch { } Version const& libraryVersion() { - static Version version( 2, 13, 9, "", 0 ); + static Version version( 2, 13, 10, "", 0 ); return version; } @@ -17528,12 +17526,20 @@ namespace Catch { #ifndef __OBJC__ +#ifndef CATCH_INTERNAL_CDECL +#ifdef _MSC_VER +#define CATCH_INTERNAL_CDECL __cdecl +#else +#define CATCH_INTERNAL_CDECL +#endif +#endif + #if defined(CATCH_CONFIG_WCHAR) && defined(CATCH_PLATFORM_WINDOWS) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN) // Standard C/C++ Win32 Unicode wmain entry point -extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) { +extern "C" int CATCH_INTERNAL_CDECL wmain (int argc, wchar_t * argv[], wchar_t * []) { #else // Standard C/C++ main entry point -int main (int argc, char * argv[]) { +int CATCH_INTERNAL_CDECL main (int argc, char * argv[]) { #endif return Catch::Session().run( argc, argv ); diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp index 94c04157f2..072324880e 100644 --- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp +++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp @@ -1,9 +1,9 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -#include <QtCore/QCoreApplication> #include <QTest> +#include <QtCore/QCoreApplication> +#include <QtCore/QTimer> #ifdef QT_GUI_LIB #include <QtGui/QColor> #include <QtGui/QImage> @@ -139,6 +139,7 @@ private slots: void compareQVector3D(); void compareQVector4D(); #endif + void tryCompare(); void verify(); void verify2(); void tryVerify(); @@ -649,16 +650,88 @@ void tst_Cmptest::verify2() QVERIFY2(opaqueFunc() < 2, QByteArray::number(opaqueFunc()).constData()); } +class DeferredFlag : public QObject // Can't be const. +{ + Q_OBJECT + bool m_flag; +public: + // A boolean that either starts out true or decays to true after 50 ms. + // However, that decay will only happen when the event loop is run. + explicit DeferredFlag(bool initial = false) : m_flag(initial) + { + if (!initial) + QTimer::singleShot(50, this, &DeferredFlag::onTimeOut); + } + explicit operator bool() const { return m_flag; } + bool operator!() const { return !m_flag; } + friend bool operator==(const DeferredFlag &a, const DeferredFlag &b) + { + return bool(a) == bool(b); + } +public slots: + void onTimeOut() { m_flag = true; } +}; + +char *toString(const DeferredFlag &val) +{ + return qstrdup(bool(val) ? "DeferredFlag(true)" : "DeferredFlag(false)"); +} + +void tst_Cmptest::tryCompare() +{ + /* Note that expected values given as DeferredFlag() shall be re-evaluated + each time the comparison is checked, hence supply a fresh false instance, + that'll be discarded before it has a chance to decay, hence only compare + equal to a false instance. Do not replace them with a local variable + initialized to false, as it would (of course) decay. + */ + DeferredFlag trueAlready(true); + { + DeferredFlag c; + // QTRY should check before looping, so be equal to the fresh false immediately. + QTRY_COMPARE(c, DeferredFlag()); + // Given time, it'll end up equal to a true one. + QTRY_COMPARE(c, trueAlready); + } + { + DeferredFlag c; + QTRY_COMPARE_WITH_TIMEOUT(c, DeferredFlag(), 300); + QVERIFY(!c); // Instantly equal, so succeeded without delay. + QTRY_COMPARE_WITH_TIMEOUT(c, trueAlready, 200); + qInfo("Should now time out and fail"); + QTRY_COMPARE_WITH_TIMEOUT(c, DeferredFlag(), 200); + } +} + void tst_Cmptest::tryVerify() { - QTRY_VERIFY(opaqueFunc() > 2); - QTRY_VERIFY_WITH_TIMEOUT(opaqueFunc() < 2, 1); + { + DeferredFlag c; + QTRY_VERIFY(!c); + QTRY_VERIFY(c); + } + { + DeferredFlag c; + QTRY_VERIFY_WITH_TIMEOUT(!c, 300); + QTRY_VERIFY_WITH_TIMEOUT(c, 200); + qInfo("Should now time out and fail"); + QTRY_VERIFY_WITH_TIMEOUT(!c, 200); + } } void tst_Cmptest::tryVerify2() { - QTRY_VERIFY2(opaqueFunc() > 2, QByteArray::number(opaqueFunc()).constData()); - QTRY_VERIFY2_WITH_TIMEOUT(opaqueFunc() < 2, QByteArray::number(opaqueFunc()).constData(), 1); + { + DeferredFlag c; + QTRY_VERIFY2(!c, "Failed to check before looping"); + QTRY_VERIFY2(c, "Failed to trigger single-shot"); + } + { + DeferredFlag c; + QTRY_VERIFY2_WITH_TIMEOUT(!c, "Failed to check before looping", 300); + QTRY_VERIFY2_WITH_TIMEOUT(c, "Failed to trigger single-shot", 200); + QTRY_VERIFY2_WITH_TIMEOUT(!c, "Should time out and fail", 200); + } } void tst_Cmptest::verifyExplicitOperatorBool() diff --git a/tests/auto/testlib/selftests/crashes/tst_crashes.cpp b/tests/auto/testlib/selftests/crashes/tst_crashes.cpp index abac42c723..38ed27d331 100644 --- a/tests/auto/testlib/selftests/crashes/tst_crashes.cpp +++ b/tests/auto/testlib/selftests/crashes/tst_crashes.cpp @@ -7,6 +7,8 @@ #ifdef Q_OS_WIN #include <qt_windows.h> +#else +#include <sys/resource.h> #endif class tst_Crashes: public QObject @@ -22,6 +24,12 @@ void tst_Crashes::crash() #if defined(Q_OS_WIN) //we avoid the error dialogbox to appear on windows SetErrorMode( SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); +#elif defined(RLIMIT_CORE) + // Unix: set our core dump limit to zero to request no dialogs. + if (struct rlimit rlim; getrlimit(RLIMIT_CORE, &rlim) == 0) { + rlim.rlim_cur = 0; + setrlimit(RLIMIT_CORE, &rlim); + } #endif /* We deliberately dereference an invalid but non-zero address; diff --git a/tests/auto/testlib/selftests/eventloop/CMakeLists.txt b/tests/auto/testlib/selftests/eventloop/CMakeLists.txt new file mode 100644 index 0000000000..f1fa9a788c --- /dev/null +++ b/tests/auto/testlib/selftests/eventloop/CMakeLists.txt @@ -0,0 +1,16 @@ +##################################################################### +## eventloop Binary: +##################################################################### + +qt_internal_add_executable(eventloop + NO_INSTALL + OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + SOURCES + tst_eventloop.cpp + PUBLIC_LIBRARIES + Qt::Test +) + +## Scopes: +##################################################################### +qt_internal_apply_testlib_coverage_options(eventloop) diff --git a/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp b/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp new file mode 100644 index 0000000000..202a8b77f1 --- /dev/null +++ b/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp @@ -0,0 +1,104 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#include <QTest> +#include <QTestEventLoop> +#include <QtCore/QTimer> + +// Tests for QTestEventLoop (and some QTRY_* details) +class tst_EventLoop: public QObject +{ +Q_OBJECT + + bool m_inTestFunction = false; +private slots: + void cleanup(); + void fail(); + void skip(); + void pass(); +}; + +class DeferredFlag : public QObject // Can't be const. +{ + Q_OBJECT + bool m_flag; +public: + // A boolean that either starts out true or decays to true after 50 ms. + // However, that decay will only happen when the event loop is run. + explicit DeferredFlag(bool initial = false) : m_flag(initial) + { + if (!initial) + QTimer::singleShot(50, this, &DeferredFlag::onTimeOut); + } + explicit operator bool() const { return m_flag; } + bool operator!() const { return !m_flag; } + friend bool operator==(const DeferredFlag &a, const DeferredFlag &b) + { + return bool(a) == bool(b); + } +public slots: + void onTimeOut() { m_flag = true; } +}; + +char *toString(const DeferredFlag &val) +{ + return qstrdup(bool(val) ? "DeferredFlag(true)" : "DeferredFlag(false)"); +} + +void tst_EventLoop::cleanup() +{ + // QTBUG-104441: looping didn't happen in cleanup() if test failed or skipped. + { + DeferredFlag flag; + auto &loop = QTestEventLoop::instance(); + loop.enterLoopMSecs(100); + QVERIFY2(loop.timeout(), "QTestEventLoop exited prematurely in cleanup()"); + QVERIFY(flag); + } + { + DeferredFlag flag; + QTRY_VERIFY2(flag, "QTRY_* loop exited prematurely in cleanup()"); + } + + m_inTestFunction = false; +} + +void tst_EventLoop::fail() +{ + QVERIFY2(!std::exchange(m_inTestFunction, true), "Earlier test failed to clean up"); + QFAIL("Failing test should still clean up"); +} + +void tst_EventLoop::skip() +{ + QVERIFY2(!std::exchange(m_inTestFunction, true), "Earlier test failed to clean up"); + QSKIP("Skipping test should still clean up"); +} + +void tst_EventLoop::pass() +{ + QVERIFY2(!std::exchange(m_inTestFunction, true), "Earlier test failed to clean up"); + { + DeferredFlag flag; + auto &loop = QTestEventLoop::instance(); + loop.enterLoopMSecs(100); + QVERIFY(loop.timeout()); + QVERIFY(flag); + } + { + DeferredFlag flag; + QTRY_VERIFY(flag); + } + DeferredFlag flag; + QTestEventLoop loop(this); + QVERIFY(!flag); + loop.enterLoopMSecs(1); + QVERIFY(loop.timeout()); + QVERIFY(!flag); + loop.enterLoopMSecs(100); + QVERIFY(loop.timeout()); + QVERIFY(flag); +} + +QTEST_MAIN(tst_EventLoop) +#include "tst_eventloop.moc" diff --git a/tests/auto/testlib/selftests/expected_cmptest.junitxml b/tests/auto/testlib/selftests/expected_cmptest.junitxml index f71b8f0a19..75ec61ba99 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.junitxml +++ b/tests/auto/testlib/selftests/expected_cmptest.junitxml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<testsuite name="tst_Cmptest" timestamp="@TEST_START_TIME@" hostname="@HOSTNAME@" tests="69" failures="48" errors="0" skipped="0" time="@TEST_DURATION@"> +<testsuite name="tst_Cmptest" timestamp="@TEST_START_TIME@" hostname="@HOSTNAME@" tests="70" failures="49" errors="0" skipped="0" time="@TEST_DURATION@"> <properties> <property name="QTestVersion" value="@INSERT_QT_VERSION_HERE@"/> <property name="QtVersion" value="@INSERT_QT_VERSION_HERE@"/> @@ -282,6 +282,15 @@ Expected (v4b): QVector4D(1, 3, 3, 4)]]> </failure> </testcase> + <testcase name="tryCompare" classname="tst_Cmptest" time="@TEST_DURATION@"> + <failure type="fail" message="Compared values are not the same"> + <![CDATA[ Actual (c) : DeferredFlag(true) + Expected (DeferredFlag()): DeferredFlag(false)]]> + </failure> + <system-out> + <![CDATA[Should now time out and fail]]> + </system-out> + </testcase> <testcase name="verify" classname="tst_Cmptest" time="@TEST_DURATION@"> <failure type="fail" message="'opaqueFunc() < 2' returned FALSE. ()"/> </testcase> @@ -289,10 +298,13 @@ <failure type="fail" message="'opaqueFunc() < 2' returned FALSE. (42)"/> </testcase> <testcase name="tryVerify" classname="tst_Cmptest" time="@TEST_DURATION@"> - <failure type="fail" message="'opaqueFunc() < 2' returned FALSE. ()"/> + <failure type="fail" message="'!c' returned FALSE. ()"/> + <system-out> + <![CDATA[Should now time out and fail]]> + </system-out> </testcase> <testcase name="tryVerify2" classname="tst_Cmptest" time="@TEST_DURATION@"> - <failure type="fail" message="'opaqueFunc() < 2' returned FALSE. (42)"/> + <failure type="fail" message="'!c' returned FALSE. (Should time out and fail)"/> </testcase> <testcase name="verifyExplicitOperatorBool" classname="tst_Cmptest" time="@TEST_DURATION@"/> <testcase name="cleanupTestCase" classname="tst_Cmptest" time="@TEST_DURATION@"/> diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml index 3cb492361b..351fad849c 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.lightxml +++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml @@ -377,6 +377,17 @@ </Incident> <Duration msecs="0"/> </TestFunction> + <TestFunction name="tryCompare"> + <Message type="qinfo" file="" line="0"> + <Description><![CDATA[Should now time out and fail]]></Description> + </Message> + <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0"> + <Description><![CDATA[Compared values are not the same + Actual (c) : DeferredFlag(true) + Expected (DeferredFlag()): DeferredFlag(false)]]></Description> + </Incident> + <Duration msecs="0"/> + </TestFunction> <TestFunction name="verify"> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0"> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> @@ -390,14 +401,17 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="tryVerify"> + <Message type="qinfo" file="" line="0"> + <Description><![CDATA[Should now time out and fail]]></Description> + </Message> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0"> - <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> + <Description><![CDATA['!c' returned FALSE. ()]]></Description> </Incident> <Duration msecs="0"/> </TestFunction> <TestFunction name="tryVerify2"> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0"> - <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description> + <Description><![CDATA['!c' returned FALSE. (Should time out and fail)]]></Description> </Incident> <Duration msecs="0"/> </TestFunction> diff --git a/tests/auto/testlib/selftests/expected_cmptest.tap b/tests/auto/testlib/selftests/expected_cmptest.tap index da7f21ab70..19c90bcb93 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.tap +++ b/tests/auto/testlib/selftests/expected_cmptest.tap @@ -516,7 +516,23 @@ not ok 63 - compareQVector4D() file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp line: 0 ... -not ok 64 - verify() +not ok 64 - tryCompare() + --- + type: QCOMPARE + message: Compared values are not the same + wanted: DeferredFlag(false) (DeferredFlag()) + found: DeferredFlag(true) (c) + expected: DeferredFlag(false) (DeferredFlag()) + actual: DeferredFlag(true) (c) + at: tst_Cmptest::tryCompare() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:0) + file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp + line: 0 + extensions: + messages: + - severity: info + message: Should now time out and fail + ... +not ok 65 - verify() --- type: QVERIFY message: Verification failed @@ -528,7 +544,7 @@ not ok 64 - verify() file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp line: 0 ... -not ok 65 - verify2() +not ok 66 - verify2() --- type: QVERIFY message: 42 @@ -540,33 +556,37 @@ not ok 65 - verify2() file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp line: 0 ... -not ok 66 - tryVerify() +not ok 67 - tryVerify() --- type: QVERIFY message: Verification failed - wanted: true (opaqueFunc() < 2) - found: false (opaqueFunc() < 2) - expected: true (opaqueFunc() < 2) - actual: false (opaqueFunc() < 2) + wanted: true (!c) + found: false (!c) + expected: true (!c) + actual: false (!c) at: tst_Cmptest::tryVerify() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:0) file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp line: 0 + extensions: + messages: + - severity: info + message: Should now time out and fail ... -not ok 67 - tryVerify2() +not ok 68 - tryVerify2() --- type: QVERIFY - message: 42 - wanted: true (opaqueFunc() < 2) - found: false (opaqueFunc() < 2) - expected: true (opaqueFunc() < 2) - actual: false (opaqueFunc() < 2) + message: Should time out and fail + wanted: true (!c) + found: false (!c) + expected: true (!c) + actual: false (!c) at: tst_Cmptest::tryVerify2() (qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp:0) file: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp line: 0 ... -ok 68 - verifyExplicitOperatorBool() -ok 69 - cleanupTestCase() -1..69 -# tests 69 +ok 69 - verifyExplicitOperatorBool() +ok 70 - cleanupTestCase() +1..70 +# tests 70 # pass 21 -# fail 48 +# fail 49 diff --git a/tests/auto/testlib/selftests/expected_cmptest.teamcity b/tests/auto/testlib/selftests/expected_cmptest.teamcity index 83e007413e..5f1e8374b9 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.teamcity +++ b/tests/auto/testlib/selftests/expected_cmptest.teamcity @@ -169,6 +169,10 @@ ##teamcity[testStarted name='compareQVector4D()' flowId='tst_Cmptest'] ##teamcity[testFailed name='compareQVector4D()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='Compared values are not the same|n Actual (v4a): QVector4D(1, 2, 3, 4)|n Expected (v4b): QVector4D(1, 3, 3, 4)' flowId='tst_Cmptest'] ##teamcity[testFinished name='compareQVector4D()' flowId='tst_Cmptest'] +##teamcity[testStarted name='tryCompare()' flowId='tst_Cmptest'] +##teamcity[testFailed name='tryCompare()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='Compared values are not the same|n Actual (c) : DeferredFlag(true)|n Expected (DeferredFlag()): DeferredFlag(false)' flowId='tst_Cmptest'] +##teamcity[testStdOut name='tryCompare()' out='QINFO: Should now time out and fail' flowId='tst_Cmptest'] +##teamcity[testFinished name='tryCompare()' flowId='tst_Cmptest'] ##teamcity[testStarted name='verify()' flowId='tst_Cmptest'] ##teamcity[testFailed name='verify()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='|'opaqueFunc() < 2|' returned FALSE. ()' flowId='tst_Cmptest'] ##teamcity[testFinished name='verify()' flowId='tst_Cmptest'] @@ -176,10 +180,11 @@ ##teamcity[testFailed name='verify2()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='|'opaqueFunc() < 2|' returned FALSE. (42)' flowId='tst_Cmptest'] ##teamcity[testFinished name='verify2()' flowId='tst_Cmptest'] ##teamcity[testStarted name='tryVerify()' flowId='tst_Cmptest'] -##teamcity[testFailed name='tryVerify()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='|'opaqueFunc() < 2|' returned FALSE. ()' flowId='tst_Cmptest'] +##teamcity[testFailed name='tryVerify()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='|'!c|' returned FALSE. ()' flowId='tst_Cmptest'] +##teamcity[testStdOut name='tryVerify()' out='QINFO: Should now time out and fail' flowId='tst_Cmptest'] ##teamcity[testFinished name='tryVerify()' flowId='tst_Cmptest'] ##teamcity[testStarted name='tryVerify2()' flowId='tst_Cmptest'] -##teamcity[testFailed name='tryVerify2()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='|'opaqueFunc() < 2|' returned FALSE. (42)' flowId='tst_Cmptest'] +##teamcity[testFailed name='tryVerify2()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)|]' details='|'!c|' returned FALSE. (Should time out and fail)' flowId='tst_Cmptest'] ##teamcity[testFinished name='tryVerify2()' flowId='tst_Cmptest'] ##teamcity[testStarted name='verifyExplicitOperatorBool()' flowId='tst_Cmptest'] ##teamcity[testFinished name='verifyExplicitOperatorBool()' flowId='tst_Cmptest'] diff --git a/tests/auto/testlib/selftests/expected_cmptest.txt b/tests/auto/testlib/selftests/expected_cmptest.txt index 8547119988..f323729000 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.txt +++ b/tests/auto/testlib/selftests/expected_cmptest.txt @@ -191,15 +191,21 @@ FAIL! : tst_Cmptest::compareQVector4D() Compared values are not the same Actual (v4a): QVector4D(1, 2, 3, 4) Expected (v4b): QVector4D(1, 3, 3, 4) Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)] +QINFO : tst_Cmptest::tryCompare() Should now time out and fail +FAIL! : tst_Cmptest::tryCompare() Compared values are not the same + Actual (c) : DeferredFlag(true) + Expected (DeferredFlag()): DeferredFlag(false) + Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)] FAIL! : tst_Cmptest::verify() 'opaqueFunc() < 2' returned FALSE. () Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)] FAIL! : tst_Cmptest::verify2() 'opaqueFunc() < 2' returned FALSE. (42) Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)] -FAIL! : tst_Cmptest::tryVerify() 'opaqueFunc() < 2' returned FALSE. () +QINFO : tst_Cmptest::tryVerify() Should now time out and fail +FAIL! : tst_Cmptest::tryVerify() '!c' returned FALSE. () Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)] -FAIL! : tst_Cmptest::tryVerify2() 'opaqueFunc() < 2' returned FALSE. (42) +FAIL! : tst_Cmptest::tryVerify2() '!c' returned FALSE. (Should time out and fail) Loc: [qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(0)] PASS : tst_Cmptest::verifyExplicitOperatorBool() PASS : tst_Cmptest::cleanupTestCase() -Totals: 21 passed, 48 failed, 0 skipped, 0 blacklisted, 0ms +Totals: 21 passed, 49 failed, 0 skipped, 0 blacklisted, 0ms ********* Finished testing of tst_Cmptest ********* diff --git a/tests/auto/testlib/selftests/expected_cmptest.xml b/tests/auto/testlib/selftests/expected_cmptest.xml index f296a9e797..0bee84c786 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xml +++ b/tests/auto/testlib/selftests/expected_cmptest.xml @@ -379,6 +379,17 @@ </Incident> <Duration msecs="0"/> </TestFunction> + <TestFunction name="tryCompare"> + <Message type="qinfo" file="" line="0"> + <Description><![CDATA[Should now time out and fail]]></Description> + </Message> + <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0"> + <Description><![CDATA[Compared values are not the same + Actual (c) : DeferredFlag(true) + Expected (DeferredFlag()): DeferredFlag(false)]]></Description> + </Incident> + <Duration msecs="0"/> + </TestFunction> <TestFunction name="verify"> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0"> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> @@ -392,14 +403,17 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="tryVerify"> + <Message type="qinfo" file="" line="0"> + <Description><![CDATA[Should now time out and fail]]></Description> + </Message> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0"> - <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> + <Description><![CDATA['!c' returned FALSE. ()]]></Description> </Incident> <Duration msecs="0"/> </TestFunction> <TestFunction name="tryVerify2"> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp" line="0"> - <Description><![CDATA['opaqueFunc() < 2' returned FALSE. (42)]]></Description> + <Description><![CDATA['!c' returned FALSE. (Should time out and fail)]]></Description> </Incident> <Duration msecs="0"/> </TestFunction> diff --git a/tests/auto/testlib/selftests/expected_eventloop.junitxml b/tests/auto/testlib/selftests/expected_eventloop.junitxml new file mode 100644 index 0000000000..566bc1605e --- /dev/null +++ b/tests/auto/testlib/selftests/expected_eventloop.junitxml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<testsuite name="tst_EventLoop" timestamp="@TEST_START_TIME@" hostname="@HOSTNAME@" tests="5" failures="1" errors="0" skipped="1" time="@TEST_DURATION@"> + <properties> + <property name="QTestVersion" value="@INSERT_QT_VERSION_HERE@"/> + <property name="QtVersion" value="@INSERT_QT_VERSION_HERE@"/> + <property name="QtBuild" value=""/> + </properties> + <testcase name="initTestCase" classname="tst_EventLoop" time="@TEST_DURATION@"/> + <testcase name="fail" classname="tst_EventLoop" time="@TEST_DURATION@"> + <failure type="fail" message="Failing test should still clean up"/> + </testcase> + <testcase name="skip" classname="tst_EventLoop" time="@TEST_DURATION@"> + <skipped message="Skipping test should still clean up"/> + </testcase> + <testcase name="pass" classname="tst_EventLoop" time="@TEST_DURATION@"/> + <testcase name="cleanupTestCase" classname="tst_EventLoop" time="@TEST_DURATION@"/> +</testsuite> diff --git a/tests/auto/testlib/selftests/expected_eventloop.lightxml b/tests/auto/testlib/selftests/expected_eventloop.lightxml new file mode 100644 index 0000000000..40880fde01 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_eventloop.lightxml @@ -0,0 +1,30 @@ + <Environment> + <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> + <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> + </Environment> + <TestFunction name="initTestCase"> + <Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> + </TestFunction> + <TestFunction name="fail"> + <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp" line="0"> + <Description><![CDATA[Failing test should still clean up]]></Description> + </Incident> + <Duration msecs="0"/> + </TestFunction> + <TestFunction name="skip"> + <Incident type="skip" file="qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp" line="0"> + <Description><![CDATA[Skipping test should still clean up]]></Description> + </Incident> + <Duration msecs="0"/> + </TestFunction> + <TestFunction name="pass"> + <Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> + </TestFunction> + <TestFunction name="cleanupTestCase"> + <Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> + </TestFunction> + <Duration msecs="0"/> diff --git a/tests/auto/testlib/selftests/expected_eventloop.tap b/tests/auto/testlib/selftests/expected_eventloop.tap new file mode 100644 index 0000000000..496a6e636a --- /dev/null +++ b/tests/auto/testlib/selftests/expected_eventloop.tap @@ -0,0 +1,17 @@ +TAP version 13 +# tst_EventLoop +ok 1 - initTestCase() +not ok 2 - fail() + --- + # Failing test should still clean up + at: tst_EventLoop::fail() (qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp:0) + file: qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp + line: 0 + ... +ok 3 - skip() # SKIP Skipping test should still clean up +ok 4 - pass() +ok 5 - cleanupTestCase() +1..5 +# tests 5 +# pass 3 +# fail 1 diff --git a/tests/auto/testlib/selftests/expected_eventloop.teamcity b/tests/auto/testlib/selftests/expected_eventloop.teamcity new file mode 100644 index 0000000000..a293a20135 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_eventloop.teamcity @@ -0,0 +1,14 @@ +##teamcity[testSuiteStarted name='tst_EventLoop' flowId='tst_EventLoop'] +##teamcity[testStarted name='initTestCase()' flowId='tst_EventLoop'] +##teamcity[testFinished name='initTestCase()' flowId='tst_EventLoop'] +##teamcity[testStarted name='fail()' flowId='tst_EventLoop'] +##teamcity[testFailed name='fail()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp(0)|]' details='Failing test should still clean up' flowId='tst_EventLoop'] +##teamcity[testFinished name='fail()' flowId='tst_EventLoop'] +##teamcity[testStarted name='skip()' flowId='tst_EventLoop'] +##teamcity[testIgnored name='skip()' message='Skipping test should still clean up |[Loc: qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp(0)|]' flowId='tst_EventLoop'] +##teamcity[testFinished name='skip()' flowId='tst_EventLoop'] +##teamcity[testStarted name='pass()' flowId='tst_EventLoop'] +##teamcity[testFinished name='pass()' flowId='tst_EventLoop'] +##teamcity[testStarted name='cleanupTestCase()' flowId='tst_EventLoop'] +##teamcity[testFinished name='cleanupTestCase()' flowId='tst_EventLoop'] +##teamcity[testSuiteFinished name='tst_EventLoop' flowId='tst_EventLoop'] diff --git a/tests/auto/testlib/selftests/expected_eventloop.txt b/tests/auto/testlib/selftests/expected_eventloop.txt new file mode 100644 index 0000000000..548ef393f6 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_eventloop.txt @@ -0,0 +1,11 @@ +********* Start testing of tst_EventLoop ********* +Config: Using QtTest library +PASS : tst_EventLoop::initTestCase() +FAIL! : tst_EventLoop::fail() Failing test should still clean up + Loc: [qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp(0)] +SKIP : tst_EventLoop::skip() Skipping test should still clean up + Loc: [qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp(0)] +PASS : tst_EventLoop::pass() +PASS : tst_EventLoop::cleanupTestCase() +Totals: 3 passed, 1 failed, 1 skipped, 0 blacklisted, 0ms +********* Finished testing of tst_EventLoop ********* diff --git a/tests/auto/testlib/selftests/expected_eventloop.xml b/tests/auto/testlib/selftests/expected_eventloop.xml new file mode 100644 index 0000000000..f9d9475666 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_eventloop.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<TestCase name="tst_EventLoop"> + <Environment> + <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> + <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> + </Environment> + <TestFunction name="initTestCase"> + <Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> + </TestFunction> + <TestFunction name="fail"> + <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp" line="0"> + <Description><![CDATA[Failing test should still clean up]]></Description> + </Incident> + <Duration msecs="0"/> + </TestFunction> + <TestFunction name="skip"> + <Incident type="skip" file="qtbase/tests/auto/testlib/selftests/eventloop/tst_eventloop.cpp" line="0"> + <Description><![CDATA[Skipping test should still clean up]]></Description> + </Incident> + <Duration msecs="0"/> + </TestFunction> + <TestFunction name="pass"> + <Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> + </TestFunction> + <TestFunction name="cleanupTestCase"> + <Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> + </TestFunction> + <Duration msecs="0"/> +</TestCase> diff --git a/tests/auto/testlib/selftests/generate_expected_output.py b/tests/auto/testlib/selftests/generate_expected_output.py index 987a08b2c1..8f6134725b 100755 --- a/tests/auto/testlib/selftests/generate_expected_output.py +++ b/tests/auto/testlib/selftests/generate_expected_output.py @@ -31,8 +31,8 @@ TESTS = ['assert', 'badxml', 'benchlibcallgrind', 'benchlibcounting', 'benchlibeventcounter', 'benchliboptions', 'benchlibtickcounter', 'benchlibwalltime', 'blacklisted', 'cmptest', 'commandlinedata', 'counting', 'crashes', 'datatable', 'datetime', 'deleteLater', - 'deleteLater_noApp', 'differentexec', 'exceptionthrow', 'expectfail', - "extendedcompare", 'failcleanup', 'failcleanuptestcase', + 'deleteLater_noApp', 'differentexec', 'eventloop', 'exceptionthrow', + 'expectfail', "extendedcompare", 'failcleanup', 'failcleanuptestcase', 'faildatatype', 'failfetchtype', 'failinit', 'failinitdata', 'fetchbogus', 'findtestdata', 'float', 'globaldata', 'longstring', 'maxwarnings', 'mouse', 'multiexec', 'pairdiagnostics', 'pass', diff --git a/tests/auto/testlib/selftests/qt_attribution.json b/tests/auto/testlib/selftests/qt_attribution.json index 6c483749a1..3a126f59ed 100644 --- a/tests/auto/testlib/selftests/qt_attribution.json +++ b/tests/auto/testlib/selftests/qt_attribution.json @@ -8,7 +8,7 @@ "Description": "Catch2 is a multi-paradigm test framework for C++.", "Homepage": "https://github.com/catchorg/Catch2", - "Version": "2.13.8", + "Version": "2.13.10", "License": "Boost Software License 1.0", "LicenseId": "BSL-1.0", "LicenseFile": "CATCH_LICENSE.txt", diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index b70aec2c85..f6c97bc345 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -432,8 +432,8 @@ BenchmarkResult BenchmarkResult::parse(QString const& line, QString* error) // format: // "function","[globaltag:]tag","metric",value_per_iteration,total,iterations QStringList split = line.split(','); - if (split.count() != 6) { - if (error) *error = QString("Wrong number of columns (%1)").arg(split.count()); + if (split.size() != 6) { + if (error) *error = QString("Wrong number of columns (%1)").arg(split.size()); return out; } @@ -636,6 +636,11 @@ bool TestLogger::shouldIgnoreTest(const QString &test) const return true; #endif + if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")) { + qDebug() << "TestLogger::shouldIgnoreTest() ignore" << test << "on wayland/xwayland!"; + return true; + } + // These tests are affected by timing and whether the CPU tick counter // is monotonically increasing. They won't work on some machines so // leave them off by default. Feel free to enable them for your own |