From: Paul Ramsey Date: Wed, 30 May 2012 18:58:45 +0000 (+0000) Subject: Update the run_test.pl script to handle the raster loader pre/post rules X-Git-Tag: 2.1.0beta2~964 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2e8e02229730763562ced4e8393365f8c2e3bc8e;p=postgis Update the run_test.pl script to handle the raster loader pre/post rules git-svn-id: http://svn.osgeo.org/postgis/trunk@9827 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/regress/README b/regress/README index add62da31..5121f864e 100644 --- a/regress/README +++ b/regress/README @@ -1,3 +1,25 @@ +Requirements for run_test.pl +---------------------------- + +run_test.pl requires the following Perl modules to be installed + + Text::Diff; + File::Which; + File::Basename; + File::Temp 'tempdir'; + File::Copy; + File::Path 'make_path'; + File::Path 'remove_tree'; + Cwd 'abs_path'; + Getopt::Long; + +Most distributions of Perl will have everything except Text::Diff and File::Which. +To install them from the command-line, as root run + + cpan Text::Diff + cpan File::Which + + How to add a regression test ---------------------------- diff --git a/regress/run_test.pl b/regress/run_test.pl index 0d8156006..5918bd599 100755 --- a/regress/run_test.pl +++ b/regress/run_test.pl @@ -35,7 +35,7 @@ $DB = "postgis_reg"; $REGDIR = abs_path(dirname($0)); $SHP2PGSQL = $REGDIR . "/../loader/shp2pgsql"; $PGSQL2SHP = $REGDIR . "/../loader/pgsql2shp"; -$RASTER2PGSQL = $REGDIR . "/../../loader/raster2pgsql"; +$RASTER2PGSQL = $REGDIR . "/../raster/loader/raster2pgsql"; ################################################################## @@ -112,7 +112,7 @@ foreach my $exec ( ("psql", "createdb", "createlang", "dropdb") ) foreach my $exec ( ($SHP2PGSQL, $PGSQL2SHP) ) { - print "Checking for $exec ... "; + printf "Checking for %s ... ", basename($exec); if ( -x $exec ) { print "found\n"; @@ -125,6 +125,19 @@ foreach my $exec ( ($SHP2PGSQL, $PGSQL2SHP) ) } +if ( $OPT_WITH_RASTER ) +{ + print "Checking for raster2pgsql ... "; + if ( -x $RASTER2PGSQL ) + { + print "found\n"; + } + else + { + print "failed\n"; + die "Unable to find raster2pgsql executable.\n"; + } +} ################################################################## # Set up the temporary directory @@ -237,6 +250,9 @@ foreach $TEST (@ARGV) start_test($TEST); + # Check for a "-pre.pl" file in case there are setup commands + eval_file("${TEST}-pre.pl"); + # Check for a "-pre.sql" file in case there is setup SQL needed before # the test can be run. if ( -r "${TEST}-pre.sql" ) @@ -278,6 +294,10 @@ foreach $TEST (@ARGV) print " ... but cleanup sql failed!"; } } + + # Check for a "-post.pl" file in case there are teardown commands + eval_file("${TEST}-post.pl"); + } @@ -463,6 +483,19 @@ sub sql $result; } +sub eval_file +{ + my $file = shift; + my $pl; + if ( -r $file ) + { + open(PL, $file); + $pl = ; + close(PL); + eval($pl); + } +} + ################################################################## # run_simple_test # Run an sql script and compare results with the given expected output @@ -878,7 +911,7 @@ sub run_raster_loader_test $custom_opts = join(" ", @opts); } - my $tblname="loadedshp"; + my $tblname="loadedrast"; # If we have some expected files to compare with, run in geography mode. if ( ! run_raster_loader_and_check_output("test", $tblname, "${TEST}.sql.expected", "${TEST}.select.expected", $custom_opts, "true") )