From bce105ead963eef8822e4b7a38e9e46ec8d06d2b Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Wed, 17 Apr 2013 13:05:50 -0700 Subject: reset count in LaconicPrinter for when using --gtest_repeat --- src/ninja_test.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ninja_test.cc b/src/ninja_test.cc index 02f2c6b..b772441 100644 --- a/src/ninja_test.cc +++ b/src/ninja_test.cc @@ -38,6 +38,11 @@ class LaconicPrinter : public testing::EmptyTestEventListener { test_count_ = unit_test.test_to_run_count(); } + virtual void OnTestIterationStart(const testing::UnitTest& test_info, + int iteration) { + tests_started_ = 0; + } + virtual void OnTestStart(const testing::TestInfo& test_info) { ++tests_started_; printer_.Print(StringPrintf("[%d/%d] %s.%s", tests_started_, test_count_, -- cgit v0.12 From 9e0443bee9c9d21f795f95f4585d578e26336dad Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Wed, 17 Apr 2013 17:30:06 -0700 Subject: also print iteration for gtest_repeat=-1 --- src/ninja_test.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ninja_test.cc b/src/ninja_test.cc index b772441..f091cc8 100644 --- a/src/ninja_test.cc +++ b/src/ninja_test.cc @@ -33,7 +33,7 @@ std::string StringPrintf(const char* format, ...) { /// A test result printer that's less wordy than gtest's default. class LaconicPrinter : public testing::EmptyTestEventListener { public: - LaconicPrinter() : tests_started_(0), test_count_(0) {} + LaconicPrinter() : tests_started_(0), test_count_(0), iteration_(0) {} virtual void OnTestProgramStart(const testing::UnitTest& unit_test) { test_count_ = unit_test.test_to_run_count(); } @@ -41,13 +41,20 @@ class LaconicPrinter : public testing::EmptyTestEventListener { virtual void OnTestIterationStart(const testing::UnitTest& test_info, int iteration) { tests_started_ = 0; + iteration_ = iteration; } virtual void OnTestStart(const testing::TestInfo& test_info) { ++tests_started_; - printer_.Print(StringPrintf("[%d/%d] %s.%s", tests_started_, test_count_, - test_info.test_case_name(), test_info.name()), - LinePrinter::ELIDE); + printer_.Print( + StringPrintf("[%d/%d%s] %s.%s", + tests_started_, + test_count_, + iteration_ ? StringPrintf(" iter %d", iteration_).c_str() + : "", + test_info.test_case_name(), + test_info.name()), + LinePrinter::ELIDE); } virtual void OnTestPartResult( @@ -67,6 +74,7 @@ class LaconicPrinter : public testing::EmptyTestEventListener { LinePrinter printer_; int tests_started_; int test_count_; + int iteration_; }; int main(int argc, char **argv) { -- cgit v0.12