]> granicus.if.org Git - postgis/commitdiff
Made regress/run_test create and drop it's regress database
authorSandro Santilli <strk@keybit.net>
Wed, 1 Feb 2006 22:15:32 +0000 (22:15 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 1 Feb 2006 22:15:32 +0000 (22:15 +0000)
unless otherwise specified using --nocreate and --nodrop switches.

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

CHANGES
regress/Makefile
regress/run_test

diff --git a/CHANGES b/CHANGES
index 6283601ff6b3bac4092e0f6d7bfa72ca9cc1d99f..478a6b49af042e5bd8cc41b6510bffad1d576365 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@ PostGIS 1.1.2CVS
 
        - Regress tests can now be run *before* postgis intallation
        - BUGFIX in SnapToGrid() computation of output bounding box
+       - More portable ./configure script
+       - Changed ./run_test script to have more sane default behaviour
 
 PostGIS 1.1.1
 2006/01/23
index e0d53a9038909fed50f5cf6294efd0037ab50a75..2fda2bbe1c817598fdc956b073c2223ffeeb42cb 100644 (file)
@@ -12,7 +12,7 @@ ifeq ($(USE_PROJ),1)
        TESTS += regress_proj
 endif
 
-all: test cleanup
+all: test 
 
 test: lwpostgis.sql ../lwgeom/liblwgeom.so
        @./run_test $(TESTS)
index e4fe9529c4c915682a92334c1c736a14ddf90e6a..d0c37d122e3c8aa7b37ab36cb765ecddc9459279 100755 (executable)
@@ -23,19 +23,59 @@ if [ -z "$TMPDIR" ]; then
        TMPDIR=/tmp
 fi
 
+VERBOSE=0
+OPT_DROP=yes
+OPT_CREATE=yes
+while [ -n "$1" ]; do
+
+       if test "$1" = "-v"; then
+               VERBOSE=1
+               shift
+               continue
+       elif test "$1" = "--nodrop"; then
+               OPT_DROP=no
+               shift
+               continue
+       elif test "$1" = "--nocreate"; then
+               OPT_CREATE=no
+               shift
+               continue
+       else
+               break
+       fi
+done
+
 if [ -z "$1" ]; then
-       echo "Usage: $0 [-v] <test> [<test>]" >&2
-       exit 1;
+       echo "Usage: $0 [-v] [--nocreate] [--nodrop] <test> [<test>]" >&2
+       exit 1
 fi
 
+
 db_exists=`psql -l | grep -w ${DB}`
-if [ -z "$db_exists" ]; then
-       echo
-       echo "Creating spatial db ${DB} " 
 
-       createdb $DB > ${TMPDIR}/regress_log_$$
-       createlang plpgsql $DB >> ${TMPDIR}/regress_log_$$ 
-       psql -f lwpostgis.sql $DB >> ${TMPDIR}/regress_log_$$ 2>&1
+if test -z "$db_exists"; then
+
+       if test x"$OPT_CREATE" = "xyes"; then
+               echo "Creating spatial db ${DB} " 
+
+               createdb $DB > ${TMPDIR}/regress_log_$$
+               createlang plpgsql $DB >> ${TMPDIR}/regress_log_$$ 
+               psql -f lwpostgis.sql $DB >> ${TMPDIR}/regress_log_$$ 2>&1
+       else
+
+               echo "Database ${DB} does not exist" >&2
+               echo "Run w/out the --nocreate flag to create it" >&2
+               exit 1
+       fi
+else
+       if test x"$OPT_CREATE" = "xyes"; then
+               echo "Database ${DB} already exist." >&2
+               echo "Run with the --nocreate flag to use it " \
+                       "or drop it and try again." >&2
+               exit 1
+       else
+               echo "Using existing database ${DB}"
+       fi
 fi
 
 libver=`psql -tAc "select postgis_lib_version()" $DB`
@@ -76,19 +116,11 @@ echo
 echo "Running tests"
 echo
 
-VERBOSE=0
 RUN=0
 SKIP=0
 FAIL=0
 SUCCESS=0
 while [ -n "$1" ]; do
-
-       if test "$1" = "-v"; then
-               VERBOSE=1
-               shift
-               continue
-       fi
-
        TEST="$1"; shift;
 
        # catch a common mistake (strip trailing .sql)
@@ -155,6 +187,10 @@ echo "Run tests: $RUN"
 echo "Successful: $SUCCESS"
 echo "Failed: $FAIL"
 
-#sleep 1
-#dropdb $DB > /dev/null
+if test x"$OPT_DROP" = "xyes" -a x"$OPT_CREATE" = "xyes"; then
+       sleep 1
+       dropdb $DB > /dev/null
+else
+       : echo "Drop database ${DB} manually"
+fi