summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucie GĂ©rard <lucie.gerard@qt.io>2021-07-01 13:35:27 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-07-02 11:13:35 +0000
commit8f18ab55ee6b4963a7234ec5dd9a2b65879d3153 (patch)
tree9f35eb24ae926b66f6f667aedd743b11c9353157
parent6bce7a3c6cebe359f1bd78c89a8e7742ccd10d1f (diff)
lupdate/clang: Add test for isolated comments
Change-Id: I7c008cfa58cbe91f73caa34c0bd9dc9f1d3865e5 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 658b9787d71e35ebecfbb962f37c4486a8c2246c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/expectedoutput.txt1
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/project.pro1
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/project.ts.result114
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/test_isolatedComments.cpp83
4 files changed, 199 insertions, 0 deletions
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/expectedoutput.txt
index 7d66b2066..a1f551fda 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/expectedoutput.txt
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/expectedoutput.txt
@@ -2,3 +2,4 @@
.*[/\\]lupdate[/\\]testdata[/\\]good[/\\]parsecpp_clang_only[/\\]test_QT_TR_NOOP_context.cpp:91:26: QT_TR_NOOP cannot be called without context\. The call is ignored \(missing Q_OBJECT maybe\?\)
.*[/\\]lupdate[/\\]testdata[/\\]good[/\\]parsecpp_clang_only[/\\]test_QT_TR_NOOP_context_bis.cpp:51:26: QT_TR_NOOP cannot be called without context\. The call is ignored \(missing Q_OBJECT maybe\?\)
.*[/\\]lupdate[/\\]testdata[/\\]good[/\\]parsecpp_clang_only[/\\]test_QT_TR_NOOP_context_bis.cpp:91:26: QT_TR_NOOP cannot be called without context\. The call is ignored \(missing Q_OBJECT maybe\?\)
+.*[/\\]lupdate[/\\]testdata[/\\]good[/\\]parsecpp_clang_only[/\\]test_isolatedComments.cpp:83:0: TRANSLATOR cannot be called without comment. The call is ignored.
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/project.pro b/tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/project.pro
index 6d72286b6..e79bee4ea 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/project.pro
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/project.pro
@@ -1,4 +1,5 @@
SOURCES += test_QT_TR_NOOP_context.cpp
SOURCES += test_QT_TR_NOOP_context_bis.cpp
+SOURCES += test_isolatedComments.cpp
TRANSLATIONS = project.ts
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/project.ts.result
index 0701b9b58..10e9817ad 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/project.ts.result
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/project.ts.result
@@ -11,6 +11,69 @@
</message>
</context>
<context>
+ <name>GluedNumber1</name>
+ <message>
+ <location filename="test_isolatedComments.cpp" line="58"/>
+ <source></source>
+ <comment>blabla</comment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>GluedNumber2</name>
+ <message>
+ <location filename="test_isolatedComments.cpp" line="59"/>
+ <source></source>
+ <comment>blabla</comment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>GluedNumber3</name>
+ <message>
+ <location filename="test_isolatedComments.cpp" line="60"/>
+ <source></source>
+ <comment>blabla</comment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>GluedNumber4</name>
+ <message>
+ <location filename="test_isolatedComments.cpp" line="61"/>
+ <source></source>
+ <comment>// whatever we have here</comment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>GluedNumber5</name>
+ <message>
+ <location filename="test_isolatedComments.cpp" line="68"/>
+ <source></source>
+ <comment>// whatever2 we2 have2 here2</comment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>GluedOnSameLineOne</name>
+ <message>
+ <location filename="test_isolatedComments.cpp" line="75"/>
+ <source></source>
+ <comment>blabla</comment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>GluedOnSameLineTwo</name>
+ <message>
+ <location filename="test_isolatedComments.cpp" line="75"/>
+ <source></source>
+ <comment>blabla</comment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
<name>IN_NESTED</name>
<message>
<location filename="test_QT_TR_NOOP_context.cpp" line="61"/>
@@ -26,6 +89,57 @@
</message>
</context>
<context>
+ <name>MULTIPLELINE</name>
+ <message>
+ <location filename="test_isolatedComments.cpp" line="30"/>
+ <source></source>
+ <comment>first line second line</comment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>MultipleAppearance</name>
+ <message>
+ <location filename="test_isolatedComments.cpp" line="54"/>
+ <source></source>
+ <comment>first appearance</comment>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="test_isolatedComments.cpp" line="56"/>
+ <source></source>
+ <comment>second appearance</comment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>MultipleLineFourthTry</name>
+ <message>
+ <location filename="test_isolatedComments.cpp" line="47"/>
+ <source></source>
+ <comment>first line second line</comment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>MultipleLineSecondTry</name>
+ <message>
+ <location filename="test_isolatedComments.cpp" line="35"/>
+ <source></source>
+ <comment>first line second line</comment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>MultipleLineThirdTry</name>
+ <message>
+ <location filename="test_isolatedComments.cpp" line="41"/>
+ <source></source>
+ <comment>first line second line</comment>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
<name>ONLY_Q</name>
<message>
<location filename="test_QT_TR_NOOP_context.cpp" line="44"/>
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/test_isolatedComments.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/test_isolatedComments.cpp
new file mode 100644
index 000000000..362b6095d
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp_clang_only/test_isolatedComments.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QtCore>
+/* TRANSLATOR MULTIPLELINE
+ first line
+ second line
+ */
+
+/* TRANSLATOR
+ MultipleLineSecondTry
+ first line
+ second line
+ */
+
+/* TRANSLATOR
+ MultipleLineThirdTry first
+ line
+ second line
+ */
+
+/* TRANSLATOR
+ MultipleLineFourthTry first
+ line
+ second line
+ */
+
+
+/* TRANSLATOR MultipleAppearance first appearance */
+
+/* TRANSLATOR MultipleAppearance second appearance */
+
+/* TRANSLATOR GluedNumber1 blabla */
+/* TRANSLATOR GluedNumber2 blabla */
+// TRANSLATOR GluedNumber3 blabla
+/*TRANSLATOR
+GluedNumber4
+ // whatever
+ we
+ have
+ here
+*/
+/* TRANSLATOR GluedNumber5
+ // whatever2
+ we2
+ have2
+ here2
+*/
+
+/* TRANSLATOR GluedOnSameLineOne blabla*/ /* TRANSLATOR GluedOnSameLineTwo blabla*/
+// TRANSLATORMISSINGSPACE this will not be picked up by clang cpp parser
+// oooTRANSLATOR SomethingBeforeTranslator this should not be picked up
+// ooo TRANSLATOR SomethingBeforeTranslatorTwo this should not be picked up
+/* ooo TRANSLATOR SomethingBeforeTranslatorThree this should not be picked up */
+/* ~ TRANSLATOR SomethingBeforeTranslatorFour this
+ should not be picked up */
+// The following comment should be ignored because the comment part is empty
+/* TRANSLATOR onlyContext */