diff options
| author | Martin Hořeňovský | 2021-01-27 09:07:15 +0100 |
|---|---|---|
| committer | GitHub | 2021-01-27 09:07:15 +0100 |
| commit | b435e391c45c7cdb23c35cd2afb3435b0b7e53c7 (patch) | |
| tree | a4bb48202c96d1dd4b7efe83f98c2919d890d1c9 /src/catch2/interfaces/catch_interfaces_reporter.cpp | |
| parent | ba8150516800dd5e18f818346a2a12c45b6ec542 (diff) | |
| parent | 971b1fc32a857caa10eb166f39442cee5237267b (diff) | |
| download | catch3-b435e391c45c7cdb23c35cd2afb3435b0b7e53c7.tar.gz | |
Merge pull request #2163 from catchorg/devel-list-outputs-to-out-flag
The output of --list-* flags obeys -o flag
Diffstat (limited to 'src/catch2/interfaces/catch_interfaces_reporter.cpp')
| -rw-r--r-- | src/catch2/interfaces/catch_interfaces_reporter.cpp | 106 |
1 files changed, 1 insertions, 105 deletions
diff --git a/src/catch2/interfaces/catch_interfaces_reporter.cpp b/src/catch2/interfaces/catch_interfaces_reporter.cpp index 948869e7..19416130 100644 --- a/src/catch2/interfaces/catch_interfaces_reporter.cpp +++ b/src/catch2/interfaces/catch_interfaces_reporter.cpp @@ -11,34 +11,15 @@ #include <catch2/internal/catch_console_width.hpp> #include <catch2/catch_message.hpp> #include <catch2/internal/catch_list.hpp> -#include <catch2/internal/catch_textflow.hpp> #include <catch2/internal/catch_string_manip.hpp> #include <catch2/catch_test_case_info.hpp> -#include <catch2/internal/catch_textflow.hpp> +#include <catch2/reporters/catch_reporter_helpers.hpp> #include <algorithm> #include <iomanip> namespace Catch { - namespace { - void listTestNamesOnly( std::vector<TestCaseHandle> const& tests ) { - for ( auto const& test : tests ) { - auto const& testCaseInfo = test.getTestCaseInfo(); - - if ( startsWith( testCaseInfo.name, '#' ) ) { - Catch::cout() << '"' << testCaseInfo.name << '"'; - } else { - Catch::cout() << testCaseInfo.name; - } - - Catch::cout() << '\n'; - } - Catch::cout() << std::flush; - } - } // end unnamed namespace - - ReporterConfig::ReporterConfig( IConfig const* _fullConfig ) : m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {} @@ -127,89 +108,4 @@ namespace Catch { void IStreamingReporter::fatalErrorEncountered( StringRef ) {} - void IStreamingReporter::listReporters(std::vector<ReporterDescription> const& descriptions, IConfig const& config) { - Catch::cout() << "Available reporters:\n"; - const auto maxNameLen = std::max_element(descriptions.begin(), descriptions.end(), - [](ReporterDescription const& lhs, ReporterDescription const& rhs) { return lhs.name.size() < rhs.name.size(); }) - ->name.size(); - - for (auto const& desc : descriptions) { - if (config.verbosity() == Verbosity::Quiet) { - Catch::cout() - << TextFlow::Column(desc.name) - .indent(2) - .width(5 + maxNameLen) << '\n'; - } else { - Catch::cout() - << TextFlow::Column(desc.name + ":") - .indent(2) - .width(5 + maxNameLen) - + TextFlow::Column(desc.description) - .initialIndent(0) - .indent(2) - .width(CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen - 8) - << '\n'; - } - } - Catch::cout() << std::endl; - } - - void IStreamingReporter::listTests(std::vector<TestCaseHandle> const& tests, IConfig const& config) { - // We special case this to provide the equivalent of old - // `--list-test-names-only`, which could then be used by the - // `--input-file` option. - if (config.verbosity() == Verbosity::Quiet) { - listTestNamesOnly(tests); - return; - } - - if (config.hasTestFilters()) { - Catch::cout() << "Matching test cases:\n"; - } else { - Catch::cout() << "All available test cases:\n"; - } - - for (auto const& test : tests) { - auto const& testCaseInfo = test.getTestCaseInfo(); - Colour::Code colour = testCaseInfo.isHidden() - ? Colour::SecondaryText - : Colour::None; - Colour colourGuard(colour); - - Catch::cout() << TextFlow::Column(testCaseInfo.name).initialIndent(2).indent(4) << '\n'; - if (config.verbosity() >= Verbosity::High) { - Catch::cout() << TextFlow::Column(Catch::Detail::stringify(testCaseInfo.lineInfo)).indent(4) << std::endl; - } - if (!testCaseInfo.tags.empty() && config.verbosity() > Verbosity::Quiet) { - Catch::cout() << TextFlow::Column(testCaseInfo.tagsAsString()).indent(6) << '\n'; - } - } - - if (!config.hasTestFilters()) { - Catch::cout() << pluralise(tests.size(), "test case") << '\n' << std::endl; - } else { - Catch::cout() << pluralise(tests.size(), "matching test case") << '\n' << std::endl; - } - } - - void IStreamingReporter::listTags(std::vector<TagInfo> const& tags, IConfig const& config) { - if (config.hasTestFilters()) { - Catch::cout() << "Tags for matching test cases:\n"; - } else { - Catch::cout() << "All available tags:\n"; - } - - for (auto const& tagCount : tags) { - ReusableStringStream rss; - rss << " " << std::setw(2) << tagCount.count << " "; - auto str = rss.str(); - auto wrapper = TextFlow::Column(tagCount.all()) - .initialIndent(0) - .indent(str.size()) - .width(CATCH_CONFIG_CONSOLE_WIDTH - 10); - Catch::cout() << str << wrapper << '\n'; - } - Catch::cout() << pluralise(tags.size(), "tag") << '\n' << std::endl; - } - } // end namespace Catch |