summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2009-04-06 09:00:05 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-04-06 10:17:57 (GMT)
commitd071b3528f51aaded18029f2f22e8db03e47a2a6 (patch)
treed53658a164bd918fa3c30efaff25364a979b18b5 /tests
parent10ba12c7b73b89761a43a450c2932c8a56bf64db (diff)
downloadQt-d071b3528f51aaded18029f2f22e8db03e47a2a6.zip
Qt-d071b3528f51aaded18029f2f22e8db03e47a2a6.tar.gz
Qt-d071b3528f51aaded18029f2f22e8db03e47a2a6.tar.bz2
Remove QTDIR dependency from moc autotest
Use qmake -query QT_INSTALL_HEADERS at test startup time instead of relying on the dead QTDIR environment variable. Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/moc/tst_moc.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp
index 4d31dfc..4e4f6e7 100644
--- a/tests/auto/moc/tst_moc.cpp
+++ b/tests/auto/moc/tst_moc.cpp
@@ -466,6 +466,8 @@ public:
inline tst_Moc() {}
private slots:
+ void initTestCase();
+
void slotWithException() throw(MyStruct);
void dontStripNamespaces();
void oldStyleCasts();
@@ -519,8 +521,28 @@ private:
bool user2() { return false; };
bool user3() { return false; };
bool userFunction(){ return false; };
+
+private:
+ QString qtIncludePath;
};
+void tst_Moc::initTestCase()
+{
+#if defined(Q_OS_UNIX)
+ QProcess proc;
+ proc.start("qmake", QStringList() << "-query" << "QT_INSTALL_HEADERS");
+ QVERIFY(proc.waitForFinished());
+ QCOMPARE(proc.exitCode(), 0);
+ QByteArray output = proc.readAllStandardOutput();
+ QVERIFY(!output.isEmpty());
+ QCOMPARE(proc.readAllStandardError(), QByteArray());
+ qtIncludePath = QString::fromLocal8Bit(output).trimmed();
+ QFileInfo fi(qtIncludePath);
+ QVERIFY(fi.exists());
+ QVERIFY(fi.isDir());
+#endif
+}
+
void tst_Moc::slotWithException() throw(MyStruct)
{
// be happy
@@ -552,8 +574,6 @@ void tst_Moc::oldStyleCasts()
QSKIP("Not tested when cross-compiled", SkipAll);
#endif
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU)
- QVERIFY(!qgetenv("QTDIR").isNull());
-
QProcess proc;
proc.start("moc", QStringList(srcify("/oldstyle-casts.h")));
QVERIFY(proc.waitForFinished());
@@ -564,7 +584,7 @@ void tst_Moc::oldStyleCasts()
QStringList args;
args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
- << "-I" << qgetenv("QTDIR") + "/include" << "-o" << "/dev/null" << "-";
+ << "-I" << qtIncludePath << "-o" << "/dev/null" << "-";
proc.start("gcc", args);
QVERIFY(proc.waitForStarted());
proc.write(mocOut);
@@ -639,7 +659,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
QStringList args;
args << "-c" << "-x" << "c++" << "-I" << ".."
- << "-I" << qgetenv("QTDIR") + "/include" << "-o" << "/dev/null" << "-";
+ << "-I" << qtIncludePath << "-o" << "/dev/null" << "-";
proc.start("gcc", args);
QVERIFY(proc.waitForStarted());
proc.write(mocOut);
@@ -844,11 +864,9 @@ void tst_Moc::warnOnMultipleInheritance()
QSKIP("Not tested when cross-compiled", SkipAll);
#endif
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU)
- QVERIFY(!qgetenv("QTDIR").isNull());
-
QProcess proc;
QStringList args;
- args << "-I" << qgetenv("QTDIR") + "/include/QtGui"
+ args << "-I" << qtIncludePath + "/QtGui"
<< srcify("warn-on-multiple-qobject-subclasses.h");
proc.start("moc", args);
QVERIFY(proc.waitForFinished());
@@ -869,11 +887,9 @@ void tst_Moc::forgottenQInterface()
QSKIP("Not tested when cross-compiled", SkipAll);
#endif
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU)
- QVERIFY(!qgetenv("QTDIR").isNull());
-
QProcess proc;
QStringList args;
- args << "-I" << qgetenv("QTDIR") + "/include/QtCore"
+ args << "-I" << qtIncludePath + "/QtCore"
<< srcify("forgotten-qinterface.h");
proc.start("moc", args);
QVERIFY(proc.waitForFinished());