diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2021-11-17 15:15:41 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-11-22 09:05:24 +0100 |
| commit | e9eb79425535740cd28c6890f40e96aed6968e5c (patch) | |
| tree | 68dffb17c0429253c30fca59354cfc518cf533da /tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp | |
| parent | a8cf502882f95e652bd0a2daa50a2f276bd97cb8 (diff) | |
Improve tst_qmlcachegen::versionChecksForAheadOfTimeUnits()
Output the messages generated by the qt.qml.diskcache logging category
while loading the original unit. This might tell us why the test
occasionally fails.
Also, make sure to clean up in case of a failure so that we don't cause
further tests to fail.
Task-number: QTBUG-98404
Change-Id: I7a6da4288721164c71bbd62d1bad0909efb35fc2
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp index f5d784140d..0ae3195234 100644 --- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp +++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp @@ -401,21 +401,33 @@ void tst_qmlcachegen::versionChecksForAheadOfTimeUnits() Q_ASSERT(!temporaryModifiedCachedUnit); QQmlMetaType::CachedUnitLookupError error = QQmlMetaType::CachedUnitLookupError::NoError; + QLoggingCategory::setFilterRules("qt.qml.diskcache.debug=true"); const QQmlPrivate::CachedQmlUnit *originalUnit = QQmlMetaType::findCachedCompilationUnit( QUrl("qrc:/data/versionchecks.qml"), &error); + QLoggingCategory::setFilterRules(QString()); QVERIFY2(originalUnit, versionCheckErrorString(error)); QV4::CompiledData::Unit *tweakedUnit = (QV4::CompiledData::Unit *)malloc(originalUnit->qmlData->unitSize); memcpy(reinterpret_cast<void *>(tweakedUnit), reinterpret_cast<const void *>(originalUnit->qmlData), originalUnit->qmlData->unitSize); tweakedUnit->version = QV4_DATA_STRUCTURE_VERSION - 1; - temporaryModifiedCachedUnit = new QQmlPrivate::CachedQmlUnit{tweakedUnit, nullptr, nullptr}; - auto testHandler = [](const QUrl &url) -> const QQmlPrivate::CachedQmlUnit * { + const auto testHandler = [](const QUrl &url) -> const QQmlPrivate::CachedQmlUnit * { if (url == QUrl("qrc:/data/versionchecks.qml")) return temporaryModifiedCachedUnit; return nullptr; }; + + const auto dropModifiedUnit = qScopeGuard([&testHandler]() { + Q_ASSERT(temporaryModifiedCachedUnit); + free(const_cast<QV4::CompiledData::Unit *>(temporaryModifiedCachedUnit->qmlData)); + delete temporaryModifiedCachedUnit; + temporaryModifiedCachedUnit = nullptr; + + QQmlMetaType::removeCachedUnitLookupFunction(testHandler); + }); + + temporaryModifiedCachedUnit = new QQmlPrivate::CachedQmlUnit{tweakedUnit, nullptr, nullptr}; QQmlMetaType::prependCachedUnitLookupFunction(testHandler); { @@ -429,13 +441,6 @@ void tst_qmlcachegen::versionChecksForAheadOfTimeUnits() CleanlyLoadingComponent component(&engine, QUrl("qrc:/data/versionchecks.qml")); QCOMPARE(component.status(), QQmlComponent::Ready); } - - Q_ASSERT(temporaryModifiedCachedUnit); - free(const_cast<QV4::CompiledData::Unit *>(temporaryModifiedCachedUnit->qmlData)); - delete temporaryModifiedCachedUnit; - temporaryModifiedCachedUnit = nullptr; - - QQmlMetaType::removeCachedUnitLookupFunction(testHandler); } void tst_qmlcachegen::retainedResources() |
