mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-17 11:12:25 +01:00
Added --list-tests-and-sources
This commit is contained in:
parent
d0bd13dc17
commit
b2c9a681bb
@ -182,6 +182,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["--list-tests-and-sources"]
|
||||||
|
.describe( "list all/matching test cases and their source files" )
|
||||||
|
.bind( &ConfigData::listTestSources );
|
||||||
|
|
||||||
cli["--list-reporters"]
|
cli["--list-reporters"]
|
||||||
.describe( "list all reporters" )
|
.describe( "list all reporters" )
|
||||||
.bind( &ConfigData::listReporters );
|
.bind( &ConfigData::listReporters );
|
||||||
|
@ -33,6 +33,7 @@ namespace Catch {
|
|||||||
listReporters( false ),
|
listReporters( false ),
|
||||||
listTestNamesAndSources( false ),
|
listTestNamesAndSources( false ),
|
||||||
listTestNamesOnly( false ),
|
listTestNamesOnly( false ),
|
||||||
|
listTestSources( false ),
|
||||||
showSuccessfulTests( false ),
|
showSuccessfulTests( false ),
|
||||||
shouldDebugBreak( false ),
|
shouldDebugBreak( false ),
|
||||||
noThrow( false ),
|
noThrow( false ),
|
||||||
@ -52,6 +53,7 @@ namespace Catch {
|
|||||||
bool listTags;
|
bool listTags;
|
||||||
bool listReporters;
|
bool listReporters;
|
||||||
bool listTestNamesAndSources;
|
bool listTestNamesAndSources;
|
||||||
|
bool listTestSources;
|
||||||
bool listTestNamesOnly;
|
bool listTestNamesOnly;
|
||||||
|
|
||||||
bool showSuccessfulTests;
|
bool showSuccessfulTests;
|
||||||
@ -111,6 +113,7 @@ namespace Catch {
|
|||||||
bool listTests() const { return m_data.listTests; }
|
bool listTests() const { return m_data.listTests; }
|
||||||
bool listTestNamesAndSources() const { return m_data.listTestNamesAndSources; }
|
bool listTestNamesAndSources() const { return m_data.listTestNamesAndSources; }
|
||||||
bool listTestNamesOnly() const { return m_data.listTestNamesOnly; }
|
bool listTestNamesOnly() const { return m_data.listTestNamesOnly; }
|
||||||
|
bool listTestSources() const { return m_data.listTestSources; }
|
||||||
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; }
|
||||||
|
|
||||||
|
@ -19,13 +19,15 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
inline std::size_t listTests( Config const& config ) {
|
inline std::size_t listTests( Config const& config, const bool includeSources ) {
|
||||||
|
|
||||||
TestSpec testSpec = config.testSpec();
|
TestSpec testSpec = config.testSpec();
|
||||||
if( config.testSpec().hasFilters() )
|
if( config.testSpec().hasFilters() )
|
||||||
|
if( !includeSources )
|
||||||
Catch::cout() << "Matching test cases:\n";
|
Catch::cout() << "Matching test cases:\n";
|
||||||
else {
|
else {
|
||||||
Catch::cout() << "All available test cases:\n";
|
if( !includeSources )
|
||||||
|
Catch::cout() << "All available test cases:\n";
|
||||||
testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec();
|
testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +50,8 @@ namespace Catch {
|
|||||||
Catch::cout() << Text( testCaseInfo.name, nameAttr ) << std::endl;
|
Catch::cout() << Text( testCaseInfo.name, nameAttr ) << 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;
|
||||||
|
if( includeSources )
|
||||||
|
Catch::cout() << testCaseInfo.lineInfo << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !config.testSpec().hasFilters() )
|
if( !config.testSpec().hasFilters() )
|
||||||
@ -163,11 +167,13 @@ namespace Catch {
|
|||||||
inline Option<std::size_t> list( Config const& config ) {
|
inline Option<std::size_t> list( Config const& config ) {
|
||||||
Option<std::size_t> listedCount;
|
Option<std::size_t> listedCount;
|
||||||
if( config.listTests() )
|
if( config.listTests() )
|
||||||
listedCount = listedCount.valueOr(0) + listTests( config );
|
listedCount = listedCount.valueOr(0) + listTests( config , false );
|
||||||
if( config.listTestNamesAndSources() )
|
if( config.listTestNamesAndSources() )
|
||||||
listedCount = listedCount.valueOr(0) + listTestsNames(config, true);
|
listedCount = listedCount.valueOr(0) + listTestsNames( config, true );
|
||||||
if( config.listTestNamesOnly() )
|
if( config.listTestNamesOnly() )
|
||||||
listedCount = listedCount.valueOr(0) + listTestsNames( config , false );
|
listedCount = listedCount.valueOr(0) + listTestsNames( config, false );
|
||||||
|
if( config.listTestSources() )
|
||||||
|
listedCount = listedCount.valueOr(0) + listTests( config, true );
|
||||||
if( config.listTags() )
|
if( config.listTags() )
|
||||||
listedCount = listedCount.valueOr(0) + listTags( config );
|
listedCount = listedCount.valueOr(0) + listTags( config );
|
||||||
if( config.listReporters() )
|
if( config.listReporters() )
|
||||||
|
Loading…
Reference in New Issue
Block a user