Commits

Matt Oswald  committed 65bfa3f

added substring matching for suites, test names to commandline runner

  • Participants
  • Parent commits 9a86d6b

Comments (0)

Files changed (4)

 create lib/include structure
 check Release builds for warnings (and failing tests)
 can runner be made configuration agnostic? (ie, can debug runner load release tests, and vice versa?)
-filter by regex/substring matching on tests/suites(/attributes)
+inline theories
 
 
 Visual Studio 2012 notes

File xUnit++.console/CommandLine.cpp

 
                     options.suites.push_back(TakeFront(arguments));
                 }
+                else if (opt == "-n" || opt == "--name")
+                {
+                    if (arguments.empty())
+                    {
+                        return opt + " expects a following test name argument." + Usage(exe());
+                    }
+
+                    options.testNames.push_back(TakeFront(arguments));
+                }
                 else if (opt == "-i" || opt == "--include")
                 {
                     auto error = EatKeyValuePairs(opt, arguments, [&](std::pair<std::string, std::string> &&kv) { options.inclusiveAttributes.emplace(kv); });
             "  -v                             : Verbose mode: include successful test timing\n"
             "  -vv                            : Very verbose: write test start message\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\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"
             "  -t --timelimit <milliseconds>  : Set the default test time limit\n"

File xUnit++.console/CommandLine.h

         bool veryVerbose;
         bool list;
         std::vector<std::string> suites;
+        std::vector<std::string> testNames;
         std::multimap<std::string, std::string> inclusiveAttributes;
         std::multimap<std::string, std::string> exclusiveAttributes;
         std::vector<std::string> libraries;

File xUnit++.console/main.cpp

                 // if any suites are specified, a test has to belong to one of them to be run
                 if (!options.suites.empty())
                 {
-                    if (std::find(options.suites.begin(), options.suites.end(), td.Suite) == options.suites.end())
+                    bool included = false;
+                    for (const auto &suite : options.suites)
+                    {
+                        if (td.Suite.find(suite) != std::string::npos)
+                        {
+                            included = true;
+                            break;
+                        }
+                    }
+
+                    if (!included)
+                    {
+                        return;
+                    }
+                }
+
+                // check names
+                if (!options.testNames.empty())
+                {
+                    bool included = false;
+                    for (const auto &name : options.testNames)
+                    {
+                        if (td.ShortName.find(name) != std::string::npos)
+                        {
+                            included = true;
+                            break;
+                        }
+                    }
+
+                    if (!included)
                     {
                         return;
                     }