Skip to content

Commit

Permalink
CaseListReporter: Log failed tests at end
Browse files Browse the repository at this point in the history
  • Loading branch information
snej committed Jul 18, 2023
1 parent 293a9ae commit c1e2276
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion vendor/catch/CaseListReporter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <chrono>
#include <iostream>
#include <time.h>
#include <vector>

#ifdef CASE_LIST_BACKTRACE
#include "Backtrace.hh"
Expand All @@ -36,7 +37,12 @@ struct CaseListReporter : public Catch::ConsoleReporter {

virtual ~CaseListReporter() override {
auto now = time(nullptr);
stream << "ENDED TESTS IN " << (now - _start) << "sec, AT " << ctime(&now);
if (!_failedTests.empty()) {
stream << "failed tests:\n";
for (std::string const& name : _failedTests)
stream << " >>> " << name << std::endl;
}
stream << "\nENDED TESTS IN " << (now - _start) << "sec, AT " << ctime(&now) << std::endl;
stream.flush();
}

Expand All @@ -61,6 +67,8 @@ struct CaseListReporter : public Catch::ConsoleReporter {
virtual void testCaseEnded( Catch::TestCaseStats const& _testCaseStats ) override {
stream << "\t [" << _stopwatch.elapsed() << " sec]\n";
stream.flush();
if (_testCaseStats.totals.testCases.failed > 0)
_failedTests.push_back(_testCaseStats.testInfo.name);
ConsoleReporter::testCaseEnded(_testCaseStats);
}

Expand Down Expand Up @@ -101,6 +109,7 @@ struct CaseListReporter : public Catch::ConsoleReporter {
unsigned _sectionNesting;
time_t _start;
fleece::Stopwatch _stopwatch;
std::vector<std::string> _failedTests;
};

CATCH_REGISTER_REPORTER("list", CaseListReporter )

0 comments on commit c1e2276

Please sign in to comment.