Remove XFAIL from selftests for some platforms
authorJason McDonald <jason.mcdonald@nokia.com>
Wed, 31 Aug 2011 04:14:06 +0000 (14:14 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 31 Aug 2011 11:12:43 +0000 (13:12 +0200)
The selftest for assert messages calls QEXPECT_FAIL if the assert
message doesn't exactly match the expected output.  This is because
Q_ASSERT uses __FILE__, which is compiler-dependant.

The expected output for this test contains various hard-coded unix
paths meaning that the test never passes on any platform.  This commit
removes those paths from the test data so that the test passes for
compilers that don't put path information in __FILE__.  This commit also
makes the XFAIL message more accurate -- absolute paths in assert
messages don't come from QTestLib, they come from Q_ASSERT's use of
__FILE__.

Change-Id: I9aae212379b43a29ae83715717cc978b4b619420
Reviewed-on: http://codereview.qt.nokia.com/3908
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
tests/auto/selftests/expected_assert.lightxml
tests/auto/selftests/expected_assert.txt
tests/auto/selftests/expected_assert.xml
tests/auto/selftests/expected_assert.xunitxml
tests/auto/selftests/tst_selftests.cpp

index 9062ca6..c9a1978 100644 (file)
@@ -10,7 +10,7 @@
 </TestFunction>
 <TestFunction name="testNumber2">
 <Message type="qfatal" file="" line="0">
-    <Description><![CDATA[ASSERT: "false" in file /local/user_builds/qt/4.6/tests/auto/selftests/assert/tst_assert.cpp, line 62]]></Description>
+    <Description><![CDATA[ASSERT: "false" in file tst_assert.cpp, line 62]]></Description>
 </Message>
 <Incident type="fail" file="Unknown file" line="0">
     <Description><![CDATA[Received a fatal error.]]></Description>
index 0203f2b..f57eb55 100644 (file)
@@ -2,7 +2,7 @@
 Config: Using QTest library 4.3.0, Qt 4.3.0
 PASS   : tst_Assert::initTestCase()
 PASS   : tst_Assert::testNumber1()
-QFATAL : tst_Assert::testNumber2() ASSERT: "false" in file /home/fenglich/dev/qt-4.3/tests/auto/selftests/assert/tst_assert.cpp, line 29
+QFATAL : tst_Assert::testNumber2() ASSERT: "false" in file tst_assert.cpp, line 62
 FAIL!  : tst_Assert::testNumber2() Received a fatal error.
    Loc: [Unknown file(0)]
 Totals: 2 passed, 1 failed, 0 skipped
index 3a7152c..60085aa 100644 (file)
@@ -12,7 +12,7 @@
 </TestFunction>
 <TestFunction name="testNumber2">
 <Message type="qfatal" file="" line="0">
-    <Description><![CDATA[ASSERT: "false" in file /local/user_builds/qt/4.6/tests/auto/selftests/assert/tst_assert.cpp, line 62]]></Description>
+    <Description><![CDATA[ASSERT: "false" in file tst_assert.cpp, line 62]]></Description>
 </Message>
 <Incident type="fail" file="Unknown file" line="0">
     <Description><![CDATA[Received a fatal error.]]></Description>
index 2a7d5eb..8761700 100644 (file)
@@ -7,10 +7,10 @@
   <testcase result="pass" name="initTestCase"/>
   <testcase result="pass" name="testNumber1"/>
   <testcase result="fail" name="testNumber2">
-    <!-- message="ASSERT: &quot;false&quot; in file /local/user_builds/qt/4.6/tests/auto/selftests/assert/tst_assert.cpp, line 62" type="qfatal" -->
+    <!-- message="ASSERT: &quot;false&quot; in file tst_assert.cpp, line 62" type="qfatal" -->
     <failure message="Received a fatal error." result="fail"/>
   </testcase>
   <system-err>
-<![CDATA[ASSERT: "false" in file /local/user_builds/qt/4.6/tests/auto/selftests/assert/tst_assert.cpp, line 62]]>
+<![CDATA[ASSERT: "false" in file tst_assert.cpp, line 62]]>
   </system-err>
 </testsuite>
index 320d993..cb5cd07 100644 (file)
@@ -416,13 +416,16 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QString const& logger, Q
         const QString output(QString::fromLatin1(line));
         const QString expected(QString::fromLatin1(exp.at(i)).replace("@INSERT_QT_VERSION_HERE@", QT_VERSION_STR));
 
+        // Q_ASSERT uses __FILE__.  Some compilers include the absolute path in
+        // __FILE__, while others do not.
         if (line.contains("ASSERT") && output != expected) {
-            QEXPECT_FAIL("assert",                "QTestLib prints out the absolute path.", Continue);
-            QEXPECT_FAIL("assert xml",            "QTestLib prints out the absolute path.", Continue);
-            QEXPECT_FAIL("assert xml flush",      "QTestLib prints out the absolute path.", Continue);
-            QEXPECT_FAIL("assert lightxml",       "QTestLib prints out the absolute path.", Continue);
-            QEXPECT_FAIL("assert lightxml flush", "QTestLib prints out the absolute path.", Continue);
-            QEXPECT_FAIL("assert xunitxml",       "QTestLib prints out the absolute path.", Continue);
+            const char msg[] = "Q_ASSERT prints out the absolute path on this platform.";
+            QEXPECT_FAIL("assert",                msg, Continue);
+            QEXPECT_FAIL("assert xml",            msg, Continue);
+            QEXPECT_FAIL("assert xml flush",      msg, Continue);
+            QEXPECT_FAIL("assert lightxml",       msg, Continue);
+            QEXPECT_FAIL("assert lightxml flush", msg, Continue);
+            QEXPECT_FAIL("assert xunitxml",       msg, Continue);
         }
 
         /* On some platforms we compile without RTTI, and as a result we never throw an exception. */