summaryrefslogtreecommitdiffstats
path: root/tests/auto/tools/moc
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-11-15 11:36:18 +1000
committerQt by Nokia <qt-info@nokia.com>2011-11-18 01:51:57 +0100
commita8fd0c3654f8352773638633778cd8003680cbc7 (patch)
tree4815cca9daf879b96a92a3de95621b56ac5ba868 /tests/auto/tools/moc
parentd90d57bb8b995c7a66e7f9b7b2515447fbe11de0 (diff)
Don't depend on moc to disable test functions.
The moc tool is not aware of all defines (particularly those that are compiler builtins) and does not correctly evaluate others that depend on compiler builtins, such as Q_OS_FOO. This commit reverts parts of the following commits, but is not a complete fix as there were many instances of this problem in the tests prior to those commits: 924d810dbdcd5b5b0fa860922b2487ea9062d002 8aaff6751038b88d17e23be6fcee945771297c5b 338d3f11973412047c2c9cd41cbd0c961d738ef3 a55034062ba2bf73a9f1ed3d9cf31745b38149e3 253497b7446c7d723aa3bdd7152e25d6852f2604 7cfad460c56319ba89c4a3a0bbcb2e54ab1cdbc6 9d2ff58f3642828e494e7e9b2df7dbb8e2cd408f 0cf6baa2d61ebaad2a2a0530c37f27e719b68f4b Change-Id: I947d797fe3ec76139ba1b55561cea569895662c5 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/tools/moc')
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp133
1 files changed, 77 insertions, 56 deletions
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index f3abe9b5ff..cfe516d999 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -467,14 +467,10 @@ private slots:
void slotWithException() throw(MyStruct);
void dontStripNamespaces();
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void oldStyleCasts();
void warnOnExtraSignalSlotQualifiaction();
-#endif
void uLongLong();
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void inputFileNameWithDotsButNoExtension();
-#endif
void userProperties();
void supportConstSignals();
void task87883();
@@ -491,47 +487,31 @@ private slots:
void slotsWithVoidTemplate();
void structQObject();
void namespacedFlags();
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void warnOnMultipleInheritance();
void forgottenQInterface();
-#endif
void os9Newline();
void winNewline();
void escapesInStringLiterals();
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS)
void frameworkSearchPath();
-#endif
void cstyleEnums();
-#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void defineMacroViaCmdline();
-#endif
void invokable();
void singleFunctionKeywordSignalAndSlot();
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void templateGtGt();
-#endif
void qprivateslots();
void qprivateproperties();
void inlineSlotsWithThrowDeclaration();
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void warnOnPropertyWithoutREAD();
-#endif
void constructors();
void typenameWithUnsigned();
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void warnOnVirtualSignal();
-#endif
void QTBUG5590_dummyProperty();
void QTBUG12260_defaultTemplate();
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void notifyError();
-#endif
void QTBUG17635_invokableAndProperty();
void revisions();
-#ifndef MOC_CROSS_COMPILED
void warnings_data();
void warnings();
-#endif
void privateClass();
void cxx11Enums_data();
void cxx11Enums();
@@ -599,10 +579,12 @@ void tst_Moc::dontStripNamespaces()
QCOMPARE(receiver.intCallCount, 1);
}
-// Only tested on linux/gcc. Not tested when cross-compiled.
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void tst_Moc::oldStyleCasts()
{
+#ifdef MOC_CROSS_COMPILED
+ QSKIP("Not tested when cross-compiled");
+#endif
+#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
QProcess proc;
proc.start("moc", QStringList(srcify("/oldstyle-casts.h")));
QVERIFY(proc.waitForFinished());
@@ -622,13 +604,17 @@ void tst_Moc::oldStyleCasts()
QVERIFY(proc.waitForFinished());
QCOMPARE(proc.exitCode(), 0);
QCOMPARE(QString::fromLocal8Bit(proc.readAllStandardError()), QString());
-}
+#else
+ QSKIP("Only tested on linux/gcc");
#endif
+}
-// Only tested on linux/gcc. Not tested when cross-compiled.
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void tst_Moc::warnOnExtraSignalSlotQualifiaction()
{
+#ifdef MOC_CROSS_COMPILED
+ QSKIP("Not tested when cross-compiled");
+#endif
+#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
QProcess proc;
proc.start("moc", QStringList(srcify("extraqualification.h")));
QVERIFY(proc.waitForFinished());
@@ -639,8 +625,10 @@ void tst_Moc::warnOnExtraSignalSlotQualifiaction()
QCOMPARE(mocWarning, QString(SRCDIR) +
QString("/extraqualification.h:53: Warning: Function declaration Test::badFunctionDeclaration contains extra qualification. Ignoring as signal or slot.\n") +
QString(SRCDIR) + QString("/extraqualification.h:56: Warning: parsemaybe: Function declaration Test::anotherOne contains extra qualification. Ignoring as signal or slot.\n"));
-}
+#else
+ QSKIP("Only tested on linux/gcc");
#endif
+}
void tst_Moc::uLongLong()
{
@@ -659,10 +647,12 @@ void tst_Moc::uLongLong()
QVERIFY(idx != -1);
}
-// Only tested on linux/gcc. Not tested when cross-compiled.
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void tst_Moc::inputFileNameWithDotsButNoExtension()
{
+#ifdef MOC_CROSS_COMPILED
+ QSKIP("Not tested when cross-compiled");
+#endif
+#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
QProcess proc;
proc.setWorkingDirectory(QString(SRCDIR) + "/task71021");
proc.start("moc", QStringList("../Header"));
@@ -683,8 +673,10 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
QVERIFY(proc.waitForFinished());
QCOMPARE(QString::fromLocal8Bit(proc.readAllStandardError()), QString());
QCOMPARE(proc.exitCode(), 0);
-}
+#else
+ QSKIP("Only tested on linux/gcc");
#endif
+}
void tst_Moc::userProperties()
{
@@ -875,10 +867,12 @@ void tst_Moc::namespacedFlags()
QCOMPARE(l, qvariant_cast<QList<Foo::Bar::Flags> >(baz.property("flagsList")));
}
-// Only tested on linux/gcc. Not tested when cross-compiled.
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void tst_Moc::warnOnMultipleInheritance()
{
+#ifdef MOC_CROSS_COMPILED
+ QSKIP("Not tested when cross-compiled");
+#endif
+#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
QProcess proc;
QStringList args;
args << "-I" << qtIncludePath + "/QtGui"
@@ -891,13 +885,17 @@ void tst_Moc::warnOnMultipleInheritance()
QString mocWarning = QString::fromLocal8Bit(proc.readAllStandardError());
QCOMPARE(mocWarning, QString(SRCDIR) +
QString("/warn-on-multiple-qobject-subclasses.h:53: Warning: Class Bar inherits from two QObject subclasses QWindow and Foo. This is not supported!\n"));
-}
+#else
+ QSKIP("Only tested on linux/gcc");
#endif
+}
-// Only tested on linux/gcc. Not tested when cross-compiled.
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void tst_Moc::forgottenQInterface()
{
+#ifdef MOC_CROSS_COMPILED
+ QSKIP("Not tested when cross-compiled");
+#endif
+#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
QProcess proc;
QStringList args;
args << "-I" << qtIncludePath + "/QtCore"
@@ -910,8 +908,10 @@ void tst_Moc::forgottenQInterface()
QString mocWarning = QString::fromLocal8Bit(proc.readAllStandardError());
QCOMPARE(mocWarning, QString(SRCDIR) +
QString("/forgotten-qinterface.h:55: Warning: Class Test implements the interface MyInterface but does not list it in Q_INTERFACES. qobject_cast to MyInterface will not work!\n"));
-}
+#else
+ QSKIP("Only tested on linux/gcc");
#endif
+}
void tst_Moc::os9Newline()
{
@@ -972,10 +972,12 @@ void tst_Moc::escapesInStringLiterals()
QByteArray("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\nb"));
}
-// Only tested on unix. Not tested when cross-compiled.
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS)
void tst_Moc::frameworkSearchPath()
{
+#ifdef MOC_CROSS_COMPILED
+ QSKIP("Not tested when cross-compiled");
+#endif
+#if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS)
QStringList args;
args << "-F" << srcify(".")
<< srcify("interface-from-framework.h")
@@ -992,8 +994,10 @@ void tst_Moc::frameworkSearchPath()
}
QCOMPARE(proc.exitCode(), 0);
QCOMPARE(proc.readAllStandardError(), QByteArray());
-}
+#else
+ QSKIP("Only tested/relevant on unixy platforms");
#endif
+}
void tst_Moc::cstyleEnums()
{
@@ -1006,10 +1010,12 @@ void tst_Moc::cstyleEnums()
QCOMPARE(metaEnum.key(1), "Bar");
}
-// Only tested on linux/gcc. Not tested when cross-compiled.
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void tst_Moc::templateGtGt()
{
+#ifdef MOC_CROSS_COMPILED
+ QSKIP("Not tested when cross-compiled");
+#endif
+#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
QProcess proc;
proc.start("moc", QStringList(srcify("template-gtgt.h")));
QVERIFY(proc.waitForFinished());
@@ -1018,13 +1024,14 @@ void tst_Moc::templateGtGt()
QVERIFY(!mocOut.isEmpty());
QString mocWarning = QString::fromLocal8Bit(proc.readAllStandardError());
QVERIFY(mocWarning.isEmpty());
-}
+#else
+ QSKIP("Only tested on linux/gcc");
#endif
+}
-// Only tested on linux/gcc.
-#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void tst_Moc::defineMacroViaCmdline()
{
+#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
QProcess proc;
QStringList args;
@@ -1037,8 +1044,10 @@ void tst_Moc::defineMacroViaCmdline()
QCOMPARE(proc.readAllStandardError(), QByteArray());
QByteArray mocOut = proc.readAllStandardOutput();
QVERIFY(!mocOut.isEmpty());
-}
+#else
+ QSKIP("Only tested on linux/gcc");
#endif
+}
void tst_Moc::invokable()
{
@@ -1155,10 +1164,12 @@ void tst_Moc::inlineSlotsWithThrowDeclaration()
QVERIFY(mobj->indexOfSlot("e()") != -1);
}
-// Only tested on linux/gcc. Not tested when cross-compiled.
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void tst_Moc::warnOnPropertyWithoutREAD()
{
+#ifdef MOC_CROSS_COMPILED
+ QSKIP("Not tested when cross-compiled");
+#endif
+#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
QProcess proc;
proc.start("moc", QStringList(srcify("warn-on-property-without-read.h")));
QVERIFY(proc.waitForFinished());
@@ -1168,8 +1179,10 @@ void tst_Moc::warnOnPropertyWithoutREAD()
QString mocWarning = QString::fromLocal8Bit(proc.readAllStandardError());
QCOMPARE(mocWarning, QString(SRCDIR) +
QString("/warn-on-property-without-read.h:46: Warning: Property declaration foo has no READ accessor function. The property will be invalid.\n"));
-}
+#else
+ QSKIP("Only tested on linux/gcc");
#endif
+}
void tst_Moc::constructors()
{
@@ -1261,10 +1274,12 @@ void tst_Moc::typenameWithUnsigned()
QVERIFY(mobj->indexOfSlot("l(unsignedQImage)") != -1);
}
-// Only tested on linux/gcc. Not tested when cross-compiled.
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void tst_Moc::warnOnVirtualSignal()
{
+#ifdef MOC_CROSS_COMPILED
+ QSKIP("Not tested when cross-compiled");
+#endif
+#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
QProcess proc;
proc.start("moc", QStringList(srcify("pure-virtual-signals.h")));
QVERIFY(proc.waitForFinished());
@@ -1274,8 +1289,10 @@ void tst_Moc::warnOnVirtualSignal()
QString mocWarning = QString::fromLocal8Bit(proc.readAllStandardError());
QCOMPARE(mocWarning, QString(SRCDIR) + QString("/pure-virtual-signals.h:48: Warning: Signals cannot be declared virtual\n") +
QString(SRCDIR) + QString("/pure-virtual-signals.h:50: Warning: Signals cannot be declared virtual\n"));
-}
+#else
+ QSKIP("Only tested on linux/gcc");
#endif
+}
class QTBUG5590_DummyObject: public QObject
{
@@ -1369,10 +1386,12 @@ void tst_Moc::QTBUG12260_defaultTemplate()
QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doAnotherThing(bool,bool)") != -1);
}
-// Only tested on linux/gcc. Not tested when cross-compiled.
-#if !defined(MOC_CROSS_COMPILED) && defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
void tst_Moc::notifyError()
{
+#ifdef MOC_CROSS_COMPILED
+ QSKIP("Not tested when cross-compiled");
+#endif
+#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
QProcess proc;
proc.start("moc", QStringList(srcify("error-on-wrong-notify.h")));
QVERIFY(proc.waitForFinished());
@@ -1383,8 +1402,10 @@ void tst_Moc::notifyError()
QString mocError = QString::fromLocal8Bit(proc.readAllStandardError());
QCOMPARE(mocError, QString(SRCDIR) +
QString("/error-on-wrong-notify.h:52: Error: NOTIFY signal 'fooChanged' of property 'foo' does not exist in class ClassWithWrongNOTIFY.\n"));
-}
+#else
+ QSKIP("Only tested on linux/gcc");
#endif
+}
class QTBUG_17635_InvokableAndProperty : public QObject
{
@@ -1523,8 +1544,6 @@ void tst_Moc::revisions()
revisions_T<VersionTestNotify>();
}
-// Not tested when cross-compiled.
-#ifndef MOC_CROSS_COMPILED
void tst_Moc::warnings_data()
{
QTest::addColumn<QByteArray>("input");
@@ -1608,6 +1627,9 @@ void tst_Moc::warnings_data()
void tst_Moc::warnings()
{
+#ifdef MOC_CROSS_COMPILED
+ QSKIP("Not tested when cross-compiled");
+#endif
QFETCH(QByteArray, input);
QFETCH(QStringList, args);
QFETCH(int, exitCode);
@@ -1639,7 +1661,6 @@ void tst_Moc::warnings()
QCOMPARE(QString::fromLocal8Bit(proc.readAllStandardOutput()).trimmed(), expectedStdOut);
QCOMPARE(QString::fromLocal8Bit(proc.readAllStandardError()).trimmed(), expectedStdErr);
}
-#endif
class tst_Moc::PrivateClass : public QObject {
Q_PROPERTY(int someProperty READ someSlot WRITE someSlot2)