mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Console reporter: Don't print full path for every line
This commit is contained in:
@@ -80,10 +80,7 @@ namespace Catch {
|
||||
|
||||
lazyPrint();
|
||||
|
||||
if( !result.getSourceInfo().empty() ) {
|
||||
TextColour colour( TextColour::FileName );
|
||||
stream << result.getSourceInfo();
|
||||
}
|
||||
printLineInfo( result.getSourceInfo() );
|
||||
|
||||
if( result.hasExpression() ) {
|
||||
TextColour colour( TextColour::OriginalExpression );
|
||||
@@ -241,6 +238,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
virtual void sectionEnded( Ptr<SectionStats const> const& _sectionStats ) {
|
||||
resetLastPrintedLine();
|
||||
if( _sectionStats->missingAssertions ) {
|
||||
lazyPrint();
|
||||
TextColour colour( TextColour::ResultError );
|
||||
@@ -263,6 +261,7 @@ namespace Catch {
|
||||
AccumulatingReporter::sectionEnded( _sectionStats );
|
||||
}
|
||||
virtual void testCaseEnded( Ptr<TestCaseStats const> const& _testCaseStats ) {
|
||||
resetLastPrintedLine();
|
||||
if( _testCaseStats->missingAssertions ) {
|
||||
lazyPrint();
|
||||
TextColour colour( TextColour::ResultError );
|
||||
@@ -292,6 +291,26 @@ namespace Catch {
|
||||
AccumulatingReporter::testRunEnded( _testRunStats );
|
||||
}
|
||||
|
||||
void printLineInfo( SourceLineInfo const& lineInfo ) {
|
||||
if( !lineInfo.empty() ) {
|
||||
if( m_lastPrintedLine.empty() ||
|
||||
m_lastPrintedLine.file != lineInfo.file ||
|
||||
abs( static_cast<int>( m_lastPrintedLine.line ) - static_cast<int>( lineInfo.line ) ) > 20 ) {
|
||||
TextColour colour( TextColour::FileName );
|
||||
stream << lineInfo << "\n";
|
||||
m_lastPrintedLine = lineInfo;
|
||||
}
|
||||
else if( lineInfo.line != m_lastPrintedLine.line ) {
|
||||
TextColour colour( TextColour::FileName );
|
||||
stream << "line " << lineInfo.line << ":\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
void resetLastPrintedLine() {
|
||||
m_lastPrintedLine = SourceLineInfo();
|
||||
}
|
||||
SourceLineInfo m_lastPrintedLine;
|
||||
|
||||
};
|
||||
|
||||
INTERNAL_CATCH_REGISTER_REPORTER( "console", ConsoleReporter )
|
||||
|
Reference in New Issue
Block a user