Skip to content
This repository has been archived by the owner on Oct 5, 2024. It is now read-only.

Commit

Permalink
Merge branch 'test'
Browse files Browse the repository at this point in the history
  • Loading branch information
emi420 committed Oct 24, 2023
2 parents bd38aa5 + b67bff3 commit 8d4a9ea
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 11 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: 🧪 Build and Test
name: 🧪 Build and test

on:
push:
branches:
- test
- master

jobs:

Expand All @@ -20,10 +20,17 @@ jobs:
- name: Start Docker Compose & build
run: cd docker && docker-compose up -d

# Run tests (FIXME: it never fails)
- name: Build tests
run: docker-compose -f docker-compose.yml exec -T underpass sh -c "cd /code/build && make check -j `nproc`"
# Copy Underpass library
- name: Copy library
run: docker-compose -f docker-compose.yml exec -T underpass sh -c "cp /code/build/.libs/libunderpass.so /usr/lib"

# Build and run tests
- name: Build and run tests
run: |
docker-compose -f docker-compose.yml exec -T underpass sh -c "cd /code/build && make check -j `nproc`"
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "Test failed with exit code $exit_code"
exit $exit_code
fi
# Run individual test for testing
- name: Run individual test
run: docker-compose -f docker-compose.yml exec -T underpass sh -c "/code/build/src/testsuite/libunderpass.all/val-test"
8 changes: 8 additions & 0 deletions src/testsuite/libunderpass.all/areafilter-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ main(int argc, char *argv[])
runtest.pass("ChangeSet areaFilter - true (whole world)");
} else {
runtest.fail("ChangeSet areaFilter - true (whole world)");
return 1;
}

// ChangeSet - Small area in North Africa
Expand All @@ -110,6 +111,7 @@ main(int argc, char *argv[])
testChangeset = changeset.changes.front().get();
if (testChangeset && testChangeset->priority) {
runtest.fail("ChangeSet areaFilter - false (small area)");
return 1;
} else {
runtest.pass("ChangeSet areaFilter - false (small area)");
}
Expand All @@ -122,6 +124,7 @@ main(int argc, char *argv[])
runtest.pass("ChangeSet areaFilter - true (empty)");
} else {
runtest.fail("ChangeSet areaFilter - true (empty)");
return 1;
}

// ChangeSet - Half area
Expand All @@ -132,6 +135,7 @@ main(int argc, char *argv[])
runtest.pass("ChangeSet areaFilter - true (half area)");
} else {
runtest.fail("ChangeSet areaFilter - true (half area)");
return 1;
}

// OsmChange - Small area in North Africa
Expand All @@ -141,6 +145,7 @@ main(int argc, char *argv[])
runtest.pass("OsmChange areaFilter - false (small area)");
} else {
runtest.fail("OsmChange areaFilter - false (small area)");
return 1;
}

// OsmChange - Whole world
Expand All @@ -150,6 +155,7 @@ main(int argc, char *argv[])
runtest.pass("OsmChange areaFilter - true (whole world)");
} else {
runtest.fail("OsmChange areaFilter - true (whole world)");
return 1;
}
// Delete all changes
osmchange.areaFilter(polySmallArea);
Expand All @@ -161,6 +167,7 @@ main(int argc, char *argv[])
runtest.pass("OsmChange areaFilter - true (empty)");
} else {
runtest.fail("OsmChange areaFilter - true (empty)");
return 1;
}
// Delete all changes
osmchange.areaFilter(polySmallArea);
Expand All @@ -172,6 +179,7 @@ main(int argc, char *argv[])
runtest.pass("OsmChange areaFilter - true (half area)");
} else {
runtest.fail("OsmChange areaFilter - true (half area)");
return 1;
}

}
Expand Down
2 changes: 2 additions & 0 deletions src/testsuite/libunderpass.all/geo-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ main(int argc, char* argv[])
runtest.pass("Read file with bad relative path");
} else {
runtest.fail("Read file with bad relative path");
return 1;
}

if (tgu.readFile("/usr/local/lib/underpass/config/priority.geojson")) {
runtest.pass("Read file with absolute path");
} else {
runtest.fail("Read file with absolute path");
return 1;
}

};
Expand Down
1 change: 1 addition & 0 deletions src/testsuite/libunderpass.all/hashtags-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ main(int argc, char *argv[])
runtest.pass("ChangeSet hashtags");
} else {
runtest.fail("ChangeSet hashtags");
return 1;
}

}
Expand Down
7 changes: 7 additions & 0 deletions src/testsuite/libunderpass.all/pq-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ main(int argc, char *argv[])
runtest.pass("PQ::PQ(void)");
} else {
runtest.fail("PQ::PQ(void)");
return 1;
}

ret = tp.parseURL("testdb");
Expand All @@ -53,20 +54,23 @@ main(int argc, char *argv[])
runtest.pass("PQ::parseURL(dbname)");
} else {
runtest.fail("PQ::parseURL(dbname)");
return 1;
}
ret = tp.parseURL("localhost/testdb");
//tp.dump();
if (ret && tp.dbname == "dbname=testdb" && tp.host.empty()) {
runtest.pass("PQ::parseURL(localhost/dbname)");
} else {
runtest.fail("PQ::parseURL(localhost/dbname)");
return 1;
}
ret = tp.parseURL("testhost/testdb");
//tp.dump();
if (ret && tp.dbname == "dbname=testdb" && tp.host == "host=testhost") {
runtest.pass("PQ::parseURL(remote/dbname)");
} else {
runtest.fail("PQ::parseURL(remote/dbname)");
return 1;
}

ret = tp.parseURL("foo@testhost/testdb");
Expand All @@ -76,6 +80,7 @@ main(int argc, char *argv[])
runtest.pass("PQ::parseURL(user@remote/dbname)");
} else {
runtest.fail("PQ::parseURL(user@remote/dbname)");
return 1;
}

ret = tp.parseURL("foo:bar@testhost/testdb");
Expand All @@ -85,6 +90,7 @@ main(int argc, char *argv[])
runtest.pass("PQ::parseURL(user:pass@remote/dbname)");
} else {
runtest.fail("PQ::parseURL(user:pass@remote/dbname)");
return 1;
}

ret = tp.parseURL("foo:bar@testhost");
Expand All @@ -94,6 +100,7 @@ main(int argc, char *argv[])
runtest.pass("PQ::parseURL(user:pass@remote)");
} else {
runtest.fail("PQ::parseURL(user:pass@remote)");
return 1;
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/testsuite/libunderpass.all/statsconfig-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,35 @@ main(int argc, char *argv[])
runtest.pass("StatsConfigSearch::search()");
} else {
runtest.fail("StatsConfigSearch::search()");
return 1;
}

if (statsconfig.search("underpass_tag", "underpass_test", osmchange::way) == "buildings") {
runtest.pass("StatsConfigSearch::search() - way custom tags");
} else {
runtest.fail("StatsConfigSearch::search() - way custom tags");
return 1;
}

if (statsconfig.search("underpass_tag", "underpass_test", osmchange::node) == "buildings") {
runtest.pass("StatsConfigSearch::search() - node custom tags");
} else {
runtest.fail("StatsConfigSearch::search() - node custom tags");
return 1;
}

if (statsconfig.search("underpass_tag2", "underpass_test", osmchange::node) == "underpass_category") {
runtest.pass("StatsConfigSearch::search() - node custom tags and custom category");
} else {
runtest.fail("StatsConfigSearch::search() - node custom tags and custom category");
return 1;
}

if (statsconfig.search("underpass_tag2", "underpass_test", osmchange::way) == "underpass_category") {
runtest.pass("StatsConfigSearch::search() - way custom tags and custom category");
} else {
runtest.fail("StatsConfigSearch::search() - way custom tags and custom category");
return 1;
}

}
Expand Down
3 changes: 3 additions & 0 deletions src/testsuite/libunderpass.all/under-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ main(int argc, char* argv[])
runtest.pass("Underpass::connect");
} else {
runtest.fail("Underpass::connect");
return 1;
}

ptime tstamp = time_from_string("2014-09-18 12:03:29");
Expand All @@ -61,6 +62,7 @@ main(int argc, char* argv[])
if (state->sequence > 0) {
if (state->path.compare("https://planet.openstreetmap.org/replication/changesets/000/972/927")) {
runtest.fail("Underpass::getState(changeset)");
return 1;
} else {
runtest.pass("Underpass::getState(changeset)");
}
Expand All @@ -70,6 +72,7 @@ main(int argc, char* argv[])
state->dump();
if (state->path.compare("https://planet.openstreetmap.org/replication/minute/001/053/674")) {
runtest.fail("Underpass::getState(minutely)");
return 1;
} else {
runtest.pass("Underpass::getState(minutely)");
}
Expand Down
16 changes: 14 additions & 2 deletions src/testsuite/libunderpass.all/val-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ test_semantic_highway(std::shared_ptr<Validate> &plugin) {
}
}

void
int
test_semantic_building(std::shared_ptr<Validate> &plugin) {
// checkTag()

Expand All @@ -137,6 +137,7 @@ test_semantic_building(std::shared_ptr<Validate> &plugin) {
runtest.pass("Validate::checkTag(good tag) [semantic building]");
} else {
runtest.fail("Validate::checkTag(good tag) [semantic building]");
return 1;
}

// Empty value
Expand All @@ -145,6 +146,7 @@ test_semantic_building(std::shared_ptr<Validate> &plugin) {
runtest.pass("Validate::checkTag(empty value) [semantic building]");
} else {
runtest.fail("Validate::checkTag(empty value) [semantic building]");
return 1;
}

// Invalid tag, not listed into the config file (ex: foo bar=bar)
Expand All @@ -153,6 +155,7 @@ test_semantic_building(std::shared_ptr<Validate> &plugin) {
runtest.pass("Validate::checkTag(space in key) [semantic building]");
} else {
runtest.fail("Validate::checkTag(space in key) [semantic building]");
return 1;
}

// Node - checkPOI()
Expand All @@ -167,6 +170,7 @@ test_semantic_building(std::shared_ptr<Validate> &plugin) {
runtest.pass("Validate::checkPOI(no tags) [semantic building]");
} else {
runtest.fail("Validate::checkPOI(no tags) [semantic building]");
return 1;
}

osmobjects::OsmNode node_place;
Expand All @@ -180,6 +184,7 @@ test_semantic_building(std::shared_ptr<Validate> &plugin) {
runtest.pass("Validate::checkPOI(incomplete but correct tagging) [semantic place]");
} else {
runtest.fail("Validate::checkPOI(incomplete but correct tagging) [semantic place]");
return 1;
}

node_place.addTag("name", "Electric City");
Expand All @@ -188,6 +193,7 @@ test_semantic_building(std::shared_ptr<Validate> &plugin) {
runtest.pass("Validate::checkPOI(complete and correct tagging) [semantic place]");
} else {
runtest.fail("Validate::checkPOI(complete and correct tagging) [semantic place]");
return 1;
}

node.addTag("building", "yes");
Expand All @@ -199,6 +205,7 @@ test_semantic_building(std::shared_ptr<Validate> &plugin) {
runtest.pass("Validate::checkPOI(bad value) [semantic building]");
} else {
runtest.fail("Validate::checkPOI(bad value) [semantic building]");
return 1;
}

// But it's complete
Expand All @@ -207,6 +214,7 @@ test_semantic_building(std::shared_ptr<Validate> &plugin) {
runtest.pass("Validate::checkPOI(complete) [semantic building]");
} else {
runtest.fail("Validate::checkPOI(complete) [semantic building]");
return 1;
}

node.addTag("building:material", "wood");
Expand All @@ -219,6 +227,7 @@ test_semantic_building(std::shared_ptr<Validate> &plugin) {
runtest.pass("Validate::checkPOI(no bad values) [semantic building]");
} else {
runtest.fail("Validate::checkPOI(no bad values) [semantic building]");
return 1;
}

// Way - checkWay()
Expand All @@ -231,7 +240,7 @@ test_semantic_building(std::shared_ptr<Validate> &plugin) {
runtest.pass("Validate::checkWay(no tags) [semantic building]");
} else {
runtest.fail("Validate::checkWay(no tags) [semantic building]");
way.dump();
return 1;
}

way.addTag("building", "yes");
Expand All @@ -243,6 +252,7 @@ test_semantic_building(std::shared_ptr<Validate> &plugin) {
runtest.pass("Validate::checkWay(bad value) [semantic building]");
} else {
runtest.fail("Validate::checkWay(bad value) [semantic building]");
return 1;
}

// But it's complete
Expand All @@ -252,6 +262,7 @@ test_semantic_building(std::shared_ptr<Validate> &plugin) {
runtest.pass("Validate::checkWay(bad value) [semantic building]");
} else {
runtest.fail("Validate::checkWay(bad value) [semantic building]");
return 1;
}

way.addTag("building:material", "wood");
Expand All @@ -264,6 +275,7 @@ test_semantic_building(std::shared_ptr<Validate> &plugin) {
runtest.pass("Validate::checkWay(no bad values) [semantic building]");
} else {
runtest.fail("Validate::checkWay(no bad values) [semantic building]");
return 1;
}
}

Expand Down
Loading

0 comments on commit 8d4a9ea

Please sign in to comment.