mapnik/test/visual/report.hpp

127 lines
2.8 KiB
C++
Raw Normal View History

2015-02-17 17:28:49 +01:00
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
2021-01-05 15:39:07 +01:00
* Copyright (C) 2021 Artem Pavlenko
2015-02-17 17:28:49 +01:00
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef CONSOLE_REPORT_HPP
#define CONSOLE_REPORT_HPP
// stl
#include <iostream>
#include <mapnik/util/variant.hpp>
#include "config.hpp"
2022-01-26 23:25:53 +01:00
namespace visual_tests {
2015-02-17 17:28:49 +01:00
class console_report
{
2022-01-26 23:25:53 +01:00
public:
console_report(bool _show_duration)
: s(std::clog)
, show_duration(_show_duration)
{}
2015-02-17 17:28:49 +01:00
2022-01-26 23:25:53 +01:00
console_report(std::ostream& _s)
: s(_s)
{}
2015-02-17 17:28:49 +01:00
2022-01-26 23:25:53 +01:00
void report(result const& r);
unsigned summary(result_list const& results);
2015-02-17 17:28:49 +01:00
2022-01-26 23:25:53 +01:00
protected:
void report_state(result const& r);
void report_failures(result_list const& results);
2022-01-26 23:25:53 +01:00
std::ostream& s;
2015-07-07 14:35:28 +02:00
bool show_duration;
2015-02-17 17:28:49 +01:00
};
class console_short_report : public console_report
{
2022-01-26 23:25:53 +01:00
public:
console_short_report(bool _show_duration)
: console_report(_show_duration)
{}
2015-02-17 17:28:49 +01:00
2022-01-26 23:25:53 +01:00
console_short_report(std::ostream& _s)
: console_report(_s)
{}
2015-02-17 17:28:49 +01:00
2022-01-26 23:25:53 +01:00
void report(result const& r);
2015-02-17 17:28:49 +01:00
};
class html_report
{
2022-01-26 23:25:53 +01:00
public:
html_report(std::ostream& _s)
: s(_s)
{}
2015-02-17 17:28:49 +01:00
2022-01-26 23:25:53 +01:00
void report(result const& r, boost::filesystem::path const& output_dir);
void summary(result_list const& results, boost::filesystem::path const& output_dir);
2015-02-17 17:28:49 +01:00
2022-01-26 23:25:53 +01:00
protected:
std::ostream& s;
2015-02-17 17:28:49 +01:00
};
using report_type = mapnik::util::variant<console_report, console_short_report>;
class report_visitor
{
2022-01-26 23:25:53 +01:00
public:
report_visitor(result const& r)
2015-02-17 17:28:49 +01:00
: result_(r)
2022-01-26 23:25:53 +01:00
{}
2015-02-17 17:28:49 +01:00
2022-01-26 23:25:53 +01:00
template<typename T>
void operator()(T& report) const
2015-02-17 17:28:49 +01:00
{
return report.report(result_);
}
2022-01-26 23:25:53 +01:00
private:
result const& result_;
2015-02-17 17:28:49 +01:00
};
class summary_visitor
{
2022-01-26 23:25:53 +01:00
public:
summary_visitor(result_list const& r)
2015-02-17 17:28:49 +01:00
: result_(r)
2022-01-26 23:25:53 +01:00
{}
2015-02-17 17:28:49 +01:00
2022-01-26 23:25:53 +01:00
template<typename T>
unsigned operator()(T& report) const
2015-02-17 17:28:49 +01:00
{
return report.summary(result_);
}
2022-01-26 23:25:53 +01:00
private:
result_list const& result_;
2015-02-17 17:28:49 +01:00
};
2022-01-26 23:25:53 +01:00
void html_summary(result_list const& results, boost::filesystem::path output_dir);
2015-02-17 17:28:49 +01:00
2022-01-26 23:25:53 +01:00
} // namespace visual_tests
2015-02-17 17:28:49 +01:00
#endif