diff --git a/CHANGELOG.md b/CHANGELOG.md index 6424b2a5..9d976042 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ 1.0.0-b12 +* Fix unit test runner to output all case names * Update README for build requirements * Rename to CHANGELOG.md diff --git a/extras/beast/unit_test/reporter.hpp b/extras/beast/unit_test/reporter.hpp index ae9794d7..9b771cd6 100644 --- a/extras/beast/unit_test/reporter.hpp +++ b/extras/beast/unit_test/reporter.hpp @@ -90,7 +90,6 @@ private: results results_; suite_results suite_results_; case_results case_results_; - bool prefixed_ = false; public: reporter(reporter const&) = delete; @@ -228,7 +227,6 @@ reporter<_>:: on_suite_begin(suite_info const& info) { suite_results_ = suite_results{info.full_name()}; - prefixed_ = false; } template @@ -244,13 +242,9 @@ reporter<_>:: on_case_begin(std::string const& name) { case_results_ = case_results(name); - if(! prefixed_) - { - os_ << suite_results_.name << - (case_results_.name.empty() ? "" : - (" " + case_results_.name)) << std::endl; - prefixed_ = true; - } + os_ << suite_results_.name << + (case_results_.name.empty() ? "" : + (" " + case_results_.name)) << std::endl; } template @@ -286,13 +280,6 @@ void reporter<_>:: on_log(std::string const& s) { - if(!prefixed_) - { - os_ << suite_results_.name << - (case_results_.name.empty() ? "" : - (" " + case_results_.name)) << "\n"; - prefixed_ = true; - } os_ << s; os_.flush(); } diff --git a/extras/beast/unit_test/suite.hpp b/extras/beast/unit_test/suite.hpp index de76802f..1903ea66 100644 --- a/extras/beast/unit_test/suite.hpp +++ b/extras/beast/unit_test/suite.hpp @@ -72,7 +72,7 @@ private: { auto const& s = this->str(); if(s.size() > 0) - suite_.runner_->on_log(s); + suite_.runner_->log(s); this->str(""); return 0; } @@ -146,7 +146,9 @@ public: /** Returns the "current" running suite. If no suite is running, nullptr is returned. */ - static suite* this_suite() + static + suite* + this_suite() { return *p_this_suite(); } @@ -158,6 +160,7 @@ public: } /** Invokes the test using the specified runner. + Data members are set up here instead of the constructor as a convenience to writing the derived class to avoid repetition of forwarded constructor arguments to the base. @@ -168,6 +171,7 @@ public: operator()(runner& r); /** Evaluate a test condition. + The condition is passed as a template argument instead of `bool` so that implicit conversion is not required. The `reason` argument is logged if the condition is false. @@ -298,7 +302,10 @@ public: { auto const& name = ss_.str(); if(! name.empty()) + { + suite_.log.flush(); suite_.runner_->testcase(name); + } } scoped_testcase(suite& self, std::stringstream& ss) @@ -333,10 +340,11 @@ public: inline void -suite::testcase_t::operator()(std::string const& name, - abort_t abort) +suite::testcase_t::operator()( + std::string const& name, abort_t abort) { suite_.abort_ = abort == abort_on_fail; + suite_.log.flush(); suite_.runner_->testcase(name); }