Skip to content

Commit 593405c

Browse files
authored
Merge pull request #1243 from joto/test-flex-example-configs
Add minimal testing of flex example configs
2 parents b5184d8 + 76f5744 commit 593405c

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

flex-config/simple.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
-- "geometries.lua".
66

77
-- For debugging
8-
inspect = require('inspect')
8+
-- inspect = require('inspect')
99

1010
-- The global variable "osm2pgsql" is used to talk to the main osm2pgsql code.
1111
-- You can, for instance, get the version of osm2pgsql:
@@ -59,7 +59,7 @@ tables.polygons = osm2pgsql.define_area_table('polygons', {
5959
for name, dtable in pairs(tables) do
6060
print("\ntable '" .. name .. "':")
6161
print(" name='" .. dtable:name() .. "'")
62-
print(" columns=" .. inspect(dtable:columns()))
62+
-- print(" columns=" .. inspect(dtable:columns()))
6363
end
6464

6565
-- Helper function to remove some of the tags we usually are not interested in.

flex-config/unitable.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
-- Put all OSM data into a single table
33

4-
inspect = require('inspect')
4+
-- inspect = require('inspect')
55

66
-- We define a single table that can take any OSM object and any geometry.
77
-- XXX expire will currently not work on these tables.
@@ -17,7 +17,7 @@ local dtable = osm2pgsql.define_table{
1717
}
1818
}
1919

20-
print("columns=" .. inspect(dtable:columns()))
20+
-- print("columns=" .. inspect(dtable:columns()))
2121

2222
-- Helper function to remove some of the tags we usually are not interested in.
2323
-- Returns true if there are no tags left.

tests/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ if (HAVE_LUA)
8989
set_test(test-output-flex-types)
9090
set_test(test-output-flex-update)
9191
set_test(test-output-flex-validgeom)
92+
93+
set_test(test-output-flex-example-configs)
94+
set(FLEX_EXAMPLE_CONFIGS "compatible,data-types,default-config,geometries,route-relations,simple,unitable")
95+
# places.lua not tested because it needs dkjson package
96+
set_tests_properties(test-output-flex-example-configs PROPERTIES ENVIRONMENT "EXAMPLE_FILES=${FLEX_EXAMPLE_CONFIGS}")
9297
endif()
9398

9499

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <catch.hpp>
2+
3+
#include "common-import.hpp"
4+
#include "common-options.hpp"
5+
#include "format.hpp"
6+
7+
#include <osmium/util/string.hpp>
8+
9+
#include <cstdlib>
10+
#include <string>
11+
#include <vector>
12+
13+
static testing::db::import_t db;
14+
15+
static char const *const data_file = "liechtenstein-2013-08-03.osm.pbf";
16+
17+
std::vector<std::string> get_files() {
18+
char const *env = std::getenv("EXAMPLE_FILES");
19+
return osmium::split_string(env, ',', true);
20+
}
21+
22+
TEST_CASE("minimal test for flex example configs")
23+
{
24+
auto const files = get_files();
25+
26+
for (auto const& file : files) {
27+
fmt::print(stderr, "Testing example config '{}.lua'\n", file);
28+
auto const conf_file = "../../flex-config/" + file + ".lua";
29+
options_t const options = testing::opt_t().flex(conf_file.c_str());
30+
31+
REQUIRE_NOTHROW(db.run_file(options, data_file));
32+
33+
auto conn = db.db().connect();
34+
}
35+
}

0 commit comments

Comments
 (0)