From 91e8d8027d6de816b80296c7ff30c942a4c629b8 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 2 Dec 2021 12:17:56 +0100 Subject: [PATCH] Tidy up in QTapTestLogger::addIncident() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After we've checked m_wasExpectedFail, we might as well set it promptly, since one of our earlier checks is on the same condition. Explain what that check is about, fix a typo in another comment and make the local ok variable const, since it can be. Change-Id: Ie04c0ad4248e47b116d3e22046116d39cf2ac6df Reviewed-by: MÃ¥rten Nordheim --- src/testlib/qtaptestlogger.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/testlib/qtaptestlogger.cpp b/src/testlib/qtaptestlogger.cpp index 0ff477e8bc..d3795b2bca 100644 --- a/src/testlib/qtaptestlogger.cpp +++ b/src/testlib/qtaptestlogger.cpp @@ -121,9 +121,9 @@ void QTapTestLogger::addIncident(IncidentTypes type, const char *description, // to emit a single test point for it, so skip the this pass. return; } - - bool ok = type == Pass || type == BlacklistedPass || type == Skip - || type == XPass || type == BlacklistedXPass; + m_wasExpectedFail = type == XFail || type == BlacklistedXFail; + const bool ok = type == Pass || type == BlacklistedPass || type == Skip + || type == XPass || type == BlacklistedXPass; const char *const incident = [type]() { switch (type) { @@ -150,15 +150,15 @@ void QTapTestLogger::addIncident(IncidentTypes type, const char *description, } int testNumber = QTestLog::totalCount(); - if (type == XFail || type == BlacklistedXFail) { - // The global test counter hasn't been updated yet for XFail + // That counts Pass, Fail, Skip and blacklisted; the XFail will eventually + // be added to it as a Pass, but that hasn't heppened yet, so count it now: + if (m_wasExpectedFail) testNumber += 1; - } outputTestLine(ok, testNumber, directive); if (!ok) { - // All failures need a diagnostics sections to not confuse consumers + // All failures need a diagnostics section to not confuse consumers // The indent needs to be two spaces for maximum compatibility #define YAML_INDENT " " @@ -250,8 +250,6 @@ void QTapTestLogger::addIncident(IncidentTypes type, const char *description, outputString(YAML_INDENT "...\n"); } - - m_wasExpectedFail = (type == XFail || type == BlacklistedXFail); } void QTapTestLogger::addMessage(MessageTypes type, const QString &message,