Skip to content

Commit 6f76c6c

Browse files
committed
Fix TAP coloring on non-terminal outputs
1 parent 65ef425 commit 6f76c6c

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

include/formatters/tap.hpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,20 @@ inline void TAP::flush() {
7676
std::string str = buffer.str();
7777
std::ostringstream oss;
7878
if (str[0] == '\n') {
79-
oss << str.substr(0, 1) << GREEN << "1.." << test_counter - 1 << RESET << std::endl << str.substr(1);
80-
} else {
81-
oss << GREEN << "1.." << test_counter - 1 << RESET << std::endl << str;
79+
oss << str[0];
8280
}
81+
82+
if (color_output) {
83+
oss << GREEN;
84+
}
85+
oss << "1.." << test_counter - 1;
86+
if (color_output) {
87+
oss << RESET;
88+
}
89+
oss << std::endl;
90+
91+
oss << ((str[0] == '\n') ? str.substr(1) : str);
92+
8393
std::cout << oss.str() << std::flush;
8494
first = false;
8595
test_counter = 1;
@@ -89,4 +99,3 @@ inline void TAP::flush() {
8999
static TAP tap;
90100

91101
} // namespace CppSpec::Formatters
92-

include/matchers/matcher_base.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ std::string MatcherBase<A, E>::failure_message_when_negated() {
141141
template <typename A, typename E>
142142
std::string MatcherBase<A, E>::description() {
143143
std::stringstream ss;
144-
std::string pretty_expected = this->to_sentence(expected_);
144+
//std::string pretty_expected = this->to_sentence(expected_);
145145
// ss << "match " <<
146146
// this->name_to_sentence(Util::demangle(typeid(*this).name()))
147147
// << "(" << pretty_expected.substr(1, pretty_expected.length()) << ")";

0 commit comments

Comments
 (0)