[postgis-tickets] r14652 - Add --dumprestore switch to ./run_test.pl
Sandro Santilli
strk at keybit.net
Tue Feb 9 08:18:51 PST 2016
Author: strk
Date: 2016-02-09 08:18:51 -0800 (Tue, 09 Feb 2016)
New Revision: 14652
Modified:
branches/2.2/regress/run_test.pl
Log:
Add --dumprestore switch to ./run_test.pl
See #3444
Modified: branches/2.2/regress/run_test.pl
===================================================================
--- branches/2.2/regress/run_test.pl 2016-02-09 15:47:59 UTC (rev 14651)
+++ branches/2.2/regress/run_test.pl 2016-02-09 16:18:51 UTC (rev 14652)
@@ -52,6 +52,7 @@
my $OPT_NODROP = 0;
my $OPT_NOCREATE = 0;
my $OPT_UPGRADE = 0;
+my $OPT_DUMPRESTORE = 0;
my $OPT_WITH_TOPO = 0;
my $OPT_WITH_RASTER = 0;
my $OPT_WITH_SFCGAL = 0;
@@ -69,6 +70,7 @@
'nodrop' => \$OPT_NODROP,
'upgrade' => \$OPT_UPGRADE,
'upgrade-path=s' => \$OPT_UPGRADE_PATH,
+ 'dumprestore' => \$OPT_DUMPRESTORE,
'nocreate' => \$OPT_NOCREATE,
'topology' => \$OPT_WITH_TOPO,
'raster' => \$OPT_WITH_RASTER,
@@ -332,7 +334,12 @@
$libver = sql("select postgis_lib_version()");
}
+if ( $OPT_DUMPRESTORE )
+{
+ dump_restore();
+}
+
##################################################################
# Report PostGIS environment
##################################################################
@@ -490,6 +497,8 @@
-v, --verbose be verbose about failures
--nocreate do not create the regression database on start
--upgrade source the upgrade scripts on start
+ --upgrade-path upgrade path, format <from>--<to>
+ --dumprestore dump and restore spatially-enabled db before running tests
--nodrop do not drop the regression database on exit
--raster load also raster extension
--topology load also topology extension
@@ -497,7 +506,6 @@
--clean cleanup test logs on exit
--expect save obtained output as expected
--extension load using extensions
- --upgrade-path upgrade path, format <from>--<to>
};
}
@@ -1501,6 +1509,43 @@
return 0;
}
+# Dump and restore the database
+sub dump_restore
+{
+ my $DBDUMP = $TMPDIR . '/' . $DB . ".dump";
+ my $rv;
+
+ print "Dumping and restoring database '${DB}'\n";
+
+ $rv = system("pg_dump -Fc ${DB} -f ${DBDUMP} >> $REGRESS_LOG 2>&1");
+ if ( $rv ) {
+ fail("Could not dump ${DB}", $REGRESS_LOG);
+ die;
+ }
+
+ $rv = system("dropdb ${DB} >> $REGRESS_LOG 2>&1");
+ if ( $rv ) {
+ fail("Could not drop ${DB}", $REGRESS_LOG);
+ die;
+ }
+
+ $rv = system("createdb ${DB} >> $REGRESS_LOG 2>&1");
+ if ( $rv ) {
+ fail("Could not create ${DB}", $REGRESS_LOG);
+ die;
+ }
+
+ $rv = system("pg_restore -d ${DB} ${DBDUMP} >> $REGRESS_LOG 2>&1");
+ if ( $rv ) {
+ fail("Could not restore ${DB}", $REGRESS_LOG);
+ die;
+ };
+
+ unlink($DBDUMP);
+
+ return 1;
+}
+
sub diff
{
my ($expected_file, $obtained_file) = @_;
More information about the postgis-tickets
mailing list