Skip to content

Commit

Permalink
Fix TAP coloring on non-terminal outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
toroidal-code committed Feb 27, 2024
1 parent 65ef425 commit 6f76c6c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions include/formatters/tap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,20 @@ inline void TAP::flush() {
std::string str = buffer.str();
std::ostringstream oss;
if (str[0] == '\n') {
oss << str.substr(0, 1) << GREEN << "1.." << test_counter - 1 << RESET << std::endl << str.substr(1);
} else {
oss << GREEN << "1.." << test_counter - 1 << RESET << std::endl << str;
oss << str[0];
}

if (color_output) {
oss << GREEN;
}
oss << "1.." << test_counter - 1;
if (color_output) {
oss << RESET;
}
oss << std::endl;

oss << ((str[0] == '\n') ? str.substr(1) : str);

std::cout << oss.str() << std::flush;
first = false;
test_counter = 1;
Expand All @@ -89,4 +99,3 @@ inline void TAP::flush() {
static TAP tap;

} // namespace CppSpec::Formatters

2 changes: 1 addition & 1 deletion include/matchers/matcher_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ std::string MatcherBase<A, E>::failure_message_when_negated() {
template <typename A, typename E>
std::string MatcherBase<A, E>::description() {
std::stringstream ss;
std::string pretty_expected = this->to_sentence(expected_);
//std::string pretty_expected = this->to_sentence(expected_);
// ss << "match " <<
// this->name_to_sentence(Util::demangle(typeid(*this).name()))
// << "(" << pretty_expected.substr(1, pretty_expected.length()) << ")";
Expand Down

0 comments on commit 6f76c6c

Please sign in to comment.