From 2d194009379a4e199ec246ca053ee97ee733482f Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 6 May 2009 10:31:28 +1000 Subject: Made tst_Selftests::checkXML actually test the new (Qt 4.6) test logger. Previously `-flush' was always passed to the child process, meaning the old (Qt 4.5) test logger was used exclusively in this test, hiding bugs. --- tests/auto/selftests/badxml/tst_badxml.cpp | 7 ++++ tests/auto/selftests/tst_selftests.cpp | 63 +++++++++++++++++------------- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/tests/auto/selftests/badxml/tst_badxml.cpp b/tests/auto/selftests/badxml/tst_badxml.cpp index 6b2e4c4..fa5b717 100644 --- a/tests/auto/selftests/badxml/tst_badxml.cpp +++ b/tests/auto/selftests/badxml/tst_badxml.cpp @@ -58,6 +58,8 @@ private slots: void badMessage() const; void badMessage_data() const; + void failWithNoFile() const; + public: static QList const& badStrings(); }; @@ -116,6 +118,11 @@ void tst_BadXml::badDataTag_data() const } } +void tst_BadXml::failWithNoFile() const +{ + QTest::qFail("failure message", 0, 0); +} + /* Outputs a message containing a bad string. */ diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index aa1048b..d4069b1 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -324,34 +324,41 @@ void tst_Selftests::checkXML() const if(m_checkXMLBlacklist.contains(subdir)) return; - arguments.prepend("-xml"); - arguments.prepend("-flush"); - - QProcess proc; - proc.setEnvironment(QStringList("")); - proc.start(subdir + "/" + subdir, arguments); - QVERIFY(proc.waitForFinished()); - - QByteArray out(proc.readAllStandardOutput()); - QByteArray err(proc.readAllStandardError()); - - /* Some platforms decides to output a message for uncaught exceptions. For instance, - * this is what windows platforms says: - * "This application has requested the Runtime to terminate it in an unusual way. - * Please contact the application's support team for more information." */ - if(subdir != QLatin1String("exception") && subdir != QLatin1String("fetchbogus")) - QVERIFY2(err.isEmpty(), err.constData()); - - QXmlStreamReader reader(out); - - while(!reader.atEnd()) - reader.readNext(); - - QVERIFY2(!reader.error(), qPrintable(QString("line %1, col %2: %3") - .arg(reader.lineNumber()) - .arg(reader.columnNumber()) - .arg(reader.errorString()) - )); + QStringList args; + /* Test both old (-flush) and new XML logger implementation */ + for (int i = 0; i < 2; ++i) { + bool flush = i; + args = arguments; + args.prepend("-xml"); + if (flush) args.prepend("-flush"); + + QProcess proc; + proc.setEnvironment(QStringList("")); + proc.start(subdir + "/" + subdir, args); + QVERIFY(proc.waitForFinished()); + + QByteArray out(proc.readAllStandardOutput()); + QByteArray err(proc.readAllStandardError()); + + /* Some platforms decides to output a message for uncaught exceptions. For instance, + * this is what windows platforms says: + * "This application has requested the Runtime to terminate it in an unusual way. + * Please contact the application's support team for more information." */ + if(subdir != QLatin1String("exception") && subdir != QLatin1String("fetchbogus")) + QVERIFY2(err.isEmpty(), err.constData()); + + QXmlStreamReader reader(out); + + while(!reader.atEnd()) + reader.readNext(); + + QVERIFY2(!reader.error(), qPrintable(QString("(flush %0) line %1, col %2: %3") + .arg(flush) + .arg(reader.lineNumber()) + .arg(reader.columnNumber()) + .arg(reader.errorString()) + )); + } } void tst_Selftests::checkXunitxml() const -- cgit v0.12