Commit 2b2a070d authored by Michael Paquier's avatar Michael Paquier

Remove reset of testtablespace from pg_regress on Windows

testtablespace is an extra path used as tablespace location in the main
regression test suite, computed from --outputdir as defined by the
caller of pg_regress (current directory if undefined).

This special handling was introduced as of f10589e5 to be specific to
MSVC, as we let pg_regress' Makefile handle this cleanup in other
environments.  This moves the cleanup to the MSVC script running
regression tests instead where needed: check, installcheck and
upgradecheck.  I have also checked this patch on MSVC with repeated runs
of each target.

Author: Kyotaro Horiguchi, Michael Paquier
Discussion: https://postgr.es/m/20200219.142519.437573253063431435.horikyota.ntt@gmail.com
parent d8b15eeb
...@@ -494,28 +494,6 @@ convert_sourcefiles_in(const char *source_subdir, const char *dest_dir, const ch ...@@ -494,28 +494,6 @@ convert_sourcefiles_in(const char *source_subdir, const char *dest_dir, const ch
snprintf(testtablespace, MAXPGPATH, "%s/testtablespace", outputdir); snprintf(testtablespace, MAXPGPATH, "%s/testtablespace", outputdir);
#ifdef WIN32
/*
* On Windows only, clean out the test tablespace dir, or create it if it
* doesn't exist. On other platforms we expect the Makefile to take care
* of that. (We don't migrate that functionality in here because it'd be
* harder to cope with platform-specific issues such as SELinux.)
*
* XXX it would be better if pg_regress.c had nothing at all to do with
* testtablespace, and this were handled by a .BAT file or similar on
* Windows. See pgsql-hackers discussion of 2008-01-18.
*/
if (directory_exists(testtablespace))
if (!rmtree(testtablespace, true))
{
fprintf(stderr, _("\n%s: could not remove test tablespace \"%s\"\n"),
progname, testtablespace);
exit(2);
}
make_directory(testtablespace);
#endif
/* finally loop on each file and do the replacement */ /* finally loop on each file and do the replacement */
for (name = names; *name; name++) for (name = names; *name; name++)
{ {
......
...@@ -123,6 +123,8 @@ sub installcheck_internal ...@@ -123,6 +123,8 @@ sub installcheck_internal
sub installcheck sub installcheck
{ {
my $schedule = shift || 'serial'; my $schedule = shift || 'serial';
CleanupTablespaceDirectory();
installcheck_internal($schedule); installcheck_internal($schedule);
return; return;
} }
...@@ -143,6 +145,7 @@ sub check ...@@ -143,6 +145,7 @@ sub check
"--temp-instance=./tmp_check"); "--temp-instance=./tmp_check");
push(@args, $maxconn) if $maxconn; push(@args, $maxconn) if $maxconn;
push(@args, $temp_config) if $temp_config; push(@args, $temp_config) if $temp_config;
CleanupTablespaceDirectory();
system(@args); system(@args);
my $status = $? >> 8; my $status = $? >> 8;
exit $status if $status; exit $status if $status;
...@@ -570,8 +573,8 @@ sub upgradecheck ...@@ -570,8 +573,8 @@ sub upgradecheck
$ENV{PGDATA} = "$data.old"; $ENV{PGDATA} = "$data.old";
my $outputdir = "$tmp_root/regress"; my $outputdir = "$tmp_root/regress";
my @EXTRA_REGRESS_OPTS = ("--outputdir=$outputdir"); my @EXTRA_REGRESS_OPTS = ("--outputdir=$outputdir");
mkdir "$outputdir" || die $!; mkdir "$outputdir" || die $!;
mkdir "$outputdir/testtablespace" || die $!; CleanupTablespaceDirectory($outputdir);
my $logdir = "$topdir/src/bin/pg_upgrade/log"; my $logdir = "$topdir/src/bin/pg_upgrade/log";
rmtree($logdir); rmtree($logdir);
...@@ -737,6 +740,16 @@ sub InstallTemp ...@@ -737,6 +740,16 @@ sub InstallTemp
return; return;
} }
sub CleanupTablespaceDirectory
{
my $testdir = shift || getcwd();
my $testtablespace = "$testdir/testtablespace";
rmtree($testtablespace) if (-d $testtablespace);
mkdir($testtablespace);
}
sub usage sub usage
{ {
print STDERR print STDERR
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment