+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
----------------------------
$REGDIR = abs_path(dirname($0));
$SHP2PGSQL = $REGDIR . "/../loader/shp2pgsql";
$PGSQL2SHP = $REGDIR . "/../loader/pgsql2shp";
-$RASTER2PGSQL = $REGDIR . "/../../loader/raster2pgsql";
+$RASTER2PGSQL = $REGDIR . "/../raster/loader/raster2pgsql";
##################################################################
foreach my $exec ( ($SHP2PGSQL, $PGSQL2SHP) )
{
- print "Checking for $exec ... ";
+ printf "Checking for %s ... ", basename($exec);
if ( -x $exec )
{
print "found\n";
}
+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
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" )
print " ... but cleanup sql failed!";
}
}
+
+ # Check for a "-post.pl" file in case there are teardown commands
+ eval_file("${TEST}-post.pl");
+
}
$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
$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") )