Commit 413c1ef9 authored by Tom Lane's avatar Tom Lane

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
parent 4f7d1c30
...@@ -119,7 +119,8 @@ submake-contrib-spi: | submake-libpgport submake-generated-headers ...@@ -119,7 +119,8 @@ submake-contrib-spi: | submake-libpgport submake-generated-headers
## Run tests ## Run tests
## ##
REGRESS_OPTS = --dlpath=. --max-concurrent-tests=20 $(EXTRA_REGRESS_OPTS) REGRESS_OPTS = --dlpath=. --max-concurrent-tests=20 --make-testtablespace-dir \
$(EXTRA_REGRESS_OPTS)
check: all check: all
$(pg_regress_check) $(REGRESS_OPTS) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) $(EXTRA_TESTS) $(pg_regress_check) $(REGRESS_OPTS) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) $(EXTRA_TESTS)
......
...@@ -504,25 +504,9 @@ convert_sourcefiles_in(const char *source_subdir, const char *dest_dir, const ch ...@@ -504,25 +504,9 @@ convert_sourcefiles_in(const char *source_subdir, const char *dest_dir, const ch
if (!directory_exists(outdir_sub)) if (!directory_exists(outdir_sub))
make_directory(outdir_sub); make_directory(outdir_sub);
/* We might need to replace @testtablespace@ */
snprintf(testtablespace, MAXPGPATH, "%s/testtablespace", outputdir); 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 */ /* finally loop on each file and do the replacement */
for (name = names; *name; name++) for (name = names; *name; name++)
{ {
...@@ -601,6 +585,32 @@ convert_sourcefiles(void) ...@@ -601,6 +585,32 @@ convert_sourcefiles(void)
convert_sourcefiles_in("output", outputdir, "expected", "out"); 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. * Scan resultmap file to find which platform-specific expected files to use.
* *
...@@ -2058,6 +2068,7 @@ help(void) ...@@ -2058,6 +2068,7 @@ help(void)
printf(_(" --launcher=CMD use CMD as launcher of psql\n")); printf(_(" --launcher=CMD use CMD as launcher of psql\n"));
printf(_(" --load-extension=EXT load the named extension before running the\n")); printf(_(" --load-extension=EXT load the named extension before running the\n"));
printf(_(" tests; can appear multiple times\n")); printf(_(" tests; can appear multiple times\n"));
printf(_(" --make-testtablespace-dir create testtablespace directory\n"));
printf(_(" --max-connections=N maximum number of concurrent connections\n")); printf(_(" --max-connections=N maximum number of concurrent connections\n"));
printf(_(" (default is 0, meaning unlimited)\n")); printf(_(" (default is 0, meaning unlimited)\n"));
printf(_(" --max-concurrent-tests=N maximum number of concurrent tests in schedule\n")); printf(_(" --max-concurrent-tests=N maximum number of concurrent tests in schedule\n"));
...@@ -2116,10 +2127,12 @@ regression_main(int argc, char *argv[], ...@@ -2116,10 +2127,12 @@ regression_main(int argc, char *argv[],
{"load-extension", required_argument, NULL, 22}, {"load-extension", required_argument, NULL, 22},
{"config-auth", required_argument, NULL, 24}, {"config-auth", required_argument, NULL, 24},
{"max-concurrent-tests", required_argument, NULL, 25}, {"max-concurrent-tests", required_argument, NULL, 25},
{"make-testtablespace-dir", no_argument, NULL, 26},
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
bool use_unix_sockets; bool use_unix_sockets;
bool make_testtablespace_dir = false;
_stringlist *sl; _stringlist *sl;
int c; int c;
int i; int i;
...@@ -2245,6 +2258,9 @@ regression_main(int argc, char *argv[], ...@@ -2245,6 +2258,9 @@ regression_main(int argc, char *argv[],
case 25: case 25:
max_concurrent_tests = atoi(optarg); max_concurrent_tests = atoi(optarg);
break; break;
case 26:
make_testtablespace_dir = true;
break;
default: default:
/* getopt_long already emitted a complaint */ /* getopt_long already emitted a complaint */
fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"), fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"),
...@@ -2297,6 +2313,9 @@ regression_main(int argc, char *argv[], ...@@ -2297,6 +2313,9 @@ regression_main(int argc, char *argv[],
unlimit_core_size(); unlimit_core_size();
#endif #endif
if (make_testtablespace_dir)
prepare_testtablespace_dir();
if (temp_instance) if (temp_instance)
{ {
FILE *pg_conf; FILE *pg_conf;
......
...@@ -118,6 +118,7 @@ sub installcheck_internal ...@@ -118,6 +118,7 @@ sub installcheck_internal
"--bindir=../../../$Config/psql", "--bindir=../../../$Config/psql",
"--schedule=${schedule}_schedule", "--schedule=${schedule}_schedule",
"--max-concurrent-tests=20", "--max-concurrent-tests=20",
"--make-testtablespace-dir",
"--encoding=SQL_ASCII", "--encoding=SQL_ASCII",
"--no-locale"); "--no-locale");
push(@args, $maxconn) if $maxconn; push(@args, $maxconn) if $maxconn;
...@@ -152,6 +153,7 @@ sub check ...@@ -152,6 +153,7 @@ sub check
"--bindir=", "--bindir=",
"--schedule=${schedule}_schedule", "--schedule=${schedule}_schedule",
"--max-concurrent-tests=20", "--max-concurrent-tests=20",
"--make-testtablespace-dir",
"--encoding=SQL_ASCII", "--encoding=SQL_ASCII",
"--no-locale", "--no-locale",
"--temp-instance=./tmp_check"); "--temp-instance=./tmp_check");
......
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