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

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authordvirtz2018-02-09 00:18:32 +0200
committerMartin Hořeňovský2018-02-09 19:55:40 +0100
commitca8470fbad3447e16b738fb6f93606dfee03f424 (patch)
tree01ebd68e928c274db15d3859c8a31665452d831d /include
parent355b3f9952430b77cc7c0ed3e273ba453f201c07 (diff)
downloadcatch3-ca8470fbad3447e16b738fb6f93606dfee03f424.tar.gz
https://github.com/catchorg/Catch2/issues/1175 - don't list hidden tests by default
Diffstat (limited to 'include')
-rw-r--r--include/internal/catch_config.cpp11
-rw-r--r--include/internal/catch_config.hpp2
-rw-r--r--include/internal/catch_interfaces_config.h1
-rw-r--r--include/internal/catch_list.cpp10
-rw-r--r--include/internal/catch_session.cpp2
5 files changed, 14 insertions, 12 deletions
diff --git a/include/internal/catch_config.cpp b/include/internal/catch_config.cpp
index 5fda44ff..1db94119 100644
--- a/include/internal/catch_config.cpp
+++ b/include/internal/catch_config.cpp
@@ -15,12 +15,16 @@ namespace Catch {
: m_data( data ),
m_stream( openStream() )
{
- if( !data.testsOrTags.empty() ) {
- TestSpecParser parser( ITagAliasRegistry::get() );
+ TestSpecParser parser(ITagAliasRegistry::get());
+ if (data.testsOrTags.empty()) {
+ parser.parse("~[.]"); // All not hidden tests
+ }
+ else {
+ m_hasTestFilters = true;
for( auto const& testOrTags : data.testsOrTags )
parser.parse( testOrTags );
- m_testSpec = parser.testSpec();
}
+ m_testSpec = parser.testSpec();
}
std::string const& Config::getFilename() const {
@@ -39,6 +43,7 @@ namespace Catch {
std::vector<std::string> const& Config::getSectionsToRun() const { return m_data.sectionsToRun; }
TestSpec const& Config::testSpec() const { return m_testSpec; }
+ bool Config::hasTestFilters() const { return m_hasTestFilters; }
bool Config::showHelp() const { return m_data.showHelp; }
diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp
index 21e04069..3afdff5e 100644
--- a/include/internal/catch_config.hpp
+++ b/include/internal/catch_config.hpp
@@ -82,6 +82,7 @@ namespace Catch {
std::vector<std::string> const& getSectionsToRun() const override;
virtual TestSpec const& testSpec() const override;
+ bool hasTestFilters() const override;
bool showHelp() const;
@@ -109,6 +110,7 @@ namespace Catch {
std::unique_ptr<IStream const> m_stream;
TestSpec m_testSpec;
+ bool m_hasTestFilters = false;
};
} // end namespace Catch
diff --git a/include/internal/catch_interfaces_config.h b/include/internal/catch_interfaces_config.h
index 35ec82cf..f509c7ed 100644
--- a/include/internal/catch_interfaces_config.h
+++ b/include/internal/catch_interfaces_config.h
@@ -68,6 +68,7 @@ namespace Catch {
virtual bool showInvisibles() const = 0;
virtual ShowDurations::OrNot showDurations() const = 0;
virtual TestSpec const& testSpec() const = 0;
+ virtual bool hasTestFilters() const = 0;
virtual RunTests::InWhatOrder runOrder() const = 0;
virtual unsigned int rngSeed() const = 0;
virtual int benchmarkResolutionMultiple() const = 0;
diff --git a/include/internal/catch_list.cpp b/include/internal/catch_list.cpp
index 3efad0b7..3b0e33f1 100644
--- a/include/internal/catch_list.cpp
+++ b/include/internal/catch_list.cpp
@@ -28,11 +28,10 @@ namespace Catch {
std::size_t listTests( Config const& config ) {
TestSpec testSpec = config.testSpec();
- if( config.testSpec().hasFilters() )
+ if( config.hasTestFilters() )
Catch::cout() << "Matching test cases:\n";
else {
Catch::cout() << "All available test cases:\n";
- testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec();
}
auto matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
@@ -54,7 +53,7 @@ namespace Catch {
Catch::cout() << Column( testCaseInfo.tagsAsString() ).indent( 6 ) << "\n";
}
- if( !config.testSpec().hasFilters() )
+ if( !config.hasTestFilters() )
Catch::cout() << pluralise( matchedTestCases.size(), "test case" ) << '\n' << std::endl;
else
Catch::cout() << pluralise( matchedTestCases.size(), "matching test case" ) << '\n' << std::endl;
@@ -63,8 +62,6 @@ namespace Catch {
std::size_t listTestsNamesOnly( Config const& config ) {
TestSpec testSpec = config.testSpec();
- if( !config.testSpec().hasFilters() )
- testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec();
std::size_t matchedTests = 0;
std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
for( auto const& testCaseInfo : matchedTestCases ) {
@@ -94,11 +91,10 @@ namespace Catch {
std::size_t listTags( Config const& config ) {
TestSpec testSpec = config.testSpec();
- if( config.testSpec().hasFilters() )
+ if( config.hasTestFilters() )
Catch::cout() << "Tags for matching test cases:\n";
else {
Catch::cout() << "All available tags:\n";
- testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec();
}
std::map<std::string, TagInfo> tagCounts;
diff --git a/include/internal/catch_session.cpp b/include/internal/catch_session.cpp
index e170f7ca..71317eba 100644
--- a/include/internal/catch_session.cpp
+++ b/include/internal/catch_session.cpp
@@ -70,8 +70,6 @@ namespace Catch {
context.testGroupStarting(config->name(), 1, 1);
TestSpec testSpec = config->testSpec();
- if (!testSpec.hasFilters())
- testSpec = TestSpecParser(ITagAliasRegistry::get()).parse("~[.]").testSpec(); // All not hidden tests
auto const& allTestCases = getAllTestCasesSorted(*config);
for (auto const& testCase : allTestCases) {