diff --git a/include/internal/catch_commandline.hpp b/include/internal/catch_commandline.hpp index ea2d7e45..b81e9931 100644 --- a/include/internal/catch_commandline.hpp +++ b/include/internal/catch_commandline.hpp @@ -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" ) diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp index 869e4c70..bc1f5b26 100644 --- a/include/internal/catch_config.hpp +++ b/include/internal/catch_config.hpp @@ -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: diff --git a/include/internal/catch_interfaces_config.h b/include/internal/catch_interfaces_config.h index 4f64f4e3..75499014 100644 --- a/include/internal/catch_interfaces_config.h +++ b/include/internal/catch_interfaces_config.h @@ -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, diff --git a/include/internal/catch_list.hpp b/include/internal/catch_list.hpp index 3cfd294b..5d9d8ed4 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 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; }