mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 03:43:28 +01:00
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::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
|
||||
= ExeName( config.processName )
|
||||
@ -125,6 +137,9 @@ namespace Catch {
|
||||
+ Opt( config.sectionsToRun, "section name" )
|
||||
["-c"]["--section"]
|
||||
( "specify section to run" )
|
||||
+ Opt( setVerbosity, "quiet|normal|high" )
|
||||
["-v"]["--verbosity"]
|
||||
( "set output verbosity" )
|
||||
+ Opt( config.listTestNamesOnly )
|
||||
["--list-test-names-only"]
|
||||
( "list all/matching test cases names only" )
|
||||
|
@ -40,7 +40,7 @@ namespace Catch {
|
||||
int abortAfter = -1;
|
||||
unsigned int rngSeed = 0;
|
||||
|
||||
Verbosity::Level verbosity = Verbosity::Normal;
|
||||
Verbosity verbosity = Verbosity::Normal;
|
||||
WarnAbout::What warnings = WarnAbout::Nothing;
|
||||
ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter;
|
||||
RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder;
|
||||
@ -81,10 +81,12 @@ namespace Catch {
|
||||
return m_data.outputFilename ;
|
||||
}
|
||||
|
||||
bool listTests() const { return m_data.listTests; }
|
||||
bool listTestNamesOnly() const { return m_data.listTestNamesOnly; }
|
||||
bool listTags() const { return m_data.listTags; }
|
||||
bool listReporters() const { return m_data.listReporters; }
|
||||
bool listTests() const { return m_data.listTests; }
|
||||
bool listTestNamesOnly() const { return m_data.listTestNamesOnly; }
|
||||
bool listTags() const { return m_data.listTags; }
|
||||
bool listReporters() const { return m_data.listReporters; }
|
||||
|
||||
Verbosity verbosity() const { return m_data.verbosity; }
|
||||
|
||||
std::string getProcessName() const { return m_data.processName; }
|
||||
|
||||
@ -96,18 +98,18 @@ namespace Catch {
|
||||
bool showHelp() const { return m_data.showHelp; }
|
||||
|
||||
// IConfig interface
|
||||
virtual bool allowThrows() const override { return !m_data.noThrow; }
|
||||
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 bool includeSuccessfulResults() const override { return m_data.showSuccessfulTests; }
|
||||
virtual bool warnAboutMissingAssertions() const override { return m_data.warnings & WarnAbout::NoAssertions; }
|
||||
virtual bool allowThrows() const override { return !m_data.noThrow; }
|
||||
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 bool includeSuccessfulResults() const override { return m_data.showSuccessfulTests; }
|
||||
virtual bool warnAboutMissingAssertions() const override { return m_data.warnings & WarnAbout::NoAssertions; }
|
||||
virtual ShowDurations::OrNot showDurations() const override { return m_data.showDurations; }
|
||||
virtual RunTests::InWhatOrder runOrder() const override { return m_data.runOrder; }
|
||||
virtual unsigned int rngSeed() const override { return m_data.rngSeed; }
|
||||
virtual UseColour::YesOrNo useColour() const override { return m_data.useColour; }
|
||||
virtual bool shouldDebugBreak() const override { return m_data.shouldDebugBreak; }
|
||||
virtual int abortAfter() const override { return m_data.abortAfter; }
|
||||
virtual bool showInvisibles() const override { return m_data.showInvisibles; }
|
||||
virtual RunTests::InWhatOrder runOrder() const override { return m_data.runOrder; }
|
||||
virtual unsigned int rngSeed() const override { return m_data.rngSeed; }
|
||||
virtual UseColour::YesOrNo useColour() const override { return m_data.useColour; }
|
||||
virtual bool shouldDebugBreak() const override { return m_data.shouldDebugBreak; }
|
||||
virtual int abortAfter() const override { return m_data.abortAfter; }
|
||||
virtual bool showInvisibles() const override { return m_data.showInvisibles; }
|
||||
|
||||
private:
|
||||
|
||||
|
@ -17,11 +17,11 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
struct Verbosity { enum Level {
|
||||
NoOutput = 0,
|
||||
Quiet,
|
||||
Normal
|
||||
}; };
|
||||
enum class Verbosity {
|
||||
Quiet = 0,
|
||||
Normal,
|
||||
High
|
||||
};
|
||||
|
||||
struct WarnAbout { enum What {
|
||||
Nothing = 0x00,
|
||||
|
@ -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 );
|
||||
@ -43,6 +44,13 @@ namespace Catch {
|
||||
Colour colourGuard( colour );
|
||||
|
||||
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() )
|
||||
Catch::cout() << Text( testCaseInfo.tagsAsString, tagsAttr ) << std::endl;
|
||||
}
|
||||
@ -63,9 +71,12 @@ namespace Catch {
|
||||
for( auto const& testCaseInfo : matchedTestCases ) {
|
||||
matchedTests++;
|
||||
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.verbosity() >= Verbosity::High )
|
||||
Catch::cout() << "\t@" << testCaseInfo.lineInfo;
|
||||
Catch::cout() << std::endl;
|
||||
}
|
||||
return matchedTests;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user