summaryrefslogtreecommitdiffstats
path: root/tests/auto/tools/moc/tst_moc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/tools/moc/tst_moc.cpp')
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 231007af1a..a6cd85ade5 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -523,6 +523,7 @@ private slots:
void structQObject();
void namespacedFlags();
void warnOnMultipleInheritance();
+ void ignoreOptionClashes();
void forgottenQInterface();
void os9Newline();
void winNewline();
@@ -970,6 +971,46 @@ void tst_Moc::warnOnMultipleInheritance()
#endif
}
+void tst_Moc::ignoreOptionClashes()
+{
+#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;
+ const QString header = m_sourceDirectory + QStringLiteral("/interface-from-include.h");
+ const QString includeDir = m_sourceDirectory + "/Test.framework/Headers";
+ // given --ignore-option-clashes, -pthread should be ignored, but the -I path should not be.
+ args << "--ignore-option-clashes" << "-pthread" << "-I" << includeDir << "-fno-builtin" << header;
+ proc.start("moc", args);
+ bool finished = proc.waitForFinished();
+ if (!finished)
+ qWarning("waitForFinished failed. QProcess error: %d", (int)proc.error());
+ QVERIFY(finished);
+ if (proc.exitCode() != 0) {
+ qDebug() << proc.readAllStandardError();
+ }
+ QCOMPARE(proc.exitCode(), 0);
+ QCOMPARE(proc.readAllStandardError(), QByteArray());
+ QByteArray mocOut = proc.readAllStandardOutput();
+
+ // If -pthread wasn't ignored, it was parsed as a prefix of "thread/", which breaks compilation.
+ QStringList gccArgs;
+ gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+ << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null" << "-fPIE" << "-";
+ proc.start("gcc", gccArgs);
+ QVERIFY(proc.waitForStarted());
+ proc.write(mocOut);
+ proc.closeWriteChannel();
+
+ QVERIFY(proc.waitForFinished());
+ QCOMPARE(QString::fromLocal8Bit(proc.readAllStandardError()), QString());
+#else
+ QSKIP("Only tested on linux/gcc");
+#endif
+}
+
void tst_Moc::forgottenQInterface()
{
#ifdef MOC_CROSS_COMPILED