]> granicus.if.org Git - postgis/commitdiff
New regress test cases and support for loader/dumper.
authorSandro Santilli <strk@keybit.net>
Fri, 16 Jun 2006 14:13:06 +0000 (14:13 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 16 Jun 2006 14:13:06 +0000 (14:13 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@2384 b70326c6-7e19-0410-871a-916f4a2858ee

24 files changed:
CHANGES
regress/Makefile
regress/loader/README [new file with mode: 0644]
regress/loader/mlines2d-wkb.expected [new file with mode: 0644]
regress/loader/mlines2d-wkt.expected [new file with mode: 0644]
regress/loader/mlines2d.dbf [new file with mode: 0644]
regress/loader/mlines2d.shp [new file with mode: 0644]
regress/loader/mlines2d.shx [new file with mode: 0644]
regress/loader/mlines3dm-wkb.expected [new file with mode: 0644]
regress/loader/mlines3dm-wkt.expected [new file with mode: 0644]
regress/loader/mlines3dm.dbf [new file with mode: 0644]
regress/loader/mlines3dm.shp [new file with mode: 0644]
regress/loader/mlines3dm.shx [new file with mode: 0644]
regress/loader/mlines3dz-wkb.expected [new file with mode: 0644]
regress/loader/mlines3dz-wkt.expected [new file with mode: 0644]
regress/loader/mlines3dz.dbf [new file with mode: 0644]
regress/loader/mlines3dz.shp [new file with mode: 0644]
regress/loader/mlines3dz.shx [new file with mode: 0644]
regress/loader/mlines4d-wkb.expected [new file with mode: 0644]
regress/loader/mlines4d-wkt.expected [new file with mode: 0644]
regress/loader/mlines4d.dbf [new file with mode: 0644]
regress/loader/mlines4d.shp [new file with mode: 0644]
regress/loader/mlines4d.shx [new file with mode: 0644]
regress/run_test

diff --git a/CHANGES b/CHANGES
index 4f49b5e7c7217679b8ec65bc756afb4835bed6d0..311846cc6b9cada99cddff02cba968a8414791d2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
 PostGIS 1.1.3CVS
 
-       - BUGXFIX in affine() failing to update bounding box
+       - New regress test support for loader/dumper.
+       - BUGFIX in pgsql2shp successful return code.
+       - BUGFIX in shp2pgsql handling of MultiLine WKT.
+       - BUGFIX in affine() failing to update bounding box
        - WKT parser: forbidden construction of multigeometries with
          EMPTY elements (still supported for GEOMETRYCOLLECTION).
        - Added --with-proj-libdir and --with-geos-libdir configure
index aab4083b8af085cb0204fe2cb3005393d4e16802..cfcf14983aa4e20bcb73938e57468a21af8e7f9d 100644 (file)
@@ -2,7 +2,7 @@ TMPDIR?=/tmp
 
 include ../Makefile.config
 
-TESTS=regress regress_index lwgeom_regress regress_lrs removepoint setpoint simplify snaptogrid affine wkt measures
+TESTS=loader/mlines2d loader/mlines3dz loader/mlines3dm loader/mlines4d regress regress_index lwgeom_regress regress_lrs removepoint setpoint simplify snaptogrid affine wkt measures 
 
 ifeq ($(USE_GEOS),1)
        TESTS += regress_ogc regress_bdpoly
diff --git a/regress/loader/README b/regress/loader/README
new file mode 100644 (file)
index 0000000..e190b48
--- /dev/null
@@ -0,0 +1,10 @@
+Fri Jun 16 15:59:14 CEST 2006 --strk;
+
+The ../run_test script will load a provided shapefile using both DUMP and INSERT
+mode and both WKT and WKB modes.
+Will compare a 'select * from loaded_table' against the provided <name>-wkb.expected
+and <name>-wkt.expected files (we need two separate files as the WKT mode will
+not support M values).
+Also, the tester file will dump the loaded table and compare the resulting shapefile
+with the original one (only .shp, .dbf is not compared as field sizes are not
+retained, we might use a dbf viewer for that, but that's not currently implemented)
diff --git a/regress/loader/mlines2d-wkb.expected b/regress/loader/mlines2d-wkb.expected
new file mode 100644 (file)
index 0000000..49e4ff5
--- /dev/null
@@ -0,0 +1,2 @@
+1|1|01050000000200000001020000000200000000000000000000000000000000000000000000000000F03F000000000000F03F0102000000020000000000000000000840000000000000084000000000000010400000000000001040
+2|2|01050000000300000001020000000200000000000000000000000000000000000000000000000000F03F000000000000F03F0102000000020000000000000000000840000000000000084000000000000010400000000000001040010200000003000000000000000000244000000000000024400000000000001440000000000000144000000000000008400000000000000840
diff --git a/regress/loader/mlines2d-wkt.expected b/regress/loader/mlines2d-wkt.expected
new file mode 100644 (file)
index 0000000..49e4ff5
--- /dev/null
@@ -0,0 +1,2 @@
+1|1|01050000000200000001020000000200000000000000000000000000000000000000000000000000F03F000000000000F03F0102000000020000000000000000000840000000000000084000000000000010400000000000001040
+2|2|01050000000300000001020000000200000000000000000000000000000000000000000000000000F03F000000000000F03F0102000000020000000000000000000840000000000000084000000000000010400000000000001040010200000003000000000000000000244000000000000024400000000000001440000000000000144000000000000008400000000000000840
diff --git a/regress/loader/mlines2d.dbf b/regress/loader/mlines2d.dbf
new file mode 100644 (file)
index 0000000..9d928dd
Binary files /dev/null and b/regress/loader/mlines2d.dbf differ
diff --git a/regress/loader/mlines2d.shp b/regress/loader/mlines2d.shp
new file mode 100644 (file)
index 0000000..db615cf
Binary files /dev/null and b/regress/loader/mlines2d.shp differ
diff --git a/regress/loader/mlines2d.shx b/regress/loader/mlines2d.shx
new file mode 100644 (file)
index 0000000..8e7fe07
Binary files /dev/null and b/regress/loader/mlines2d.shx differ
diff --git a/regress/loader/mlines3dm-wkb.expected b/regress/loader/mlines3dm-wkb.expected
new file mode 100644 (file)
index 0000000..ae7e007
--- /dev/null
@@ -0,0 +1 @@
+1|01050000400300000001020000400200000000000000000000000000000000000000000000000000F03F000000000000F03F000000000000F03F0000000000000040010200004002000000000000000000084000000000000008400000000000000840000000000000104000000000000010400000000000001040010200004003000000000000000000244000000000000024400000000000001440000000000000144000000000000014400000000000001840000000000000084000000000000008400000000000001C40
diff --git a/regress/loader/mlines3dm-wkt.expected b/regress/loader/mlines3dm-wkt.expected
new file mode 100644 (file)
index 0000000..10ed768
--- /dev/null
@@ -0,0 +1 @@
+1|01050000000300000001020000000200000000000000000000000000000000000000000000000000F03F000000000000F03F0102000000020000000000000000000840000000000000084000000000000010400000000000001040010200000003000000000000000000244000000000000024400000000000001440000000000000144000000000000008400000000000000840
diff --git a/regress/loader/mlines3dm.dbf b/regress/loader/mlines3dm.dbf
new file mode 100644 (file)
index 0000000..13b4aee
Binary files /dev/null and b/regress/loader/mlines3dm.dbf differ
diff --git a/regress/loader/mlines3dm.shp b/regress/loader/mlines3dm.shp
new file mode 100644 (file)
index 0000000..673dc42
Binary files /dev/null and b/regress/loader/mlines3dm.shp differ
diff --git a/regress/loader/mlines3dm.shx b/regress/loader/mlines3dm.shx
new file mode 100644 (file)
index 0000000..9a00a4c
Binary files /dev/null and b/regress/loader/mlines3dm.shx differ
diff --git a/regress/loader/mlines3dz-wkb.expected b/regress/loader/mlines3dz-wkb.expected
new file mode 100644 (file)
index 0000000..3828939
--- /dev/null
@@ -0,0 +1 @@
+1|01050000C00300000001020000C00200000000000000000000000000000000000000000000000000F03F0000000000000000000000000000F03F000000000000F03F0000000000000040000000000000000001020000C0020000000000000000000840000000000000084000000000000008400000000000000000000000000000104000000000000010400000000000001040000000000000000001020000C00300000000000000000024400000000000002440000000000000144000000000000000000000000000001440000000000000144000000000000018400000000000000000000000000000084000000000000008400000000000001C400000000000000000
diff --git a/regress/loader/mlines3dz-wkt.expected b/regress/loader/mlines3dz-wkt.expected
new file mode 100644 (file)
index 0000000..22619e3
--- /dev/null
@@ -0,0 +1 @@
+1|01050000800300000001020000800200000000000000000000000000000000000000000000000000F03F000000000000F03F000000000000F03F0000000000000040010200008002000000000000000000084000000000000008400000000000000840000000000000104000000000000010400000000000001040010200008003000000000000000000244000000000000024400000000000001440000000000000144000000000000014400000000000001840000000000000084000000000000008400000000000001C40
diff --git a/regress/loader/mlines3dz.dbf b/regress/loader/mlines3dz.dbf
new file mode 100644 (file)
index 0000000..13b4aee
Binary files /dev/null and b/regress/loader/mlines3dz.dbf differ
diff --git a/regress/loader/mlines3dz.shp b/regress/loader/mlines3dz.shp
new file mode 100644 (file)
index 0000000..c2ad6cc
Binary files /dev/null and b/regress/loader/mlines3dz.shp differ
diff --git a/regress/loader/mlines3dz.shx b/regress/loader/mlines3dz.shx
new file mode 100644 (file)
index 0000000..10eaae9
Binary files /dev/null and b/regress/loader/mlines3dz.shx differ
diff --git a/regress/loader/mlines4d-wkb.expected b/regress/loader/mlines4d-wkb.expected
new file mode 100644 (file)
index 0000000..e4381fc
--- /dev/null
@@ -0,0 +1 @@
+1|01050000C00300000001020000C00200000000000000000000000000000000000000000000000000F03F0000000000002240000000000000F03F000000000000F03F0000000000000040000000000000204001020000C0020000000000000000000840000000000000084000000000000008400000000000001C40000000000000104000000000000010400000000000001040000000000000184001020000C00300000000000000000024400000000000002440000000000000144000000000000014400000000000001440000000000000144000000000000018400000000000001040000000000000084000000000000008400000000000001C400000000000001040
diff --git a/regress/loader/mlines4d-wkt.expected b/regress/loader/mlines4d-wkt.expected
new file mode 100644 (file)
index 0000000..22619e3
--- /dev/null
@@ -0,0 +1 @@
+1|01050000800300000001020000800200000000000000000000000000000000000000000000000000F03F000000000000F03F000000000000F03F0000000000000040010200008002000000000000000000084000000000000008400000000000000840000000000000104000000000000010400000000000001040010200008003000000000000000000244000000000000024400000000000001440000000000000144000000000000014400000000000001840000000000000084000000000000008400000000000001C40
diff --git a/regress/loader/mlines4d.dbf b/regress/loader/mlines4d.dbf
new file mode 100644 (file)
index 0000000..13b4aee
Binary files /dev/null and b/regress/loader/mlines4d.dbf differ
diff --git a/regress/loader/mlines4d.shp b/regress/loader/mlines4d.shp
new file mode 100644 (file)
index 0000000..d0f80af
Binary files /dev/null and b/regress/loader/mlines4d.shp differ
diff --git a/regress/loader/mlines4d.shx b/regress/loader/mlines4d.shx
new file mode 100644 (file)
index 0000000..bf8b5ee
Binary files /dev/null and b/regress/loader/mlines4d.shx differ
index 69b6c5043de974ff9c46f49c49e7cd3cf7cb2bc3..7d3a94e2454cae7ed7d18f5abd4ab06d2652ad00 100755 (executable)
@@ -1,6 +1,8 @@
 #!/bin/sh
 
 DB=postgis_reg
+SHP2PGSQL=../loader/shp2pgsql
+PGSQL2SHP=../loader/pgsql2shp
 
 ###################################################
 #
@@ -19,13 +21,287 @@ DB=postgis_reg
 PGOPTIONS="${PGOPTIONS} -c lc_messages=C"
 export PGOPTIONS
 
+PSQL="psql"
+
 if [ -z "$TMPDIR" ]; then
-       TMPDIR=/tmp
+       TMPDIR=/tmp/pgis_reg_$$
 fi
 
+mkdir -p ${TMPDIR}
+
+echo "TMPDIR is ${TMPDIR}"
+
 VERBOSE=0
 OPT_DROP=yes
 OPT_CREATE=yes
+
+###################################################
+# 
+# Helper functions
+#
+###################################################
+
+#
+# fail <msg> <log>
+#
+function fail ()
+{
+       _msg="$1"
+       _log="$2"
+
+       if [ -z "$_log" ]; then
+               echo " failed ($_msg)"
+       elif test "$VERBOSE" -eq "1"; then
+               echo " failed ($_msg: $_log)"
+               echo "-----------------------------------------------------------------------------"
+               cat $_log
+               echo "-----------------------------------------------------------------------------"
+       else
+               echo " failed ($_msg: $_log)"
+       fi
+
+       FAIL=`expr $FAIL + 1`
+}
+
+#
+#  run_simple_test 
+#
+#  Run an sql script and compare results with the given expected output
+#
+#  SQL input is ${TEST}.sql, expected output is {$TEST}_expected
+#
+function run_simple_test ()
+{
+       _sql="$1"
+       _expected="$2"
+       if [ -n "$3" ]; then
+               _msg="$3: "
+       else
+               _msg=
+       fi
+
+       if [ ! -r "$_expected" ]; then
+               fail "can't read $_expected"
+               return 1
+       fi
+
+
+       echo -n "."
+
+       OUTFILE="${TMPDIR}/test_${RUN}_out"
+       TMPFILE="${TMPDIR}/test_${RUN}_tmp"
+       DIFFILE="${TMPDIR}/test_${RUN}_diff"
+
+       # Use intermediate file to prevent MingW buffering problems
+       ${PSQL} -tA < "${TEST}.sql" ${DB} > ${TMPFILE} 2>&1
+       cat ${TMPFILE} \
+               | grep -v "^$" \
+               | grep -v "^INSERT" \
+               | grep -v "^UPDATE" \
+               | grep -v "^DROP" \
+               | grep -v "^CREATE" \
+               | grep -v "^SET" \
+               | sed 's/Infinity/inf/g;s/Inf/inf/g;s/1\.#INF/inf/g' \
+               | sed 's/[eE]\([+-]\)0\{1,\}\([0-9]\{1,\}\)/e\1\2/g' \
+               | sed 's/Self-intersection .*/Self-intersection/' \
+               > "${OUTFILE}"
+       rm ${TMPFILE}
+
+       if diff "${_expected}" "${OUTFILE}" > ${DIFFILE}; then
+               #SUCCESS=`expr $SUCCESS + 1`
+               rm "${OUTFILE}" "${DIFFILE}" # we don't need these anymore
+               return 0
+       else
+               fail "${_msg}diff expected obtained" "${DIFFILE}"
+               rm "${OUTFILE}" # diff is enough
+               return 1
+       fi
+}
+
+#
+#  run_loader_test 
+#
+#  Load a shapefile with different methods, create a 'select *' SQL
+#  test and run simple test with provided expected output. 
+#
+#  SHP input is ${TEST}.shp, expected output is {$TEST}_expected
+#
+function run_loader_test ()
+{
+       _tblname=loadertest
+
+       # ON_ERROR_STOP is used by psql to return non-0 on an error
+       _psql_opts="--variable ON_ERROR_STOP=true"
+
+       echo "SELECT * from ${_tblname}" > ${TEST}.sql
+
+
+       #
+       # Run in HEXWKB insert mode
+       #
+
+       echo -n "."
+
+       ${SHP2PGSQL} ${TEST}.shp $_tblname \
+               > ${TMPDIR}/loader \
+               2> ${TMPDIR}/loader.err
+
+       if [ $? -gt 0 ]; then
+               fail "running shp2pgsql" "${TMPDIR}/loader.err"
+               return 1
+
+       fi
+
+       echo -n "."
+
+       ${PSQL} -c "DROP table ${_tblname}" "${DB}" >> ${TMPDIR}/regress_log 2>&1
+       ${PSQL} ${_psql_opts} -f ${TMPDIR}/loader "${DB}" > ${TMPDIR}/loader.err 2>&1
+       if [ $? -gt 0 ]; then
+               fail "sourcing shp2pgsql output" "${TMPDIR}/loader.err"
+               return 1
+       fi
+
+       if ! run_simple_test ${TEST}.sql ${TEST}-wkb.expected "wkb insert"; then
+               return 1
+       fi
+
+
+       #
+       # Run in HEXWKB dump mode
+       #
+
+       echo -n "."
+
+       ${SHP2PGSQL} -D ${TEST}.shp $_tblname \
+               > ${TMPDIR}/loader \
+               2> ${TMPDIR}/loader.err
+
+       if [ $? -gt 0 ]; then
+               fail "running shp2pgsql -D" "${TMPDIR}/loader.err"
+               return 1
+
+       fi
+
+       echo -n "."
+
+       ${PSQL} -c "DROP table ${_tblname}" "${DB}" >> ${TMPDIR}/regress_log 2>&1
+       ${PSQL} ${_psql_opts} -f ${TMPDIR}/loader "${DB}" > ${TMPDIR}/loader.err 2>&1
+       if [ $? -gt 0 ]; then
+               fail "sourcing shp2pgsql -D output" "${TMPDIR}/loader.err"
+               return 1
+       fi
+
+       if ! run_simple_test ${TEST}.sql ${TEST}-wkb.expected "wkb dump"; then
+               return 1
+       fi
+
+       ###########################################################
+       #
+       # Dump and compare.
+       # Do this using WKB mode, as WKT is unable to reproduce
+       # M values
+       #
+
+       echo -n "."
+
+       ${PGSQL2SHP} -f ${TMPDIR}/dumper ${DB} "${_tblname}" > "${TMPDIR}/dumper.err" 2>&1
+       if [ $? -gt 0 ]; then
+               fail "dumping loaded table" "${TMPDIR}/dumper.err"
+               return 1
+       fi
+
+       echo -n "."
+
+       if ! diff "${TMPDIR}"/dumper.shp "${TEST}".shp > /dev/null; then
+               ls -lL "${TMPDIR}"/dumper.shp "${TEST}".shp > "${TMPDIR}"/dumper.diff
+               fail "dumping loaded table" "${TMPDIR}/dumper.diff"
+               return 1
+       fi
+
+# I'm not sure it's safe to compare indexes
+#      if ! diff "${TMPDIR}"/dumper.shx "${TEST}".shx; then
+#              ls -lL "${TMPDIR}"/dumper.shx "${TEST}".shx > "${TMPDIR}"/dumper.diff
+#              fail "dumping loaded table" "${TMPDIR}/dumper.diff"
+#              return 1
+#      fi
+
+# Change in attribute sizes would make this fail
+#      if ! diff "${TMPDIR}"/dumper.dbf "${TEST}".dbf; then
+#              ls -lL "${TMPDIR}"/dumper.dbf "${TEST}".dbf > "${TMPDIR}"/dumper.diff
+#              fail "dumping loaded table" "${TMPDIR}/dumper.diff"
+#              return 1
+#      fi
+
+
+       #
+       # End of dump and compare.
+       #
+       ################################################
+
+       echo -n "."
+
+       ${SHP2PGSQL} -w ${TEST}.shp $_tblname \
+               > ${TMPDIR}/loader \
+               2> ${TMPDIR}/loader.err
+
+       if [ $? -gt 0 ]; then
+               fail "running shp2pgsql -w" "${TMPDIR}/loader.err"
+               return 1
+       fi
+
+       echo -n "."
+
+       ${PSQL} -c "DROP table ${_tblname}" "${DB}" >> ${TMPDIR}/regress_log 2>&1
+       ${PSQL} ${_psql_opts} -f ${TMPDIR}/loader "${DB}" > ${TMPDIR}/loader.err 2>&1
+       if [ $? -gt 0 ]; then
+               fail "sourcing shp2pgsql -w output" "${TMPDIR}/loader.err"
+               return 1
+       fi
+
+       if ! run_simple_test ${TEST}.sql ${TEST}-wkt.expected "wkt insert"; then
+               return 1
+       fi
+
+       #
+       # Run in WKT dump mode
+       #
+
+       echo -n "."
+
+       ${SHP2PGSQL} -D -w ${TEST}.shp $_tblname \
+               > ${TMPDIR}/loader \
+               2> ${TMPDIR}/loader.err
+
+       if [ $? -gt 0 ]; then
+               fail "running shp2pgsql -D -w" "${TMPDIR}/loader.err"
+               return 1
+
+       fi
+
+       echo -n "."
+
+       ${PSQL} -c "DROP table ${_tblname}" "${DB}" >> ${TMPDIR}/regress_log 2>&1
+       ${PSQL} ${_psql_opts} -f ${TMPDIR}/loader "${DB}" > ${TMPDIR}/loader.err 2>&1
+       if [ $? -gt 0 ]; then
+               fail "sourcing shp2pgsql -D -w output" "${TMPDIR}/loader.err"
+               return 1
+       fi
+
+       if ! run_simple_test ${TEST}.sql ${TEST}-wkt.expected "wkt dump"; then
+               return 1
+       fi
+
+       rm ${TEST}.sql
+
+       return 0;
+}
+
+###################################################
+# 
+# Parse command line opts
+#
+###################################################
+
 while [ -n "$1" ]; do
 
        if test "$1" = "-v"; then
@@ -50,17 +326,22 @@ if [ -z "$1" ]; then
        exit 1
 fi
 
+###################################################
+# 
+# Prepare the database
+#
+###################################################
 
-db_exists=`psql -l | grep -w ${DB}`
+db_exists=`${PSQL} -l | grep -w ${DB}`
 
 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
+               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
@@ -78,11 +359,11 @@ else
        fi
 fi
 
-libver=`psql -tAc "select postgis_lib_version()" $DB`
+libver=`${PSQL} -tAc "select postgis_lib_version()" "${DB}"`
 
 if [ -z "$libver" ]; then
        echo
-       echo " Something went wrong (no postgis installed in $DB)." 
+       echo " Something went wrong (no postgis installed in ${DB})." 
        if [ -z "$db_exists" ]; then
                echo " Check ${TMPDIR}/regress_log_$$ for details."
        else
@@ -93,11 +374,17 @@ if [ -z "$libver" ]; then
        exit 1
 fi
 
-geosver=`psql -tAc "select postgis_geos_version()" $DB`
-jtsver=`psql -tAc "select postgis_jts_version()" $DB`
-projver=`psql -tAc "select postgis_proj_version()" $DB`
-libbuilddate=`psql -tAc "select postgis_lib_build_date()" $DB`
-pgsqlver=`psql -tAc "select version()" $DB`
+###################################################
+# 
+# Report runtime environment 
+#
+###################################################
+
+geosver=`${PSQL} -tAc "select postgis_geos_version()" "${DB}"`
+jtsver=`${PSQL} -tAc "select postgis_jts_version()" "${DB}"`
+projver=`${PSQL} -tAc "select postgis_proj_version()" "${DB}"`
+libbuilddate=`${PSQL} -tAc "select postgis_lib_build_date()" "${DB}"`
+pgsqlver=`${PSQL} -tAc "select version()" "${DB}"`
 
 echo
 echo " $pgsqlver"
@@ -112,6 +399,12 @@ if [ -n "$projver" ]; then
        echo "   PROJ: $projver"
 fi
 
+###################################################
+# 
+# Run the tests
+#
+###################################################
+
 echo 
 echo "Running tests"
 echo
@@ -119,78 +412,46 @@ echo
 RUN=0
 SKIP=0
 FAIL=0
-SUCCESS=0
+#SUCCESS=0
 while [ -n "$1" ]; do
        TEST="$1"; shift;
 
        # catch a common mistake (strip trailing .sql)
        TEST=`echo "$TEST" | sed 's/\.sql$//'`
 
-       OUTFILE="${TMPDIR}/regress_${TEST}_out_$$"
-       TMPFILE="${TMPDIR}/regress_${TEST}_tmp_$$"
-       DIFFILE="${TMPDIR}/regress_${TEST}_diff_$$"
+       #printf %20s " ${TEST}"
+       echo -ne " ${TEST}"
 
-       printf %20s " ${TEST}: "
-       #echo -ne " ${TEST}:\t"
+       RUN=`expr $RUN + 1`
 
-       if [ ! -r "${TEST}.sql" ]; then
+       # Check .shp *before* .sql as loader test would
+       # create the .sql
+       if [ -r "${TEST}.shp" ]; then
+               if run_loader_test; then
+                       echo " ok"
+               fi
+       elif [ -r "${TEST}.sql" ]; then
+               if run_simple_test ${TEST}.sql ${TEST}_expected; then
+                       echo " ok"
+               fi
+       else
                echo "Skipped (can't read ${TEST}.sql)"
                SKIP=`expr $SKIP + 1`
                continue
        fi
 
-       if [ ! -r "${TEST}_expected" ]; then
-               echo " Skipped (can't read ${TEST}_expected)"
-               SKIP=`expr $SKIP + 1`
-               continue
-       fi
-
-       # Use intermediate file to prevent MingW buffering problems
-       psql -tA < "${TEST}.sql" $DB > ${TMPFILE} 2>&1
-       cat ${TMPFILE} \
-               | grep -v "^$" \
-               | grep -v "^INSERT" \
-               | grep -v "^UPDATE" \
-               | grep -v "^DROP" \
-               | grep -v "^CREATE" \
-               | grep -v "^SET" \
-               | sed 's/Infinity/inf/g;s/Inf/inf/g;s/1\.#INF/inf/g' \
-               | sed 's/[eE]\([+-]\)0\{1,\}\([0-9]\{1,\}\)/e\1\2/g' \
-               | sed 's/Self-intersection .*/Self-intersection/' \
-               > "${OUTFILE}"
-       rm ${TMPFILE}
-
-       if diff "${TEST}_expected" "${OUTFILE}" > ${DIFFILE}; then
-               SUCCESS=`expr $SUCCESS + 1`
-               echo "Ok."
-               rm "${OUTFILE}" "${DIFFILE}" # we don't need these anymore
-       else
-               FAIL=`expr $FAIL + 1`
-               if test "$VERBOSE" -eq "1"; then
-                       echo "Failed (diff ${DIFFILE})"
-                       echo "-----------------------------------------------------------------------------"
-                       echo "expected:'<'     obtained:'>'"
-                       echo "-----------------------------------------------------------------------------"
-                       cat ${DIFFILE}
-                       echo "-----------------------------------------------------------------------------"
-               else
-                       echo "Failed (diff ${DIFFILE})"
-               fi
-               rm "${OUTFILE}" # diff is enough
-       fi
-       RUN=`expr $RUN + 1`
 
 done
 
 echo
 echo "Run tests: $RUN"
 #echo "Skipped: $SKIP"
-echo "Successful: $SUCCESS"
+#echo "Successful: $SUCCESS"
 echo "Failed: $FAIL"
 
 if test x"$OPT_DROP" = "xyes" -a x"$OPT_CREATE" = "xyes"; then
        sleep 1
-       dropdb $DB > /dev/null
+       dropdb "${DB}" > /dev/null
 else
        : echo "Drop database ${DB} manually"
 fi