Print the testcase header prior to logging (fix #56)

This commit is contained in:
Nik Bougalis
2016-08-19 19:16:23 -07:00
committed by Vinnie Falco
parent fc677536bf
commit cbf1af97c5

View File

@@ -56,7 +56,7 @@ private:
typename clock_type::time_point start = clock_type::now(); typename clock_type::time_point start = clock_type::now();
explicit explicit
suite_results(std::string const& name_ = "") suite_results(std::string name_ = "")
: name(std::move(name_)) : name(std::move(name_))
{ {
} }
@@ -90,6 +90,7 @@ private:
results results_; results results_;
suite_results suite_results_; suite_results suite_results_;
case_results case_results_; case_results case_results_;
bool prefixed_ = false;
public: public:
reporter(reporter const&) = delete; reporter(reporter const&) = delete;
@@ -227,6 +228,7 @@ reporter<_>::
on_suite_begin(suite_info const& info) on_suite_begin(suite_info const& info)
{ {
suite_results_ = suite_results{info.full_name()}; suite_results_ = suite_results{info.full_name()};
prefixed_ = false;
} }
template<class _> template<class _>
@@ -242,10 +244,13 @@ reporter<_>::
on_case_begin(std::string const& name) on_case_begin(std::string const& name)
{ {
case_results_ = case_results (name); case_results_ = case_results (name);
os_ << if(!prefixed_)
suite_results_.name << {
(case_results_.name.empty() ? os_ << suite_results_.name <<
"" : (" " + case_results_.name)) << std::endl; (case_results_.name.empty() ? "" :
(" " + case_results_.name)) << std::endl;
prefixed_ = true;
}
} }
template<class _> template<class _>
@@ -281,6 +286,13 @@ void
reporter<_>:: reporter<_>::
on_log(std::string const& s) 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_ << s;
os_.flush(); os_.flush();
} }