diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2022-09-13 09:03:06 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2022-09-28 09:58:29 +0200 |
commit | db830ae43414a4882bd263641dad07b0b23811d7 (patch) | |
tree | 84d1fe14919228876285d07b5bfe0e1ab4294a7b /tests | |
parent | 4b600512329ab595b5971ee79ee104db956f6129 (diff) | |
download | qttools-db830ae43414a4882bd263641dad07b0b23811d7.tar.gz |
lupdate: Parse .qrc files when using -project
Files in .qrc files were not taken into account when passing -project to
lupdate.
lupdate converts .pro files to .json files internally with the lprodump
tool. That tool already expanded .qrc files - that's why tst_lupdate
good:parseqrc succeeded.
Fixes: QTBUG-102282
Change-Id: Ib4cb2bfeb81eab7d165e6865629f69f951dc6492
Reviewed-by: Lucie Gerard <lucie.gerard@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'tests')
7 files changed, 79 insertions, 2 deletions
diff --git a/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/main.cpp new file mode 100644 index 000000000..77e41a392 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/main.cpp @@ -0,0 +1,10 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +// IMPORTANT!!!! If you want to add testdata to this file, +// always add it to the end in order to not change the linenumbers of translations!!! +#include <QtCore/QCoreApplication> + +void func1() { + QCoreApplication::tr("Hello world"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/main.js b/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/main.js new file mode 100644 index 000000000..b2e1dd9e0 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/main.js @@ -0,0 +1 @@ +qsTr("From JavaScript file"); diff --git a/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/main.qml b/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/main.qml new file mode 100644 index 000000000..fc7a465c5 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/main.qml @@ -0,0 +1,10 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +import QtQuick 1.0 + +QtObject { + function translate() { + qsTr("From QML file in root"); + } +} diff --git a/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/project.json b/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/project.json new file mode 100644 index 000000000..d7a1db7a3 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/project.json @@ -0,0 +1,16 @@ +[ + { + "excluded": [], + "includePaths": [ + ], + "projectFile": "project.pro", + "sources": [ + "main.cpp", + "main.qml", + "project.qrc" + ], + "translations": [ + "project.ts" + ] + } +] diff --git a/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/project.qrc b/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/project.qrc new file mode 100644 index 000000000..87bacf228 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/project.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/"> + <file>main.js</file> +</qresource> +</RCC> diff --git a/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/project.ts.result new file mode 100644 index 000000000..ea847ab55 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parseqrc_json/project.ts.result @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1"> +<context> + <name>QCoreApplication</name> + <message> + <location filename="main.cpp" line="9"/> + <source>Hello world</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>main</name> + <message> + <location filename="main.qml" line="8"/> + <source>From QML file in root</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.js" line="1"/> + <source>From JavaScript file</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/tst_lupdate.cpp b/tests/auto/linguist/lupdate/tst_lupdate.cpp index 9580cd92d..eecba1d73 100644 --- a/tests/auto/linguist/lupdate/tst_lupdate.cpp +++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp @@ -17,6 +17,8 @@ #include <iostream> +using namespace Qt::Literals::StringLiterals; + class tst_lupdate : public QObject { Q_OBJECT @@ -226,6 +228,7 @@ void tst_lupdate::good_data() "parsecontexts", "parsecpp", "parsecpp2", + "parseqrc_json", "prefix", "preprocess", "proparsing2", // llvm8 cannot handle file name without extension @@ -290,8 +293,15 @@ void tst_lupdate::good() QVERIFY(file.open(QIODevice::WriteOnly)); file.close(); - if (lupdateArguments.isEmpty()) - lupdateArguments.append(QLatin1String("project.pro")); + if (lupdateArguments.isEmpty()) { + // Automatically pass "project.pro" or "-project project.json". + if (QFile::exists(dir + u"/project.json"_s)) { + lupdateArguments << u"-project"_s << u"project.json"_s; + } else { + lupdateArguments.append(QLatin1String("project.pro")); + } + } + lupdateArguments.prepend("-silent"); if (useClangCpp) lupdateArguments.append("-clang-parser"); |