]> granicus.if.org Git - postgis/commitdiff
Style only: remove trailing blankspaces
authorSandro Santilli <strk@kbt.io>
Wed, 7 Sep 2016 18:21:35 +0000 (18:21 +0000)
committerSandro Santilli <strk@kbt.io>
Wed, 7 Sep 2016 18:21:35 +0000 (18:21 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@15079 b70326c6-7e19-0410-871a-916f4a2858ee

regress/run_test.pl

index 626686eb5695a46b223af869b98892b3abc8554f..192e7cb1192df58577c14f13bd7806c63a1cab3a 100755 (executable)
@@ -33,7 +33,7 @@ BEGIN {
 ##################################################################
 # Usage ./run_test.pl <testname> [<testname>]
 #
-#  Create the spatial database 'postgis_reg' (or whatever $DB 
+#  Create the spatial database 'postgis_reg' (or whatever $DB
 #  is set to) if it doesn't already exist.
 #
 #  Run the <testname>.sql script
@@ -74,7 +74,7 @@ my $VERBOSE = 0;
 GetOptions (
        'verbose' => \$VERBOSE,
        'clean' => \$OPT_CLEAN,
-       'nodrop' => \$OPT_NODROP, 
+       'nodrop' => \$OPT_NODROP,
        'upgrade' => \$OPT_UPGRADE,
        'upgrade-path=s' => \$OPT_UPGRADE_PATH,
        'dumprestore' => \$OPT_DUMPRESTORE,
@@ -97,7 +97,7 @@ if ( $OPT_UPGRADE_PATH )
   {
     die "--upgrade-path is only supported with --extension"
   }
-  $OPT_UPGRADE = 1; # implied 
+  $OPT_UPGRADE = 1; # implied
   my @path = split ('--', $OPT_UPGRADE_PATH);
   $OPT_UPGRADE_FROM = $path[0]
     || die "Malformed upgrade path, <from>--<to> expected, $OPT_UPGRADE_PATH given";
@@ -170,7 +170,7 @@ foreach my $exec ( ($SHP2PGSQL, $PGSQL2SHP) )
                print "failed\n";
                die "Unable to find $exec executable.\n";
        }
-       
+
 }
 
 if ( $OPT_WITH_RASTER )
@@ -393,13 +393,13 @@ foreach $TEST (@ARGV)
 
        start_test($TEST);
 
-       # Check for a "-pre.pl" file in case there are setup commands 
+       # 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" )
-       {       
+       {
                run_simple_sql("${TEST}-pre.sql");
                show_progress();
        }
@@ -442,18 +442,18 @@ foreach $TEST (@ARGV)
                        print " ... but cleanup sql failed!";
                }
        }
-       
-       # Check for a "-post.pl" file in case there are teardown commands 
+
+       # Check for a "-post.pl" file in case there are teardown commands
     eval_file("${TEST}-post.pl");
-       
+
 }
 
 
-################################################################### 
+###################################################################
 # Uninstall postgis (serves as an uninstall test)
 ##################################################################
 
-# We only test uninstall if we've been asked to drop 
+# We only test uninstall if we've been asked to drop
 # and we did create
 # and nobody requested raster or topology
 # (until they have an uninstall script themself)
@@ -497,7 +497,7 @@ exit($FAIL);
 # Utility functions
 #
 
-sub usage 
+sub usage
 {
        die qq{
 Usage: $0 [<options>] <testname> [<testname>]
@@ -540,7 +540,7 @@ sub show_progress
        print ".";
 }
 
-# pass <msg> 
+# pass <msg>
 sub pass
 {
   my $msg = shift;
@@ -574,10 +574,10 @@ sub fail
        $FAIL++;
 }
 
-  
+
 
 ##################################################################
-# run_simple_sql 
+# run_simple_sql
 #   Run an sql script and hide results unless it fails.
 #   SQL input file name is $1
 ##################################################################
@@ -585,7 +585,7 @@ sub run_simple_sql
 {
        my $sql = shift;
 
-       if ( ! -r $sql ) 
+       if ( ! -r $sql )
        {
                fail("can't read $sql");
                return 0;
@@ -597,18 +597,18 @@ sub run_simple_sql
        #print($cmd);
        my $rv = system($cmd);
        # Check if psql errored out.
-       if ( $rv != 0 ) 
+       if ( $rv != 0 )
        {
                fail("Unable to run sql script $sql", $tmpfile);
                return 0;
        }
-       
+
        # Check for ERROR lines
        open FILE, "$tmpfile";
        my @lines = <FILE>;
        close FILE;
        my @errors = grep(/^ERROR/, @lines);
-       
+
        if ( @errors > 0 )
        {
                fail("Errors while running sql script $sql", $tmpfile);
@@ -624,7 +624,7 @@ sub drop_table
        my $tblname = shift;
        my $cmd = "psql -tXA -d $DB -c \"DROP TABLE IF EXISTS $tblname\" >> $REGRESS_LOG 2>&1";
        my $rv = system($cmd);
-       die "Could not run: $cmd\n" if $rv;     
+       die "Could not run: $cmd\n" if $rv;
 }
 
 sub sql
@@ -650,7 +650,7 @@ sub eval_file
 }
 
 ##################################################################
-# run_simple_test 
+# 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
 ##################################################################
@@ -665,7 +665,7 @@ sub run_simple_test
                fail("can't read $sql");
                return 0;
        }
-       
+
        if ( ! $OPT_EXPECT )
        {
                if ( ! -r "$expected" )
@@ -728,10 +728,10 @@ sub run_simple_test
                $lines[$i] =~ s/^ROLLBACK/COMMIT/;
                $lines[$i] =~ s/^psql.*(NOTICE|WARNING|ERROR):/\1:/g;
        }
-       
+
        # Write out output file
        open(FILE, ">$outfile");
-       foreach my $l (@lines) 
+       foreach my $l (@lines)
        {
                print FILE $l;
        }
@@ -739,7 +739,7 @@ sub run_simple_test
 
        # Clean up interim stuff
        #remove_tree($betmpdir);
-       
+
        if ( $OPT_EXPECT )
        {
                print " (expected)";
@@ -762,7 +762,7 @@ sub run_simple_test
                        return 1;
                }
        }
-       
+
        return 1;
 }
 
@@ -795,7 +795,7 @@ sub run_loader_and_check_output
        my ( $cmd, $rv );
        my $outfile = "${TMPDIR}/loader.out";
        my $errfile = "${TMPDIR}/loader.err";
-       
+
        # ON_ERROR_STOP is used by psql to return non-0 on an error
        my $psql_opts = " --no-psqlrc --variable ON_ERROR_STOP=true";
 
@@ -823,7 +823,7 @@ sub run_loader_and_check_output
                                return 0;
                        }
                }
-               
+
                # Run the loader SQL script.
                show_progress();
                $cmd = "psql $psql_opts -f $outfile $DB > $errfile 2>&1";
@@ -865,13 +865,13 @@ sub run_dumper_and_check_output
 
        my ($cmd, $rv);
        my $errfile = "${TMPDIR}/dumper.err";
-       
-       if ( $run_always || -r $expected_shp_file ) 
+
+       if ( $run_always || -r $expected_shp_file )
        {
                show_progress();
                $cmd = "${PGSQL2SHP} -f ${TMPDIR}/dumper $DB $tblname > $errfile 2>&1";
                $rv = system($cmd);
-       
+
                if ( $rv )
                {
                        fail("$description: dumping loaded table", $errfile);
@@ -879,11 +879,11 @@ sub run_dumper_and_check_output
                }
 
                # Compare with expected output if there is any.
-               
+
                if ( -r $expected_shp_file )
                {
                        show_progress();
-                       
+
                        my $diff = diff($expected_shp_file,  "$TMPDIR/dumper.shp");
                        if ( $diff )
                        {
@@ -922,7 +922,7 @@ sub run_raster_loader_and_check_output
        my $expected_select_results_file = shift;
        my $loader_options = shift;
        my $run_always = shift;
-       
+
        # ON_ERROR_STOP is used by psql to return non-0 on an error
        my $psql_opts="--no-psqlrc --variable ON_ERROR_STOP=true";
 
@@ -930,20 +930,20 @@ sub run_raster_loader_and_check_output
        my $outfile = "${TMPDIR}/loader.out";
        my $errfile = "${TMPDIR}/loader.err";
 
-       if ( $run_always || -r $expected_sql_file || -r $expected_select_results_file ) 
+       if ( $run_always || -r $expected_sql_file || -r $expected_select_results_file )
        {
                show_progress();
 
                # Produce the output SQL file.
                $cmd = "$RASTER2PGSQL $loader_options ${TEST}.tif $tblname > $outfile 2> $errfile";
                $rv = system($cmd);
-               
+
                if ( $rv )
                {
                    fail("$description: running raster2pgsql", $errfile);
                    return 0;
            }
-           
+
            if ( -r $expected_sql_file )
            {
                show_progress();
@@ -953,7 +953,7 @@ sub run_raster_loader_and_check_output
                                fail(" $description: actual SQL does not match expected.", "$outfile");
                                return 0;
                        }
-               
+
         }
 
                # Run the loader SQL script.
@@ -973,26 +973,26 @@ sub run_raster_loader_and_check_output
                return 0 if ( ! $rv );
        }
        }
-       
+
     return 1;
 }
 
 
 
 ##################################################################
-#  run_loader_test 
+#  run_loader_test
 #
 #  Load a shapefile with different methods, create a 'select *' SQL
-#  test and run simple test with provided expected output. 
+#  test and run simple test with provided expected output.
 #
 #  SHP input is ${TEST}.shp, expected output is {$TEST}.expected
 ##################################################################
-sub run_loader_test 
+sub run_loader_test
 {
        # See if there is a custom command-line options file
        my $opts_file = "${TEST}.opts";
        my $custom_opts="";
-       
+
        if ( -r $opts_file )
        {
                open(FILE, $opts_file);
@@ -1060,22 +1060,22 @@ sub run_loader_test
                }
                drop_table($tblname);
        }
-       
+
        return 1;
 }
 
 ##################################################################
-#  run_dumper_test 
+#  run_dumper_test
 #
 #  Run dumper and compare output with various expectances
-#  test and run simple test with provided expected output. 
+#  test and run simple test with provided expected output.
 #
 # input is ${TEST}.dmp, where last line is considered to be the
 # [table|query] argument for pgsql2shp and all the previous lines,
-# if any are 
+# if any are
 #
 ##################################################################
-sub run_dumper_test 
+sub run_dumper_test
 {
   my $dump_file  = "${TEST}.dmp";
 
@@ -1149,14 +1149,14 @@ sub run_dumper_test
 
 
 ##################################################################
-#  run_raster_loader_test 
+#  run_raster_loader_test
 ##################################################################
 sub run_raster_loader_test
 {
        # See if there is a custom command-line options file
        my $opts_file = "${TEST}.opts";
        my $custom_opts="";
-       
+
        if ( -r $opts_file )
        {
                open(FILE, $opts_file);
@@ -1174,9 +1174,9 @@ sub run_raster_loader_test
        {
                return 0;
        }
-       
+
        drop_table($tblname);
-       
+
        return 1;
 }
 
@@ -1187,15 +1187,15 @@ sub run_raster_loader_test
 sub count_db_objects
 {
        my $count = sql("WITH counts as (
-               select count(*) from pg_type union all 
-               select count(*) from pg_proc union all 
+               select count(*) from pg_type union all
+               select count(*) from pg_proc union all
                select count(*) from pg_cast union all
                select count(*) from pg_aggregate union all
                select count(*) from pg_operator union all
                select count(*) from pg_opclass union all
                select count(*) from pg_namespace
                        where nspname NOT LIKE 'pg_%' union all
-               select count(*) from pg_opfamily ) 
+               select count(*) from pg_opfamily )
                select sum(count) from counts");
 
        return $count;
@@ -1211,7 +1211,7 @@ sub create_db
        return system($cmd);
 }
 
-sub create_spatial 
+sub create_spatial
 {
        my ($cmd, $rv);
        print "Creating database '$DB' \n";
@@ -1224,7 +1224,7 @@ sub create_spatial
        # Count database objects before installing anything
        $OBJ_COUNT_PRE = count_db_objects();
 
-       if ( $OPT_EXTENSIONS ) 
+       if ( $OPT_EXTENSIONS )
        {
                prepare_spatial_extensions();
        }
@@ -1239,12 +1239,12 @@ sub load_sql_file
 {
        my $file = shift;
        my $strict = shift;
-       
+
        if ( $strict && ! -e $file )
        {
-               die "Unable to find $file\n"; 
+               die "Unable to find $file\n";
        }
-       
+
        if ( -e $file )
        {
                # ON_ERROR_STOP is used by psql to return non-0 on an error
@@ -1275,7 +1275,7 @@ sub prepare_spatial_extensions
                $sql .= " VERSION '" . $OPT_UPGRADE_FROM . "'";
        }
 
-       print "Preparing db '${DB}' using: ${sql}\n"; 
+       print "Preparing db '${DB}' using: ${sql}\n";
 
        my $cmd = "psql $psql_opts -c \"". $sql . "\" $DB >> $REGRESS_LOG 2>&1";
        my $rv = system($cmd);
@@ -1325,14 +1325,14 @@ sub prepare_spatial
        load_sql_file("${STAGED_SCRIPTS_DIR}/postgis.sql", 1);
        load_sql_file("${STAGED_SCRIPTS_DIR}/postgis_comments.sql", 0);
        load_sql_file("${STAGED_SCRIPTS_DIR}/postgis_proc_set_search_path.sql", 0);
-       
+
        if ( $OPT_WITH_TOPO )
        {
                print "Loading Topology into '${DB}'\n";
                load_sql_file("${STAGED_SCRIPTS_DIR}/topology.sql", 1);
                load_sql_file("${STAGED_SCRIPTS_DIR}/topology_comments.sql", 0);
        }
-       
+
        if ( $OPT_WITH_RASTER )
        {
                print "Loading Raster into '${DB}'\n";
@@ -1368,8 +1368,8 @@ sub upgrade_spatial
     {
         die "$script not found\n";
     }
-    
-    if ( $OPT_WITH_TOPO ) 
+
+    if ( $OPT_WITH_TOPO )
     {
         my $script = `ls ${STAGED_SCRIPTS_DIR}/topology_upgrade.sql`;
         chomp($script);
@@ -1383,8 +1383,8 @@ sub upgrade_spatial
             die "$script not found\n";
         }
     }
-    
-    if ( $OPT_WITH_RASTER ) 
+
+    if ( $OPT_WITH_RASTER )
     {
         my $script = `ls ${STAGED_SCRIPTS_DIR}/rtpostgis_upgrade.sql`;
         chomp($script);
@@ -1423,7 +1423,7 @@ sub upgrade_spatial_extensions
       die;
     }
 
-    if ( $OPT_WITH_TOPO ) 
+    if ( $OPT_WITH_TOPO )
     {
       my $sql = "ALTER EXTENSION postgis_topology UPDATE TO '${nextver}'";
       my $cmd = "psql $psql_opts -c \"" . $sql . "\" $DB >> $REGRESS_LOG 2>&1";
@@ -1433,7 +1433,7 @@ sub upgrade_spatial_extensions
         die;
       }
     }
-    
+
     return 1;
 }
 
@@ -1462,9 +1462,9 @@ sub drop_spatial_extensions
 {
     # ON_ERROR_STOP is used by psql to return non-0 on an error
     my $psql_opts="--no-psqlrc --variable ON_ERROR_STOP=true";
-    my $ok = 1; 
+    my $ok = 1;
     my ($cmd, $rv);
-    
+
     if ( $OPT_WITH_TOPO )
     {
         # NOTE: "manually" dropping topology schema as EXTENSION does not
@@ -1481,7 +1481,7 @@ sub drop_spatial_extensions
         $rv = system($cmd);
         $ok = 0 if $rv;
     }
-    
+
     $cmd = "psql $psql_opts -c \"DROP EXTENSION postgis\" $DB >> $REGRESS_LOG 2>&1";
     $rv = system($cmd);
        die "\nError encountered dropping EXTENSION POSTGIS, see $REGRESS_LOG for details\n\n"
@@ -1495,9 +1495,9 @@ sub uninstall_spatial
 {
        my $ok;
        start_test("uninstall");
-       
+
        if ( $OPT_EXTENSIONS )
-       {       
+       {
                $ok = drop_spatial_extensions();
        }
        else
@@ -1505,11 +1505,11 @@ sub uninstall_spatial
                $ok = drop_spatial();
        }
 
-       if ( $ok ) 
+       if ( $ok )
        {
                show_progress(); # on to objects count
                $OBJ_COUNT_POST = count_db_objects();
-               
+
                if ( $OBJ_COUNT_POST != $OBJ_COUNT_PRE )
                {
                        fail("Object count pre-install ($OBJ_COUNT_PRE) != post-uninstall ($OBJ_COUNT_POST)");
@@ -1521,9 +1521,9 @@ sub uninstall_spatial
                        return 1;
                }
        }
-       
+
        return 0;
-}  
+}
 
 # Dump and restore the database
 sub dump_restore