Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/interfaces/catch_interfaces_reporter.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2020-10-20 15:09:48 +0200
committerMartin Hořeňovský2020-10-20 15:09:48 +0200
commit923bcc5d6fc2bf0123d883f7d18a678ce63bbfe4 (patch)
tree6f653cfb05f33a902e9b0e9c740dc3f451861db1 /src/catch2/interfaces/catch_interfaces_reporter.cpp
parentb6a3e2e26b8afabd9a8a89a353662eda9b67097e (diff)
downloadcatch3-923bcc5d6fc2bf0123d883f7d18a678ce63bbfe4.tar.gz
Special case --list-tests --verbosity quiet
The new output (mostly) follows the old `--list-test-names-only` format, with the exception of no longer supporting line output for `--verbosity high`. Fixes #2051
Diffstat (limited to 'src/catch2/interfaces/catch_interfaces_reporter.cpp')
-rw-r--r--src/catch2/interfaces/catch_interfaces_reporter.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/catch2/interfaces/catch_interfaces_reporter.cpp b/src/catch2/interfaces/catch_interfaces_reporter.cpp
index c9a36166..948869e7 100644
--- a/src/catch2/interfaces/catch_interfaces_reporter.cpp
+++ b/src/catch2/interfaces/catch_interfaces_reporter.cpp
@@ -21,6 +21,24 @@
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 ) {}
@@ -137,6 +155,14 @@ namespace Catch {
}
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 {