X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fframework.cc;h=92aacfeea30a37f117efabfa514285b1ae9f50bb;hb=f03c69858ae94c14939af2fa0280dc049d6b714a;hp=55881b189b7d99bbe665d01a8e2fb355a68b11f3;hpb=a75ccc958c9407f482708d1a491e4bf6054d6998;p=awesomized%2Flibmemcached diff --git a/libtest/framework.cc b/libtest/framework.cc index 55881b18..92aacfee 100644 --- a/libtest/framework.cc +++ b/libtest/framework.cc @@ -34,37 +34,43 @@ * */ -#include +#include "libtest/yatlcon.h" #include #include #include +#include #include #include -using namespace libtest; +namespace libtest { -Framework::Framework(libtest::SignalThread& signal, +Framework::Framework(libtest::SignalThread& signal_, + const std::string& name_, const std::string& only_run_arg, const std::string& wildcard_arg) : - collections(NULL), _total(0), _success(0), _skipped(0), _failed(0), _create(NULL), _destroy(NULL), + _on_error(NULL), _runner(NULL), _socket(false), _creators_ptr(NULL), - _signal(signal), + _signal(signal_), _only_run(only_run_arg), - _wildcard(wildcard_arg) + _wildcard(wildcard_arg), + _name(name_) { get_world(this); +} - for (collection_st *next= collections; next and next->name; next++) +void Framework::collections(collection_st collections_[]) +{ + for (collection_st *next= collections_; next and next->name; next++) { _collection.push_back(new Collection(this, next)); } @@ -81,12 +87,8 @@ Framework::~Framework() delete _runner; - for (std::vector::iterator iter= _collection.begin(); - iter != _collection.end(); - iter++) - { - delete *iter; - } + std::for_each(_collection.begin(), _collection.end(), DeleteFromVector()); + _collection.clear(); } bool Framework::match(const char* arg) @@ -103,7 +105,7 @@ void Framework::exec() { for (std::vector::iterator iter= _collection.begin(); iter != _collection.end() and (_signal.is_shutdown() == false); - iter++) + ++iter) { if (_only_run.empty() == false and fnmatch(_only_run.c_str(), (*iter)->name(), 0)) @@ -131,18 +133,25 @@ void Framework::exec() break; } } - catch (libtest::fatal& e) + catch (const libtest::fatal& e) { - stream::cerr(e.file(), e.line(), e.func()) << e.mesg(); + _failed++; + stream::cerr(e.file(), e.line(), e.func()) << e.what(); } - catch (libtest::disconnected& e) + catch (const libtest::disconnected& e) { + _failed++; Error << "Unhandled disconnection occurred:" << e.what(); throw; } - - Outn(); + catch (...) + { + _failed++; + throw; + } } + + void xml(const std::string& testsuites_name, std::ostream& output); } uint32_t Framework::sum_total() @@ -150,7 +159,7 @@ uint32_t Framework::sum_total() uint32_t count= 0; for (std::vector::iterator iter= _collection.begin(); iter != _collection.end(); - iter++) + ++iter) { count+= (*iter)->total(); } @@ -163,7 +172,7 @@ uint32_t Framework::sum_success() uint32_t count= 0; for (std::vector::iterator iter= _collection.begin(); iter != _collection.end(); - iter++) + ++iter) { count+= (*iter)->success(); } @@ -176,7 +185,7 @@ uint32_t Framework::sum_skipped() uint32_t count= 0; for (std::vector::iterator iter= _collection.begin(); iter != _collection.end(); - iter++) + ++iter) { count+= (*iter)->skipped(); } @@ -189,7 +198,7 @@ uint32_t Framework::sum_failed() uint32_t count= 0; for (std::vector::iterator iter= _collection.begin(); iter != _collection.end(); - iter++) + ++iter) { count+= (*iter)->failed(); } @@ -218,3 +227,5 @@ test_return_t Framework::create() return rc; } + +} // namespace libtest