[SCM] PostGIS branch master updated. 3.4.0rc1-958-g340197426

git at osgeo.org git at osgeo.org
Fri Mar 1 02:06:48 PST 2024


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  340197426c7fcaa4b7e79c74cabd98a688cc6b89 (commit)
      from  07a73c0f2c5cb07e33fd64dadd24fac35efdc0a5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 340197426c7fcaa4b7e79c74cabd98a688cc6b89
Author: Sandro Santilli <strk at kbt.io>
Date:   Thu Feb 29 10:34:37 2024 +0100

    Have run_test.pl bail out on WARNINGS during script-based db preparation
    
    References #5678
    References #5679

diff --git a/regress/run_test.pl b/regress/run_test.pl
index 959fed22d..246a9546c 100755
--- a/regress/run_test.pl
+++ b/regress/run_test.pl
@@ -908,6 +908,7 @@ sub drop_table
 sub sql
 {
 	my $sql = shift;
+	# TODO: capture or discard stderr ?
 	my $result = `psql -qtXA -d $DB -c 'SET search_path TO public,$OPT_SCHEMA' -c "$sql" | sed '/^SET\$/d'`;
 	$result =~ s/[\n\r]*$//;
 	$result;
@@ -1576,34 +1577,45 @@ sub create_spatial
 
 sub load_sql_file
 {
-	my $file = shift;
-	my $strict = shift;
+    my $file = shift;
+    my $strict = shift;
+    my $werror = shift;
 
-	if ( -e $file )
-	{
-		# ON_ERROR_STOP is used by psql to return non-0 on an error
-		my $psql_opts = "--quiet --no-psqlrc --variable ON_ERROR_STOP=true";
-		my $cmd = "psql $psql_opts -c 'CREATE SCHEMA IF NOT EXISTS $OPT_SCHEMA' ";
-		$cmd .= "-c 'SET search_path TO $OPT_SCHEMA,topology'";
-		$cmd .= " -v \"opt_dumprestore=${OPT_DUMPRESTORE}\"";
-		$cmd .= " -v \"regdir=$REGDIR\"";
-		$cmd .= " -Xf $file $DB >> $REGRESS_LOG 2>&1";
-		#print "  $file\n" if $VERBOSE;
-		my $rv = system($cmd);
-		if ( $rv )
-		{
-		  fail "Error encountered loading $file", $REGRESS_LOG;
-		  #exit 1;
-			return 0;
-		}
-	}
-	elsif ( $strict )
-	{
-		fail "Unable to find $file";
-		return 0;
-	}
+    my $tmplog = ${REGRESS_LOG} . '.tmp';
 
-	return 1;
+    if ( -e $file )
+    {
+        # ON_ERROR_STOP is used by psql to return non-0 on an error
+        my $psql_opts = "--quiet --no-psqlrc --variable ON_ERROR_STOP=true";
+        my $cmd = "psql $psql_opts -c 'CREATE SCHEMA IF NOT EXISTS $OPT_SCHEMA' ";
+        $cmd .= "-c 'SET search_path TO $OPT_SCHEMA,topology'";
+        $cmd .= " -v \"opt_dumprestore=${OPT_DUMPRESTORE}\"";
+        $cmd .= " -v \"regdir=$REGDIR\"";
+        $cmd .= " -Xf $file $DB 2>&1 | tee -a $REGRESS_LOG > $tmplog";
+        #print "  $file\n" if $VERBOSE;
+        my $rv = system($cmd);
+        if ( $rv )
+        {
+            fail "Error encountered loading $file", $tmplog;
+            return 0;
+        }
+
+        if ( $werror )
+        {
+            if ( system("grep -A3 WARNING $tmplog") == 0 )
+            {
+                fail "Warnings encountered loading $file", $tmplog;
+                return 0;
+            }
+        }
+    }
+    elsif ( $strict )
+    {
+        fail "Unable to find $file";
+        return 0;
+    }
+
+    return 1;
 }
 
 # Prepare the database for spatial operations (extension method)
@@ -1734,40 +1746,39 @@ sub prepare_spatial_extensions
 sub prepare_spatial
 {
 	my $version = shift;
+	my $werror = defined ($version) ? 0 : 1; # threat warnings as errors
 	my $scriptdir = scriptdir($version);
-	print "Loading unpackaged components from $scriptdir\n";
-
-	print "Loading PostGIS into '${DB}' \n";
+	print "Loading PostGIS in '${DB} using scripts from $scriptdir'\n";
 
 	# Load postgis.sql into the database
-	return 0 unless load_sql_file("${scriptdir}/postgis.sql", 1);
-	return 0 unless load_sql_file("${scriptdir}/postgis_comments.sql", 0);
-	return 0 unless load_sql_file("${scriptdir}/spatial_ref_sys.sql", 0);
+	return 0 unless load_sql_file("${scriptdir}/postgis.sql", 1, $werror);
+	return 0 unless load_sql_file("${scriptdir}/postgis_comments.sql", 0, $werror);
+	return 0 unless load_sql_file("${scriptdir}/spatial_ref_sys.sql", 0, $werror);
 	if ( $OPT_LEGACY )
 	{
 		print "Loading legacy.sql from $scriptdir\n";
-		return 0 unless load_sql_file("${scriptdir}/legacy.sql", 0);
+		return 0 unless load_sql_file("${scriptdir}/legacy.sql", 0, $werror);
 	}
 
 	if ( $OPT_WITH_TOPO )
 	{
 		print "Loading Topology into '${DB}'\n";
-		return 0 unless load_sql_file("${scriptdir}/topology.sql", 1);
-		return 0 unless load_sql_file("${scriptdir}/topology_comments.sql", 0);
+		return 0 unless load_sql_file("${scriptdir}/topology.sql", 1, $werror);
+		return 0 unless load_sql_file("${scriptdir}/topology_comments.sql", 0, $werror);
 	}
 
 	if ( $OPT_WITH_RASTER )
 	{
 		print "Loading Raster into '${DB}'\n";
-		return 0 unless load_sql_file("${scriptdir}/rtpostgis.sql", 1);
-		return 0 unless load_sql_file("${scriptdir}/raster_comments.sql", 0);
+		return 0 unless load_sql_file("${scriptdir}/rtpostgis.sql", 1, $werror);
+		return 0 unless load_sql_file("${scriptdir}/raster_comments.sql", 0, $werror);
 	}
 
 	if ( $OPT_WITH_SFCGAL )
 	{
 		print "Loading SFCGAL into '${DB}'\n";
-		return 0 unless load_sql_file("${scriptdir}/sfcgal.sql", 1);
-		return 0 unless load_sql_file("${scriptdir}/sfcgal_comments.sql", 0);
+		return 0 unless load_sql_file("${scriptdir}/sfcgal.sql", 1, $werror);
+		return 0 unless load_sql_file("${scriptdir}/sfcgal_comments.sql", 0, $werror);
 	}
 
 	return 1;

-----------------------------------------------------------------------

Summary of changes:
 regress/run_test.pl | 89 ++++++++++++++++++++++++++++++-----------------------
 1 file changed, 50 insertions(+), 39 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list