script:
- cd $TRAVIS_BUILD_DIR/build
- if [[ $TEST_SUITE == "monaco" ]]; then wget --no-verbose --output-document=../data/monaco.osm.pbf http://download.geofabrik.de/europe/monaco-latest.osm.pbf; fi
- - if [[ $TEST_SUITE == "monaco" ]]; then ./utils/setup.php --osm-file ../data/monaco.osm.pbf --osm2pgsql-cache 1000 --all 2>&1 | grep -v 'ETA (seconds)'; fi
- - if [[ $TEST_SUITE == "monaco" ]]; then ./utils/specialphrases.php --wiki-import | psql -d test_api_nominatim >/dev/null; fi
+ - if [[ $TEST_SUITE == "monaco" ]]; then /usr/bin/env php ./utils/setup.php --osm-file ../data/monaco.osm.pbf --osm2pgsql-cache 1000 --all 2>&1 | grep -v 'ETA (seconds)'; fi
+ - if [[ $TEST_SUITE == "monaco" ]]; then /usr/bin/env php ./utils/specialphrases.php --wiki-import | psql -d test_api_nominatim >/dev/null; fi
- cd $TRAVIS_BUILD_DIR/test/php
- if [[ $TEST_SUITE == "tests" ]]; then phpunit ./ ; fi
- if [[ $TEST_SUITE == "tests" ]]; then phpcs --report-width=120 . ; fi
self.run_nominatim_script('update', *args, **kwargs)
def run_nominatim_script(self, script, *args, **kwargs):
- cmd = [os.path.join(self.build_dir, 'utils', '%s.php' % script)]
+ cmd = ['/usr/bin/env', 'php', '-Cq']
+ cmd.append(os.path.join(self.build_dir, 'utils', '%s.php' % script))
cmd.extend(['--%s' % x for x in args])
for k, v in kwargs.items():
cmd.extend(('--' + k.replace('_', '-'), str(v)))
def query_cmd(context, query, dups):
""" Query directly via PHP script.
"""
- cmd = [os.path.join(context.nominatim.build_dir, 'utils', 'query.php'),
- '--search', query]
+ cmd = ['/usr/bin/env', 'php']
+ cmd.append(os.path.join(context.nominatim.build_dir, 'utils', 'query.php'))
+ cmd.extend(['--search', query])
# add more parameters in table form
if context.table:
for h in context.table.headings:
if hasattr(context, 'http_headers'):
env.update(context.http_headers)
- cmd = ['/usr/bin/php-cgi', '-f']
+ cmd = ['/usr/bin/env', 'php-cgi', '-f']
if context.nominatim.code_coverage_path:
env['COV_SCRIPT_FILENAME'] = env['SCRIPT_FILENAME']
env['COV_PHP_DIR'] = os.path.join(context.nominatim.src_dir, "lib")
+ outp + "\n===============================\n")
assert_equals(0, proc.returncode,
- "query.php failed with message: %s\noutput: %s" % (err, outp))
+ "%s failed with message: %s\noutput: %s" % (env['SCRIPT_FILENAME'], err, outp))
assert_equals(0, len(err), "Unexpected PHP error: %s" % (err))
context.response = SearchResponse(outp, outfmt, status)
-
@step(u'(?P<operator>less than|more than|exactly|at least|at most) (?P<number>\d+) results? (?:is|are) returned')
def validate_result_number(context, operator, number):
eq_(context.response.errorcode, 200)
libboost-filesystem-dev libexpat1-dev zlib1g-dev libxml2-dev\
libbz2-dev libpq-dev libgeos-c1 libgeos++-dev libproj-dev \
postgresql-server-dev-9.6 postgresql-9.6-postgis-2.3 postgresql-contrib-9.6 \
- apache2 php5 php5-pgsql php-pear php-db php5-intl
+ apache2 php5 php5-pgsql php5-intl php-pear
-sudo apt-get install -y -qq python3-dev python3-pip python3-psycopg2 phpunit php5-cgi
+sudo apt-get install -y -qq python3-dev python3-pip python3-psycopg2 php5-cgi
pip3 install --quiet behave nose pytidylib psycopg2
-sudo pear -q install PHP_CodeSniffer
+
+# Travis uses phpenv to support multiple PHP versions. We need to make sure
+# these packages get installed to the phpenv-set PHP (below /home/travis/.phpenv/),
+# not the system PHP (/usr/bin/php)
+sudo PHP_PEAR_PHP_BIN=`which php` pear -q install pear/PEAR-1.10.0
+sudo PHP_PEAR_PHP_BIN=`which php` pear -q install DB
+sudo PHP_PEAR_PHP_BIN=`which php` pear -q install PHP_CodeSniffer
+sudo PHP_PEAR_PHP_BIN=`which php` pear list
+# re-populate the shims/ directory, e.g. adds phpcs
+phpenv rehash
+ls -la /home/travis/.phpenv/shims/
+
+# $PHPENV_VERSION and $TRAVIS_PHP_VERSION are unset.
+export PHPENV_VERSION=$(cat /home/travis/.phpenv/version)
+
+# add lib/php/pear to the PHP include path
+tee /tmp/travis.php.ini << EOF
+include_path = .:/home/travis/.phpenv/versions/$PHPENV_VERSION/share/pear:/home/travis/.phpenv/versions/$PHPENV_VERSION/lib/php/pear
+EOF
+phpenv config-add /tmp/travis.php.ini
+
sudo -u postgres createuser -S www-data