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

summaryrefslogtreecommitdiffhomepage
path: root/include/internal/catch_config.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2019-09-09 11:30:45 +0200
committerMartin Hořeňovský2019-09-09 14:28:11 +0200
commitaf8b2538a62db34b3cec10ceb74e3d29bd06e37f (patch)
tree32069c3bf1662b5d50a78829584b3352458f238c /include/internal/catch_config.cpp
parenta156440b19c1103419b6e4d3ebbfe3c7ddb948dc (diff)
downloadcatch3-af8b2538a62db34b3cec10ceb74e3d29bd06e37f.tar.gz
Ignore leading/trailing whitespace in test/section specs
The leading/trailing whitespace is problematic because of e.g. `WHEN` macro having preceeding whitespace for alignment, and it is generally messy. Credits to Phil who did lot of the original work. Closes #1708
Diffstat (limited to 'include/internal/catch_config.cpp')
-rw-r--r--include/internal/catch_config.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/include/internal/catch_config.cpp b/include/internal/catch_config.cpp
index 076ae718..e222328b 100644
--- a/include/internal/catch_config.cpp
+++ b/include/internal/catch_config.cpp
@@ -15,11 +15,23 @@ namespace Catch {
: m_data( data ),
m_stream( openStream() )
{
+ // We need to trim filter specs to avoid trouble with superfluous
+ // whitespace (esp. important for bdd macros, as those are manually
+ // aligned with whitespace).
+
+ for (auto& elem : m_data.testsOrTags) {
+ elem = trim(elem);
+ }
+ for (auto& elem : m_data.sectionsToRun) {
+ elem = trim(elem);
+ }
+
TestSpecParser parser(ITagAliasRegistry::get());
- if (!data.testsOrTags.empty()) {
+ if (!m_data.testsOrTags.empty()) {
m_hasTestFilters = true;
- for( auto const& testOrTags : data.testsOrTags )
- parser.parse( testOrTags );
+ for (auto const& testOrTags : m_data.testsOrTags) {
+ parser.parse(testOrTags);
+ }
}
m_testSpec = parser.testSpec();
}
@@ -32,7 +44,7 @@ namespace Catch {
bool Config::listTestNamesOnly() const { return m_data.listTestNamesOnly; }
bool Config::listTags() const { return m_data.listTags; }
bool Config::listReporters() const { return m_data.listReporters; }
-
+
std::string Config::getProcessName() const { return m_data.processName; }
std::string const& Config::getReporterName() const { return m_data.reporterName; }