diff options
Diffstat (limited to 'tests/auto/tools')
-rw-r--r-- | tests/auto/tools/moc/moc.pro | 3 | ||||
-rw-r--r-- | tests/auto/tools/moc/namespace.h | 77 | ||||
-rw-r--r-- | tests/auto/tools/moc/namespace_no_merge.h | 74 | ||||
-rw-r--r-- | tests/auto/tools/moc/parse-defines.h | 3 | ||||
-rw-r--r-- | tests/auto/tools/moc/subdir/extradefines.h | 1 | ||||
-rw-r--r-- | tests/auto/tools/moc/tst_moc.cpp | 275 | ||||
-rw-r--r-- | tests/auto/tools/qdbuscpp2xml/qdbuscpp2xml.pro | 2 | ||||
-rw-r--r-- | tests/auto/tools/qdbusxml2cpp/qdbusxml2cpp.pro | 1 | ||||
-rw-r--r-- | tests/auto/tools/qmakelib/evaltest.cpp | 198 | ||||
-rw-r--r-- | tests/auto/tools/qmakelib/parsertest.cpp | 2 | ||||
-rw-r--r-- | tests/auto/tools/qmakelib/testdata/include/inc.pri | 6 | ||||
-rw-r--r-- | tests/auto/tools/rcc/data/images/images.expected | 10 | ||||
-rw-r--r-- | tests/auto/tools/rcc/tst_rcc.cpp | 17 |
13 files changed, 637 insertions, 32 deletions
diff --git a/tests/auto/tools/moc/moc.pro b/tests/auto/tools/moc/moc.pro index 688799048f..d2b750bdc5 100644 --- a/tests/auto/tools/moc/moc.pro +++ b/tests/auto/tools/moc/moc.pro @@ -28,7 +28,8 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n qtbug-35657-gadget.h \ non-gadget-parent-class.h grand-parent-gadget-class.h \ related-metaobjects-in-gadget.h \ - related-metaobjects-name-conflict.h + related-metaobjects-name-conflict.h \ + namespace.h if(*-g++*|*-icc*|*-clang*|*-llvm):!irix-*:!win32-*: HEADERS += os9-newlines.h win-newlines.h diff --git a/tests/auto/tools/moc/namespace.h b/tests/auto/tools/moc/namespace.h new file mode 100644 index 0000000000..6e04831589 --- /dev/null +++ b/tests/auto/tools/moc/namespace.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite 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$ +** +****************************************************************************/ + +#ifndef NAMESPACE_H +#define NAMESPACE_H + +#include <QObject> + +#include "namespace_no_merge.h" +// moc should not merge namespace_no_merge.h content with this one ! + +namespace FooNamespace { + Q_NAMESPACE + enum class Enum1 { + Key1, + Key2 + }; + Q_ENUM_NS(Enum1) + + namespace FooNestedNamespace { + Q_NAMESPACE + enum class Enum2 { + Key3, + Key4 + }; + Q_ENUM_NS(Enum2) + } + + using namespace FooNamespace; + namespace Bar = FooNamespace; + + // Moc should merge this namespace with the previous one + namespace FooNestedNamespace { + Q_NAMESPACE + enum class Enum3 { + Key5, + Key6 + }; + Q_ENUM_NS(Enum3) + + namespace FooMoreNestedNamespace { + Q_NAMESPACE + enum class Enum4 { + Key7, + Key8 + }; + Q_ENUM_NS(Enum4) + } + } +} + +#endif // NAMESPACE_H diff --git a/tests/auto/tools/moc/namespace_no_merge.h b/tests/auto/tools/moc/namespace_no_merge.h new file mode 100644 index 0000000000..8d1639ad4c --- /dev/null +++ b/tests/auto/tools/moc/namespace_no_merge.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite 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$ +** +****************************************************************************/ + +#ifndef NAMESPACE_NO_MERGE_H +#define NAMESPACE_NO_MERGE_H + +#include <QObject> + +namespace FooNamespace { + Q_NAMESPACE + enum class MEnum1 { + Key1, + Key2 + }; + Q_ENUM_NS(MEnum1) + + namespace FooNestedNamespace { + Q_NAMESPACE + enum class MEnum2 { + Key3, + Key4 + }; + Q_ENUM_NS(MEnum2) + } + + using namespace FooNamespace; + namespace Bar = FooNamespace; + + // Moc should merge this namespace with the previous one + namespace FooNestedNamespace { + Q_NAMESPACE + enum class MEnum3 { + Key5, + Key6 + }; + Q_ENUM_NS(MEnum3) + + namespace FooMoreNestedNamespace { + Q_NAMESPACE + enum class MEnum4 { + Key7, + Key8 + }; + Q_ENUM_NS(MEnum4) + } + } +} + +#endif // NAMESPACE_NO_MERGE_H diff --git a/tests/auto/tools/moc/parse-defines.h b/tests/auto/tools/moc/parse-defines.h index 9fb5da4b07..6100bf67ad 100644 --- a/tests/auto/tools/moc/parse-defines.h +++ b/tests/auto/tools/moc/parse-defines.h @@ -139,6 +139,9 @@ public slots: signals: DEFINE_CMDLINE_SIGNAL; +#define QTBUG55853(X) PD_DEFINE1(X, signalQTBUG55853) +#define PD_EMPTY /* empty */ + void QTBUG55853(PD_EMPTY)(); }; #undef QString diff --git a/tests/auto/tools/moc/subdir/extradefines.h b/tests/auto/tools/moc/subdir/extradefines.h new file mode 100644 index 0000000000..e7888ce80d --- /dev/null +++ b/tests/auto/tools/moc/subdir/extradefines.h @@ -0,0 +1 @@ +#define FOO 1 diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index b49d7bc477..ecf6c7e992 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -69,9 +69,83 @@ #include "non-gadget-parent-class.h" #include "grand-parent-gadget-class.h" +#include "namespace.h" + +#ifdef Q_MOC_RUN +// check that moc can parse these constructs, they are being used in Windows winsock2.h header +#define STRING_HASH_HASH(x) ("foo" ## x ## "bar") +const char *string_hash_hash = STRING_HASH_HASH("baz"); +#endif Q_DECLARE_METATYPE(const QMetaObject*); +namespace TestNonQNamespace { + +struct TestGadget { + Q_GADGET + Q_CLASSINFO("key", "value") +public: + enum class TestGEnum1 { + Key1 = 11, + Key2 + }; + Q_ENUM(TestGEnum1) + + enum class TestGEnum2 { + Key1 = 17, + Key2 + }; + Q_ENUM(TestGEnum2) +}; + +} + +namespace TestQNamespace { + Q_NAMESPACE + enum class TestEnum1 { + Key1 = 11, + Key2 + }; + Q_ENUM_NS(TestEnum1) + + enum class TestEnum2 { + Key1 = 17, + Key2 + }; + Q_ENUM_NS(TestEnum2) + + // try to dizzy moc by adding a struct in between + struct TestGadget { + Q_GADGET + public: + enum class TestGEnum1 { + Key1 = 13, + Key2 + }; + enum class TestGEnum2 { + Key1 = 23, + Key2 + }; + Q_ENUM(TestGEnum1) + Q_ENUM(TestGEnum2) + }; + + enum class TestFlag1 { + None = 0, + Flag1 = 1, + Flag2 = 2, + Any = Flag1 | Flag2 + }; + Q_FLAG_NS(TestFlag1) + + enum class TestFlag2 { + None = 0, + Flag1 = 4, + Flag2 = 8, + Any = Flag1 | Flag2 + }; + Q_FLAG_NS(TestFlag2) +} QT_USE_NAMESPACE @@ -489,13 +563,6 @@ public: Q_ENUMS(EnumSourceClass::TestEnum) }; -#if defined(Q_MOC_RUN) -// Task #119503 -#define _TASK_119503 -#if !_TASK_119503 -#endif -#endif - class CtorTestClass : public QObject { Q_OBJECT @@ -576,6 +643,10 @@ private slots: void frameworkSearchPath(); void cstyleEnums(); void defineMacroViaCmdline(); + void defineMacroViaForcedInclude(); + void defineMacroViaForcedIncludeRelative(); + void environmentIncludePaths_data(); + void environmentIncludePaths(); void specifyMetaTagsFromCmdline(); void invokable(); void singleFunctionKeywordSignalAndSlot(); @@ -624,6 +695,7 @@ private slots: void gadgetHierarchy(); void optionsFileError_data(); void optionsFileError(); + void testQNamespace(); signals: void sigWithUnsignedArg(unsigned foo); @@ -1254,6 +1326,92 @@ void tst_Moc::defineMacroViaCmdline() #endif } +void tst_Moc::defineMacroViaForcedInclude() +{ +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) + QProcess proc; + + QStringList args; + args << "--include" << m_sourceDirectory + QLatin1String("/subdir/extradefines.h"); + args << m_sourceDirectory + QStringLiteral("/macro-on-cmdline.h"); + + proc.start(m_moc, args); + QVERIFY(proc.waitForFinished()); + QCOMPARE(proc.exitCode(), 0); + QCOMPARE(proc.readAllStandardError(), QByteArray()); + QByteArray mocOut = proc.readAllStandardOutput(); + QVERIFY(!mocOut.isEmpty()); +#else + QSKIP("Only tested on linux/gcc"); +#endif +} + +void tst_Moc::defineMacroViaForcedIncludeRelative() +{ +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) + QProcess proc; + + QStringList args; + args << "--include" << QStringLiteral("extradefines.h") << "-I" + m_sourceDirectory + "/subdir"; + args << m_sourceDirectory + QStringLiteral("/macro-on-cmdline.h"); + + proc.start(m_moc, args); + QVERIFY(proc.waitForFinished()); + QCOMPARE(proc.exitCode(), 0); + QCOMPARE(proc.readAllStandardError(), QByteArray()); + QByteArray mocOut = proc.readAllStandardOutput(); + QVERIFY(!mocOut.isEmpty()); +#else + QSKIP("Only tested on linux/gcc"); +#endif +} + + +void tst_Moc::environmentIncludePaths_data() +{ +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) + QTest::addColumn<QString>("cmdline"); + QTest::addColumn<QString>("varname"); + + QTest::newRow("INCLUDE") << "--compiler-flavor=msvc" << "INCLUDE"; + QTest::newRow("CPATH1") << QString() << "CPATH"; + QTest::newRow("CPATH2") << "--compiler-flavor=unix" << "CPATH"; + QTest::newRow("CPLUS_INCLUDE_PATH1") << QString() << "CPLUS_INCLUDE_PATH"; + QTest::newRow("CPLUS_INCLUDE_PATH2") << "--compiler-flavor=unix" << "CPLUS_INCLUDE_PATH"; +#endif +} + +void tst_Moc::environmentIncludePaths() +{ +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) + QFETCH(QString, cmdline); + QFETCH(QString, varname); + + QStringList args; + if (!cmdline.isEmpty()) + args << cmdline; + args << "--include" << QStringLiteral("extradefines.h") + << m_sourceDirectory + QStringLiteral("/macro-on-cmdline.h"); + + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + env.remove("INCLUDE"); + env.remove("CPATH"); + env.remove("CPLUS_INCLUDE_PATH"); + env.insert(varname, m_sourceDirectory + "/subdir"); + + QProcess proc; + proc.setProcessEnvironment(env); + proc.start(m_moc, args); + QVERIFY(proc.waitForFinished()); + QCOMPARE(proc.exitCode(), 0); + QCOMPARE(proc.readAllStandardError(), QByteArray()); + QByteArray mocOut = proc.readAllStandardOutput(); + QVERIFY(!mocOut.isEmpty()); +#else + QSKIP("Only tested on linux/gcc"); +#endif +} + // tst_Moc::specifyMetaTagsFromCmdline() // plugin_metadata.h contains a plugin which we register here. Since we're not building this // application as a plugin, we need top copy some of the initializer code found in qplugin.h: @@ -1918,6 +2076,41 @@ void tst_Moc::warnings_data() << QString() << QString("standard input:5: Error: Class declaration lacks Q_OBJECT macro."); + QTest::newRow("Namespace declaration lacks Q_NAMESPACE macro.") + << QByteArray("namespace X {\nQ_CLASSINFO(\"key\",\"value\")\nenum class MyEnum {Key1 = 1}\nQ_ENUMS(MyEnum)\n}\n") + << QStringList() + << 1 + << QString() + << QString("standard input:1: Error: Namespace declaration lacks Q_NAMESPACE macro."); + + QTest::newRow("Wrong Q_ENUM context.") + << QByteArray("namespace X {\nQ_NAMESPACE\n\nenum class MyEnum {Key1 = 1}\nQ_ENUM(MyEnum)\n}\n") + << QStringList() + << 1 + << QString() + << QString("standard input:5: Error: Q_ENUM can't be used in a Q_NAMESPACE, use Q_ENUM_NS instead"); + + QTest::newRow("Wrong Q_FLAG context.") + << QByteArray("namespace X {\nQ_NAMESPACE\n\nenum class MyEnum {Key1 = 1}\nQ_FLAG(MyEnum)\n}\n") + << QStringList() + << 1 + << QString() + << QString("standard input:5: Error: Q_FLAG can't be used in a Q_NAMESPACE, use Q_FLAG_NS instead"); + + QTest::newRow("Wrong Q_ENUM_NS context.") + << QByteArray("class X {\nQ_GADGET\n\nenum class MyEnum {Key1 = 1}\nQ_ENUM_NS(MyEnum)\n};\n") + << QStringList() + << 1 + << QString() + << QString("standard input:5: Error: Q_ENUM_NS can't be used in a Q_OBJECT/Q_GADGET, use Q_ENUM instead"); + + QTest::newRow("Wrong Q_FLAG_NS context.") + << QByteArray("class X {\nQ_GADGET\n\nenum class MyEnum {Key1 = 1}\nQ_FLAG_NS(MyEnum)\n};\n") + << QStringList() + << 1 + << QString() + << QString("standard input:5: Error: Q_FLAG_NS can't be used in a Q_OBJECT/Q_GADGET, use Q_FLAG instead"); + QTest::newRow("Invalid macro definition") << QByteArray("#define Foo(a, b, c) a b c #a #b #c a##b##c #d\n Foo(45, 42, 39);") << QStringList() @@ -1939,6 +2132,13 @@ void tst_Moc::warnings_data() << QString("IGNORE_ALL_STDOUT") << QString(":-1: Error: Unexpected character in macro argument list."); + QTest::newRow("Missing header warning") + << QByteArray("class X : public QObject { Q_OBJECT };") + << (QStringList() << QStringLiteral("--include") << QStringLiteral("doesnotexist.h")) + << 0 + << QString("IGNORE_ALL_STDOUT") + << QStringLiteral("Warning: Failed to resolve include \"doesnotexist.h\" for moc file <standard input>"); + QTest::newRow("QTBUG-54815: Crash on invalid input") << QByteArray("class M{(})F<{}d000000000000000#0") << QStringList() @@ -2012,18 +2212,19 @@ void tst_Moc::cxx11Enums_data() QTest::addColumn<const QMetaObject *>("meta"); QTest::addColumn<QByteArray>("enumName"); QTest::addColumn<char>("prefix"); + QTest::addColumn<bool>("isScoped"); const QMetaObject *meta1 = &CXX11Enums::staticMetaObject; const QMetaObject *meta2 = &CXX11Enums2::staticMetaObject; - QTest::newRow("EnumClass") << meta1 << QByteArray("EnumClass") << 'A'; - QTest::newRow("EnumClass 2") << meta2 << QByteArray("EnumClass") << 'A'; - QTest::newRow("TypedEnum") << meta1 << QByteArray("TypedEnum") << 'B'; - QTest::newRow("TypedEnum 2") << meta2 << QByteArray("TypedEnum") << 'B'; - QTest::newRow("TypedEnumClass") << meta1 << QByteArray("TypedEnumClass") << 'C'; - QTest::newRow("TypedEnumClass 2") << meta2 << QByteArray("TypedEnumClass") << 'C'; - QTest::newRow("NormalEnum") << meta1 << QByteArray("NormalEnum") << 'D'; - QTest::newRow("NormalEnum 2") << meta2 << QByteArray("NormalEnum") << 'D'; + QTest::newRow("EnumClass") << meta1 << QByteArray("EnumClass") << 'A' << true; + QTest::newRow("EnumClass 2") << meta2 << QByteArray("EnumClass") << 'A' << true; + QTest::newRow("TypedEnum") << meta1 << QByteArray("TypedEnum") << 'B' << false; + QTest::newRow("TypedEnum 2") << meta2 << QByteArray("TypedEnum") << 'B' << false; + QTest::newRow("TypedEnumClass") << meta1 << QByteArray("TypedEnumClass") << 'C' << true; + QTest::newRow("TypedEnumClass 2") << meta2 << QByteArray("TypedEnumClass") << 'C' << true; + QTest::newRow("NormalEnum") << meta1 << QByteArray("NormalEnum") << 'D' << false; + QTest::newRow("NormalEnum 2") << meta2 << QByteArray("NormalEnum") << 'D' << false; } void tst_Moc::cxx11Enums() @@ -2033,6 +2234,7 @@ void tst_Moc::cxx11Enums() QFETCH(QByteArray, enumName); QFETCH(char, prefix); + QFETCH(bool, isScoped); int idx; idx = meta->indexOfEnumerator(enumName); @@ -2046,6 +2248,7 @@ void tst_Moc::cxx11Enums() QCOMPARE(meta->enumerator(idx).keyToValue(v), i); QCOMPARE(meta->enumerator(idx).valueToKey(i), v.constData()); } + QCOMPARE(meta->enumerator(idx).isScoped(), isScoped); } void tst_Moc::returnRefs() @@ -3194,6 +3397,9 @@ void tst_Moc::parseDefines() index = mo->indexOfSignal("cmdlineSignal(QMap<int,int>)"); QVERIFY(index != -1); + + index = mo->indexOfSignal("signalQTBUG55853()"); + QVERIFY(index != -1); } void tst_Moc::preprocessorOnly() @@ -3538,6 +3744,45 @@ void tst_Moc::optionsFileError() #endif } +static void checkEnum(const QMetaEnum &enumerator, const QByteArray &name, const QVector<QPair<QByteArray, int >> &keys) +{ + QCOMPARE(name, QByteArray{enumerator.name()}); + QCOMPARE(keys.size(), enumerator.keyCount()); + for (int i = 0; i < enumerator.keyCount(); ++i) { + QCOMPARE(keys[i].first, QByteArray{enumerator.key(i)}); + QCOMPARE(keys[i].second, enumerator.value(i)); + } +} + +void tst_Moc::testQNamespace() +{ + QCOMPARE(TestQNamespace::staticMetaObject.enumeratorCount(), 4); + checkEnum(TestQNamespace::staticMetaObject.enumerator(0), "TestEnum1", + {{"Key1", 11}, {"Key2", 12}}); + checkEnum(TestQNamespace::staticMetaObject.enumerator(1), "TestEnum2", + {{"Key1", 17}, {"Key2", 18}}); + checkEnum(TestQNamespace::staticMetaObject.enumerator(2), "TestFlag1", + {{"None", 0}, {"Flag1", 1}, {"Flag2", 2}, {"Any", 1 | 2}}); + checkEnum(TestQNamespace::staticMetaObject.enumerator(3), "TestFlag2", + {{"None", 0}, {"Flag1", 4}, {"Flag2", 8}, {"Any", 4 | 8}}); + + QCOMPARE(TestQNamespace::TestGadget::staticMetaObject.enumeratorCount(), 2); + checkEnum(TestQNamespace::TestGadget::staticMetaObject.enumerator(0), "TestGEnum1", + {{"Key1", 13}, {"Key2", 14}}); + checkEnum(TestQNamespace::TestGadget::staticMetaObject.enumerator(1), "TestGEnum2", + {{"Key1", 23}, {"Key2", 24}}); + + QMetaEnum meta = QMetaEnum::fromType<TestQNamespace::TestEnum1>(); + QVERIFY(meta.isValid()); + QCOMPARE(meta.name(), "TestEnum1"); + QCOMPARE(meta.enclosingMetaObject(), &TestQNamespace::staticMetaObject); + QCOMPARE(meta.keyCount(), 2); + + QCOMPARE(FooNamespace::staticMetaObject.enumeratorCount(), 1); + QCOMPARE(FooNamespace::FooNestedNamespace::staticMetaObject.enumeratorCount(), 2); + QCOMPARE(FooNamespace::FooNestedNamespace::FooMoreNestedNamespace::staticMetaObject.enumeratorCount(), 1); +} + QTEST_MAIN(tst_Moc) // the generated code must compile with QT_NO_KEYWORDS diff --git a/tests/auto/tools/qdbuscpp2xml/qdbuscpp2xml.pro b/tests/auto/tools/qdbuscpp2xml/qdbuscpp2xml.pro index 4bfa89a44e..7389e9d44a 100644 --- a/tests/auto/tools/qdbuscpp2xml/qdbuscpp2xml.pro +++ b/tests/auto/tools/qdbuscpp2xml/qdbuscpp2xml.pro @@ -2,8 +2,6 @@ CONFIG += testcase QT = core testlib dbus TARGET = tst_qdbuscpp2xml -QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS - SOURCES += tst_qdbuscpp2xml.cpp \ RESOURCES += qdbuscpp2xml.qrc diff --git a/tests/auto/tools/qdbusxml2cpp/qdbusxml2cpp.pro b/tests/auto/tools/qdbusxml2cpp/qdbusxml2cpp.pro index 8c29ff47c4..9fc0af98b4 100644 --- a/tests/auto/tools/qdbusxml2cpp/qdbusxml2cpp.pro +++ b/tests/auto/tools/qdbusxml2cpp/qdbusxml2cpp.pro @@ -2,4 +2,3 @@ CONFIG += testcase QT = core testlib TARGET = tst_qdbusxml2cpp SOURCES += tst_qdbusxml2cpp.cpp -QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index df8736a1b1..e3be294e5f 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -815,6 +815,49 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) << "##:2: member() argument 2 (start) '4..foo' invalid." << true; + // The argument processing is shared with $$member(), so some tests are skipped. + QTest::newRow("$$str_member(): empty") + << "VAR = $$str_member()" + << "VAR =" + << "" + << true; + + QTest::newRow("$$str_member(): too short") + << "VAR = $$str_member(string_value, 7, 12)" + << "VAR =" // this is actually kinda stupid + << "" + << true; + + QTest::newRow("$$str_member(): ok") + << "VAR = $$str_member(string_value, 7, 11)" + << "VAR = value" + << "" + << true; + + QTest::newRow("$$str_member(): ok (default start)") + << "VAR = $$str_member(string_value)" + << "VAR = s" + << "" + << true; + + QTest::newRow("$$str_member(): ok (default end)") + << "VAR = $$str_member(string_value, 7)" + << "VAR = v" + << "" + << true; + + QTest::newRow("$$str_member(): negative") + << "VAR = $$str_member(string_value, -5, -3)" + << "VAR = val" + << "" + << true; + + QTest::newRow("$$str_member(): inverse") + << "VAR = $$str_member(string_value, -2, 1)" + << "VAR = ulav_gnirt" + << "" + << true; + QTest::newRow("$$first(): empty") << "IN = \nVAR = $$first(IN)" << "VAR =" @@ -839,6 +882,30 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) << "##:1: first(var) requires one argument." << true; + QTest::newRow("$$take_first(): empty") + << "IN = \nVAR = $$take_first(IN)" + << "VAR =\nIN =" + << "" + << true; + + QTest::newRow("$$take_first(): one") + << "IN = one\nVAR = $$take_first(IN)" + << "VAR = one\nIN =" + << "" + << true; + + QTest::newRow("$$take_first(): multiple") + << "IN = one two three\nVAR = $$take_first(IN)" + << "VAR = one\nIN = two three" + << "" + << true; + + QTest::newRow("$$take_first(): bad number of arguments") + << "VAR = $$take_first(1, 2)" + << "VAR =" + << "##:1: take_first(var) requires one argument." + << true; + QTest::newRow("$$last(): empty") << "IN = \nVAR = $$last(IN)" << "VAR =" @@ -863,6 +930,30 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) << "##:1: last(var) requires one argument." << true; + QTest::newRow("$$take_last(): empty") + << "IN = \nVAR = $$take_last(IN)" + << "VAR =\nIN =" + << "" + << true; + + QTest::newRow("$$take_last(): one") + << "IN = one\nVAR = $$take_last(IN)" + << "VAR = one\nIN =" + << "" + << true; + + QTest::newRow("$$take_last(): multiple") + << "IN = one two three\nVAR = $$take_last(IN)" + << "VAR = three\nIN = one two" + << "" + << true; + + QTest::newRow("$$take_last(): bad number of arguments") + << "VAR = $$take_last(1, 2)" + << "VAR =" + << "##:1: take_last(var) requires one argument." + << true; + QTest::newRow("$$size()") << "IN = one two three\nVAR = $$size(IN)" << "VAR = 3" @@ -875,6 +966,18 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) << "##:1: size(var) requires one argument." << true; + QTest::newRow("$$str_size()") + << "VAR = $$str_size(one two three)" + << "VAR = 13" + << "" + << true; + + QTest::newRow("$$str_size(): bad number of arguments") + << "VAR = $$str_size(1, 2)" + << "VAR =" + << "##:1: str_size(str) requires one argument." + << true; + QTest::newRow("$$fromfile(): right var") << "VAR = $$fromfile(" + qindir + "/fromfile/infile.prx, DEFINES)" << "VAR = QT_DLL" @@ -1003,6 +1106,48 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) << "##:1: format_number(): invalid format option foo=bar." << true; + QTest::newRow("$$num_add(): one") + << "VAR = $$num_add(10)" + << "VAR = 10" + << "" + << true; + + QTest::newRow("$$num_add(): two") + << "VAR = $$num_add(1, 2)" + << "VAR = 3" + << "" + << true; + + QTest::newRow("$$num_add(): three") + << "VAR = $$num_add(1, 3, 5)" + << "VAR = 9" + << "" + << true; + + QTest::newRow("$$num_add(): negative") + << "VAR = $$num_add(7, -13)" + << "VAR = -6" + << "" + << true; + + QTest::newRow("$$num_add(): bad number of arguments") + << "VAR = $$num_add()" + << "VAR = " + << "##:1: num_add(num, ...) requires at least one argument." + << true; + + QTest::newRow("$$num_add(): bad number: float") + << "VAR = $$num_add(1.1)" + << "VAR =" + << "##:1: num_add(): floats are currently not supported." + << true; + + QTest::newRow("$$num_add(): bad number: malformed") + << "VAR = $$num_add(fail)" + << "VAR =" + << "##:1: num_add(): malformed number fail." + << true; + QTest::newRow("$$join(): empty") << "IN = \nVAR = $$join(IN, //)" << "VAR =" @@ -1181,9 +1326,9 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) << true; QTest::newRow("$$system(): bad number of arguments") - << "VAR = $$system(1, 2, 3)" + << "VAR = $$system(1, 2, 3, 4)" << "VAR =" - << "##:1: system(execute) requires one or two arguments." + << "##:1: system(command, [mode], [stsvar]) requires one to three arguments." << true; QTest::newRow("$$unique()") @@ -1198,6 +1343,18 @@ void tst_qmakelib::addReplaceFunctions(const QString &qindir) << "##:1: unique(var) requires one argument." << true; + QTest::newRow("$$sorted()") + << "IN = one two three\nVAR = $$sorted(IN)" + << "VAR = one three two" + << "" + << true; + + QTest::newRow("$$sorted(): bad number of arguments") + << "VAR = $$sorted(1, 2)" + << "VAR =" + << "##:1: sorted(var) requires one argument." + << true; + QTest::newRow("$$reverse()") << "IN = one two three\nVAR = $$reverse(IN)" << "VAR = three two one" @@ -2102,7 +2259,7 @@ void tst_qmakelib::addTestFunctions(const QString &qindir) << "jsontext = not good\n" "parseJson(jsontext, json): OK = 1" << "OK = UNDEF" - << "" + << "##:2: Error parsing JSON at 1:1: illegal value" << true; QTest::newRow("parseJson(): bad number of arguments") @@ -2168,6 +2325,26 @@ void tst_qmakelib::addTestFunctions(const QString &qindir) << "##:1: load(feature) requires one or two arguments." << true; + QTest::newRow("discard_from()") + << "HERE = 1\nPLUS = one\n" + "defineTest(tfunc) {}\ndefineReplace(rfunc) {}\n" + "include(include/inc.pri)\n" + "contains(QMAKE_INTERNAL_INCLUDED_FILES, .*/include/inc\\\\.pri): PRE = 1\n" + "discard_from(include/inc.pri): OK = 1\n" + "!contains(QMAKE_INTERNAL_INCLUDED_FILES, .*/include/inc\\\\.pri): POST = 1\n" + "defined(tfunc, test): TDEF = 1\ndefined(rfunc, replace): RDEF = 1\n" + "defined(func, test): DTDEF = 1\ndefined(func, replace): DRDEF = 1\n" + << "PRE = 1\nPOST = 1\nOK = 1\nHERE = 1\nPLUS = one\nVAR = UNDEF\n" + "TDEF = 1\nRDEF = 1\nDTDEF = UNDEF\nDRDEF = UNDEF" + << "" + << true; + + QTest::newRow("discard_from(): bad number of arguments") + << "discard_from(1, 2): OK = 1" + << "OK = UNDEF" + << "##:1: discard_from(file) requires one argument." + << true; + // We don't test debug() and log(), because they print directly to stderr. QTest::newRow("message()") @@ -2189,12 +2366,18 @@ void tst_qmakelib::addTestFunctions(const QString &qindir) << "Project WARNING: World, be warned!" << true; - QTest::newRow("error()") + QTest::newRow("error(message)") << "error('World, you FAIL!'): OK = 1\nOKE = 1" << "OK = UNDEF\nOKE = UNDEF" << "Project ERROR: World, you FAIL!" << false; + QTest::newRow("error(empty)") + << "error(): OK = 1\nOKE = 1" + << "OK = UNDEF\nOKE = UNDEF" + << "" + << false; + QTest::newRow("if(error())") << "if(error(\\'World, you FAIL!\\')): OK = 1\nOKE = 1" << "OK = UNDEF\nOKE = UNDEF" @@ -2581,19 +2764,20 @@ void tst_qmakelib::proEval() QMakeTestHandler handler; handler.setExpectedMessages(msgs.replace("##:", infile + ':').split('\n', QString::SkipEmptyParts)); QMakeVfs vfs; - QMakeParser parser(0, &vfs, &handler); + ProFileCache cache; + QMakeParser parser(&cache, &vfs, &handler); QMakeGlobals globals; globals.do_cache = false; globals.xqmakespec = "fake-g++"; globals.environment = m_env; globals.setProperties(m_prop); globals.setDirectories(m_indir, m_outdir); - ProFile *outPro = parser.parsedProBlock(out, "out", 1, QMakeParser::FullGrammar); + ProFile *outPro = parser.parsedProBlock(QStringRef(&out), "out", 1, QMakeParser::FullGrammar); if (!outPro->isOk()) { qWarning("Expected output is malformed"); verified = false; } - ProFile *pro = parser.parsedProBlock(in, infile, 1, QMakeParser::FullGrammar); + ProFile *pro = parser.parsedProBlock(QStringRef(&in), infile, 1, QMakeParser::FullGrammar); QMakeEvaluator visitor(&globals, &parser, &vfs, &handler); visitor.setOutputDir(m_outdir); #ifdef Q_OS_WIN diff --git a/tests/auto/tools/qmakelib/parsertest.cpp b/tests/auto/tools/qmakelib/parsertest.cpp index 5e12d930f8..dc92f98f45 100644 --- a/tests/auto/tools/qmakelib/parsertest.cpp +++ b/tests/auto/tools/qmakelib/parsertest.cpp @@ -1962,7 +1962,7 @@ void tst_qmakelib::proParser() handler.setExpectedMessages(msgs.split('\n', QString::SkipEmptyParts)); QMakeVfs vfs; QMakeParser parser(0, &vfs, &handler); - ProFile *pro = parser.parsedProBlock(in, "in", 1, QMakeParser::FullGrammar); + ProFile *pro = parser.parsedProBlock(QStringRef(&in), "in", 1, QMakeParser::FullGrammar); if (handler.printedMessages()) { qWarning("Got unexpected message(s)"); verified = false; diff --git a/tests/auto/tools/qmakelib/testdata/include/inc.pri b/tests/auto/tools/qmakelib/testdata/include/inc.pri index 1f1b3a287f..5c570f49e5 100644 --- a/tests/auto/tools/qmakelib/testdata/include/inc.pri +++ b/tests/auto/tools/qmakelib/testdata/include/inc.pri @@ -1,8 +1,14 @@ VAR = val .VAR = nope +PLUS += more + fake-*: MATCH = 1 defineTest(func) { message("say hi!") } + +defineReplace(func) { + return("say hi!") +} diff --git a/tests/auto/tools/rcc/data/images/images.expected b/tests/auto/tools/rcc/data/images/images.expected index 1f0157d51c..eb5d9222c8 100644 --- a/tests/auto/tools/rcc/data/images/images.expected +++ b/tests/auto/tools/rcc/data/images/images.expected @@ -79,16 +79,22 @@ static const unsigned char qt_resource_name[] = { static const unsigned char qt_resource_struct[] = { // : 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, // :/images 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x3,0x0,0x0,0x0,0x2, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, // :/images/subdir 0x0,0x0,0x0,0x12,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x5, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, // :/images/square.png 0x0,0x0,0x0,0x3e,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0xa9, +TIMESTAMP:images/square.png // :/images/circle.png 0x0,0x0,0x0,0x24,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0, +TIMESTAMP:images/circle.png // :/images/subdir/triangle.png 0x0,0x0,0x0,0x58,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x1,0xb, +TIMESTAMP:images/subdir/triangle.png }; @@ -120,7 +126,7 @@ int QT_RCC_MANGLE_NAMESPACE(qInitResources)(); int QT_RCC_MANGLE_NAMESPACE(qInitResources)() { QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData) - (0x01, qt_resource_struct, qt_resource_name, qt_resource_data); + (0x02, qt_resource_struct, qt_resource_name, qt_resource_data); return 1; } @@ -128,7 +134,7 @@ int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)() { QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData) - (0x01, qt_resource_struct, qt_resource_name, qt_resource_data); + (0x02, qt_resource_struct, qt_resource_name, qt_resource_data); return 1; } diff --git a/tests/auto/tools/rcc/tst_rcc.cpp b/tests/auto/tools/rcc/tst_rcc.cpp index 8d95d06e30..54a2854ede 100644 --- a/tests/auto/tools/rcc/tst_rcc.cpp +++ b/tests/auto/tools/rcc/tst_rcc.cpp @@ -92,12 +92,23 @@ static QString doCompare(const QStringList &actual, const QStringList &expected) QByteArray ba; for (int i = 0, n = expected.size(); i != n; ++i) { - if (expected.at(i).startsWith("IGNORE:")) + QString expectedLine = expected.at(i); + if (expectedLine.startsWith("IGNORE:")) continue; - if (expected.at(i) != actual.at(i)) { + if (expectedLine.startsWith("TIMESTAMP:")) { + const QString relativePath = expectedLine.mid(strlen("TIMESTAMP:")); + const quint64 timeStamp = QFileInfo(relativePath).lastModified().toMSecsSinceEpoch(); + expectedLine.clear(); + for (int shift = 56; shift >= 0; shift -= 8) { + expectedLine.append(QLatin1String("0x")); + expectedLine.append(QString::number(quint8(timeStamp >> shift), 16)); + expectedLine.append(QLatin1Char(',')); + } + } + if (expectedLine != actual.at(i)) { qDebug() << "LINES" << i << "DIFFER"; ba.append( - "\n<<<<<< actual\n" + actual.at(i) + "\n======\n" + expected.at(i) + "\n<<<<<< actual\n" + actual.at(i) + "\n======\n" + expectedLine + "\n>>>>>> expected\n" ); } |