summaryrefslogtreecommitdiffstats
path: root/tests/auto/testlib
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2013-11-12 15:03:54 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-17 19:10:22 +0100
commit943ae8bb701a8187d295b747ba82025c55ca9add (patch)
treec851d2d4d82d53a5df7f32a175996d425821cc17 /tests/auto/testlib
parent331bc16afd23414493b842819e0b747e8f364243 (diff)
Add overload of QTest::ignoreMessage() taking a QRegularExpression.
Make it possible to match messages by a pattern. Change-Id: I713312e86db5471755459f1ecc43e8f1ac7a95fb Reviewed-by: Jason McDonald <macadder1@gmail.com>
Diffstat (limited to 'tests/auto/testlib')
-rw-r--r--tests/auto/testlib/selftests/expected_warnings.lightxml14
-rw-r--r--tests/auto/testlib/selftests/expected_warnings.txt6
-rw-r--r--tests/auto/testlib/selftests/expected_warnings.xml14
-rw-r--r--tests/auto/testlib/selftests/expected_warnings.xunitxml11
-rw-r--r--tests/auto/testlib/selftests/warnings/tst_warnings.cpp17
5 files changed, 60 insertions, 2 deletions
diff --git a/tests/auto/testlib/selftests/expected_warnings.lightxml b/tests/auto/testlib/selftests/expected_warnings.lightxml
index ad786832ca..2ad9e97449 100644
--- a/tests/auto/testlib/selftests/expected_warnings.lightxml
+++ b/tests/auto/testlib/selftests/expected_warnings.lightxml
@@ -24,6 +24,12 @@
<Message type="qdebug" file="" line="0">
<Description><![CDATA[Baba]]></Description>
</Message>
+<Message type="qdebug" file="" line="0">
+ <Description><![CDATA[Bubublabla]]></Description>
+</Message>
+<Message type="qwarn" file="" line="0">
+ <Description><![CDATA[Babablabla]]></Description>
+</Message>
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="testMissingWarnings">
@@ -37,6 +43,14 @@
<Description><![CDATA[Not all expected messages were received]]></Description>
</Incident>
</TestFunction>
+<TestFunction name="testMissingWarningsRegularExpression">
+<Message type="info" file="" line="0">
+ <Description><![CDATA[Did not receive any message matching: "Warning\s\d"]]></Description>
+</Message>
+<Incident type="fail" file="" line="0">
+ <Description><![CDATA[Not all expected messages were received]]></Description>
+</Incident>
+</TestFunction>
<TestFunction name="testMissingWarningsWithData">
<Message type="info" file="" line="0">
<DataTag><![CDATA[first row]]></DataTag>
diff --git a/tests/auto/testlib/selftests/expected_warnings.txt b/tests/auto/testlib/selftests/expected_warnings.txt
index d8064651b0..e73de980cb 100644
--- a/tests/auto/testlib/selftests/expected_warnings.txt
+++ b/tests/auto/testlib/selftests/expected_warnings.txt
@@ -7,10 +7,14 @@ QDEBUG : tst_Warnings::testWarnings() Debug
QDEBUG : tst_Warnings::testWarnings() Debug
QDEBUG : tst_Warnings::testWarnings() Baba
QDEBUG : tst_Warnings::testWarnings() Baba
+QDEBUG : tst_Warnings::testWarnings() Bubublabla
+QWARN : tst_Warnings::testWarnings() Babablabla
PASS : tst_Warnings::testWarnings()
INFO : tst_Warnings::testMissingWarnings() Did not receive message: "Warning0"
INFO : tst_Warnings::testMissingWarnings() Did not receive message: "Warning1"
FAIL! : tst_Warnings::testMissingWarnings() Not all expected messages were received
+INFO : tst_Warnings::testMissingWarningsRegularExpression() Did not receive any message matching: "Warning\s\d"
+FAIL! : tst_Warnings::testMissingWarningsRegularExpression() Not all expected messages were received
INFO : tst_Warnings::testMissingWarningsWithData(first row) Did not receive message: "Warning0"
INFO : tst_Warnings::testMissingWarningsWithData(first row) Did not receive message: "Warning1"
FAIL! : tst_Warnings::testMissingWarningsWithData(first row) Not all expected messages were received
@@ -18,5 +22,5 @@ INFO : tst_Warnings::testMissingWarningsWithData(second row) Did not receive m
INFO : tst_Warnings::testMissingWarningsWithData(second row) Did not receive message: "Warning1"
FAIL! : tst_Warnings::testMissingWarningsWithData(second row) Not all expected messages were received
PASS : tst_Warnings::cleanupTestCase()
-Totals: 3 passed, 3 failed, 0 skipped
+Totals: 3 passed, 4 failed, 0 skipped
********* Finished testing of tst_Warnings *********
diff --git a/tests/auto/testlib/selftests/expected_warnings.xml b/tests/auto/testlib/selftests/expected_warnings.xml
index 8ad236b52a..14a45ca4fd 100644
--- a/tests/auto/testlib/selftests/expected_warnings.xml
+++ b/tests/auto/testlib/selftests/expected_warnings.xml
@@ -26,6 +26,12 @@
<Message type="qdebug" file="" line="0">
<Description><![CDATA[Baba]]></Description>
</Message>
+<Message type="qdebug" file="" line="0">
+ <Description><![CDATA[Bubublabla]]></Description>
+</Message>
+<Message type="qwarn" file="" line="0">
+ <Description><![CDATA[Babablabla]]></Description>
+</Message>
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="testMissingWarnings">
@@ -39,6 +45,14 @@
<Description><![CDATA[Not all expected messages were received]]></Description>
</Incident>
</TestFunction>
+<TestFunction name="testMissingWarningsRegularExpression">
+<Message type="info" file="" line="0">
+ <Description><![CDATA[Did not receive any message matching: "Warning\s\d"]]></Description>
+</Message>
+<Incident type="fail" file="" line="0">
+ <Description><![CDATA[Not all expected messages were received]]></Description>
+</Incident>
+</TestFunction>
<TestFunction name="testMissingWarningsWithData">
<Message type="info" file="" line="0">
<DataTag><![CDATA[first row]]></DataTag>
diff --git a/tests/auto/testlib/selftests/expected_warnings.xunitxml b/tests/auto/testlib/selftests/expected_warnings.xunitxml
index 3e3b9ce18e..7be47174c6 100644
--- a/tests/auto/testlib/selftests/expected_warnings.xunitxml
+++ b/tests/auto/testlib/selftests/expected_warnings.xunitxml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<testsuite errors="12" failures="3" tests="5" name="tst_Warnings">
+<testsuite errors="15" failures="4" tests="6" name="tst_Warnings">
<properties>
<property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/>
<property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/>
@@ -12,12 +12,18 @@
<!-- message="Debug" type="qdebug" -->
<!-- message="Baba" type="qdebug" -->
<!-- message="Baba" type="qdebug" -->
+ <!-- message="Bubublabla" type="qdebug" -->
+ <!-- message="Babablabla" type="qwarn" -->
</testcase>
<testcase result="fail" name="testMissingWarnings">
<!-- message="Did not receive message: &quot;Warning0&quot;" type="info" -->
<!-- message="Did not receive message: &quot;Warning1&quot;" type="info" -->
<failure message="Not all expected messages were received" result="fail"/>
</testcase>
+ <testcase result="fail" name="testMissingWarningsRegularExpression">
+ <!-- message="Did not receive any message matching: &quot;Warning\s\d&quot;" type="info" -->
+ <failure message="Not all expected messages were received" result="fail"/>
+ </testcase>
<testcase result="fail" name="testMissingWarningsWithData">
<!-- tag="first row" message="Did not receive message: &quot;Warning0&quot;" type="info" -->
<!-- tag="first row" message="Did not receive message: &quot;Warning1&quot;" type="info" -->
@@ -34,8 +40,11 @@
<![CDATA[Debug]]>
<![CDATA[Baba]]>
<![CDATA[Baba]]>
+<![CDATA[Bubublabla]]>
+<![CDATA[Babablabla]]>
<![CDATA[Did not receive message: "Warning0"]]>
<![CDATA[Did not receive message: "Warning1"]]>
+<![CDATA[Did not receive any message matching: "Warning\s\d"]]>
<![CDATA[Did not receive message: "Warning0"]]>
<![CDATA[Did not receive message: "Warning1"]]>
<![CDATA[Did not receive message: "Warning0"]]>
diff --git a/tests/auto/testlib/selftests/warnings/tst_warnings.cpp b/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
index 20f53fdc91..ff4357f11f 100644
--- a/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
+++ b/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
@@ -41,6 +41,7 @@
#include <QtCore/QCoreApplication>
+#include <QtCore/QRegularExpression>
#include <QtTest/QtTest>
class tst_Warnings: public QObject
@@ -49,6 +50,7 @@ class tst_Warnings: public QObject
private slots:
void testWarnings();
void testMissingWarnings();
+ void testMissingWarningsRegularExpression();
void testMissingWarningsWithData_data();
void testMissingWarningsWithData();
};
@@ -73,6 +75,13 @@ void tst_Warnings::testWarnings()
qDebug("Baba");
qDebug("Bubu");
qDebug("Baba");
+
+ QTest::ignoreMessage(QtDebugMsg, QRegularExpression("^Bubu.*"));
+ QTest::ignoreMessage(QtWarningMsg, QRegularExpression("^Baba.*"));
+ qDebug("Bubublabla");
+ qWarning("Babablabla");
+ qDebug("Bubublabla");
+ qWarning("Babablabla");
}
void tst_Warnings::testMissingWarnings()
@@ -84,6 +93,14 @@ void tst_Warnings::testMissingWarnings()
qWarning("Warning2");
}
+void tst_Warnings::testMissingWarningsRegularExpression()
+{
+ QTest::ignoreMessage(QtWarningMsg, QRegularExpression("Warning\\d\\d"));
+ QTest::ignoreMessage(QtWarningMsg, QRegularExpression("Warning\\s\\d"));
+
+ qWarning("Warning11");
+}
+
void tst_Warnings::testMissingWarningsWithData_data()
{
QTest::addColumn<int>("dummy");