Author: kpvdr
Date: 2008-10-10 08:49:25 -0400 (Fri, 10 Oct 2008)
New Revision: 2614
Modified:
store/trunk/cpp/tests/jrnl/jtt/main.cpp
store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp
store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.hpp
store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp
store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp
Log:
Fixed jtt so that non-zero result is returned on test failures, not just jtt exceptions.
Modified: store/trunk/cpp/tests/jrnl/jtt/main.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/main.cpp 2008-10-10 12:43:43 UTC (rev 2613)
+++ store/trunk/cpp/tests/jrnl/jtt/main.cpp 2008-10-10 12:49:25 UTC (rev 2614)
@@ -48,11 +48,12 @@
{
mrg::jtt::test_mgr tm(args);
tm.run();
+ if (tm.error()) return 2; // One or more tests threw exceptions
}
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
- return 1;
+ return 3;
}
return 0;
}
Modified: store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp 2008-10-10 12:43:43 UTC
(rev 2613)
+++ store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp 2008-10-10 12:49:25 UTC
(rev 2614)
@@ -65,6 +65,24 @@
}
}
+bool
+test_case_result_agregation::exception() const
+{
+ for (tcrp_list_citr i = _rlist.begin(); i < _rlist.end(); i++)
+ if ((*i)->exception())
+ return true;
+ return false;
+}
+
+unsigned
+test_case_result_agregation::exception_count() const
+{
+ unsigned cnt = 0;
+ for (tcrp_list_citr i = _rlist.begin(); i < _rlist.end(); i++)
+ cnt += (*i)->exception_count();
+ return cnt;
+}
+
void
test_case_result_agregation::clear()
{
Modified: store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.hpp 2008-10-10 12:43:43 UTC
(rev 2613)
+++ store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.hpp 2008-10-10 12:49:25 UTC
(rev 2614)
@@ -64,6 +64,8 @@
inline tcrp_list_citr rlist_end() const { return _rlist.end(); }
inline const test_case_result::shared_ptr& operator[](unsigned i) const
{ return _rlist[i]; }
+ bool exception() const;
+ unsigned exception_count() const;
void clear();
const std::string str(const bool last_only, const bool summary) const;
Modified: store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp 2008-10-10 12:43:43 UTC (rev 2613)
+++ store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp 2008-10-10 12:49:25 UTC (rev 2614)
@@ -35,6 +35,7 @@
test_mgr::test_mgr(args& args):
_ji_list(),
_args(args),
+ _err_flag(false),
_random_fn_ptr(random_fn)
{
if (_args.seed)
@@ -125,6 +126,8 @@
catch (...) {} // TODO - work out exception strategy for failure
here...
print_results(*tci, summary);
+ if ((*tci)->average().exception())
+ _err_flag = true;
if (_abort || (!_args.repeat_flag && _signal))
break;
if (_args.pause_secs && tci != tcs.end())
Modified: store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp 2008-10-10 12:43:43 UTC (rev 2613)
+++ store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp 2008-10-10 12:49:25 UTC (rev 2614)
@@ -43,6 +43,7 @@
private:
ji_list _ji_list;
args& _args;
+ bool _err_flag;
ptrdiff_t (*_random_fn_ptr)(const ptrdiff_t i);
static volatile std::sig_atomic_t _signal;
static volatile bool _abort;
@@ -51,6 +52,7 @@
test_mgr(args& args);
virtual ~test_mgr();
void run();
+ inline bool error() const { return _err_flag; }
static void signal_handler(int signal);