Skip to content

Commit

Permalink
TAP reporter now behaves as if -s was always set
Browse files Browse the repository at this point in the history
This should fulfill the TAP specification better.
  • Loading branch information
horenmar committed Mar 2, 2017
1 parent 0b28d3d commit 95b0eb2
Showing 1 changed file with 7 additions and 32 deletions.
39 changes: 7 additions & 32 deletions include/reporters/catch_reporter_tap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,9 @@ namespace Catch {
virtual void assertionStarting( AssertionInfo const& ) {}

virtual bool assertionEnded( AssertionStats const& _assertionStats ) {
AssertionResult const& result = _assertionStats.assertionResult;
++counter;

bool printInfoMessages = true;

// Drop out if result was successful and we're not printing those
if ( !m_config->includeSuccessfulResults() && result.isOk() ) {
if ( result.getResultType() != ResultWas::Warning )
return false;
printInfoMessages = false;
}

AssertionPrinter printer( stream, _assertionStats, printInfoMessages, counter );
AssertionPrinter printer( stream, _assertionStats, counter );
printer.print();
stream << " # " << currentTestCaseInfo->name ;

Expand All @@ -76,13 +66,13 @@ namespace Catch {
class AssertionPrinter {
void operator= ( AssertionPrinter const& );
public:
AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages, size_t counter )
AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, size_t counter )
: stream( _stream )
, stats( _stats )
, result( _stats.assertionResult )
, messages( _stats.infoMessages )
, itMessage( _stats.infoMessages.begin() )
, printInfoMessages( _printInfoMessages )
, printInfoMessages( true )
, counter(counter)
{}

Expand Down Expand Up @@ -157,24 +147,19 @@ namespace Catch {
}

private:

static Colour::Code dimColour() { return Colour::FileName; }

static const char* failedString() { return "not ok"; }
static const char* passedString() { return "ok"; }

void printSourceInfo() const {
Colour colourGuard( Colour::FileName );
Colour colourGuard( dimColour() );
stream << result.getSourceInfo() << ":";
}

void printResultType( std::string passOrFail ) const {
if( !passOrFail.empty() ) {
{
//Colour colourGuard( colour );
stream << passOrFail << " " << counter;
}
stream << " -";
stream << passOrFail << ' ' << counter << " -";
}
}

Expand Down Expand Up @@ -219,8 +204,9 @@ namespace Catch {
}

void printRemainingMessages( Colour::Code colour = dimColour() ) {
if ( itMessage == messages.end() )
if (itMessage == messages.end()) {
return;
}

// using messages.end() directly yields compilation error:
std::vector<MessageInfo>::const_iterator itEnd = messages.end();
Expand Down Expand Up @@ -253,17 +239,6 @@ namespace Catch {
size_t counter;
};

// Colour, message variants:
// - white: No tests ran.
// - red: Failed [both/all] N test cases, failed [both/all] M assertions.
// - white: Passed [both/all] N test cases (no assertions).
// - red: Failed N tests cases, failed M assertions.
// - green: Passed [both/all] N tests cases with M assertions.

std::string bothOrAll( std::size_t count ) const {
return count == 1 ? "" : count == 2 ? "both " : "all " ;
}

void printTotals( const Totals& totals ) const {
if( totals.testCases.total() == 0 ) {
stream << "1..0 # Skipped: No tests ran.";
Expand Down

0 comments on commit 95b0eb2

Please sign in to comment.