#include <testsuite.h>
Collaboration diagram for test_driver:
Public Member Functions | |
XAPIAN_NORETURN (static void usage()) | |
test_driver (const test_desc *tests_) | |
The constructor, which sets up the test driver. | |
result | run_tests () |
Run all the tests supplied and return the results. | |
result | run_tests (std::vector< std::string >::const_iterator b, std::vector< std::string >::const_iterator e) |
Run the tests in the list and return the results. | |
Static Public Member Functions | |
static void | add_command_line_option (const std::string &l, char s, std::string *arg) |
Add a test-specific command line option. | |
static void | parse_command_line (int argc, char **argv) |
Parse the command line arguments. | |
static int | run (const test_desc *tests) |
static std::string | get_srcdir () |
Read srcdir from environment and if not present, make a valiant attempt to guess a value. | |
static void | report (const test_driver::result &r, const std::string &desc) |
Print summary of tests passed, failed, and skipped. | |
Static Public Attributes | |
static result | subtotal |
static result | total |
Private Types | |
enum | test_result { PASS = 1, FAIL = 0, SKIP = -1 } |
Private Member Functions | |
test_driver (const test_driver &) | |
Prevent copying. | |
test_driver & | operator= (const test_driver &) |
test_result | runtest (const test_desc *test) |
Runs the test function and returns its result. | |
result | do_run_tests (std::vector< std::string >::const_iterator b, std::vector< std::string >::const_iterator e) |
The implementation used by run_tests. | |
Private Attributes | |
std::ostream | out |
const test_desc * | tests |
Static Private Attributes | |
static std::map< int, std::string * > | short_opts |
static std::string | opt_help |
static std::vector< std::string > | test_names |
static bool | abort_on_error = false |
static int | runs = 0 |
static std::string | argv0 |
static std::string | col_red |
static std::string | col_green |
static std::string | col_yellow |
static std::string | col_reset |
static bool | use_cr = false |
Classes | |
struct | result |
A structure used to report the summary of tests passed and failed. More... |
Definition at line 94 of file testsuite.h.
enum test_driver::test_result [private] |
test_driver::test_driver | ( | const test_desc * | tests_ | ) |
The constructor, which sets up the test driver.
tests | The zero-terminated array of tests to run. |
Definition at line 150 of file testsuite.cc.
test_driver::test_driver | ( | const test_driver & | ) | [private] |
Prevent copying.
static void test_driver::add_command_line_option | ( | const std::string & | l, | |
char | s, | |||
std::string * | arg | |||
) | [static] |
void test_driver::parse_command_line | ( | int | argc, | |
char ** | argv | |||
) | [static] |
Parse the command line arguments.
Definition at line 616 of file testsuite.cc.
References abort_on_error, argv0, col_green, col_red, col_reset, col_yellow, DEBUGLINE, gnu_getopt_long(), long_opts, no_argument, Xapian::Remote::open(), optarg, optind, opts, short_opts, test_names, unlink(), use_cr, and verbose.
Referenced by main().
test_driver::XAPIAN_NORETURN | ( | static void | usage() | ) |
int test_driver::run | ( | const test_desc * | tests | ) | [static] |
Definition at line 706 of file testsuite.cc.
References test_driver::result::failed, run_tests(), subtotal, test_names, and tests.
test_driver::result test_driver::run_tests | ( | ) |
Run all the tests supplied and return the results.
Definition at line 498 of file testsuite.cc.
References do_run_tests().
Referenced by run().
result test_driver::run_tests | ( | std::vector< std::string >::const_iterator | b, | |
std::vector< std::string >::const_iterator | e | |||
) |
Run the tests in the list and return the results.
string test_driver::get_srcdir | ( | ) | [static] |
Read srcdir from environment and if not present, make a valiant attempt to guess a value.
Definition at line 103 of file testsuite.cc.
References argv0, endswith(), file_exists(), srcdir, and startswith().
Referenced by DEFINE_TESTCASE(), and main().
static void test_driver::report | ( | const test_driver::result & | r, | |
const std::string & | desc | |||
) | [static] |
test_driver& test_driver::operator= | ( | const test_driver & | ) | [private] |
test_driver::test_result test_driver::runtest | ( | const test_desc * | test | ) | [private] |
Runs the test function and returns its result.
It will also trap exceptions and some memory leaks and force a failure in those cases.
Definition at line 218 of file testsuite.cc.
References SignalRedirector::activate(), col_red, col_reset, col_yellow, dummy, expected_exception, FAIL, Xapian::Error::get_description(), Xapian::Error::get_type(), jb, out, PASS, test_desc::run, signum, SKIP, tout, and verbose.
result test_driver::do_run_tests | ( | std::vector< std::string >::const_iterator | b, | |
std::vector< std::string >::const_iterator | e | |||
) | [private] |
The implementation used by run_tests.
it runs test(s) (with runtest()), prints out messages for the user, and tracks the successes and failures.
b,e | If b != e, a vector of the test(s) to run. If b == e, all tests will be run. |
Referenced by run_tests().
test_driver::result test_driver::subtotal [static] |
test_driver::result test_driver::total [static] |
map< int, string * > test_driver::short_opts [static, private] |
string test_driver::opt_help [static, private] |
Definition at line 185 of file testsuite.h.
vector< string > test_driver::test_names [static, private] |
bool test_driver::abort_on_error = false [static, private] |
std::ostream test_driver::out [private] |
const test_desc* test_driver::tests [private] |
int test_driver::runs = 0 [static, private] |
Definition at line 217 of file testsuite.h.
string test_driver::argv0 [static, private] |
string test_driver::col_red [static, private] |
string test_driver::col_green [static, private] |
string test_driver::col_yellow [static, private] |
string test_driver::col_reset [static, private] |
bool test_driver::use_cr = false [static, private] |