Create by default sql/ and expected/ for output directory in pg_regress

Using --outputdir with a custom output repository has never created by
default the sql/ and expected/ paths generated with contents from
respectively input/ and output/ if they don't exist, while the base
output directory gets created if it does not exist.  If sql/ and
expected/ are not present, pg_regress would fail with the path missing,
requiring test scripts to create those extra paths by themselves.  This
commit changes pg_regress so as both get created by default if they do
not exist, removing the need for external test scripts to do so.

This cleans up two code paths in the tree for pg_upgrade tests in MSVC
and environments able to use test.sh.  sql/ and expected/ were created
as part of each test script, but this is not needed anymore as
pg_regress handles the work now.

Author: Roman Zharkov, Daniel Gustafsson
Reviewed-by: Michael Paquier, Tom Lane
Discussion: https://postgr.es/m/16484-4d89e9cc11241996@postgresql.org
This commit is contained in:
Michael Paquier 2020-06-13 14:04:56 +09:00
parent 64725728e7
commit e78900afd2
3 changed files with 7 additions and 8 deletions

View File

@ -106,8 +106,6 @@ outputdir="$temp_root/regress"
EXTRA_REGRESS_OPTS="$EXTRA_REGRESS_OPTS --outputdir=$outputdir" EXTRA_REGRESS_OPTS="$EXTRA_REGRESS_OPTS --outputdir=$outputdir"
export EXTRA_REGRESS_OPTS export EXTRA_REGRESS_OPTS
mkdir "$outputdir" mkdir "$outputdir"
mkdir "$outputdir"/sql
mkdir "$outputdir"/expected
mkdir "$outputdir"/testtablespace mkdir "$outputdir"/testtablespace
logdir=`pwd`/log logdir=`pwd`/log

View File

@ -465,8 +465,7 @@ convert_sourcefiles_in(const char *source_subdir, const char *dest_dir, const ch
{ {
char testtablespace[MAXPGPATH]; char testtablespace[MAXPGPATH];
char indir[MAXPGPATH]; char indir[MAXPGPATH];
struct stat st; char outdir_sub[MAXPGPATH];
int ret;
char **name; char **name;
char **names; char **names;
int count = 0; int count = 0;
@ -474,8 +473,7 @@ convert_sourcefiles_in(const char *source_subdir, const char *dest_dir, const ch
snprintf(indir, MAXPGPATH, "%s/%s", inputdir, source_subdir); snprintf(indir, MAXPGPATH, "%s/%s", inputdir, source_subdir);
/* Check that indir actually exists and is a directory */ /* Check that indir actually exists and is a directory */
ret = stat(indir, &st); if (!directory_exists(indir))
if (ret != 0 || !S_ISDIR(st.st_mode))
{ {
/* /*
* No warning, to avoid noise in tests that do not have these * No warning, to avoid noise in tests that do not have these
@ -489,6 +487,11 @@ convert_sourcefiles_in(const char *source_subdir, const char *dest_dir, const ch
/* Error logged in pgfnames */ /* Error logged in pgfnames */
exit(2); exit(2);
/* Create the "dest" subdirectory if not present */
snprintf(outdir_sub, MAXPGPATH, "%s/%s", dest_dir, dest_subdir);
if (!directory_exists(outdir_sub))
make_directory(outdir_sub);
snprintf(testtablespace, MAXPGPATH, "%s/testtablespace", outputdir); snprintf(testtablespace, MAXPGPATH, "%s/testtablespace", outputdir);
#ifdef WIN32 #ifdef WIN32

View File

@ -571,8 +571,6 @@ sub upgradecheck
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/sql" || die $!;
mkdir "$outputdir/expected" || die $!;
mkdir "$outputdir/testtablespace" || die $!; mkdir "$outputdir/testtablespace" || die $!;
my $logdir = "$topdir/src/bin/pg_upgrade/log"; my $logdir = "$topdir/src/bin/pg_upgrade/log";