tcase_set_timeout(tc, 30);
cases_.insert(std::make_pair(name, tc));
}
+
+std::vector<std::string> GlobalTestSuite::testNames(const std::string& testPattern) const
+{
+ boost::regex exp(testPattern, boost::regex::egrep | boost::regex::icase);
+ boost::cmatch what;
+ std::vector<std::string> result;
+ foreach (const Cases::value_type& tcase, cases_)
+ {
+ if (boost::regex_match(tcase.first.c_str(), what, exp))
+ {
+ result.push_back(tcase.first);
+ }
+ }
+ return result;
+}
\ No newline at end of file
#include <boost/foreach.hpp>
#include <map>
+#include <vector>
#include <check.h> // Check unit testing framework... see http://check.sourceforge.net
#include "singleton.h"
const std::string name;
+ std::vector<std::string> testNames(const std::string& = ".*") const;
+
private:
friend class Singleton<GlobalTestSuite>;
GlobalTestSuite(); // non-default constructible
#include <fstream>
#include <deque>
#include <map>
+#include <vector>
#include <boost/algorithm/string.hpp>
#include <boost/program_options.hpp>
#include <boost/shared_ptr.hpp>
po::options_description options("optional arguments");
options.add_options()
("help", "display this help message")
+ ("list", "list test names")
("xml", po::value<std::string>(), "send results to XML file")
("filter", po::value<std::string>()->default_value(".*"), "egrep style regular expression to match tests to run")
;
std::cout << options << std::endl;
exit(EXIT_SUCCESS);
}
-
+
return args;
}
{
po::variables_map args(parseArgs(argc, argv));
+ if (args.count("list"))
+ {
+ std::vector<std::string> names = TheGlobalTestSuite::instance().testNames(args["filter"].as<std::string>());
+ std::copy(names.begin(), names.end(), std::ostream_iterator<std::string>(std::cout, "\n"));
+ exit(EXIT_SUCCESS);
+ }
+
TheGlobalTestSuite::instance().argc = argc;
TheGlobalTestSuite::instance().argv = argv;