diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2022-01-24 13:46:58 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-02-03 08:46:02 +0000 |
commit | 4cbbe17dedd0274e0e46c523d0f868a87ae7e957 (patch) | |
tree | b7394e8e609a453cf0eddaf1571408d40a5a9800 /tests | |
parent | 1140e5551ebb6f67252ba4af193015e5d4ceaaf0 (diff) |
qmltc: Rely on QQmlJSResourceFileMapper
Similarly to qmllint, we should use QQmlJSResourceFileMapper
in qmltc. This should in theory allow us to avoid
implicit import dir vs qmldir path issues (where the former
comes from source dir while the latter comes from build dir)
At present, it does not seem to be the case, however. But
this is to be addressed separately
Task-number: QTBUG-100103
Change-Id: Ie85799cb0a4b8b1620964000bc5939e9d046678e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 8a72c684464a48595337b01ada5605f612f7971e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qmltc_qprocess/CMakeLists.txt | 9 | ||||
-rw-r--r-- | tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp | 18 |
2 files changed, 19 insertions, 8 deletions
diff --git a/tests/auto/qml/qmltc_qprocess/CMakeLists.txt b/tests/auto/qml/qmltc_qprocess/CMakeLists.txt index e6a031ddcf..46f1d856d3 100644 --- a/tests/auto/qml/qmltc_qprocess/CMakeLists.txt +++ b/tests/auto/qml/qmltc_qprocess/CMakeLists.txt @@ -15,6 +15,15 @@ qt6_add_qml_module(tst_qmltc_qprocess ) add_dependencies(tst_qmltc_qprocess Qt::qmltc) +# fetch --resource arguments manually (mimics the logic of qmltc compilation +# command) +_qt_internal_genex_getjoinedproperty(qrc_args tst_qmltc_qprocess + _qt_generated_qrc_files "" "_::_" +) +target_compile_definitions(tst_qmltc_qprocess PRIVATE + TST_QMLTC_QPROCESS_RESOURCES="${qrc_args}" +) + qt_internal_extend_target(tst_qmltc_qprocess CONDITION ANDROID OR IOS DEFINES QT_QMLTEST_DATADIR=\\\":/data\\\" diff --git a/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp b/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp index 6f12e585ba..7ba31fc652 100644 --- a/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp +++ b/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp @@ -48,7 +48,7 @@ class tst_qmltc_qprocess : public QQmlDataTest QString m_qmltcPath; QString m_tmpPath; - QHash<QString, QString> m_resourcePaths; + QStringList m_resources; QString runQmltc(const QString &inputFile, std::function<void(QProcess &)> handleResult, const QStringList &extraArgs = {}); @@ -70,6 +70,10 @@ private slots: void inlineComponent(); }; +#ifndef TST_QMLTC_QPROCESS_RESOURCES +# error "This test expects TST_QMLTC_QPROCESS_RESOURCES to be defined through CMake." +#endif + void tst_qmltc_qprocess::initTestCase() { QQmlDataTest::initTestCase(); @@ -86,8 +90,7 @@ void tst_qmltc_qprocess::initTestCase() QVERIFY(QDir(m_tmpPath).removeRecursively()); // in case it's already there QVERIFY(QDir().mkpath(m_tmpPath)); - m_resourcePaths = { { u"dummy.qml"_qs, u"data/dummy.qml"_qs }, - { u"inlineComponent.qml"_qs, u"data/inlineComponent.qml"_qs } }; + m_resources = QStringLiteral(TST_QMLTC_QPROCESS_RESOURCES).split(u"_::_"_qs); } void tst_qmltc_qprocess::cleanupTestCase() @@ -102,10 +105,8 @@ QString tst_qmltc_qprocess::runQmltc(const QString &inputFile, QStringList args; args << (QFileInfo(inputFile).isAbsolute() ? inputFile : testFile(inputFile)); - if (auto it = m_resourcePaths.constFind(inputFile); it != m_resourcePaths.cend()) { - // otherwise expect resource path to come from extraArgs - args << u"--resource-path"_qs << it.value(); - } + for (const QString &resource : m_resources) + args << u"--resource"_qs << resource; args << u"--header"_qs << (m_tmpPath + u"/"_qs + QFileInfo(inputFile).baseName() + u".h"_qs); args << u"--impl"_qs << (m_tmpPath + u"/"_qs + QFileInfo(inputFile).baseName() + u".cpp"_qs); @@ -147,7 +148,8 @@ QString tst_qmltc_qprocess::runQmltc(const QString &inputFile, bool shouldSuccee void tst_qmltc_qprocess::sanity() { - QVERIFY(runQmltc(u"dummy.qml"_qs, true).isEmpty()); + const auto output = runQmltc(u"dummy.qml"_qs, true); + QVERIFY2(output.isEmpty(), qPrintable(output)); } void tst_qmltc_qprocess::noBuiltins() |