40#ifndef HYRAX_GIT_RUN_TESTS_CPPUNIT_H
41#define HYRAX_GIT_RUN_TESTS_CPPUNIT_H
48#include <cppunit/TextTestRunner.h>
49#include <cppunit/extensions/TestFactoryRegistry.h>
50#include <cppunit/extensions/HelperMacros.h>
57#define DBG(x) do { if (debug) (x); } while(false)
62#define DBG2(x) do { if (debug2) (x); } while(false)
64void show_file(
const std::string &filename)
66 std::ifstream t(filename);
69 std::string file_content((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());
70 std::cout <<
"##################################################################" << std::endl;
71 std::cout <<
"file: " << filename << std::endl;
72 std::cout <<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . " << std::endl;
73 std::cout << file_content << std::endl;
74 std::cout <<
". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . " << std::endl;
92bool bes_run_tests(
int argc,
char *argv[],
const std::string &besdebug_contexts)
94 CppUnit::TextTestRunner runner;
95 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
98 while ((option_char = getopt(argc, argv,
"dDbh")) != -1) {
99 switch (option_char) {
110 std::cerr <<
"Usage: the following tests can be run individually or in combination:" << std::endl;
111 auto &tests = CLASS::suite()->getTests();
112 unsigned int prefix_len = CLASS::suite()->getName().append(
"::").size();
113 for (
auto &t: tests) {
114 std::cerr << t->getName().replace(0, prefix_len,
"") << std::endl;
127 return runner.run(
"");
130 bool wasSuccessful =
true;
133 std::string test = CLASS::suite()->getName().append(
"::").append(argv[i++]);
134 if (debug) std::cerr <<
"Running " << test << std::endl;
135 wasSuccessful = wasSuccessful && runner.run(test);
137 return wasSuccessful;
static void SetUp(const std::string &values)
Sets up debugging for the bes.