diff --git a/base/regexp.hpp b/base/regexp.hpp index 0425921d7d..6a5dbd3597 100644 --- a/base/regexp.hpp +++ b/base/regexp.hpp @@ -13,6 +13,11 @@ namespace regexp out = RegExpT::compile(regexp); } + inline bool Matches(string const & str, RegExpT const & regexp) + { + return boost::xpressive::regex_match(str, regexp); + } + inline bool IsExist(string const & str, RegExpT const & regexp) { return boost::xpressive::regex_search(str, regexp); diff --git a/testing/testingmain.cpp b/testing/testingmain.cpp index dda353a36e..58c3d6032d 100644 --- a/testing/testingmain.cpp +++ b/testing/testingmain.cpp @@ -2,6 +2,8 @@ #include "testing.hpp" #include "../base/logging.hpp" +#include "../base/string_utils.hpp" +#include "../base/regexp.hpp" #include "../std/iostream.hpp" #include "../std/string.hpp" @@ -43,6 +45,20 @@ int main(int argc, char * argv[]) vector testResults; int numFailedTests = 0; + char const filterOptionPrefix[] = "--filter="; + char const * testsFilter = nullptr; + + regexp::RegExpT testsFilterRegExp; + + for (int arg = 1; arg < argc; ++arg) + { + if (strings::StartsWith(argv[arg], filterOptionPrefix)) + testsFilter = argv[arg] + sizeof(filterOptionPrefix) - 1; + } + + if (testsFilter) + regexp::Create(testsFilter, testsFilterRegExp); + for (TestRegister * pTest = TestRegister::FirstRegister(); pTest; pTest = pTest->m_pNext) { string fileName(pTest->m_FileName); @@ -63,6 +79,8 @@ int main(int argc, char * argv[]) int iTest = 0; for (TestRegister * pTest = TestRegister::FirstRegister(); pTest; ++iTest, pTest = pTest->m_pNext) { + if (testsFilter && !regexp::Matches(testNames[iTest], testsFilterRegExp)) + continue; cerr << "Running " << testNames[iTest] << endl << flush; if (!g_bLastTestOK) {