Skip to content

Commit c855872

Browse files
committedAug 20, 2022
regress: allow to specify directory containing expected files, for ecpg
The ecpg tests have their input directory in the build directory, as the tests need to be built. Until now that required copying the expected/ directory to the build directory in VPATH builds. To avoid needing to implement the same for the meson build, add support for specifying the location of the expected directory. Now that that's not needed anymore, remove the copying of ecpg's expected directory to the build directory in VPATH builds. Author: Nazir Bilal Yavuz <[email protected]> Author: Andres Freund <[email protected]> Reviewed-by: Andres Freund <[email protected]> Reviewed-by: Peter Eisentraut <[email protected]> Discussion: https://postgr.es/m/[email protected]

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed
 

‎src/interfaces/ecpg/test/Makefile

+10-18
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,16 @@ pg_regress_ecpg.o: pg_regress_ecpg.c $(top_builddir)/src/port/pg_config_paths.h
5959
$(top_builddir)/src/port/pg_config_paths.h: $(top_builddir)/src/Makefile.global
6060
$(MAKE) -C $(top_builddir)/src/port pg_config_paths.h
6161

62-
# When doing a VPATH build, copy over the .pgc, .stdout and .stderr
63-
# files so that the driver script can find them. We have to use an
64-
# absolute path for the targets, because otherwise make will try to
65-
# locate the missing files using VPATH, and will find them in
66-
# $(srcdir), but the point here is that we want to copy them from
67-
# $(srcdir) to the build directory.
68-
69-
ifdef VPATH
70-
remaining_files_src := $(wildcard $(srcdir)/*/*.pgc) $(wildcard $(srcdir)/expected/*.c) $(wildcard $(srcdir)/expected/*.stdout) $(wildcard $(srcdir)/expected/*.stderr)
71-
remaining_files_build := $(patsubst $(srcdir)/%, $(abs_builddir)/%, $(remaining_files_src))
72-
73-
all: $(remaining_files_build)
74-
$(remaining_files_build): $(abs_builddir)/%: $(srcdir)/%
75-
ln -s $< $@
76-
endif
77-
78-
# Common options for tests. Also pick up anything passed in EXTRA_REGRESS_OPTS
79-
REGRESS_OPTS = --dbname=ecpg1_regression,ecpg2_regression --create-role=regress_ecpg_user1,regress_ecpg_user2 $(EXTRA_REGRESS_OPTS)
62+
# Common options for tests
63+
#
64+
# Need to specify expecteddir explicitly, as the inputdir is located in the
65+
# build directory, because the files need to be compiled. Other pg_regress
66+
# style tests have the expecteddir in the source directory.
67+
#
68+
# Also pick up anything passed in EXTRA_REGRESS_OPTS.
69+
REGRESS_OPTS = --expecteddir=$(srcdir) \
70+
--dbname=ecpg1_regression,ecpg2_regression --create-role=regress_ecpg_user1,regress_ecpg_user2 \
71+
$(EXTRA_REGRESS_OPTS)
8072

8173
check: all
8274
$(with_temp_install) ./pg_regress $(REGRESS_OPTS) --temp-instance=./tmp_check $(TEMP_CONF) --bindir= $(pg_regress_locale_flags) $(THREAD) --schedule=$(srcdir)/ecpg_schedule sql/twophase

‎src/interfaces/ecpg/test/pg_regress_ecpg.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ ecpg_start_test(const char *testname,
164164
char *appnameenv;
165165

166166
snprintf(inprg, sizeof(inprg), "%s/%s", inputdir, testname);
167-
snprintf(insource, sizeof(insource), "%s.c", testname);
167+
snprintf(insource, sizeof(insource), "%s/%s.c", inputdir, testname);
168168

169169
/* make a version of the test name that has dashes in place of slashes */
170170
initStringInfo(&testname_dash);
@@ -177,13 +177,13 @@ ecpg_start_test(const char *testname,
177177

178178
snprintf(expectfile_stdout, sizeof(expectfile_stdout),
179179
"%s/expected/%s.stdout",
180-
outputdir, testname_dash.data);
180+
expecteddir, testname_dash.data);
181181
snprintf(expectfile_stderr, sizeof(expectfile_stderr),
182182
"%s/expected/%s.stderr",
183-
outputdir, testname_dash.data);
183+
expecteddir, testname_dash.data);
184184
snprintf(expectfile_source, sizeof(expectfile_source),
185185
"%s/expected/%s.c",
186-
outputdir, testname_dash.data);
186+
expecteddir, testname_dash.data);
187187

188188
snprintf(outfile_stdout, sizeof(outfile_stdout),
189189
"%s/results/%s.stdout",

‎src/test/regress/pg_regress.c

+7
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ _stringlist *dblist = NULL;
7373
bool debug = false;
7474
char *inputdir = ".";
7575
char *outputdir = ".";
76+
char *expecteddir = ".";
7677
char *bindir = PGBINDIR;
7778
char *launcher = NULL;
7879
static _stringlist *loadextension = NULL;
@@ -1975,6 +1976,7 @@ help(void)
19751976
printf(_(" --debug turn on debug mode in programs that are run\n"));
19761977
printf(_(" --dlpath=DIR look for dynamic libraries in DIR\n"));
19771978
printf(_(" --encoding=ENCODING use ENCODING as the encoding\n"));
1979+
printf(_(" --expecteddir=DIR take expected files from DIR (default \".\")\n"));
19781980
printf(_(" -h, --help show this help, then exit\n"));
19791981
printf(_(" --inputdir=DIR take input files from DIR (default \".\")\n"));
19801982
printf(_(" --launcher=CMD use CMD as launcher of psql\n"));
@@ -2038,6 +2040,7 @@ regression_main(int argc, char *argv[],
20382040
{"load-extension", required_argument, NULL, 22},
20392041
{"config-auth", required_argument, NULL, 24},
20402042
{"max-concurrent-tests", required_argument, NULL, 25},
2043+
{"expecteddir", required_argument, NULL, 26},
20412044
{NULL, 0, NULL, 0}
20422045
};
20432046

@@ -2164,6 +2167,9 @@ regression_main(int argc, char *argv[],
21642167
case 25:
21652168
max_concurrent_tests = atoi(optarg);
21662169
break;
2170+
case 26:
2171+
expecteddir = pg_strdup(optarg);
2172+
break;
21672173
default:
21682174
/* getopt_long already emitted a complaint */
21692175
fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"),
@@ -2203,6 +2209,7 @@ regression_main(int argc, char *argv[],
22032209

22042210
inputdir = make_absolute_path(inputdir);
22052211
outputdir = make_absolute_path(outputdir);
2212+
expecteddir = make_absolute_path(expecteddir);
22062213
dlpath = make_absolute_path(dlpath);
22072214

22082215
/*

‎src/test/regress/pg_regress.h

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ extern _stringlist *dblist;
5353
extern bool debug;
5454
extern char *inputdir;
5555
extern char *outputdir;
56+
extern char *expecteddir;
5657
extern char *launcher;
5758

5859
extern const char *basic_diff_opts;

0 commit comments

Comments
 (0)
Please sign in to comment.