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;
'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,
$libver = sql("select postgis_lib_version()");
}
+if ( $OPT_DUMPRESTORE )
+{
+ dump_restore();
+}
+
##################################################################
# Report PostGIS environment
-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
--clean cleanup test logs on exit
--expect save obtained output as expected
--extension load using extensions
- --upgrade-path upgrade path, format <from>--<to>
};
}
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) = @_;