diff --git a/CHANGELOG.md b/CHANGELOG.md index 538d4ca6c..889e4adc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ Released: YYYY XX, 2015 (Packaged from xxxx) +#### Summary + +- Visual tests: new command line arguments `--agg`, `--cairo`, `--svg`, `--grid` for selecting renderers (https://github.com/mapnik/mapnik/pull/3074) + ## 3.0.5 Released: September 16, 2015 diff --git a/test/visual/renderer.hpp b/test/visual/renderer.hpp index 6ad979165..6b033f99c 100644 --- a/test/visual/renderer.hpp +++ b/test/visual/renderer.hpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #if defined(GRID_RENDERER) #include @@ -326,11 +327,23 @@ private: } const Renderer ren; - boost::filesystem::path const & output_dir; - boost::filesystem::path const & reference_dir; + const boost::filesystem::path output_dir; + const boost::filesystem::path reference_dir; const bool overwrite; }; +using renderer_type = mapnik::util::variant +#if defined(HAVE_CAIRO) + ,renderer +#endif +#if defined(SVG_RENDERER) + ,renderer +#endif +#if defined(GRID_RENDERER) + ,renderer +#endif + >; + } #endif diff --git a/test/visual/run.cpp b/test/visual/run.cpp index 833f97b60..e00ae0ae1 100644 --- a/test/visual/run.cpp +++ b/test/visual/run.cpp @@ -43,11 +43,50 @@ log_levels_map log_levels }; #endif +using namespace visual_tests; +namespace po = boost::program_options; + +runner::renderer_container create_renderers(po::variables_map const & args, + boost::filesystem::path const & output_dir, + bool append_all = false) +{ + boost::filesystem::path reference_dir(args["images-dir"].as()); + bool overwrite = args.count("overwrite"); + runner::renderer_container renderers; + + if (append_all || args.count(agg_renderer::name)) + { + renderers.emplace_back(renderer(output_dir, reference_dir, overwrite)); + } +#if defined(HAVE_CAIRO) + if (append_all || args.count(cairo_renderer::name)) + { + renderers.emplace_back(renderer(output_dir, reference_dir, overwrite)); + } +#endif +#if defined(SVG_RENDERER) + if (append_all || args.count(svg_renderer::name)) + { + renderers.emplace_back(renderer(output_dir, reference_dir, overwrite)); + } +#endif +#if defined(GRID_RENDERER) + if (append_all || args.count(grid_renderer::name)) + { + renderers.emplace_back(renderer(output_dir, reference_dir, overwrite)); + } +#endif + + if (renderers.empty()) + { + return create_renderers(args, output_dir, true); + } + + return renderers; +} + int main(int argc, char** argv) { - using namespace visual_tests; - namespace po = boost::program_options; - po::options_description desc("visual test runner"); desc.add_options() ("help,h", "produce usage message") @@ -68,6 +107,16 @@ int main(int argc, char** argv) ("log", po::value()->default_value(std::find_if(log_levels.begin(), log_levels.end(), [](log_levels_map::value_type const & level) { return level.second == mapnik::logger::get_severity(); } )->first), "log level (debug, warn, error, none)") +#endif + (agg_renderer::name, "render with AGG renderer") +#if defined(HAVE_CAIRO) + (cairo_renderer::name, "render with Cairo renderer") +#endif +#if defined(SVG_RENDERER) + (svg_renderer::name, "render with SVG renderer") +#endif +#if defined(GRID_RENDERER) + (grid_renderer::name, "render with Grid renderer") #endif ; @@ -108,12 +157,10 @@ int main(int argc, char** argv) } runner run(vm["styles-dir"].as(), - output_dir, - vm["images-dir"].as(), - vm.count("overwrite"), vm["iterations"].as(), vm["limit"].as(), - vm["jobs"].as()); + vm["jobs"].as(), + create_renderers(vm, output_dir)); bool show_duration = vm.count("duration"); report_type report(vm.count("verbose") ? report_type((console_report(show_duration))) : report_type((console_short_report(show_duration)))); result_list results; diff --git a/test/visual/runner.cpp b/test/visual/runner.cpp index a987d05d9..f8e8e4e1c 100644 --- a/test/visual/runner.cpp +++ b/test/visual/runner.cpp @@ -126,29 +126,15 @@ private: }; runner::runner(runner::path_type const & styles_dir, - runner::path_type const & output_dir, - runner::path_type const & reference_dir, - bool overwrite, std::size_t iterations, std::size_t fail_limit, - std::size_t jobs) + std::size_t jobs, + runner::renderer_container const & renderers) : styles_dir_(styles_dir), - output_dir_(output_dir), - reference_dir_(reference_dir), jobs_(jobs), iterations_(iterations), fail_limit_(fail_limit), - renderers_{ renderer(output_dir_, reference_dir_, overwrite) -#if defined(HAVE_CAIRO) - ,renderer(output_dir_, reference_dir_, overwrite) -#endif -#if defined(SVG_RENDERER) - ,renderer(output_dir_, reference_dir_, overwrite) -#endif -#if defined(GRID_RENDERER) - ,renderer(output_dir_, reference_dir_, overwrite) -#endif - } + renderers_(renderers) { } diff --git a/test/visual/runner.hpp b/test/visual/runner.hpp index 65b19bb45..0461c03af 100644 --- a/test/visual/runner.hpp +++ b/test/visual/runner.hpp @@ -23,8 +23,6 @@ #ifndef VISUAL_TEST_RUNNER_HPP #define VISUAL_TEST_RUNNER_HPP -#include - #include "config.hpp" #include "report.hpp" #include "renderer.hpp" @@ -35,28 +33,17 @@ namespace visual_tests class runner { - using renderer_type = mapnik::util::variant -#if defined(HAVE_CAIRO) - ,renderer -#endif -#if defined(SVG_RENDERER) - ,renderer -#endif -#if defined(GRID_RENDERER) - ,renderer -#endif - >; using path_type = boost::filesystem::path; using files_iterator = std::vector::const_iterator; public: + using renderer_container = std::vector; + runner(path_type const & styles_dir, - path_type const & output_dir, - path_type const & reference_dir, - bool overwrite, std::size_t iterations, std::size_t fail_limit, - std::size_t jobs); + std::size_t jobs, + renderer_container const & renderers); result_list test_all(report_type & report) const; result_list test(std::vector const & style_names, report_type & report) const; @@ -74,12 +61,10 @@ private: const map_sizes_grammar map_sizes_parser_; const path_type styles_dir_; - const path_type output_dir_; - const path_type reference_dir_; const std::size_t jobs_; const std::size_t iterations_; const std::size_t fail_limit_; - const renderer_type renderers_[boost::mpl::size::value]; + const renderer_container renderers_; }; }