2 #include <libmesh/ignore_warnings.h> 3 #include <cppunit/extensions/TestFactoryRegistry.h> 4 #include <cppunit/ui/text/TestRunner.h> 5 #include <cppunit/BriefTestProgressListener.h> 6 #include <cppunit/TestPath.h> 7 #include <cppunit/TestResult.h> 8 #include <libmesh/restore_warnings.h> 11 #include <libmesh/libmesh.h> 16 #ifdef LIBMESH_HAVE_CXX11_REGEX 44 virtual bool findTestPath (
const std::string & testName, CppUnit::TestPath & testPath)
const override {
return _shimmed_test.findTestPath(testName, testPath); }
46 virtual bool findTestPath (
const CppUnit::Test * test, CppUnit::TestPath & testPath)
const override {
return _shimmed_test.findTestPath(test, testPath); }
48 virtual CppUnit::Test *
findTest(
const std::string & testName)
const override {
return _shimmed_test.findTest(testName); }
64 const std::string & allow_r_str,
65 const std::regex & allow_r,
66 const std::string & deny_r_str,
67 const std::regex & deny_r,
68 CppUnit::TextUi::TestRunner & runner)
70 int n_tests_added = 0;
73 if (test->getName() ==
"All Tests" && allow_r_str ==
"All Tests" &&
81 if (test->getChildTestCount() == 0)
84 if ((allow_r_str ==
"All Tests" ||
85 std::regex_search(test->getName(), allow_r)) &&
86 !std::regex_search(test->getName(), deny_r))
97 for (
int i = 0; i < test->getChildTestCount(); i++)
100 deny_r_str, deny_r, runner);
102 return n_tests_added;
108 int main(
int argc,
char ** argv)
152 std::string allow_regex_string =
"All Tests";
156 std::string deny_regex_string =
"^$";
161 std::unique_ptr<CppUnit::Test> owned_suite;
164 CppUnit::TextUi::TestRunner runner;
168 CppUnit::TestFactoryRegistry & registry = CppUnit::TestFactoryRegistry::getRegistry();
169 CppUnit::Test * suite = registry.makeTest();
171 #ifdef LIBMESH_HAVE_CXX11_REGEX 173 const std::regex allow_regex(allow_regex_string);
174 const std::regex deny_regex(deny_regex_string);
177 libMesh::out <<
"Will run the following tests:" << std::endl;
178 const int n_tests_added =
180 allow_regex_string, allow_regex,
181 deny_regex_string, deny_regex,
183 if (n_tests_added >= 0)
184 libMesh::out <<
"--- Running " << n_tests_added <<
" tests in total." << std::endl;
189 owned_suite.
reset(suite);
192 runner.addTest(suite);
195 std::unique_ptr<CppUnit::TestResult> controller;
196 std::unique_ptr<CppUnit::BriefTestProgressListener> listener;
202 listener = std::make_unique<CppUnit::BriefTestProgressListener>();
203 runner.eventManager().addListener(listener.get());
206 bool succeeded = runner.run();
209 #ifndef LIBMESH_ENABLE_PERFORMANCE_LOGGING 211 driver_unitlog.
clear();
T command_line_next(std::string name, T default_value)
Use GetPot's search()/next() functions to get following arguments from the command line...
virtual CppUnit::Test * findTest(const std::string &testName) const override
virtual CppUnit::TestPath resolveTestPath(const std::string &testPath) const override
virtual void run(CppUnit::TestResult *result) override
libMesh::Parallel::Communicator * TestCommWorld
virtual bool findTestPath(const CppUnit::Test *test, CppUnit::TestPath &testPath) const override
virtual std::string getName() const override
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
void reset(streamT &target)
Reset the proxy to point to a different target.
The PerfLog class allows monitoring of specific events.
virtual int countTestCases() const override
void enable_summarized_logs()
Tells the PerfLog to only print log results summarized by header.
CppUnit::Test & _shimmed_test
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
void clear()
Clears all the internal data and restores the data structures to a pristine state.
virtual int getChildTestCount() const override
libMesh::PerfLog * unitlog
virtual bool findTestPath(const std::string &testName, CppUnit::TestPath &testPath) const override
virtual CppUnit::Test * doGetChildTestAt(int index) const override
TestShim(CppUnit::Test &shimmed_test)
int main(int argc, char **argv)
bool on_command_line(std::string arg)
int add_matching_tests_to_runner(CppUnit::Test *test, const std::string &allow_r_str, const std::regex &allow_r, const std::string &deny_r_str, const std::regex &deny_r, CppUnit::TextUi::TestRunner &runner)
static constexpr int added_whole_suite