make linguist test work with shadow builds
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>
Thu, 6 Sep 2012 14:54:34 +0000 (16:54 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 20 Sep 2012 12:35:15 +0000 (14:35 +0200)
Change-Id: I8aefcd88f95f6527f62029cc8afc88d42b02ec33
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
tests/auto/linguist/lconvert/tst_lconvert.cpp
tests/auto/linguist/lrelease/testdata/dupes.errors
tests/auto/linguist/lrelease/tst_lrelease.cpp
tests/auto/linguist/lupdate/tst_lupdate.cpp

index a5d7602..d6a676d 100644 (file)
@@ -47,7 +47,7 @@ class tst_lconvert : public QObject
     Q_OBJECT
 
 public:
-    tst_lconvert() : dataDir("data/"), binDir(QLibraryInfo::location(QLibraryInfo::BinariesPath)) {}
+    tst_lconvert() : dataDir(QFINDTESTDATA("data/")), binDir(QLibraryInfo::location(QLibraryInfo::BinariesPath)) {}
 
 private slots:
     void initTestCase();
@@ -78,9 +78,9 @@ private:
 
 void tst_lconvert::initTestCase()
 {
-    if (!QFile::exists(QLatin1String("data/plural-1.po")))
-        QProcess::execute(QLatin1String("perl"), QStringList() << QLatin1String("data/makeplurals.pl") << QLatin1String("data/"));
-    QVERIFY(QFile::exists(QLatin1String("data/plural-1.po")));
+    if (!QFile::exists(dataDir + QLatin1String("plural-1.po")))
+        QProcess::execute(QLatin1String("perl"), QStringList() << dataDir + QLatin1String("makeplurals.pl") << dataDir + QLatin1String(""));
+    QVERIFY(QFile::exists(dataDir + QLatin1String("plural-1.po")));
 }
 
 void tst_lconvert::doWait(QProcess *cvt, int stage)
index 74fcbbb..9af5f05 100644 (file)
@@ -1,4 +1,4 @@
-Warning: dropping duplicate messages in 'testdata/dupes\.qm':
+Warning: dropping duplicate messages in '.*testdata/dupes\.qm':
 
 \* Context: FindDialog
 \* Source: Text not found
index a7a040d..f3368f7 100644 (file)
@@ -51,7 +51,10 @@ class tst_lrelease : public QObject
     Q_OBJECT
 
 public:
-    tst_lrelease() : binDir(QLibraryInfo::location(QLibraryInfo::BinariesPath)) {}
+    tst_lrelease()
+         : binDir(QLibraryInfo::location(QLibraryInfo::BinariesPath))
+         , dataDir(QFINDTESTDATA("testdata/"))
+    {}
 
 private:
 
@@ -67,6 +70,7 @@ private:
     void doCompare(const QStringList &actual, const QString &expectedFn);
 
     QString binDir;
+    QString dataDir;
 };
 
 void tst_lrelease::doCompare(const QStringList &actual, const QString &expectedFn)
@@ -119,10 +123,10 @@ void tst_lrelease::doCompare(const QStringList &actual, const QString &expectedF
 
 void tst_lrelease::translate()
 {
-    QVERIFY(!QProcess::execute(binDir + "/lrelease testdata/translate.ts"));
+    QVERIFY(!QProcess::execute(binDir + "/lrelease " + dataDir + "translate.ts"));
 
     QTranslator translator;
-    QVERIFY(translator.load("testdata/translate.qm"));
+    QVERIFY(translator.load(dataDir + "translate.qm"));
     qApp->installTranslator(&translator);
 
     QCOMPARE(QObject::tr("\nnewline at the start"), QString("\nNEWLINE AT THE START"));
@@ -169,16 +173,16 @@ void tst_lrelease::translate()
 
 void tst_lrelease::mixedcodecs()
 {
-    QVERIFY(!QProcess::execute(binDir + "/lrelease testdata/mixedcodecs-ts11.ts"));
-    QVERIFY(!QProcess::execute(binDir + "/lrelease testdata/mixedcodecs-ts20.ts"));
+    QVERIFY(!QProcess::execute(binDir + "/lrelease " + dataDir + "mixedcodecs-ts11.ts"));
+    QVERIFY(!QProcess::execute(binDir + "/lrelease " + dataDir + "mixedcodecs-ts20.ts"));
 #ifdef Q_OS_WIN
     QVERIFY(!QProcess::execute("fc /b testdata\\mixedcodecs-ts11.qm testdata\\mixedcodecs-ts20.qm"));
 #else
-    QVERIFY(!QProcess::execute("cmp testdata/mixedcodecs-ts11.qm testdata/mixedcodecs-ts20.qm"));
+    QVERIFY(!QProcess::execute("cmp " + dataDir + "mixedcodecs-ts11.qm " + dataDir + "mixedcodecs-ts20.qm"));
 #endif
 
     QTranslator translator;
-    QVERIFY(translator.load("testdata/mixedcodecs-ts11.qm"));
+    QVERIFY(translator.load(dataDir + "mixedcodecs-ts11.qm"));
     qApp->installTranslator(&translator);
 
     QCOMPARE(QCoreApplication::translate("FooBar", "this contains an umlaut \xfc &uuml;"),
@@ -189,10 +193,10 @@ void tst_lrelease::mixedcodecs()
 
 void tst_lrelease::compressed()
 {
-    QVERIFY(!QProcess::execute(binDir + "/lrelease -compress testdata/compressed.ts"));
+    QVERIFY(!QProcess::execute(binDir + "/lrelease -compress " + dataDir + "compressed.ts"));
 
     QTranslator translator;
-    QVERIFY(translator.load("testdata/compressed.qm"));
+    QVERIFY(translator.load(dataDir + "compressed.qm"));
     qApp->installTranslator(&translator);
 
     QCOMPARE(QCoreApplication::translate("Context1", "Foo"), QString::fromLatin1("in first context"));
@@ -206,10 +210,10 @@ void tst_lrelease::compressed()
 
 void tst_lrelease::idbased()
 {
-    QVERIFY(!QProcess::execute(binDir + "/lrelease -idbased testdata/idbased.ts"));
+    QVERIFY(!QProcess::execute(binDir + "/lrelease -idbased " + dataDir + "idbased.ts"));
 
     QTranslator translator;
-    QVERIFY(translator.load("testdata/idbased.qm"));
+    QVERIFY(translator.load(dataDir + "idbased.qm"));
     qApp->installTranslator(&translator);
 
     QCOMPARE(qtTrId("test_id"), QString::fromLatin1("This is a test string."));
@@ -218,10 +222,10 @@ void tst_lrelease::idbased()
 
 void tst_lrelease::markuntranslated()
 {
-    QVERIFY(!QProcess::execute(binDir + "/lrelease -markuntranslated # -idbased testdata/idbased.ts"));
+    QVERIFY(!QProcess::execute(binDir + "/lrelease -markuntranslated # -idbased " + dataDir + "idbased.ts"));
 
     QTranslator translator;
-    QVERIFY(translator.load("testdata/idbased.qm"));
+    QVERIFY(translator.load(dataDir + "idbased.qm"));
     qApp->installTranslator(&translator);
 
     QCOMPARE(qtTrId("test_id"), QString::fromLatin1("This is a test string."));
@@ -231,10 +235,10 @@ void tst_lrelease::markuntranslated()
 void tst_lrelease::dupes()
 {
     QProcess proc;
-    proc.start(binDir + "/lrelease testdata/dupes.ts", QIODevice::ReadWrite | QIODevice::Text);
+    proc.start(binDir + "/lrelease " + dataDir + "dupes.ts", QIODevice::ReadWrite | QIODevice::Text);
     QVERIFY(proc.waitForFinished());
     QVERIFY(proc.exitStatus() == QProcess::NormalExit);
-    doCompare(QString(proc.readAllStandardError()).trimmed().split('\n'), "testdata/dupes.errors");
+    doCompare(QString(proc.readAllStandardError()).trimmed().split('\n'), dataDir + "dupes.errors");
 }
 
 QTEST_MAIN(tst_lrelease)
index e3803da..6587b41 100644 (file)
@@ -77,7 +77,7 @@ tst_lupdate::tst_lupdate()
 {
     QString binPath = QLibraryInfo::location(QLibraryInfo::BinariesPath);
     m_cmdLupdate = binPath + QLatin1String("/lupdate");
-    m_basePath = QDir::currentPath() + QLatin1String("/testdata/");
+    m_basePath = QFINDTESTDATA("testdata/");
 }
 
 static bool prepareMatch(const QString &expect, QString *tmpl, int *require, int *accept)