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
This commit is contained in:
Paul Ramsey 2012-05-30 18:58:45 +00:00
parent 74fcf50478
commit 2e8e022297
2 changed files with 58 additions and 3 deletions

View file

@ -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
----------------------------

View file

@ -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 = <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") )