mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-30 01:03:30 +01:00
add --extra-info flag
this will add line info to test lists, and test descriptions to the long form of the test list
This commit is contained in:
parent
396ecf6021
commit
616f7235ef
@ -187,6 +187,10 @@ namespace Catch {
|
|||||||
.describe( "list all/matching test cases names only" )
|
.describe( "list all/matching test cases names only" )
|
||||||
.bind( &ConfigData::listTestNamesOnly );
|
.bind( &ConfigData::listTestNamesOnly );
|
||||||
|
|
||||||
|
cli["--extra-info"]
|
||||||
|
.describe( "list more info" )
|
||||||
|
.bind( &ConfigData::extraInfo );
|
||||||
|
|
||||||
cli["--list-reporters"]
|
cli["--list-reporters"]
|
||||||
.describe( "list all reporters" )
|
.describe( "list all reporters" )
|
||||||
.bind( &ConfigData::listReporters );
|
.bind( &ConfigData::listReporters );
|
||||||
|
@ -31,6 +31,7 @@ namespace Catch {
|
|||||||
listTags( false ),
|
listTags( false ),
|
||||||
listReporters( false ),
|
listReporters( false ),
|
||||||
listTestNamesOnly( false ),
|
listTestNamesOnly( false ),
|
||||||
|
extraInfo( false ),
|
||||||
showSuccessfulTests( false ),
|
showSuccessfulTests( false ),
|
||||||
shouldDebugBreak( false ),
|
shouldDebugBreak( false ),
|
||||||
noThrow( false ),
|
noThrow( false ),
|
||||||
@ -50,6 +51,7 @@ namespace Catch {
|
|||||||
bool listTags;
|
bool listTags;
|
||||||
bool listReporters;
|
bool listReporters;
|
||||||
bool listTestNamesOnly;
|
bool listTestNamesOnly;
|
||||||
|
bool extraInfo;
|
||||||
|
|
||||||
bool showSuccessfulTests;
|
bool showSuccessfulTests;
|
||||||
bool shouldDebugBreak;
|
bool shouldDebugBreak;
|
||||||
@ -109,6 +111,7 @@ namespace Catch {
|
|||||||
bool listTestNamesOnly() const { return m_data.listTestNamesOnly; }
|
bool listTestNamesOnly() const { return m_data.listTestNamesOnly; }
|
||||||
bool listTags() const { return m_data.listTags; }
|
bool listTags() const { return m_data.listTags; }
|
||||||
bool listReporters() const { return m_data.listReporters; }
|
bool listReporters() const { return m_data.listReporters; }
|
||||||
|
bool extraInfo() const { return m_data.extraInfo; }
|
||||||
|
|
||||||
std::string getProcessName() const { return m_data.processName; }
|
std::string getProcessName() const { return m_data.processName; }
|
||||||
|
|
||||||
|
@ -30,8 +30,9 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::size_t matchedTests = 0;
|
std::size_t matchedTests = 0;
|
||||||
TextAttributes nameAttr, tagsAttr;
|
TextAttributes nameAttr, descAttr, tagsAttr;
|
||||||
nameAttr.setInitialIndent( 2 ).setIndent( 4 );
|
nameAttr.setInitialIndent( 2 ).setIndent( 4 );
|
||||||
|
descAttr.setIndent( 4 );
|
||||||
tagsAttr.setIndent( 6 );
|
tagsAttr.setIndent( 6 );
|
||||||
|
|
||||||
std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
|
std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
|
||||||
@ -46,6 +47,13 @@ namespace Catch {
|
|||||||
Colour colourGuard( colour );
|
Colour colourGuard( colour );
|
||||||
|
|
||||||
Catch::cout() << Text( testCaseInfo.name, nameAttr ) << std::endl;
|
Catch::cout() << Text( testCaseInfo.name, nameAttr ) << std::endl;
|
||||||
|
if( config.extraInfo() ) {
|
||||||
|
Catch::cout() << " " << testCaseInfo.lineInfo << std::endl;
|
||||||
|
std::string description = testCaseInfo.description;
|
||||||
|
if( description == "" )
|
||||||
|
description = "(NO DESCRIPTION)";
|
||||||
|
Catch::cout() << Text( description, descAttr ) << std::endl;
|
||||||
|
}
|
||||||
if( !testCaseInfo.tags.empty() )
|
if( !testCaseInfo.tags.empty() )
|
||||||
Catch::cout() << Text( testCaseInfo.tagsAsString, tagsAttr ) << std::endl;
|
Catch::cout() << Text( testCaseInfo.tagsAsString, tagsAttr ) << std::endl;
|
||||||
}
|
}
|
||||||
@ -69,9 +77,12 @@ namespace Catch {
|
|||||||
matchedTests++;
|
matchedTests++;
|
||||||
TestCaseInfo const& testCaseInfo = it->getTestCaseInfo();
|
TestCaseInfo const& testCaseInfo = it->getTestCaseInfo();
|
||||||
if( startsWith( testCaseInfo.name, '#' ) )
|
if( startsWith( testCaseInfo.name, '#' ) )
|
||||||
Catch::cout() << '"' << testCaseInfo.name << '"' << std::endl;
|
Catch::cout() << '"' << testCaseInfo.name << '"';
|
||||||
else
|
else
|
||||||
Catch::cout() << testCaseInfo.name << std::endl;
|
Catch::cout() << testCaseInfo.name;
|
||||||
|
if ( config.extraInfo() )
|
||||||
|
Catch::cout() << "\t@" << testCaseInfo.lineInfo;
|
||||||
|
Catch::cout() << std::endl;
|
||||||
}
|
}
|
||||||
return matchedTests;
|
return matchedTests;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user