Skip to content

Commit 413c1ef

Browse files
committed
Avoid creating testtablespace directories where not wanted.
Recently we refactored things so that pg_regress makes the "testtablespace" subdirectory used by the core regression tests, instead of doing that in the makefiles. That had the undesirable side effect of making such a subdirectory in every directory that has "input" or "output" test files. Since these subdirectories remain empty, git doesn't complain about them, but nonetheless they're clutter. To fix, invent an explicit --make-testtablespace-dir switch, so that pg_regress only makes the subdirectory when explicitly told to. Discussion: https://postgr.es/m/2854388.1621284789@sss.pgh.pa.us
1 parent 4f7d1c3 commit 413c1ef

File tree

3 files changed

+40
-18
lines changed

3 files changed

+40
-18
lines changed

src/test/regress/GNUmakefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ submake-contrib-spi: | submake-libpgport submake-generated-headers
119119
## Run tests
120120
##
121121

122-
REGRESS_OPTS = --dlpath=. --max-concurrent-tests=20 $(EXTRA_REGRESS_OPTS)
122+
REGRESS_OPTS = --dlpath=. --max-concurrent-tests=20 --make-testtablespace-dir \
123+
$(EXTRA_REGRESS_OPTS)
123124

124125
check: all
125126
$(pg_regress_check) $(REGRESS_OPTS) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) $(EXTRA_TESTS)

src/test/regress/pg_regress.c

+36-17
Original file line numberDiff line numberDiff line change
@@ -504,25 +504,9 @@ convert_sourcefiles_in(const char *source_subdir, const char *dest_dir, const ch
504504
if (!directory_exists(outdir_sub))
505505
make_directory(outdir_sub);
506506

507+
/* We might need to replace @testtablespace@ */
507508
snprintf(testtablespace, MAXPGPATH, "%s/testtablespace", outputdir);
508509

509-
/*
510-
* Clean out the test tablespace dir, or create it if it doesn't exist. On
511-
* Windows, doing this cleanup here makes possible to run the regression
512-
* tests as a Windows administrative user account with the restricted
513-
* token obtained when starting pg_regress.
514-
*/
515-
if (directory_exists(testtablespace))
516-
{
517-
if (!rmtree(testtablespace, true))
518-
{
519-
fprintf(stderr, _("\n%s: could not remove test tablespace \"%s\"\n"),
520-
progname, testtablespace);
521-
exit(2);
522-
}
523-
}
524-
make_directory(testtablespace);
525-
526510
/* finally loop on each file and do the replacement */
527511
for (name = names; *name; name++)
528512
{
@@ -601,6 +585,32 @@ convert_sourcefiles(void)
601585
convert_sourcefiles_in("output", outputdir, "expected", "out");
602586
}
603587

588+
/*
589+
* Clean out the test tablespace dir, or create it if it doesn't exist.
590+
*
591+
* On Windows, doing this cleanup here makes it possible to run the
592+
* regression tests under a Windows administrative user account with the
593+
* restricted token obtained when starting pg_regress.
594+
*/
595+
static void
596+
prepare_testtablespace_dir(void)
597+
{
598+
char testtablespace[MAXPGPATH];
599+
600+
snprintf(testtablespace, MAXPGPATH, "%s/testtablespace", outputdir);
601+
602+
if (directory_exists(testtablespace))
603+
{
604+
if (!rmtree(testtablespace, true))
605+
{
606+
fprintf(stderr, _("\n%s: could not remove test tablespace \"%s\"\n"),
607+
progname, testtablespace);
608+
exit(2);
609+
}
610+
}
611+
make_directory(testtablespace);
612+
}
613+
604614
/*
605615
* Scan resultmap file to find which platform-specific expected files to use.
606616
*
@@ -2058,6 +2068,7 @@ help(void)
20582068
printf(_(" --launcher=CMD use CMD as launcher of psql\n"));
20592069
printf(_(" --load-extension=EXT load the named extension before running the\n"));
20602070
printf(_(" tests; can appear multiple times\n"));
2071+
printf(_(" --make-testtablespace-dir create testtablespace directory\n"));
20612072
printf(_(" --max-connections=N maximum number of concurrent connections\n"));
20622073
printf(_(" (default is 0, meaning unlimited)\n"));
20632074
printf(_(" --max-concurrent-tests=N maximum number of concurrent tests in schedule\n"));
@@ -2116,10 +2127,12 @@ regression_main(int argc, char *argv[],
21162127
{"load-extension", required_argument, NULL, 22},
21172128
{"config-auth", required_argument, NULL, 24},
21182129
{"max-concurrent-tests", required_argument, NULL, 25},
2130+
{"make-testtablespace-dir", no_argument, NULL, 26},
21192131
{NULL, 0, NULL, 0}
21202132
};
21212133

21222134
bool use_unix_sockets;
2135+
bool make_testtablespace_dir = false;
21232136
_stringlist *sl;
21242137
int c;
21252138
int i;
@@ -2245,6 +2258,9 @@ regression_main(int argc, char *argv[],
22452258
case 25:
22462259
max_concurrent_tests = atoi(optarg);
22472260
break;
2261+
case 26:
2262+
make_testtablespace_dir = true;
2263+
break;
22482264
default:
22492265
/* getopt_long already emitted a complaint */
22502266
fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"),
@@ -2297,6 +2313,9 @@ regression_main(int argc, char *argv[],
22972313
unlimit_core_size();
22982314
#endif
22992315

2316+
if (make_testtablespace_dir)
2317+
prepare_testtablespace_dir();
2318+
23002319
if (temp_instance)
23012320
{
23022321
FILE *pg_conf;

src/tools/msvc/vcregress.pl

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ sub installcheck_internal
118118
"--bindir=../../../$Config/psql",
119119
"--schedule=${schedule}_schedule",
120120
"--max-concurrent-tests=20",
121+
"--make-testtablespace-dir",
121122
"--encoding=SQL_ASCII",
122123
"--no-locale");
123124
push(@args, $maxconn) if $maxconn;
@@ -152,6 +153,7 @@ sub check
152153
"--bindir=",
153154
"--schedule=${schedule}_schedule",
154155
"--max-concurrent-tests=20",
156+
"--make-testtablespace-dir",
155157
"--encoding=SQL_ASCII",
156158
"--no-locale",
157159
"--temp-instance=./tmp_check");

0 commit comments

Comments
 (0)