Create by default sql/ and expected/ for output directory in pg_regress
authorMichael Paquier <michael@paquier.xyz>
Sat, 13 Jun 2020 05:04:56 +0000 (14:04 +0900)
committerMichael Paquier <michael@paquier.xyz>
Sat, 13 Jun 2020 05:04:56 +0000 (14:04 +0900)
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

src/bin/pg_upgrade/test.sh
src/test/regress/pg_regress.c
src/tools/msvc/vcregress.pl

index 10a28d8133c7904a27729601df2a4b5acd60a2c9..7ff06de6d182b1030d4474f21a279182958644ce 100644 (file)
@@ -106,8 +106,6 @@ outputdir="$temp_root/regress"
 EXTRA_REGRESS_OPTS="$EXTRA_REGRESS_OPTS --outputdir=$outputdir"
 export EXTRA_REGRESS_OPTS
 mkdir "$outputdir"
-mkdir "$outputdir"/sql
-mkdir "$outputdir"/expected
 mkdir "$outputdir"/testtablespace
 
 logdir=`pwd`/log
index 38b2b1e8e1ba4ea1acb79442c0ef7c99cb7bd2e8..f11a3b9e26e621d1291df74bd1c08ed05cc17a4f 100644 (file)
@@ -465,8 +465,7 @@ convert_sourcefiles_in(const char *source_subdir, const char *dest_dir, const ch
 {
    char        testtablespace[MAXPGPATH];
    char        indir[MAXPGPATH];
-   struct stat st;
-   int         ret;
+   char        outdir_sub[MAXPGPATH];
    char      **name;
    char      **names;
    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);
 
    /* Check that indir actually exists and is a directory */
-   ret = stat(indir, &st);
-   if (ret != 0 || !S_ISDIR(st.st_mode))
+   if (!directory_exists(indir))
    {
        /*
         * 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 */
        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);
 
 #ifdef WIN32
index 4a53a004b78285851401cddfdcd7615b79cda64d..3365ee578c3dbd1d717c42ba47348d9a1b702724 100644 (file)
@@ -571,8 +571,6 @@ sub upgradecheck
    my $outputdir          = "$tmp_root/regress";
    my @EXTRA_REGRESS_OPTS = ("--outputdir=$outputdir");
    mkdir "$outputdir"                || die $!;
-   mkdir "$outputdir/sql"            || die $!;
-   mkdir "$outputdir/expected"       || die $!;
    mkdir "$outputdir/testtablespace" || die $!;
 
    my $logdir = "$topdir/src/bin/pg_upgrade/log";