1#!/bin/bash 2#/*PGR-GNU***************************************************************** 3 4# FILE: update_tester.sh 5 6# Copyright (c) 2016 pgRouting developers 7# Mail: project@pgrouting.org 8# 9# ------ 10# 11# This program is free software; you can redistribute it and/or modify 12# it under the terms of the GNU General Public License as published by 13# the Free Software Foundation; either version 2 of the License, or 14# (at your option) any later version. 15 16# This program is distributed in the hope that it will be useful, 17# but WITHOUT ANY WARRANTY; without even the implied warranty of 18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19# GNU General Public License for more details. 20 21# You should have received a copy of the GNU General Public License 22# along with this program; if not, write to the Free Software 23# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 25# ********************************************************************PGR-GNU*/ 26 27set -e 28 29PGPORT=5432 30echo "sorry this only works on vicky's computer" 31PGUSER="vicky" 32DB="___pgr___test___" 33 34function info { 35 36 # ---------------------- 37 # 38 echo "**pgRouting version must be installed before calling**" 39 echo "$1" 40 41 echo "EXAMPLE USAGE" 42 echo "- Short execution" 43 echo "bash tools/testers/update-tester.sh $1 $2" 44 echo "- For running pgtap tests:" 45 echo "bash tools/testers/update-tester.sh $1 $2 long" 46 47} 48 49 50if [[ -z "$1" ]]; then 51 echo missing version example: 52 info 2.6.3 12 53 exit 1 54fi 55 56FROM_PGR="$1" 57CURRENT=$(grep -Po '(?<=project\(PGROUTING VERSION )[^;]+' CMakeLists.txt) 58TWEAK=$(grep -Po '(?<=set\(PGROUTING_VERSION_DEV ")[^;]+(?="\))' CMakeLists.txt) 59LONG=$3 60 61if [[ "$FROM_PGR" == 2.* ]]; 62then 63 exit 0 64fi 65 66dropdb --if-exists "$DB" 67 68cd build 69cmake -DPGROUTING_DEBUG=ON -DCMAKE_BUILD_TYPE=Debug .. 70make -j 4 71sudo make install 72cd .. 73 74 75 76function update_test { 77 78echo 79echo 80echo "Updating from $1 to $2" 81echo ------------------------------------ 82 83 84createdb "$DB" 85psql "$DB" <<EOF 86CREATE extension postgis; 87CREATE extension pgrouting with version '$1'; 88EOF 89 90OLD_VERSION=$(psql "$DB" -t -c 'SELECT * FROM pgr_version()') 91echo "$OLD_VERSION" 92 93 94psql "$DB" -e -c "ALTER extension pgrouting update to '$2'" 95 96 97NEW_VERSION=$(psql "$DB" -t -c 'SELECT * FROM pgr_version()') 98 99echo "$OLD_VERSION ->> $NEW_VERSION" 100 101if [ "b$NEW_VERSION" != "b $2$TWEAK" ] 102then 103 echo "FAIL: Could not update from version $1 to version $2" 104 dropdb "${DB}" 105 exit 1 106fi 107 108 109DIR="sql/sigs" 110FILE="$DIR/pgrouting--$2.sig" 111 112echo "#VERSION pgrouting $2" > "$FILE" 113{ 114 echo "#TYPES" 115 psql "${DB}" -c '\dx+ pgrouting' -A | grep '^type' | cut -d ' ' -f2- 116 echo "#FUNCTIONS" 117 psql ${DB} -c '\dx+ pgrouting' -A | grep '^function' | cut -d ' ' -f2- 118} >> "${FILE}" 119 120 121DIFF=$(git diff "$FILE") 122if [ -n "$DIFF" ] 123then 124 echo "$DIFF" 125else 126 echo "$2 sigunatures are OK" 127fi 128 129 130if [ -n "$LONG" ] 131then 132 ./tools/testers/pg_prove_tests.sh $PGUSER $PGPORT Release 133fi 134 135dropdb "$DB" 136 137} # end of function 138 139 140update_test "${FROM_PGR}" "${CURRENT}" 141