ColourGuard is no longer constructed engaged

Forcing it to be engaged explicitly, either via `op<<`, or by
`ColourGuard::engage`, fixes an issue with multiple `ColourGuard`s
being constructed in a single expression. Because the construction
of the `ColourGuard` instances can happen in arbitrary order,
colours would be applied in arbitrary order too. However, a chain
of `op<<`s has strict call orders, fixing this issue.
This commit is contained in:
Martin Hořeňovský
2022-03-24 16:02:54 +01:00
parent 4d8acafecb
commit 081a1e9aba
7 changed files with 126 additions and 58 deletions
+2 -2
View File
@@ -153,7 +153,7 @@ namespace Catch {
m_startupExceptions = true;
auto errStream = makeStream( "%stderr" );
auto colourImpl = makeColourImpl( &config(), errStream.get() );
auto guard = colourImpl->startColour( Colour::Red );
auto guard = colourImpl->guardColour( Colour::Red );
errStream->stream() << "Errors occurred during startup!" << '\n';
// iterate over all exceptions and notify user
for ( const auto& ex_ptr : exceptions ) {
@@ -200,7 +200,7 @@ namespace Catch {
auto colour = makeColourImpl( &config(), errStream.get() );
errStream->stream()
<< colour->startColour( Colour::Red )
<< colour->guardColour( Colour::Red )
<< "\nError(s) in input:\n"
<< TextFlow::Column( result.errorMessage() ).indent( 2 )
<< "\n\n";