]> git.openstreetmap.org Git - nominatim.git/commitdiff
enable test execution using ctest
authorSarah Hoffmann <lonvia@denofr.de>
Mon, 29 Feb 2016 22:45:30 +0000 (23:45 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 29 Feb 2016 22:45:30 +0000 (23:45 +0100)
CMakeLists.txt
tests/steps/db_results.py
tests/steps/db_setup.py
tests/steps/osm2pgsql_setup.py
tests/steps/terrain.py

index ceffb6fccd217d39e5594694ddc963f8b93afc50..a561e020d30a87edc5ce7bea7f1f2de79f73d091 100644 (file)
@@ -32,6 +32,7 @@ add_definitions(-DNOMINATIM_VERSION="${NOMINATIM_VERSION}")
 #
 #-----------------------------------------------------------------------------
 
+set(BUILD_TESTS on)
 add_subdirectory(osm2pgsql)
 
 find_package(Threads REQUIRED)
@@ -73,6 +74,28 @@ execute_process(
     COMMAND ln -s -t ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/utils
 )
 
+#-----------------------------------------------------------------------------
+#
+# Tests
+#
+#-----------------------------------------------------------------------------
+
+include(CTest)
+
+set(TEST_BDD db osm2pgsql api)
+
+foreach (test ${TEST_BDD})
+    add_test(NAME bdd_${test}
+             COMMAND lettuce features/${test}
+             WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests)
+    set_tests_properties(bdd_${test}
+        PROPERTIES ENVIRONMENT "NOMINATIM_DIR=${PROJECT_BINARY_DIR}")
+endforeach()
+
+add_test(NAME php
+         COMMAND phpunit ./
+         WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests-php)
+
 #-----------------------------------------------------------------------------
 
 add_subdirectory(module)
index c3ac9445fe55738c8e87f9f78dc855c91c0c2ba8..71a30927b3314076ff7427a59b7ed71ce3b7f5c8 100644 (file)
@@ -11,7 +11,6 @@ import psycopg2
 import psycopg2.extensions
 import psycopg2.extras
 import os
-import subprocess
 import random
 import json
 import re
index e1315ed95a74f65dbe9c2ab7cd994d4d3d9b24be..8041c6cc6070ad49791a5eb8c0a022a046256e9e 100644 (file)
@@ -266,7 +266,8 @@ def query_cmd(step, query, with_dups):
            '--search', query]
     if with_dups is not None:
         cmd.append('--nodedupe')
-    proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    proc = subprocess.Popen(cmd, cwd=world.config.source_dir,
+                            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     (outp, err) = proc.communicate()
     assert (proc.returncode == 0), "query.php failed with message: %s" % err
     world.page = outp
index eaa14573b58675b9ce2ac403f51ba3a14e3c2223..4b03b1ea48efcd97011d8920e7a1e61900da7b42 100644 (file)
@@ -155,7 +155,8 @@ def osm2pgsql_load_place(step):
 
     cmd = [os.path.join(world.config.source_dir, 'utils', 'setup.php')]
     cmd.extend(['--osm-file', fname, '--import-data','--osm2pgsql-cache', '300'])
-    proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    proc = subprocess.Popen(cmd, cwd=world.config.source_dir,
+                            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     (outp, outerr) = proc.communicate()
     assert (proc.returncode == 0), "OSM data import failed:\n%s\n%s\n" % (outp, outerr)
 
@@ -204,7 +205,8 @@ def osm2pgsql_update_place(step):
 
     cmd = [os.path.join(world.config.source_dir, 'utils', 'update.php')]
     cmd.extend(['--import-diff', fname])
-    proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    proc = subprocess.Popen(cmd, cwd=world.config.source_dir,
+                            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     (outp, outerr) = proc.communicate()
     assert (proc.returncode == 0), "OSM data update failed:\n%s\n%s\n" % (outp, outerr)
 
index e9561d1a9fd11b52653f8d383d7f5d9eb8872785..349deafed691d76e1c58a8a49f77c632a112a4bf 100644 (file)
@@ -23,7 +23,7 @@ class NominatimConfig:
             logging.basicConfig(level=loglevel)
         # Nominatim test setup
         self.base_url = os.environ.get('NOMINATIM_SERVER', 'http://localhost/nominatim')
-        self.source_dir = os.path.abspath(os.environ.get('NOMINATIM_DIR', '..'))
+        self.source_dir = os.path.abspath(os.environ.get('NOMINATIM_DIR', '../build'))
         self.template_db = os.environ.get('TEMPLATE_DB', 'test_template_nominatim')
         self.test_db = os.environ.get('TEST_DB', 'test_nominatim')
         self.local_settings_file = os.environ.get('NOMINATIM_SETTINGS', '/tmp/nominatim_settings.php')
@@ -52,7 +52,8 @@ def write_nominatim_config(dbname):
 def run_nominatim_script(script, *args):
     cmd = [os.path.join(world.config.source_dir, 'utils', '%s.php' % script)]
     cmd.extend(['--%s' % x for x in args])
-    proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    proc = subprocess.Popen(cmd, cwd=world.config.source_dir,
+                            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     (outp, outerr) = proc.communicate()
     assert (proc.returncode == 0), "Script '%s' failed:\n%s\n%s\n" % (script, outp, outerr)
 
@@ -176,8 +177,9 @@ def db_template_setup():
     conn.close()
     # execute osm2pgsql on an empty file to get the right tables
     osm2pgsql = os.path.join(world.config.source_dir, 'osm2pgsql', 'osm2pgsql')
-    proc = subprocess.Popen([osm2pgsql, '-lsc', '-O', 'gazetteer', '-d', world.config.template_db, '-'],
-    stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    proc = subprocess.Popen([osm2pgsql, '-lsc', '-r', 'xml', '-O', 'gazetteer', '-d', world.config.template_db, '-'],
+                            cwd=world.config.source_dir, stdin=subprocess.PIPE,
+                            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     [outstr, errstr] = proc.communicate(input='<osm version="0.6"></osm>')
     world.run_nominatim_script('setup', 'create-functions', 'create-tables', 'create-partition-tables', 'create-partition-functions', 'load-data', 'create-search-indices')