2015-04-25 20:08:12 +00:00
|
|
|
#define CATCH_CONFIG_RUNNER
|
|
|
|
#include "catch.hpp"
|
|
|
|
|
2016-01-06 01:13:36 +00:00
|
|
|
#include <string>
|
|
|
|
#include <mapnik/util/fs.hpp>
|
2015-07-27 22:35:00 +00:00
|
|
|
#include <mapnik/datasource_cache.hpp>
|
2016-01-06 01:13:36 +00:00
|
|
|
#include <boost/filesystem/convenience.hpp>
|
2015-07-27 22:35:00 +00:00
|
|
|
|
2015-06-13 02:52:58 +00:00
|
|
|
#include "cleanup.hpp" // run_cleanup()
|
2015-04-25 20:08:12 +00:00
|
|
|
|
2016-01-06 01:13:36 +00:00
|
|
|
std::string plugin_path;
|
|
|
|
|
|
|
|
inline void set_plugin_path(Catch::ConfigData&, std::string const& _plugin_path ) {
|
|
|
|
plugin_path = _plugin_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string working_dir;
|
|
|
|
|
|
|
|
inline void set_working_dir(Catch::ConfigData&, std::string const& _working_dir ) {
|
|
|
|
working_dir = _working_dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-25 20:08:12 +00:00
|
|
|
int main (int argc, char* const argv[])
|
|
|
|
{
|
2016-01-06 01:13:36 +00:00
|
|
|
Catch::Session session;
|
2015-07-27 22:35:00 +00:00
|
|
|
|
2016-01-06 01:13:36 +00:00
|
|
|
auto & cli = session.cli();
|
|
|
|
|
|
|
|
cli["-p"]["--plugins"]
|
|
|
|
.describe("path to mapnik plugins")
|
|
|
|
.bind(&set_plugin_path, "plugins");
|
|
|
|
|
|
|
|
cli["-C"]["--working-directory"]
|
|
|
|
.describe("change working directory")
|
|
|
|
.bind(&set_working_dir, "working directory");
|
|
|
|
|
|
|
|
int result = session.applyCommandLine(argc, argv);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
boost::filesystem::current_path(working_dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result == 0)
|
|
|
|
{
|
|
|
|
result = session.run();
|
|
|
|
}
|
2015-04-26 21:26:11 +00:00
|
|
|
|
2015-06-13 02:52:58 +00:00
|
|
|
testing::run_cleanup();
|
2015-04-26 21:26:11 +00:00
|
|
|
|
2015-04-25 20:08:12 +00:00
|
|
|
return result;
|
2016-01-06 01:13:36 +00:00
|
|
|
|
2015-04-25 20:08:12 +00:00
|
|
|
}
|