Commits

Matt Oswald committed e2dc0b8

added regex matching for suites, test names

Comments (0)

Files changed (2)

xUnit++.console/CommandLine.cpp

             "options:\n\n"
             "  -v --verbose                   : Verbose mode: include successful test timing\n"
             "  -l --list                      : Do not run tests, just list the ones that pass the filters\n"
-            "  -s --suite <SUITE>+            : Suite(s) of tests to run (substring match)\n"
-            "  -n --name <TEST>+              : Test(s) to run (substring match)\n"
-            "  -i --include <NAME=[VALUE]>+   : Include tests with matching <name=value> attribute(s)\n"
-            "  -e --exclude <NAME=[VALUE]>+   : Exclude tests with matching <name=value> attribute(s)\n"
+            "  -s --suite <SUITE>+            : Suite(s) of tests to run (regex match)\n"
+            "  -n --name <TEST>+              : Test(s) to run (regex match)\n"
+            "  -i --include <NAME=[VALUE]>+   : Include tests with exactly matching <name=value> attribute(s)\n"
+            "  -e --exclude <NAME=[VALUE]>+   : Exclude tests with exactly matching <name=value> attribute(s)\n"
             "  -t --timelimit <milliseconds>  : Set the default test time limit\n"
             "  -x --xml <FILENAME>            : Output Xunit-style XML file\n"
             "  -c --concurrent <max tests>    : Set maximum number of concurrent tests\n"

xUnit++.console/main.cpp

 #include <algorithm>
 #include <iostream>
+#include <regex>
 #include <string>
 #include <tuple>
 #include <vector>
                     bool included = false;
                     for (const auto &suite : options.suites)
                     {
-                        if (td.Suite.find(suite) != std::string::npos)
+                        std::regex regex(suite, std::regex_constants::icase);
+
+                        if (std::regex_search(td.Suite, regex))
                         {
                             included = true;
                             break;
                     bool included = false;
                     for (const auto &name : options.testNames)
                     {
-                        if (td.ShortName.find(name) != std::string::npos)
+                        std::regex regex(name, std::regex_constants::icase);
+
+                        if (std::regex_search(td.ShortName, regex))
                         {
                             included = true;
                             break;