summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2013-09-24 11:38:56 -0400
committerEliot Horowitz <eliot@10gen.com>2013-09-24 11:39:10 -0400
commit555cbd552bf404d4e9344fe19495fcb7a36e95ac (patch)
tree29ef94a654ad4b38012149575de2da61068b200c /src
parent6fd8a847809b626bf13762045c7b75730c55e784 (diff)
downloadmongo-555cbd552bf404d4e9344fe19495fcb7a36e95ac.tar.gz
add time to unittest output and fix formatting
Diffstat (limited to 'src')
-rw-r--r--src/mongo/unittest/unittest.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/mongo/unittest/unittest.cpp b/src/mongo/unittest/unittest.cpp
index a891b7a10f7..53273a52fcc 100644
--- a/src/mongo/unittest/unittest.cpp
+++ b/src/mongo/unittest/unittest.cpp
@@ -28,6 +28,7 @@
#include "mongo/logger/message_log_domain.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/log.h"
+#include "mongo/util/timer.h"
namespace mongo {
@@ -61,13 +62,16 @@ namespace mongo {
class Result {
public:
- Result( const std::string& name ) : _name( name ) , _rc(0) , _tests(0) , _fails(0) , _asserts(0) {}
+ Result( const std::string& name )
+ : _name( name ) , _rc(0) , _tests(0) , _fails(0) , _asserts(0), _millis(0) {}
std::string toString() {
std::stringstream ss;
char result[128];
- sprintf(result, "%-20s | tests: %4d | fails: %4d | assert calls: %6d\n", _name.c_str(), _tests, _fails, _asserts);
+ sprintf(result,
+ "%-30s | tests: %4d | fails: %4d | assert calls: %10d | time secs: %6.3f\n",
+ _name.c_str(), _tests, _fails, _asserts, _millis/1000.0 );
ss << result;
for ( std::vector<std::string>::iterator i=_messages.begin(); i!=_messages.end(); i++ ) {
@@ -87,6 +91,7 @@ namespace mongo {
int _tests;
int _fails;
int _asserts;
+ int _millis;
std::vector<std::string> _messages;
static Result * cur;
@@ -138,6 +143,7 @@ namespace mongo {
setupTests();
LOG(1) << "\t done setupTests" << std::endl;
+ Timer timer;
Result * r = new Result( _name );
Result::cur = r;
@@ -185,6 +191,7 @@ namespace mongo {
if ( r->_fails )
r->_rc = 17;
+ r->_millis = timer.millis();
onCurrentTestNameChange( "" );
@@ -235,6 +242,7 @@ namespace mongo {
int tests = 0;
int fails = 0;
int asserts = 0;
+ int millis = 0;
for ( std::vector<Result*>::iterator i=results.begin(); i!=results.end(); i++ ) {
Result* r = *i;
@@ -245,12 +253,14 @@ namespace mongo {
tests += r->_tests;
fails += r->_fails;
asserts += r->_asserts;
+ millis += r->_millis;
}
Result totals ("TOTALS");
totals._tests = tests;
totals._fails = fails;
totals._asserts = asserts;
+ totals._millis = millis;
log() << totals.toString(); // includes endl