diff options
Diffstat (limited to 'tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp')
-rw-r--r-- | tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp | 71 |
1 files changed, 62 insertions, 9 deletions
diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp index 5c84c46bf8..a2639bc532 100644 --- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp +++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp @@ -114,6 +114,10 @@ public: static bool generateCache(const QString &qmlFileName, QByteArray *capturedStderr = nullptr) { +#if defined(QTEST_CROSS_COMPILED) + QTest::qFail("You cannot call qmlcachegen on the target.", __FILE__, __LINE__); + return false; +#endif QProcess proc; if (capturedStderr == nullptr) proc.setProcessChannelMode(QProcess::ForwardedChannels); @@ -152,6 +156,10 @@ void tst_qmlcachegen::initTestCase() void tst_qmlcachegen::loadGeneratedFile() { +#if defined(QTEST_CROSS_COMPILED) + QSKIP("Cannot call qmlcachegen on cross-compiled target."); +#endif + QTemporaryDir tempDir; QVERIFY(tempDir.isValid()); @@ -214,6 +222,10 @@ public: void tst_qmlcachegen::translationExpressionSupport() { +#if defined(QTEST_CROSS_COMPILED) + QSKIP("Cannot call qmlcachegen on cross-compiled target."); +#endif + QTemporaryDir tempDir; QVERIFY(tempDir.isValid()); @@ -259,6 +271,10 @@ void tst_qmlcachegen::translationExpressionSupport() void tst_qmlcachegen::signalHandlerParameters() { +#if defined(QTEST_CROSS_COMPILED) + QSKIP("Cannot call qmlcachegen on cross-compiled target."); +#endif + QTemporaryDir tempDir; QVERIFY(tempDir.isValid()); @@ -322,6 +338,10 @@ void tst_qmlcachegen::signalHandlerParameters() void tst_qmlcachegen::errorOnArgumentsInSignalHandler() { +#if defined(QTEST_CROSS_COMPILED) + QSKIP("Cannot call qmlcachegen on cross-compiled target."); +#endif + QTemporaryDir tempDir; QVERIFY(tempDir.isValid()); @@ -347,6 +367,10 @@ void tst_qmlcachegen::errorOnArgumentsInSignalHandler() void tst_qmlcachegen::aheadOfTimeCompilation() { +#if defined(QTEST_CROSS_COMPILED) + QSKIP("Cannot call qmlcachegen on cross-compiled target."); +#endif + QTemporaryDir tempDir; QVERIFY(tempDir.isValid()); @@ -387,21 +411,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()); QVERIFY(originalUnit); 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); { @@ -415,13 +451,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() @@ -459,6 +488,10 @@ void tst_qmlcachegen::workerScripts() void tst_qmlcachegen::functionExpressions() { +#if defined(QTEST_CROSS_COMPILED) + QSKIP("Cannot call qmlcachegen on cross-compiled target."); +#endif + QTemporaryDir tempDir; QVERIFY(tempDir.isValid()); @@ -556,6 +589,10 @@ void tst_qmlcachegen::qrcScriptImport() void tst_qmlcachegen::fsScriptImport() { +#if defined(QTEST_CROSS_COMPILED) + QSKIP("Cannot call qmlcachegen on cross-compiled target."); +#endif + QTemporaryDir tempDir; QVERIFY(tempDir.isValid()); @@ -681,6 +718,10 @@ void tst_qmlcachegen::reproducibleCache_data() void tst_qmlcachegen::reproducibleCache() { +#if defined(QTEST_CROSS_COMPILED) + QSKIP("Cannot call qmlcachegen on cross-compiled target."); +#endif + QFETCH(QString, filePath); QFile file(filePath); @@ -712,6 +753,10 @@ void tst_qmlcachegen::parameterAdjustment() void tst_qmlcachegen::inlineComponent() { +#if defined(QTEST_CROSS_COMPILED) + QSKIP("Cannot call qmlcachegen on cross-compiled target."); +#endif + QByteArray errors; bool ok = generateCache(testFile("inlineComponentWithId.qml"), &errors); QVERIFY2(ok, errors); @@ -724,6 +769,10 @@ void tst_qmlcachegen::inlineComponent() void tst_qmlcachegen::posthocRequired() { +#if defined(QTEST_CROSS_COMPILED) + QSKIP("Cannot call qmlcachegen on cross-compiled target."); +#endif + bool ok = generateCache(testFile("posthocrequired.qml")); QVERIFY(ok); QQmlEngine engine; @@ -735,6 +784,10 @@ void tst_qmlcachegen::posthocRequired() void tst_qmlcachegen::scriptStringCachegenInteraction() { +#if defined(QTEST_CROSS_COMPILED) + QSKIP("Cannot call qmlcachegen on cross-compiled target."); +#endif + bool ok = generateCache(testFile("scriptstring.qml")); QVERIFY(ok); QQmlEngine engine; |