diff options
author | Rohan McGovern <rohan.mcgovern@nokia.com> | 2012-02-22 11:09:23 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-22 02:17:35 +0100 |
commit | b09a7971daeea7e42af2f4f5ae3a12b29c1692e2 (patch) | |
tree | 28d6338642e95c268b65607c9bfca7f015e78e10 /tests | |
parent | 65d2458408ccda1b37e1069fd13791a60fa0c672 (diff) | |
download | qtxmlpatterns-b09a7971daeea7e42af2f4f5ae3a12b29c1692e2.tar.gz |
Fixed failure of tst_xmlpatterns due to Qt plugin loading changes
The test tries to verify that the xmlpatterns command outputs nothing on
standard error. Qt makes this difficult by warning about some plugins
(unrelated to xmlpatterns) using the old plugin API.
Those plugins should be updated, but the warnings are irrelevant to
xmlpatterns, so ignore them.
Change-Id: I3c8cb0145a326a82eed3db547c5ae68315ec3cf1
Reviewed-by: Toby Tomkins <toby.tomkins@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/xmlpatterns/tst_xmlpatterns.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp index 2d67bcd..abae5d8 100644 --- a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp +++ b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp @@ -81,6 +81,8 @@ private: static void createNonWritable(const QString &name); static void removeNonWritable(QFile &outFile); + QString filterStderr(const QString &in); + int m_generatedTests; /** * Get rid of characters that complicates on various file systems. @@ -89,14 +91,12 @@ private: /** * @note Perforce disallows wildcards in the name. */ - const QRegExp m_filenameInStderr; const QString m_command; bool m_dontRun; }; tst_XmlPatterns::tst_XmlPatterns() : m_generatedTests(0) , m_normalizeTestName(QLatin1String("[\\*\\?#\\-\\/:; ()',&]")) - , m_filenameInStderr(QLatin1String("file:\\/\\/.*(\\.xq|\\.gccxml|\\.xml|\\.xsl|-)(,|:)")) , m_command(QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/xmlpatterns")) , m_dontRun(false) { @@ -107,7 +107,6 @@ void tst_XmlPatterns::initTestCase() QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); QVERIFY(m_normalizeTestName.isValid()); - QVERIFY(m_filenameInStderr.isValid()); QProcess process; process.start(m_command); @@ -158,7 +157,7 @@ void tst_XmlPatterns::xquerySupport() QCOMPARE(process.exitCode(), expectedExitCode); const QByteArray rawProducedStderr((process.readAllStandardError())); - QString fixedStderr(QString::fromLocal8Bit(rawProducedStderr).remove(m_filenameInStderr)); + QString fixedStderr = filterStderr(QString::fromLocal8Bit(rawProducedStderr)); // convert Windows line endings to Unix ones fixedStderr.replace("\r\n", "\n"); @@ -176,7 +175,7 @@ void tst_XmlPatterns::xquerySupport() /* On Windows, at least MinGW, this differs. */ if(qstrcmp(QTest::currentDataTag(), "-output with a non-writable file") == 0) { - QVERIFY(fixedStderr == rawExpectedStdErr.remove(m_filenameInStderr) || + QVERIFY(fixedStderr == filterStderr(rawExpectedStdErr) || fixedStderr.trimmed() == "Failed to open file notWritable.out for writing: Access is denied."); } else if(qstrcmp(QTest::currentDataTag(), "Invoke -version") == 0) @@ -188,7 +187,7 @@ void tst_XmlPatterns::xquerySupport() QCOMPARE(QString(fixedStderr).remove(removeVersion) + QChar('|'), rawExpectedStdErr + QChar('|')); } else - QCOMPARE(fixedStderr, rawExpectedStdErr.remove(m_filenameInStderr)); + QCOMPARE(fixedStderr, filterStderr(rawExpectedStdErr)); } else { @@ -1009,6 +1008,29 @@ void tst_XmlPatterns::xsltSupport_data() const // TODO invoke a template which has required params. } +/* + Return a copy of some stderr text with some irrelevant things filtered. +*/ +QString tst_XmlPatterns::filterStderr(const QString &in) +{ + static QList<QRegExp> irrelevant = QList<QRegExp>() + + // specific filenames + << QRegExp(QLatin1String("file:\\/\\/.*(\\.xq|\\.gccxml|\\.xml|\\.xsl|-)(,|:)")) + + // warning messages about old-style plugins + << QRegExp(QLatin1String("Old plugin format found in lib [^\n]+\n")) + << QRegExp(QLatin1String("Qt plugin loader: Compatibility plugin [^\n]+\n")) + ; + + QString out = in; + foreach (const QRegExp& rx, irrelevant) { + out = out.remove(rx); + } + + return out; +} + QTEST_MAIN(tst_XmlPatterns) #include "tst_xmlpatterns.moc" |