mirror of https://github.com/catchorg/Catch2.git
Merged implemention of #934, but using 'verbose' option on command line instead.
(see 616f7235ef
on master for original merge)
This commit is contained in:
parent
9382534d59
commit
1e7000ed55
|
@ -73,6 +73,18 @@ namespace Catch {
|
||||||
return ParserResult::runtimeError( "colour mode must be one of: auto, yes or no. '" + useColour + "' not recognised" );
|
return ParserResult::runtimeError( "colour mode must be one of: auto, yes or no. '" + useColour + "' not recognised" );
|
||||||
return ParserResult::ok( ParseResultType::Matched );
|
return ParserResult::ok( ParseResultType::Matched );
|
||||||
};
|
};
|
||||||
|
auto const setVerbosity = [&]( std::string const& verbosity ) {
|
||||||
|
auto lcVerbosity = toLower( verbosity );
|
||||||
|
if( lcVerbosity == "quiet" )
|
||||||
|
config.verbosity = Verbosity::Quiet;
|
||||||
|
else if( lcVerbosity == "normal" )
|
||||||
|
config.verbosity = Verbosity::Normal;
|
||||||
|
else if( lcVerbosity == "high" )
|
||||||
|
config.verbosity = Verbosity::High;
|
||||||
|
else
|
||||||
|
return ParserResult::runtimeError( "Unrecognised verbosity, '" + verbosity + "'" );
|
||||||
|
return ParserResult::ok( ParseResultType::Matched );
|
||||||
|
};
|
||||||
|
|
||||||
auto cli
|
auto cli
|
||||||
= ExeName( config.processName )
|
= ExeName( config.processName )
|
||||||
|
@ -125,6 +137,9 @@ namespace Catch {
|
||||||
+ Opt( config.sectionsToRun, "section name" )
|
+ Opt( config.sectionsToRun, "section name" )
|
||||||
["-c"]["--section"]
|
["-c"]["--section"]
|
||||||
( "specify section to run" )
|
( "specify section to run" )
|
||||||
|
+ Opt( setVerbosity, "quiet|normal|high" )
|
||||||
|
["-v"]["--verbosity"]
|
||||||
|
( "set output verbosity" )
|
||||||
+ Opt( config.listTestNamesOnly )
|
+ Opt( config.listTestNamesOnly )
|
||||||
["--list-test-names-only"]
|
["--list-test-names-only"]
|
||||||
( "list all/matching test cases names only" )
|
( "list all/matching test cases names only" )
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace Catch {
|
||||||
int abortAfter = -1;
|
int abortAfter = -1;
|
||||||
unsigned int rngSeed = 0;
|
unsigned int rngSeed = 0;
|
||||||
|
|
||||||
Verbosity::Level verbosity = Verbosity::Normal;
|
Verbosity verbosity = Verbosity::Normal;
|
||||||
WarnAbout::What warnings = WarnAbout::Nothing;
|
WarnAbout::What warnings = WarnAbout::Nothing;
|
||||||
ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter;
|
ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter;
|
||||||
RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder;
|
RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder;
|
||||||
|
@ -81,10 +81,12 @@ namespace Catch {
|
||||||
return m_data.outputFilename ;
|
return m_data.outputFilename ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool listTests() const { return m_data.listTests; }
|
bool listTests() const { return m_data.listTests; }
|
||||||
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; }
|
||||||
|
|
||||||
|
Verbosity verbosity() const { return m_data.verbosity; }
|
||||||
|
|
||||||
std::string getProcessName() const { return m_data.processName; }
|
std::string getProcessName() const { return m_data.processName; }
|
||||||
|
|
||||||
|
@ -96,18 +98,18 @@ namespace Catch {
|
||||||
bool showHelp() const { return m_data.showHelp; }
|
bool showHelp() const { return m_data.showHelp; }
|
||||||
|
|
||||||
// IConfig interface
|
// IConfig interface
|
||||||
virtual bool allowThrows() const override { return !m_data.noThrow; }
|
virtual bool allowThrows() const override { return !m_data.noThrow; }
|
||||||
virtual std::ostream& stream() const override { return m_stream->stream(); }
|
virtual std::ostream& stream() const override { return m_stream->stream(); }
|
||||||
virtual std::string name() const override { return m_data.name.empty() ? m_data.processName : m_data.name; }
|
virtual std::string name() const override { return m_data.name.empty() ? m_data.processName : m_data.name; }
|
||||||
virtual bool includeSuccessfulResults() const override { return m_data.showSuccessfulTests; }
|
virtual bool includeSuccessfulResults() const override { return m_data.showSuccessfulTests; }
|
||||||
virtual bool warnAboutMissingAssertions() const override { return m_data.warnings & WarnAbout::NoAssertions; }
|
virtual bool warnAboutMissingAssertions() const override { return m_data.warnings & WarnAbout::NoAssertions; }
|
||||||
virtual ShowDurations::OrNot showDurations() const override { return m_data.showDurations; }
|
virtual ShowDurations::OrNot showDurations() const override { return m_data.showDurations; }
|
||||||
virtual RunTests::InWhatOrder runOrder() const override { return m_data.runOrder; }
|
virtual RunTests::InWhatOrder runOrder() const override { return m_data.runOrder; }
|
||||||
virtual unsigned int rngSeed() const override { return m_data.rngSeed; }
|
virtual unsigned int rngSeed() const override { return m_data.rngSeed; }
|
||||||
virtual UseColour::YesOrNo useColour() const override { return m_data.useColour; }
|
virtual UseColour::YesOrNo useColour() const override { return m_data.useColour; }
|
||||||
virtual bool shouldDebugBreak() const override { return m_data.shouldDebugBreak; }
|
virtual bool shouldDebugBreak() const override { return m_data.shouldDebugBreak; }
|
||||||
virtual int abortAfter() const override { return m_data.abortAfter; }
|
virtual int abortAfter() const override { return m_data.abortAfter; }
|
||||||
virtual bool showInvisibles() const override { return m_data.showInvisibles; }
|
virtual bool showInvisibles() const override { return m_data.showInvisibles; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct Verbosity { enum Level {
|
enum class Verbosity {
|
||||||
NoOutput = 0,
|
Quiet = 0,
|
||||||
Quiet,
|
Normal,
|
||||||
Normal
|
High
|
||||||
}; };
|
};
|
||||||
|
|
||||||
struct WarnAbout { enum What {
|
struct WarnAbout { enum What {
|
||||||
Nothing = 0x00,
|
Nothing = 0x00,
|
||||||
|
|
|
@ -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 );
|
||||||
|
@ -43,6 +44,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.verbosity() >= Verbosity::High ) {
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
@ -63,9 +71,12 @@ namespace Catch {
|
||||||
for( auto const& testCaseInfo : matchedTestCases ) {
|
for( auto const& testCaseInfo : matchedTestCases ) {
|
||||||
matchedTests++;
|
matchedTests++;
|
||||||
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.verbosity() >= Verbosity::High )
|
||||||
|
Catch::cout() << "\t@" << testCaseInfo.lineInfo;
|
||||||
|
Catch::cout() << std::endl;
|
||||||
}
|
}
|
||||||
return matchedTests;
|
return matchedTests;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue