summaryrefslogtreecommitdiffstats
path: root/tests/auto/linguist/lupdate/tst_lupdate.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-01-06 11:36:35 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-01-06 18:16:22 (GMT)
commitb1b6b0aae294def9b7d04a1fea387d82ed852026 (patch)
tree053f7c8f0ea999ac140f36982a3c30d60b78dd90 /tests/auto/linguist/lupdate/tst_lupdate.cpp
parent40e3c68a38152ecdc354a2d503490f9b0ff49740 (diff)
downloadQt-b1b6b0aae294def9b7d04a1fea387d82ed852026.zip
Qt-b1b6b0aae294def9b7d04a1fea387d82ed852026.tar.gz
Qt-b1b6b0aae294def9b7d04a1fea387d82ed852026.tar.bz2
make the lupdate tests more verbose in case of failure
on the way, replace the convoluted TestLUpdate class with a few QProcess calls.
Diffstat (limited to 'tests/auto/linguist/lupdate/tst_lupdate.cpp')
-rw-r--r--tests/auto/linguist/lupdate/tst_lupdate.cpp50
1 files changed, 36 insertions, 14 deletions
diff --git a/tests/auto/linguist/lupdate/tst_lupdate.cpp b/tests/auto/linguist/lupdate/tst_lupdate.cpp
index 02bb71e..80c8f4f 100644
--- a/tests/auto/linguist/lupdate/tst_lupdate.cpp
+++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp
@@ -39,7 +39,6 @@
**
****************************************************************************/
-#include "testlupdate.h"
#if CHECK_SIMTEXTH
#include "../shared/simtexth.h"
#endif
@@ -55,7 +54,7 @@ class tst_lupdate : public QObject
{
Q_OBJECT
public:
- tst_lupdate() { m_basePath = QDir::currentPath() + QLatin1String("/testdata/"); }
+ tst_lupdate();
private slots:
void good_data();
@@ -68,7 +67,7 @@ private slots:
#endif
private:
- TestLUpdate m_lupdate;
+ QString m_cmdLupdate;
QString m_basePath;
void doCompare(const QStringList &actual, const QString &expectedFn, bool err);
@@ -76,10 +75,17 @@ private:
};
+tst_lupdate::tst_lupdate()
+{
+ QString binPath = QLibraryInfo::location(QLibraryInfo::BinariesPath);
+ m_cmdLupdate = binPath + QLatin1String("/lupdate");
+ m_basePath = QDir::currentPath() + QLatin1String("/testdata/");
+}
+
void tst_lupdate::doCompare(const QStringList &actual, const QString &expectedFn, bool err)
{
QFile file(expectedFn);
- QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
+ QVERIFY2(file.open(QIODevice::ReadOnly | QIODevice::Text), qPrintable(expectedFn));
QStringList expected = QString(file.readAll()).trimmed().split('\n');
int i = 0, ei = expected.size(), gi = actual.size();
@@ -140,7 +146,7 @@ void tst_lupdate::doCompare(const QStringList &actual, const QString &expectedFn
void tst_lupdate::doCompare(const QString &actualFn, const QString &expectedFn, bool err)
{
QFile afile(actualFn);
- QVERIFY(afile.open(QIODevice::ReadOnly | QIODevice::Text));
+ QVERIFY2(afile.open(QIODevice::ReadOnly | QIODevice::Text), qPrintable(actualFn));
QStringList actual = QString(afile.readAll()).trimmed().split('\n');
doCompare(actual, expectedFn, err);
@@ -169,14 +175,13 @@ void tst_lupdate::good()
qDebug() << "Checking...";
- QString generatedtsfile(QLatin1String("project.ts"));
+ QString generatedtsfile(dir + QLatin1String("/project.ts"));
- m_lupdate.setWorkingDirectory(dir);
// look for a command
QString lupdatecmd;
QFile file(dir + "/lupdatecmd");
if (file.exists()) {
- QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
+ QVERIFY2(file.open(QIODevice::ReadOnly | QIODevice::Text), qPrintable(file.fileName()));
while (!file.atEnd()) {
QByteArray cmdstring = file.readLine().simplified();
if (cmdstring.startsWith('#'))
@@ -201,14 +206,24 @@ void tst_lupdate::good()
if (lupdatecmd.isEmpty())
lupdatecmd = QLatin1String("project.pro");
lupdatecmd.prepend("-silent ");
- m_lupdate.updateProFile(lupdatecmd);
+
+ QProcess proc;
+ proc.setWorkingDirectory(dir);
+ proc.setProcessChannelMode(QProcess::MergedChannels);
+ proc.start(m_cmdLupdate + ' ' + lupdatecmd, QIODevice::ReadWrite | QIODevice::Text);
+ QVERIFY2(proc.waitForFinished(5000), qPrintable(lupdatecmd));
+ QByteArray output = proc.readAll().trimmed();
+ QVERIFY2(proc.exitStatus() == QProcess::NormalExit,
+ "\"lupdate " + lupdatecmd.toLatin1() + "\" crashed\n" + output);
+ QVERIFY2(!proc.exitCode(),
+ "\"lupdate " + lupdatecmd.toLatin1() + "\" exited with code " +
+ QByteArray::number(proc.exitCode()) + "\n" + proc.readAll());
// If the file expectedoutput.txt exists, compare the
// console output with the content of that file
QFile outfile(dir + "/expectedoutput.txt");
if (outfile.exists()) {
- QString errs = m_lupdate.getErrorMessages().at(1).trimmed();
- QStringList errslist = errs.split(QLatin1Char('\n'));
+ QStringList errslist = QString::fromLatin1(output).split(QLatin1Char('\n'));
doCompare(errslist, outfile.fileName(), true);
if (QTest::currentTestFailed())
return;
@@ -238,14 +253,21 @@ void tst_lupdate::commandline()
QFETCH(QString, generatedtsfile);
QFETCH(QString, expectedtsfile);
- m_lupdate.setWorkingDirectory(m_basePath + currentPath);
QString generated =
m_basePath + currentPath + QLatin1Char('/') + generatedtsfile;
QFile gen(generated);
if (gen.exists())
QVERIFY(gen.remove());
- if (!m_lupdate.run("-silent " + commandline))
- qDebug() << m_lupdate.getErrorMessages().last();
+ QProcess proc;
+ proc.setWorkingDirectory(m_basePath + currentPath);
+ proc.setProcessChannelMode(QProcess::MergedChannels);
+ proc.start(m_cmdLupdate + " -silent " + commandline, QIODevice::ReadWrite | QIODevice::Text);
+ QVERIFY2(proc.waitForFinished(5000), qPrintable(commandline));
+ QVERIFY2(proc.exitStatus() == QProcess::NormalExit,
+ "\"lupdate -silent " + commandline.toLatin1() + "\" crashed\n" + proc.readAll());
+ QVERIFY2(!proc.exitCode(),
+ "\"lupdate -silent " + commandline.toLatin1() + "\" exited with code " +
+ QByteArray::number(proc.exitCode()) + "\n" + proc.readAll());
doCompare(generated, m_basePath + currentPath + QLatin1Char('/') + expectedtsfile, false);
}