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" )
|
||||
.bind( &ConfigData::listTestNamesOnly );
|
||||
|
||||
cli["--list-tests-and-sources"]
|
||||
.describe( "list all/matching test cases and their source files" )
|
||||
.bind( &ConfigData::listTestSources );
|
||||
|
||||
cli["--list-reporters"]
|
||||
.describe( "list all reporters" )
|
||||
.bind( &ConfigData::listReporters );
|
||||
|
@ -33,6 +33,7 @@ namespace Catch {
|
||||
listReporters( false ),
|
||||
listTestNamesAndSources( false ),
|
||||
listTestNamesOnly( false ),
|
||||
listTestSources( false ),
|
||||
showSuccessfulTests( false ),
|
||||
shouldDebugBreak( false ),
|
||||
noThrow( false ),
|
||||
@ -52,6 +53,7 @@ namespace Catch {
|
||||
bool listTags;
|
||||
bool listReporters;
|
||||
bool listTestNamesAndSources;
|
||||
bool listTestSources;
|
||||
bool listTestNamesOnly;
|
||||
|
||||
bool showSuccessfulTests;
|
||||
@ -111,6 +113,7 @@ namespace Catch {
|
||||
bool listTests() const { return m_data.listTests; }
|
||||
bool listTestNamesAndSources() const { return m_data.listTestNamesAndSources; }
|
||||
bool listTestNamesOnly() const { return m_data.listTestNamesOnly; }
|
||||
bool listTestSources() const { return m_data.listTestSources; }
|
||||
bool listTags() const { return m_data.listTags; }
|
||||
bool listReporters() const { return m_data.listReporters; }
|
||||
|
||||
|
@ -19,12 +19,14 @@
|
||||
|
||||
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();
|
||||
if( config.testSpec().hasFilters() )
|
||||
if( !includeSources )
|
||||
Catch::cout() << "Matching test cases:\n";
|
||||
else {
|
||||
if( !includeSources )
|
||||
Catch::cout() << "All available test cases:\n";
|
||||
testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec();
|
||||
}
|
||||
@ -48,6 +50,8 @@ namespace Catch {
|
||||
Catch::cout() << Text( testCaseInfo.name, nameAttr ) << std::endl;
|
||||
if( !testCaseInfo.tags.empty() )
|
||||
Catch::cout() << Text( testCaseInfo.tagsAsString, tagsAttr ) << std::endl;
|
||||
if( includeSources )
|
||||
Catch::cout() << testCaseInfo.lineInfo << std::endl;
|
||||
}
|
||||
|
||||
if( !config.testSpec().hasFilters() )
|
||||
@ -163,11 +167,13 @@ namespace Catch {
|
||||
inline Option<std::size_t> list( Config const& config ) {
|
||||
Option<std::size_t> listedCount;
|
||||
if( config.listTests() )
|
||||
listedCount = listedCount.valueOr(0) + listTests( config );
|
||||
listedCount = listedCount.valueOr(0) + listTests( config , false );
|
||||
if( config.listTestNamesAndSources() )
|
||||
listedCount = listedCount.valueOr(0) + listTestsNames(config, true);
|
||||
listedCount = listedCount.valueOr(0) + listTestsNames( config, true );
|
||||
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() )
|
||||
listedCount = listedCount.valueOr(0) + listTags( config );
|
||||
if( config.listReporters() )
|
||||
|
Loading…
Reference in New Issue
Block a user