summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-11-24 13:18:17 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2021-12-09 20:54:26 +0100
commit6729a4b29c0ffa41fbd6c85ddb7c01678443c0bf (patch)
treee1ee7322cf30c27702036948dad2e7d454c4caa0
parent98a42b1627dba24d8bcdf5f7647c7b74b6e15d51 (diff)
TAP test logger: avoid dangling space on TODO and SKIP lines
If an incident has an empty description we produced output with a dangling space. Avoid triggering the inanity 'bot with those. Reorganise the code to save some duplication. Change-Id: I1dc29fa8ad4449a4584f11dddcf002e405cd9238 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/testlib/qtaptestlogger.cpp26
-rw-r--r--tests/auto/testlib/selftests/expected_blacklisted.tap2
2 files changed, 21 insertions, 7 deletions
diff --git a/src/testlib/qtaptestlogger.cpp b/src/testlib/qtaptestlogger.cpp
index 3a8e3674d7..0ff477e8bc 100644
--- a/src/testlib/qtaptestlogger.cpp
+++ b/src/testlib/qtaptestlogger.cpp
@@ -125,14 +125,28 @@ void QTapTestLogger::addIncident(IncidentTypes type, const char *description,
bool ok = type == Pass || type == BlacklistedPass || type == Skip
|| type == XPass || type == BlacklistedXPass;
- QTestCharBuffer directive;
- if (type == XFail || type == XPass || type == BlacklistedFail || type == BlacklistedPass
- || type == BlacklistedXFail || type == BlacklistedXPass) {
+ const char *const incident = [type]() {
+ switch (type) {
// We treat expected or blacklisted failures/passes as TODO-failures/passes,
// which should be treated as soft issues by consumers. Not all do though :/
- QTest::qt_asprintf(&directive, " # TODO %s", description);
- } else if (type == Skip) {
- QTest::qt_asprintf(&directive, " # SKIP %s", description);
+ case BlacklistedPass:
+ case XFail: case BlacklistedXFail:
+ case XPass: case BlacklistedXPass:
+ case BlacklistedFail:
+ return "TODO";
+ case Skip:
+ return "SKIP";
+ case Pass:
+ case Fail:
+ break;
+ }
+ return static_cast<const char *>(nullptr);
+ }();
+
+ QTestCharBuffer directive;
+ if (incident) {
+ QTest::qt_asprintf(&directive, " # %s%s%s", incident,
+ qstrlen(description) ? " " : "", description);
}
int testNumber = QTestLog::totalCount();
diff --git a/tests/auto/testlib/selftests/expected_blacklisted.tap b/tests/auto/testlib/selftests/expected_blacklisted.tap
index 3ea8db06e1..af0dab417f 100644
--- a/tests/auto/testlib/selftests/expected_blacklisted.tap
+++ b/tests/auto/testlib/selftests/expected_blacklisted.tap
@@ -2,7 +2,7 @@ TAP version 13
# tst_Blacklisted
ok 1 - initTestCase()
# This test should BPASS
-ok 2 - pass() # TODO
+ok 2 - pass() # TODO
ok 3 - skip() # SKIP This test should SKIP
not ok 4 - fail() # TODO 'false' returned FALSE. (This test should BFAIL)
---