X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Fcollection.cc;h=040dd8b4690ec1c4574454c948b9e9c8c6bd5465;hb=50532bea9eb770554e1e962d03b868987303acbe;hp=bfd1fac20799ef09aff58e74e6b08293a1591691;hpb=16381b55407865d6d45e73518865e18bf72c3b13;p=m6w6%2Flibmemcached diff --git a/libtest/collection.cc b/libtest/collection.cc index bfd1fac2..040dd8b4 100644 --- a/libtest/collection.cc +++ b/libtest/collection.cc @@ -34,10 +34,11 @@ * */ -#include "mem_config.h" +#include "libtest/yatlcon.h" #include +// @todo possibly have this code fork off so if it fails nothing goes bad static test_return_t runner_code(libtest::Framework* frame, test_st* run, libtest::Timer& _timer) @@ -50,11 +51,14 @@ static test_return_t runner_code(libtest::Framework* frame, try { _timer.reset(); - return_code= frame->runner()->run(run->test_fn, frame->creators_ptr()); + assert(frame); + assert(frame->runner()); + assert(run->test_fn); + return_code= frame->runner()->main(run->test_fn, frame->creators_ptr()); } // Special case where check for the testing of the exception // system. - catch (libtest::fatal &e) + catch (const libtest::fatal& e) { if (libtest::fatal::is_disabled()) { @@ -92,7 +96,7 @@ Collection::Collection(Framework* frame_arg, test_return_t Collection::exec() { - if (test_success(_frame->runner()->pre(_pre, _frame->creators_ptr()))) + if (test_success(_frame->runner()->setup(_pre, _frame->creators_ptr()))) { for (test_st *run= _tests; run->name; run++) { @@ -132,11 +136,24 @@ test_return_t Collection::exec() } libtest::cancel_alarm(); } - catch (libtest::fatal &e) + catch (const libtest::fatal& e) { - stream::cerr(e.file(), e.line(), e.func()) << e.what(); _failed++; formatter()->failed(); + stream::make_cerr err(e.file(), e.line(), e.func()); + err << e.what(); + for (auto server : _frame->servers().servers) + { + auto output = server->output(); + if (output.first.size()) + { + err << "Server stdout:\n" << output.first << "\n"; + } + if (output.second.size()) + { + err << "Server stderr:\n" << output.second << "\n"; + } + } throw; } @@ -150,6 +167,18 @@ test_return_t Collection::exec() case TEST_FAILURE: _failed++; formatter()->failed(); + for (auto server : _frame->servers().servers) + { + auto output = server->output(); + if (output.first.size()) + { + Out << "Server stdout:\n" << output.first << "\n"; + } + if (output.second.size()) + { + Out << "Server stderr:\n" << output.second << "\n"; + } + } break; case TEST_SKIPPED: @@ -158,14 +187,14 @@ test_return_t Collection::exec() break; default: - fatal_message("invalid return code"); + FATAL("invalid return code"); } #if 0 @TODO add code here to allow for a collection to define a method to reset to allow tests to continue. #endif } - (void) _frame->runner()->post(_post, _frame->creators_ptr()); + (void) _frame->runner()->teardown(_post, _frame->creators_ptr()); } if (_failed == 0 and _skipped == 0 and _success)