Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lil9c-0003hy-3Q for pgsql-committers@arkaria.postgresql.org; Mon, 17 May 2021 21:52:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lil9Z-0003hO-TQ for pgsql-committers@arkaria.postgresql.org; Mon, 17 May 2021 21:51:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lil9Z-0003hG-Nn for pgsql-committers@lists.postgresql.org; Mon, 17 May 2021 21:51:57 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lil9X-00062t-FU for pgsql-committers@lists.postgresql.org; Mon, 17 May 2021 21:51:56 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 14HLpsvQ2917893; Mon, 17 May 2021 17:51:54 -0400 From: Tom Lane To: Michael Paquier cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Move tablespace path re-creation from the makefiles to pg_regres In-reply-to: <2854388.1621284789@sss.pgh.pa.us> References: <2854388.1621284789@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 17 May 2021 16:53:09 -0400" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <2917885.1621288310.0@sss.pgh.pa.us> Date: Mon, 17 May 2021 17:51:54 -0400 Message-ID: <2917892.1621288314@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2917885.1621288310.1@sss.pgh.pa.us> I wrote: > I think what we want to do is have this code invoked only in > test directories that explicitly ask for it, say with a new > "--make-testtablespace" switch for pg_regress. Say, as attached. (Windows part is untested.) regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="fix-testtablespace-creation.patch"; charset="us-ascii" Content-ID: <2917885.1621288310.2@sss.pgh.pa.us> Content-Description: fix-testtablespace-creation.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile index 5dc4bbcb00..fe6e0c98aa 100644 --- a/src/test/regress/GNUmakefile +++ b/src/test/regress/GNUmakefile @@ -119,7 +119,8 @@ submake-contrib-spi: | submake-libpgport submake-gener= ated-headers ## Run tests ## = -REGRESS_OPTS =3D --dlpath=3D. --max-concurrent-tests=3D20 $(EXTRA_REGRESS= _OPTS) +REGRESS_OPTS =3D --dlpath=3D. --max-concurrent-tests=3D20 --make-testtabl= espace-dir \ + $(EXTRA_REGRESS_OPTS) = check: all $(pg_regress_check) $(REGRESS_OPTS) --schedule=3D$(srcdir)/parallel_sche= dule $(MAXCONNOPT) $(EXTRA_TESTS) diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index b7d80bd9bb..5918e8b412 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -504,25 +504,9 @@ convert_sourcefiles_in(const char *source_subdir, con= st char *dest_dir, const ch if (!directory_exists(outdir_sub)) make_directory(outdir_sub); = + /* We might need to replace @testtablespace@ */ snprintf(testtablespace, MAXPGPATH, "%s/testtablespace", outputdir); = - /* - * Clean out the test tablespace dir, or create it if it doesn't exist. = On - * Windows, doing this cleanup here makes possible to run the regression - * tests as a Windows administrative user account with the restricted - * token obtained when starting pg_regress. - */ - 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); - /* finally loop on each file and do the replacement */ for (name =3D names; *name; name++) { @@ -601,6 +585,32 @@ convert_sourcefiles(void) convert_sourcefiles_in("output", outputdir, "expected", "out"); } = +/* + * Clean out the test tablespace dir, or create it if it doesn't exist. + * + * On Windows, doing this cleanup here makes it possible to run the + * regression tests under a Windows administrative user account with the + * restricted token obtained when starting pg_regress. + */ +static void +prepare_testtablespace_dir(void) +{ + char testtablespace[MAXPGPATH]; + + snprintf(testtablespace, MAXPGPATH, "%s/testtablespace", outputdir); + + 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); +} + /* * Scan resultmap file to find which platform-specific expected files to = use. * @@ -2062,6 +2072,7 @@ help(void) printf(_(" (default is 0, meaning unlimit= ed)\n")); printf(_(" --max-concurrent-tests=3DN maximum number of concurrent= tests in schedule\n")); printf(_(" (default is 0, meaning unlimit= ed)\n")); + printf(_(" --make-testtablespace-dir create testtablespace director= y\n")); printf(_(" --outputdir=3DDIR place output files in DIR (d= efault \".\")\n")); printf(_(" --schedule=3DFILE use test ordering schedule f= rom FILE\n")); printf(_(" (can be used multiple times to= concatenate)\n")); @@ -2116,10 +2127,12 @@ regression_main(int argc, char *argv[], {"load-extension", required_argument, NULL, 22}, {"config-auth", required_argument, NULL, 24}, {"max-concurrent-tests", required_argument, NULL, 25}, + {"make-testtablespace-dir", no_argument, NULL, 26}, {NULL, 0, NULL, 0} }; = bool use_unix_sockets; + bool make_testtablespace_dir =3D false; _stringlist *sl; int c; int i; @@ -2245,6 +2258,9 @@ regression_main(int argc, char *argv[], case 25: max_concurrent_tests =3D atoi(optarg); break; + case 26: + make_testtablespace_dir =3D true; + break; default: /* getopt_long already emitted a complaint */ fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"), @@ -2297,6 +2313,9 @@ regression_main(int argc, char *argv[], unlimit_core_size(); #endif = + if (make_testtablespace_dir) + prepare_testtablespace_dir(); + if (temp_instance) { FILE *pg_conf; diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl index 1852c34109..35e8f67f01 100644 --- a/src/tools/msvc/vcregress.pl +++ b/src/tools/msvc/vcregress.pl @@ -118,6 +118,7 @@ sub installcheck_internal "--bindir=3D../../../$Config/psql", "--schedule=3D${schedule}_schedule", "--max-concurrent-tests=3D20", + "--make-testtablespace-dir", "--encoding=3DSQL_ASCII", "--no-locale"); push(@args, $maxconn) if $maxconn; @@ -152,6 +153,7 @@ sub check "--bindir=3D", "--schedule=3D${schedule}_schedule", "--max-concurrent-tests=3D20", + "--make-testtablespace-dir", "--encoding=3DSQL_ASCII", "--no-locale", "--temp-instance=3D./tmp_check"); ------- =_aaaaaaaaaa0--