summaryrefslogtreecommitdiffstats
path: root/tests/auto/testlib
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-07-31 18:25:42 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-08-04 19:31:51 +0200
commitbef57b317f2efc0e73f2275d594be9d69f5a75d0 (patch)
treefc277768e0812c65c5a860a2971b859a833c5088 /tests/auto/testlib
parentfe9c705e9aa0e25760646695820bd876de590893 (diff)
testlib: Deprecate QWARN() in favor of qWarning()
The QtTest best practices documentations recommends using output mechanisms such as qDebug() and qWarning() for diagnostic messages, and this is also what most of our own tests do. The QWARN() macro and corresponding internal QTest::qWarn() function was added when QtTest was first implemented, but was likely meant as an internal implementation detail, like its cousin QTestLog::info(), which does not have any corresponding macro. This theory is backed by our own QtTest self-test (tst_silent) describing the output from QWARN() as "an internal testlib warning". The only difference between QWARN() and qWarning(), besides the much richer feature set of the latter, is that qWarning() will not pass on file and line number information in release mode, but QWARN() will. This is an acceptable loss of functionality, considering that the user can override this behavior by defining QT_MESSAGELOGCONTEXT. [ChangeLog][QtTest] QWARN() has been deprecated in favor of qWarning() Pick-to: 6.2 Change-Id: I5a2431ce48c47392244560dd520953b9fc735c85 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/testlib')
-rw-r--r--tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp2
-rw-r--r--tests/auto/testlib/selftests/expected_junit.junitxml4
-rw-r--r--tests/auto/testlib/selftests/junit/tst_junit.cpp2
-rw-r--r--tests/auto/testlib/selftests/silent/tst_silent.cpp2
4 files changed, 5 insertions, 5 deletions
diff --git a/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp b/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp
index a419c13160..86f445b926 100644
--- a/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp
+++ b/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp
@@ -89,7 +89,7 @@ static void abort_handler(int)
void tst_Blacklisted::messages()
{
qWarning("This is a warning that should not appear in silent test output");
- QWARN("This is an internal testlib warning that should not appear in silent test output");
+ QTestLog::warn("This is an internal testlib warning that should not appear in silent test output", __FILE__, __LINE__);
qDebug("This is a debug message that should not appear in silent test output");
qCritical("This is a critical message that should not appear in silent test output");
qInfo("This is an info message that should not appear in silent test output");
diff --git a/tests/auto/testlib/selftests/expected_junit.junitxml b/tests/auto/testlib/selftests/expected_junit.junitxml
index b3591a6868..787c422251 100644
--- a/tests/auto/testlib/selftests/expected_junit.junitxml
+++ b/tests/auto/testlib/selftests/expected_junit.junitxml
@@ -7,7 +7,7 @@
</properties>
<testcase name="initTestCase" result="pass" time="@TEST_DURATION@"/>
<testcase name="testFunc1" result="pass" time="@TEST_DURATION@">
- <!-- type="warn" message="just a QWARN() !" -->
+ <!-- type="qwarn" message="just a qWarning() !" -->
</testcase>
<testcase name="testFunc2" result="fail" time="@TEST_DURATION@">
<!-- type="qdebug" message="a qDebug() call with comment&#x002D;ending stuff &#x002D;&#x002D;&gt;" -->
@@ -38,6 +38,6 @@
<![CDATA[this failure is also expected]]>
</system-out>
<system-err>
-<![CDATA[just a QWARN() !]]>
+<![CDATA[just a qWarning() !]]>
</system-err>
</testsuite>
diff --git a/tests/auto/testlib/selftests/junit/tst_junit.cpp b/tests/auto/testlib/selftests/junit/tst_junit.cpp
index 77f369b779..c434704d83 100644
--- a/tests/auto/testlib/selftests/junit/tst_junit.cpp
+++ b/tests/auto/testlib/selftests/junit/tst_junit.cpp
@@ -51,7 +51,7 @@ tst_JUnit::tst_JUnit()
void tst_JUnit::testFunc1()
{
- QWARN("just a QWARN() !");
+ qWarning("just a qWarning() !");
QCOMPARE(1,1);
}
diff --git a/tests/auto/testlib/selftests/silent/tst_silent.cpp b/tests/auto/testlib/selftests/silent/tst_silent.cpp
index f21f7798eb..34b33e1391 100644
--- a/tests/auto/testlib/selftests/silent/tst_silent.cpp
+++ b/tests/auto/testlib/selftests/silent/tst_silent.cpp
@@ -86,7 +86,7 @@ static void abort_handler(int)
void tst_Silent::messages()
{
qWarning("This is a warning that should not appear in silent test output");
- QWARN("This is an internal testlib warning that should not appear in silent test output");
+ QTestLog::warn("This is an internal testlib warning that should not appear in silent test output", __FILE__, __LINE__);
qDebug("This is a debug message that should not appear in silent test output");
qCritical("This is a critical message that should not appear in silent test output");
qInfo("This is an info message that should not appear in silent test output");