Allow more filters and rename member.

This commit is contained in:
chriseth 2019-04-17 11:45:51 +02:00
parent 827e13a2d7
commit 669df0d1e5
3 changed files with 7 additions and 6 deletions

View File

@ -59,7 +59,7 @@ IsolTestOptions::IsolTestOptions(std::string* _editor):
("editor", po::value<std::string>(_editor)->default_value(editorPath()), "Path to editor for opening test files.") ("editor", po::value<std::string>(_editor)->default_value(editorPath()), "Path to editor for opening test files.")
("help", po::bool_switch(&showHelp), "Show this help screen.") ("help", po::bool_switch(&showHelp), "Show this help screen.")
("no-color", po::bool_switch(&noColor), "Don't use colors.") ("no-color", po::bool_switch(&noColor), "Don't use colors.")
("test,t", po::value<std::string>(&test)->default_value("*/*"), "Filters which test units to include."); ("test,t", po::value<std::string>(&testFilter)->default_value("*/*"), "Filters which test units to include.");
} }
bool IsolTestOptions::parse(int _argc, char const* const* _argv) bool IsolTestOptions::parse(int _argc, char const* const* _argv)
@ -77,11 +77,12 @@ bool IsolTestOptions::parse(int _argc, char const* const* _argv)
void IsolTestOptions::validate() const void IsolTestOptions::validate() const
{ {
std::regex filterExpression{"(((\\*+|\\w+|\\w+\\*+)\\/)+(\\*|\\w+\\**))"}; static std::string filterString{"[a-zA-Z1-9_/*]*"};
static std::regex filterExpression{filterString};
assertThrow( assertThrow(
regex_match(test, filterExpression), regex_match(testFilter, filterExpression),
ConfigException, ConfigException,
"Invalid test unit filter: " + test "Invalid test unit filter - can only contain '" + filterString + ": " + testFilter
); );
} }

View File

@ -32,7 +32,7 @@ struct IsolTestOptions: CommonOptions
{ {
bool showHelp = false; bool showHelp = false;
bool noColor = false; bool noColor = false;
std::string test = std::string{}; std::string testFilter = std::string{};
IsolTestOptions(std::string* _editor); IsolTestOptions(std::string* _editor);
bool parse(int _argc, char const* const* _argv) override; bool parse(int _argc, char const* const* _argv) override;

View File

@ -98,7 +98,7 @@ public:
): ):
m_testCaseCreator(_testCaseCreator), m_testCaseCreator(_testCaseCreator),
m_options(_options), m_options(_options),
m_filter(TestFilter{_options.test}), m_filter(TestFilter{_options.testFilter}),
m_path(_path), m_path(_path),
m_name(_name) m_name(_name)
{} {}