]> granicus.if.org Git - postgis/commitdiff
Enhance staged install to include raster, topology and all scripts
authorSandro Santilli <strk@keybit.net>
Tue, 17 Jan 2012 17:13:32 +0000 (17:13 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 17 Jan 2012 17:13:32 +0000 (17:13 +0000)
Add an --upgrade switch to regress/run_test in preparation of
regress testing upgrade scripts (#1326)

git-svn-id: http://svn.osgeo.org/postgis/trunk@8853 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/Makefile.in
raster/rt_pg/Makefile.in
raster/test/regress/Makefile.in
regress/Makefile.in
regress/run_test
topology/Makefile.in
topology/test/Makefile

index a07d869631f6677bb6886aa216403c795a9cf7ac..e359fb0492abe471cdcb5bf7c356fcc84bfda526 100644 (file)
@@ -104,6 +104,7 @@ ifeq ($(REGRESS),1)
         bindir=/bin
         pkglibdir=/lib
         datadir=/share
+        MODULEDIR=contrib/postgis
 endif
 
 # Make all PostGIS objects depend upon liblwgeom, so that if an underlying
index c2e51096f9e4afc32a4b16913555e8e0625cef89..df44b9e0f516ae10b61acea87e6ee94a8ff38f7d 100644 (file)
@@ -77,6 +77,7 @@ ifeq ($(REGRESS),1)
         bindir=/bin
         pkglibdir=/lib
         datadir=/share
+        MODULEDIR=contrib/postgis
 endif
 
 # Borrow the $libdir substitution from PGXS but customise by adding the version number
index 5bb4ac102ea718e202001bd70134a168d99b5d34..8af8245b78f4a1daf8bf6946f66a6f0f778c5409 100644 (file)
@@ -140,9 +140,8 @@ rtpostgis.sql: ../../rt_pg/rtpostgis.sql
        sed 's,$$libdir,$(REGRESS_INSTALLDIR)/lib,g' ../../rt_pg/rtpostgis.sql > rtpostgis.sql
 
 
-check: rtpostgis.sql
-       $(MAKE) -C ../../../regress postgis.sql staged-install
-       $(MAKE) -C ../../rt_pg REGRESS=1 DESTDIR=$(REGRESS_INSTALLDIR) install
+check: 
+       $(MAKE) -C ../../../regress staged-install
        ../../../regress/run_test $(RUNTESTFLAGS) --raster $(TESTS)
 
 #all: run_test
index 5bf372e3e780e9aabeb69e11a678fb9eb19f5ca4..2deed9178f40107cc05c517659df98cbe979131e 100644 (file)
@@ -1,3 +1,18 @@
+# **********************************************************************
+# *
+# * PostGIS - Spatial Types for PostgreSQL
+# * http://postgis.refractions.net
+# * 
+# * Copyright (C) 2011-2012 Sandro Santilli <strk@keybit.net>
+# * Copyright (C) 2009-2011 Paul Ramsey <pramsey@cleverelephant.ca>
+# * Copyright (C) 2008-2009 Mark Cave-Ayland
+# *
+# * This is free software; you can redistribute and/or modify it under
+# * the terms of the GNU General Public Licence. See the COPYING file.
+# *
+# **********************************************************************
+
+PERL=@PERL@
 TMPDIR?=/tmp
 
 POSTGIS_PGSQL_VERSION=@POSTGIS_PGSQL_VERSION@
@@ -129,14 +144,19 @@ endif
 
 all install uninstall distclean:
 
-postgis.sql: $(REGRESS_INSTALLDIR)/postgis.sql
+staged-install-topology:
+       @if test x"@TOPOLOGY@" != "x"; then \
+               $(MAKE) -C ../topology REGRESS=1 DESTDIR=$(REGRESS_INSTALLDIR) install; \
+       fi
 
-$(REGRESS_INSTALLDIR)/postgis.sql: ../postgis/postgis.sql
-       mkdir -p $(REGRESS_INSTALLDIR)
-       sed 's,$$libdir,$(REGRESS_INSTALLDIR)/lib,g' ../postgis/postgis.sql > $@
+staged-install-raster:
+       @if test x"@RASTER@" != "x"; then \
+               $(MAKE) -C ../raster/rt_pg REGRESS=1 DESTDIR=$(REGRESS_INSTALLDIR) install; \
+       fi
 
-staged-install: postgis.sql
+staged-install: staged-install-raster staged-install-topology
        $(MAKE) -C ../postgis REGRESS=1 DESTDIR=$(REGRESS_INSTALLDIR) install
+       $(PERL) -pi -e 's,\$$libdir,$(REGRESS_INSTALLDIR)/lib,g' $(REGRESS_INSTALLDIR)/share/contrib/postgis/*.sql
        #$(MAKE) -C ../loader REGRESS=1 DESTDIR=$(REGRESS_INSTALLDIR) install
 
 test check: staged-install
index 87ad26c26e99d4e73637fe13be63817366ff7836..3cf0f31fe6310ba9139ca32b4cc2df35ff31363f 100755 (executable)
@@ -34,6 +34,8 @@ export PGOPTIONS
 
 REGDIR=`dirname $0`
 REGDIR=`cd "${REGDIR}" && pwd`
+STAGED_INSTALL_DIR="${REGDIR}/00-regress-install"
+STAGED_SCRIPTS_DIR="${STAGED_INSTALL_DIR}/share/contrib/postgis"
 
 PSQL="psql"
 
@@ -47,6 +49,7 @@ VERBOSE=0
 OPT_CLEAN=no
 OPT_DROP=yes
 OPT_CREATE=yes
+OPT_UPGRADE=no
 OPT_WITH_TOPO=no
 OPT_WITH_RASTER=no
 
@@ -434,9 +437,9 @@ init_db_error ()
                echo "-----------------------------------------------------------------------------"
                tail -5 ${TMPDIR}/regress_log
                echo "-----------------------------------------------------------------------------"
-  else
+       else
          echo " For details, check ${TMPDIR}/regress_log"
-  fi
+       fi
        echo
 
        if test x"$OPT_DROP" = "xyes" -a x"$OPT_CREATE" = "xyes"; then
@@ -485,6 +488,10 @@ while [ -n "$1" ]; do
                OPT_CREATE=no
                shift
                continue
+       elif test "$1" = "--upgrade"; then
+               OPT_UPGRADE=yes
+               shift
+               continue
        elif test "$1" = "--topology"; then
                OPT_WITH_TOPO=yes
                shift
@@ -507,6 +514,7 @@ if [ -z "$1" ]; then
        echo "Options:" >&2
        echo " -v           be verbose about failures" >&2
        echo " --nocreate   do not create the regression database on start" >&2
+       echo " --upgrade    source the upgrade scripts on start" >&2
        echo " --nodrop     do not drop the regression database on exit" >&2
        echo " --raster     load also topology extension" >&2
        echo " --topology   load also topology extension" >&2
@@ -536,23 +544,26 @@ if test -z "$db_exists"; then
                # Count database objects before installing anything
                object_count_pre=$(count_db_objects "counting object before postgis install")
 
-               ${PSQL} ${_psql_opts} -Xf ${REGDIR}/00-regress-install/postgis.sql "${DB}" >> ${TMPDIR}/regress_log 2>&1 || init_db_error "core module"
+               ${PSQL} ${_psql_opts} -Xf ${STAGED_SCRIPTS_DIR}/postgis.sql "${DB}" >> ${TMPDIR}/regress_log 2>&1 || init_db_error "core module"
 
                if test x"$OPT_WITH_TOPO" = "xyes"; then
-                       if test -e ${REGDIR}/../topology/topology.sql; then
+                       SCRIPT=${STAGED_SCRIPTS_DIR}/topology.sql
+                       if test -e ${SCRIPT}; then
                                echo "Adding topology support" 
                                ${PSQL} ${_psql_opts} -Xf ${REGDIR}/../topology/topology.sql "${DB}" >> ${TMPDIR}/regress_log 2>&1 || init_db_error "topology module"
                        else
-                               echo "Topology support skipped (topology.sql  not found)" 
+                               echo "${SCRIPT} not found" >&2
+                               exit 1
                        fi
                fi
                if test x"$OPT_WITH_RASTER" = "xyes"; then
-                       SCRIPT=${REGDIR}/../raster/test/regress/rtpostgis.sql
+                       SCRIPT=${STAGED_SCRIPTS_DIR}/rtpostgis.sql
                        if test -e ${SCRIPT}; then
                                echo "Adding raster support"
                                ${PSQL} ${_psql_opts} -Xf ${SCRIPT} "${DB}" >> ${TMPDIR}/regress_log 2>&1 || init_db_error "raster module"
                        else
-                               echo "Raster support skipped (rtpostgis.sql  not found)" 
+                               echo "${SCRIPT} not found" >&2
+                               exit 1
                        fi
                fi
        else
@@ -572,6 +583,39 @@ else
        fi
 fi
 
+if test x"$OPT_UPGRADE" = "xyes"; then
+  SCRIPT=${STAGED_SCRIPTS_DIR}/postgis_upgrade_*_minor.sql
+  if test -e ${SCRIPT}; then
+    echo "Loading ${SCRIPT}"
+    ${PSQL} ${_psql_opts} -Xf ${SCRIPT} "${DB}" >> ${TMPDIR}/regress_log 2>&1 || init_db_error "core upgrade"
+  else
+    echo "${SCRIPT} not found" >&2
+      exit 1
+  fi
+
+  if test x"$OPT_WITH_TOPO" = "xyes"; then
+    SCRIPT=${STAGED_SCRIPTS_DIR}/topology_upgrade_*_minor.sql
+    if test -e ${SCRIPT}; then
+      echo "Loading ${SCRIPT}"
+      ${PSQL} ${_psql_opts} -Xf ${SCRIPT} "${DB}" >> ${TMPDIR}/regress_log 2>&1 || init_db_error "topology upgrade"
+    else
+      echo "${SCRIPT} not found" >&2
+        exit 1
+    fi
+  fi
+
+  if test x"$OPT_WITH_RASTER" = "xyes"; then
+    SCRIPT=${STAGED_SCRIPTS_DIR}/rtpostgis_upgrade_*_minor.sql
+    if test -e ${SCRIPT}; then
+      echo "Loading ${SCRIPT}"
+      ${PSQL} ${_psql_opts} -Xf ${SCRIPT} "${DB}" >> ${TMPDIR}/regress_log 2>&1 || init_db_error "raster upgrade"
+    else
+      echo "${SCRIPT} not found" >&2
+        exit 1
+    fi
+  fi
+fi
+
 libver=`${PSQL} -tAc "select postgis_lib_version()" "${DB}"`
 
 if [ -z "$libver" ]; then
index d862d3c78f53b57235440a865c41412e8119b979..cd76a442fab361d6ff57c7bf8371bede69c09f66 100644 (file)
@@ -52,6 +52,17 @@ ifeq ($(PGXSOVERRIDE),1)
        include ../postgis/Makefile.pgxs
 endif
 
+# If REGRESS=1 passed as a parameter, change the default install paths
+# so that no prefix is included. This allows us to relocate to a temporary
+# directory for regression testing.
+ifeq ($(REGRESS),1)
+        bindir=/bin
+        pkglibdir=/lib
+        datadir=/share
+        MODULEDIR=contrib/postgis
+endif
+
+
 
 # Unfortunately we have to copy this from the PGXS Makefile as it only gets picked up
 # if MODULE_big is defined
index 3dc48fb61f9c67981b60f900f2ec4fd280f93d3c..6f8aba8a655c278ae3ce169da6e1e187fc752396 100644 (file)
@@ -61,5 +61,5 @@ TESTS = regress/legacy_validate.sql regress/legacy_predicate.sql \
        regress/layertrigger.sql
 
 check: topo_predicates.sql load_topology.sql load_topology-4326.sql
-       $(MAKE) -C ../../regress postgis.sql staged-install
+       $(MAKE) -C ../../regress staged-install
        ../../regress/run_test $(RUNTESTFLAGS) --topology $(TESTS)