Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorBaruch Burstein2017-06-20 22:14:38 +0300
committerMartin Hořeňovský2017-06-25 17:12:29 +0200
commit616f7235efc875ee239c1dc6ddb48025e05e57ff (patch)
tree898718a734f4950a592fa3aac6b404b1677fac5d /include
parent396ecf6021b9c0e2b6799d091adf49b0182b180f (diff)
downloadcatch3-616f7235efc875ee239c1dc6ddb48025e05e57ff.tar.gz
add --extra-info flag
this will add line info to test lists, and test descriptions to the long form of the test list
Diffstat (limited to 'include')
-rw-r--r--include/internal/catch_commandline.hpp4
-rw-r--r--include/internal/catch_config.hpp3
-rw-r--r--include/internal/catch_list.hpp17
3 files changed, 21 insertions, 3 deletions
diff --git a/include/internal/catch_commandline.hpp b/include/internal/catch_commandline.hpp
index 742f01a4..07115db4 100644
--- a/include/internal/catch_commandline.hpp
+++ b/include/internal/catch_commandline.hpp
@@ -187,6 +187,10 @@ namespace Catch {
.describe( "list all/matching test cases names only" )
.bind( &ConfigData::listTestNamesOnly );
+ cli["--extra-info"]
+ .describe( "list more info" )
+ .bind( &ConfigData::extraInfo );
+
cli["--list-reporters"]
.describe( "list all reporters" )
.bind( &ConfigData::listReporters );
diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp
index 174850bf..304fe32b 100644
--- a/include/internal/catch_config.hpp
+++ b/include/internal/catch_config.hpp
@@ -31,6 +31,7 @@ namespace Catch {
listTags( false ),
listReporters( false ),
listTestNamesOnly( false ),
+ extraInfo( false ),
showSuccessfulTests( false ),
shouldDebugBreak( false ),
noThrow( false ),
@@ -50,6 +51,7 @@ namespace Catch {
bool listTags;
bool listReporters;
bool listTestNamesOnly;
+ bool extraInfo;
bool showSuccessfulTests;
bool shouldDebugBreak;
@@ -109,6 +111,7 @@ namespace Catch {
bool listTestNamesOnly() const { return m_data.listTestNamesOnly; }
bool listTags() const { return m_data.listTags; }
bool listReporters() const { return m_data.listReporters; }
+ bool extraInfo() const { return m_data.extraInfo; }
std::string getProcessName() const { return m_data.processName; }
diff --git a/include/internal/catch_list.hpp b/include/internal/catch_list.hpp
index e09898e9..b692f4e3 100644
--- a/include/internal/catch_list.hpp
+++ b/include/internal/catch_list.hpp
@@ -30,8 +30,9 @@ namespace Catch {
}
std::size_t matchedTests = 0;
- TextAttributes nameAttr, tagsAttr;
+ TextAttributes nameAttr, descAttr, tagsAttr;
nameAttr.setInitialIndent( 2 ).setIndent( 4 );
+ descAttr.setIndent( 4 );
tagsAttr.setIndent( 6 );
std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
@@ -46,6 +47,13 @@ namespace Catch {
Colour colourGuard( colour );
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() )
Catch::cout() << Text( testCaseInfo.tagsAsString, tagsAttr ) << std::endl;
}
@@ -69,9 +77,12 @@ namespace Catch {
matchedTests++;
TestCaseInfo const& testCaseInfo = it->getTestCaseInfo();
if( startsWith( testCaseInfo.name, '#' ) )
- Catch::cout() << '"' << testCaseInfo.name << '"' << std::endl;
+ Catch::cout() << '"' << testCaseInfo.name << '"';
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;
}