From b1c45652e51426ca8b489d7567291152d4930a22 Mon Sep 17 00:00:00 2001 From: Gavin S Date: Sun, 12 Jul 2020 01:17:37 -0700 Subject: [PATCH] Update catch_reporter_tap.hpp TAP format requires all results to be reported. Removed extraneous preferences function (handled by parent) Incorporated fix from 3d9e7db2e0fff8fc2edcf59d24351f3937e3ac62 Simplified total printing --- include/reporters/catch_reporter_tap.hpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/include/reporters/catch_reporter_tap.hpp b/include/reporters/catch_reporter_tap.hpp index 1bfe4f5e..ecc8754e 100644 --- a/include/reporters/catch_reporter_tap.hpp +++ b/include/reporters/catch_reporter_tap.hpp @@ -23,16 +23,17 @@ namespace Catch { using StreamingReporterBase::StreamingReporterBase; + TAPReporter( ReporterConfig const& config ) + : StreamingReporterBase( config ) { + m_reporterPrefs.shouldReportAllAssertions = true; + } + ~TAPReporter() override; static std::string getDescription() { return "Reports test results in TAP format, suitable for test harnesses"; } - ReporterPreferences getPreferences() const override { - return m_reporterPrefs; - } - void noMatchingTestCases( std::string const& spec ) override { stream << "# No test cases matched '" << spec << "'" << std::endl; } @@ -203,16 +204,15 @@ namespace Catch { return; } - // using messages.end() directly (or auto) yields compilation error: - std::vector::const_iterator itEnd = messages.end(); - const std::size_t N = static_cast( std::distance( itMessage, itEnd ) ); + const auto itEnd = messages.cend(); + const auto N = static_cast( std::distance( itMessage, itEnd ) ); { Colour colourGuard( colour ); stream << " with " << pluralise( N, "message" ) << ":"; } - for(; itMessage != itEnd; ) { + while( itMessage != itEnd ) { // If this assertion is a warning ignore any INFO messages if( printInfoMessages || itMessage->type != ResultWas::Info ) { stream << " '" << itMessage->message << "'"; @@ -220,7 +220,9 @@ namespace Catch { Colour colourGuard( dimColour() ); stream << " and"; } + continue; } + ++itMessage; } } @@ -234,10 +236,9 @@ namespace Catch { }; void printTotals( const Totals& totals ) const { + stream << "1.." << totals.assertions.total(); if( totals.testCases.total() == 0 ) { - stream << "1..0 # Skipped: No tests ran."; - } else { - stream << "1.." << counter; + stream << " # Skipped: No tests ran."; } } };