2015-04-25 22:08:12 +02:00
|
|
|
#define CATCH_CONFIG_RUNNER
|
|
|
|
#include "catch.hpp"
|
|
|
|
|
2016-01-06 02:13:36 +01:00
|
|
|
#include <string>
|
2022-02-02 17:20:29 +01:00
|
|
|
#include <mapnik/mapnik.hpp>
|
2023-03-13 15:27:02 +01:00
|
|
|
#include <mapnik/filesystem.hpp>
|
2016-01-06 02:13:36 +01:00
|
|
|
#include <mapnik/util/fs.hpp>
|
2015-07-28 00:35:00 +02:00
|
|
|
#include <mapnik/datasource_cache.hpp>
|
|
|
|
|
2015-06-13 04:52:58 +02:00
|
|
|
#include "cleanup.hpp" // run_cleanup()
|
2015-04-25 22:08:12 +02:00
|
|
|
|
2022-01-26 23:25:53 +01:00
|
|
|
int main(int argc, char** argv)
|
2015-04-25 22:08:12 +02:00
|
|
|
{
|
2016-01-06 02:13:36 +01:00
|
|
|
Catch::Session session;
|
2020-09-10 16:34:52 +02:00
|
|
|
std::string plugin_path;
|
|
|
|
std::string working_dir;
|
2022-01-26 23:25:53 +01:00
|
|
|
auto cli =
|
|
|
|
session.cli() | Catch::clara::Opt(plugin_path, "plugins")["-p"]["--plugins"]("path to mapnik plugins") |
|
|
|
|
Catch::clara::Opt(working_dir, "working directory")["-C"]["--working-directory"]("change working directory");
|
2020-09-10 16:34:52 +02:00
|
|
|
|
|
|
|
session.cli(cli);
|
2016-01-06 02:13:36 +01:00
|
|
|
int result = session.applyCommandLine(argc, argv);
|
|
|
|
|
2022-02-02 17:20:29 +01:00
|
|
|
mapnik::setup();
|
2016-01-06 02:13:36 +01:00
|
|
|
if (!plugin_path.empty())
|
|
|
|
{
|
|
|
|
if (!mapnik::util::exists(plugin_path))
|
|
|
|
{
|
|
|
|
std::clog << "Could not find " << plugin_path << "\n";
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
mapnik::datasource_cache::instance().register_datasources(plugin_path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mapnik::datasource_cache::instance().register_datasources("plugins/input/");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!working_dir.empty())
|
|
|
|
{
|
|
|
|
if (!mapnik::util::exists(working_dir))
|
|
|
|
{
|
|
|
|
std::clog << "Could not find " << working_dir << "\n";
|
|
|
|
return -1;
|
|
|
|
}
|
2023-03-13 15:27:02 +01:00
|
|
|
mapnik::fs::current_path(working_dir);
|
2016-01-06 02:13:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (result == 0)
|
|
|
|
{
|
|
|
|
result = session.run();
|
|
|
|
}
|
2015-04-26 23:26:11 +02:00
|
|
|
|
2015-06-13 04:52:58 +02:00
|
|
|
testing::run_cleanup();
|
2015-04-26 23:26:11 +02:00
|
|
|
|
2015-04-25 22:08:12 +02:00
|
|
|
return result;
|
|
|
|
}
|