| 9126 | namespace Catch { |
| 9127 | |
| 9128 | std::size_t listTests( Config const& config ) { |
| 9129 | TestSpec testSpec = config.testSpec(); |
| 9130 | if( config.hasTestFilters() ) |
| 9131 | Catch::cout() << "Matching test cases:\n"; |
| 9132 | else { |
| 9133 | Catch::cout() << "All available test cases:\n"; |
| 9134 | } |
| 9135 | |
| 9136 | auto matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); |
| 9137 | for( auto const& testCaseInfo : matchedTestCases ) { |
| 9138 | Colour::Code colour = testCaseInfo.isHidden() |
| 9139 | ? Colour::SecondaryText |
| 9140 | : Colour::None; |
| 9141 | Colour colourGuard( colour ); |
| 9142 | |
| 9143 | Catch::cout() << Column( testCaseInfo.name ).initialIndent( 2 ).indent( 4 ) << "\n"; |
| 9144 | if( config.verbosity() >= Verbosity::High ) { |
| 9145 | Catch::cout() << Column( Catch::Detail::stringify( testCaseInfo.lineInfo ) ).indent(4) << std::endl; |
| 9146 | std::string description = testCaseInfo.description; |
| 9147 | if( description.empty() ) |
| 9148 | description = "(NO DESCRIPTION)"; |
| 9149 | Catch::cout() << Column( description ).indent(4) << std::endl; |
| 9150 | } |
| 9151 | if( !testCaseInfo.tags.empty() ) |
| 9152 | Catch::cout() << Column( testCaseInfo.tagsAsString() ).indent( 6 ) << "\n"; |
| 9153 | } |
| 9154 | |
| 9155 | if( !config.hasTestFilters() ) |
| 9156 | Catch::cout() << pluralise( matchedTestCases.size(), "test case" ) << '\n' << std::endl; |
| 9157 | else |
| 9158 | Catch::cout() << pluralise( matchedTestCases.size(), "matching test case" ) << '\n' << std::endl; |
| 9159 | return matchedTestCases.size(); |
| 9160 | } |
| 9161 | |
| 9162 | std::size_t listTestsNamesOnly( Config const& config ) { |
| 9163 | TestSpec testSpec = config.testSpec(); |
no test coverage detected