centralize plugin registration for unit tests

This commit is contained in:
Dane Springmeyer 2015-07-27 15:35:00 -07:00
parent 871a881634
commit e82de0109d
5 changed files with 8 additions and 8 deletions

View file

@ -23,7 +23,6 @@ SECTION("layers") {
std::string shape_plugin("./plugins/input/shape.input"); std::string shape_plugin("./plugins/input/shape.input");
if (mapnik::util::exists(shape_plugin)) if (mapnik::util::exists(shape_plugin))
{ {
mapnik::datasource_cache::instance().register_datasources("plugins/input/shape.input");
mapnik::parameters p; mapnik::parameters p;
p["type"]="shape"; p["type"]="shape";
p["file"]="demo/data/boundaries"; p["file"]="demo/data/boundaries";

View file

@ -62,7 +62,6 @@ SECTION("handling") {
std::string csv_plugin("./plugins/input/csv.input"); std::string csv_plugin("./plugins/input/csv.input");
if (mapnik::util::exists(csv_plugin)) { if (mapnik::util::exists(csv_plugin)) {
try { try {
mapnik::datasource_cache::instance().register_datasource(csv_plugin);
mapnik::parameters p; mapnik::parameters p;
p["type"]="csv"; p["type"]="csv";
p["inline"]="x,y\n0,0"; p["inline"]="x,y\n0,0";
@ -88,7 +87,6 @@ SECTION("handling") {
std::string shape_plugin("./plugins/input/shape.input"); std::string shape_plugin("./plugins/input/shape.input");
if (mapnik::util::exists(shape_plugin)) { if (mapnik::util::exists(shape_plugin)) {
try { try {
mapnik::datasource_cache::instance().register_datasource(shape_plugin);
mapnik::parameters p2; mapnik::parameters p2;
p2["type"]="shape"; p2["type"]="shape";
p2["file"]="foo"; p2["file"]="foo";

View file

@ -33,7 +33,6 @@ TEST_CASE("geojson") {
std::string geojson_plugin("./plugins/input/geojson.input"); std::string geojson_plugin("./plugins/input/geojson.input");
if (mapnik::util::exists(geojson_plugin)) if (mapnik::util::exists(geojson_plugin))
{ {
mapnik::datasource_cache::instance().register_datasources("plugins/input/geojson.input");
SECTION("json feature cache-feature=\"true\"") SECTION("json feature cache-feature=\"true\"")
{ {
// Create datasource // Create datasource
@ -50,6 +49,7 @@ TEST_CASE("geojson") {
query.add_property_name(field.get_name()); query.add_property_name(field.get_name());
} }
auto features = ds->features(query); auto features = ds->features(query);
REQUIRE(features != nullptr);
auto feature = features->next(); auto feature = features->next();
REQUIRE(feature != nullptr); REQUIRE(feature != nullptr);
} }
@ -69,11 +69,11 @@ TEST_CASE("geojson") {
query.add_property_name(field.get_name()); query.add_property_name(field.get_name());
} }
auto features = ds->features(query); auto features = ds->features(query);
REQUIRE(features != nullptr);
auto feature = features->next(); auto feature = features->next();
REQUIRE(feature != nullptr); REQUIRE(feature != nullptr);
} }
mapnik::datasource_cache::instance().register_datasources("plugins/input/geojson.input");
SECTION("json extra properties cache-feature=\"true\"") SECTION("json extra properties cache-feature=\"true\"")
{ {
// Create datasource // Create datasource
@ -90,12 +90,12 @@ TEST_CASE("geojson") {
query.add_property_name(field.get_name()); query.add_property_name(field.get_name());
} }
auto features = ds->features(query); auto features = ds->features(query);
REQUIRE(features != nullptr);
auto feature = features->next(); auto feature = features->next();
REQUIRE(feature != nullptr); REQUIRE(feature != nullptr);
REQUIRE(feature->envelope() == mapnik::box2d<double>(123,456,123,456)); REQUIRE(feature->envelope() == mapnik::box2d<double>(123,456,123,456));
} }
mapnik::datasource_cache::instance().register_datasources("plugins/input/geojson.input");
SECTION("json extra properties cache-feature=\"false\"") SECTION("json extra properties cache-feature=\"false\"")
{ {
// Create datasource // Create datasource
@ -112,6 +112,7 @@ TEST_CASE("geojson") {
query.add_property_name(field.get_name()); query.add_property_name(field.get_name());
} }
auto features = ds->features(query); auto features = ds->features(query);
REQUIRE(features != nullptr);
auto feature = features->next(); auto feature = features->next();
REQUIRE(feature != nullptr); REQUIRE(feature != nullptr);
REQUIRE(feature->envelope() == mapnik::box2d<double>(123,456,123,456)); REQUIRE(feature->envelope() == mapnik::box2d<double>(123,456,123,456));

View file

@ -21,8 +21,6 @@ SECTION("painting") {
std::string csv_plugin("./plugins/input/csv.input"); std::string csv_plugin("./plugins/input/csv.input");
if (mapnik::util::exists(csv_plugin)) if (mapnik::util::exists(csv_plugin))
{ {
datasource_cache::instance().register_datasources(csv_plugin);
Map m(256, 256); Map m(256, 256);
feature_type_style lines_style; feature_type_style lines_style;

View file

@ -1,10 +1,14 @@
#define CATCH_CONFIG_RUNNER #define CATCH_CONFIG_RUNNER
#include "catch.hpp" #include "catch.hpp"
#include <mapnik/datasource_cache.hpp>
#include "cleanup.hpp" // run_cleanup() #include "cleanup.hpp" // run_cleanup()
int main (int argc, char* const argv[]) int main (int argc, char* const argv[])
{ {
mapnik::datasource_cache::instance().register_datasources("plugins/input/");
int result = Catch::Session().run( argc, argv ); int result = Catch::Session().run( argc, argv );
testing::run_cleanup(); testing::run_cleanup();