Commit 827149d9 authored by Dominik Charousset's avatar Dominik Charousset

Add CLI query for test names to unit test binary

parent 99aad0ea
...@@ -305,6 +305,8 @@ public: ...@@ -305,6 +305,8 @@ public:
static std::vector<std::string> available_suites(); static std::vector<std::string> available_suites();
static std::vector<std::string> available_tests(const std::string& suite);
private: private:
engine() = default; engine() = default;
......
...@@ -514,9 +514,18 @@ test* engine::current_test() { ...@@ -514,9 +514,18 @@ test* engine::current_test() {
std::vector<std::string> engine::available_suites() { std::vector<std::string> engine::available_suites() {
std::vector<std::string> result; std::vector<std::string> result;
for (auto& kvp : instance().suites_) { for (auto& kvp : instance().suites_)
result.push_back(kvp.first); result.push_back(kvp.first);
} return result;
}
std::vector<std::string> engine::available_tests(const std::string& suite) {
std::vector<std::string> result;
auto i = instance().suites_.find(suite);
if (i == instance().suites_.end())
return result;
for (auto& ptr : i->second)
result.push_back(ptr->name());
return result; return result;
} }
...@@ -546,6 +555,7 @@ int main(int argc, char** argv) { ...@@ -546,6 +555,7 @@ int main(int argc, char** argv) {
std::string not_suites; std::string not_suites;
std::string tests = ".*"; std::string tests = ".*";
std::string not_tests; std::string not_tests;
std::string suite_query;
// use all arguments after '--' for the test engine. // use all arguments after '--' for the test engine.
std::string delimiter = "--"; std::string delimiter = "--";
auto divider = argc; auto divider = argc;
...@@ -570,17 +580,23 @@ int main(int argc, char** argv) { ...@@ -570,17 +580,23 @@ int main(int argc, char** argv) {
{"not-suites,S", "exclude suites", not_suites}, {"not-suites,S", "exclude suites", not_suites},
{"tests,t", "set tests", tests}, {"tests,t", "set tests", tests},
{"not-tests,T", "exclude tests", not_tests}, {"not-tests,T", "exclude tests", not_tests},
{"available-suites,a", "print available suites"} {"available-suites,a", "print available suites"},
{"available-tests,A", "print available tests for given suite", suite_query}
}); });
if (res.opts.count("help") > 0) { if (res.opts.count("help") > 0) {
std::cout << res.helptext << std::endl; std::cout << res.helptext << std::endl;
return 0; return 0;
} }
if (! suite_query.empty()) {
std::cout << "available tests in suite " << suite_query << ":" << std::endl;
for (auto& t : engine::available_tests(suite_query))
std::cout << " - " << t << std::endl;
return 0;
}
if (res.opts.count("available-suites") > 0) { if (res.opts.count("available-suites") > 0) {
std::cout << "available suites:" << std::endl; std::cout << "available suites:" << std::endl;
for (auto& s : engine::available_suites()) { for (auto& s : engine::available_suites())
std::cout << " - " << s << std::endl; std::cout << " - " << s << std::endl;
}
return 0; return 0;
} }
if (! res.remainder.empty()) { if (! res.remainder.empty()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment