]> granicus.if.org Git - postgis/commitdiff
Update the run_test.pl script to handle the raster loader pre/post rules
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 30 May 2012 18:58:45 +0000 (18:58 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 30 May 2012 18:58:45 +0000 (18:58 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9827 b70326c6-7e19-0410-871a-916f4a2858ee

regress/README
regress/run_test.pl

index add62da31d16dd718645007ec90deea92bebb5b0..5121f864eaf912e22360b759e3c2bfb47515434f 100644 (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
 ----------------------------
 
index 0d8156006d4d7fb73e94b32b32931afff242a2ae..5918bd599cb808e343529ecd6a03ba32e64e0fd5 100755 (executable)
@@ -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") )