Hi, On 2022-07-21 15:26:05 +0300, Bilal Yavuz wrote: > > On 2022-07-06 11:03:31 +0200, Peter Eisentraut wrote: > > > dff7b5a960 meson: prereq: regress: allow to specify director containing > > > expected files. > > > > > > This could use a bit more explanation, but it doesn't look > > > controversial so far. > > While testing ECPG, C and exe files are generated by meson so these files > are in the meson's build directory but expected files are in the source > directory. However; there was no way to set different paths for inputs (C > and exe files') and expected files' directory. So, I added `--expecteddir` > to separately set expected files' directory.
Attached is a version of this patch that also removes the copying of these files from ecpg's makefile. Bilal's version checked different directories for expected files, but I don't think that's necessary. Bilal, do you remember why you added that? I'm somewhat tempted to rename ecpg's pg_regress to pg_regress_ecpg as part of this, given the .c file is named pg_regress_ecpg.c and that pg_regress is a pre-existing binary. Greetings, Andres Freund
>From 9645e0a01305ce42fdacaae73bd0d021a5a1c47e Mon Sep 17 00:00:00 2001 From: Andres Freund <and...@anarazel.de> Date: Thu, 30 Jun 2022 18:28:17 -0700 Subject: [PATCH] meson: prereq: regress: allow to specify director containing expected files 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 expected directory/. Remove the copying of ecpg's expected/ to the build dir in VPATH builds. Author: Nazir Bilal Yavuz <byavu...@gmail.com> Author: Andres Freund <and...@anarazel.de> Reviewed-By: Andres Freund <and...@anarazel.de> Discussion: https://postgr.es/m/20220718202327.pspcqz5mwbi2y...@awork3.anarazel.de --- src/interfaces/ecpg/test/Makefile | 28 ++++++++-------------- src/interfaces/ecpg/test/pg_regress_ecpg.c | 8 +++---- src/test/regress/pg_regress.c | 7 ++++++ src/test/regress/pg_regress.h | 1 + 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/interfaces/ecpg/test/Makefile b/src/interfaces/ecpg/test/Makefile index 10f53c708c8..d7a7d1d1ca5 100644 --- a/src/interfaces/ecpg/test/Makefile +++ b/src/interfaces/ecpg/test/Makefile @@ -59,24 +59,16 @@ pg_regress_ecpg.o: pg_regress_ecpg.c $(top_builddir)/src/port/pg_config_paths.h $(top_builddir)/src/port/pg_config_paths.h: $(top_builddir)/src/Makefile.global $(MAKE) -C $(top_builddir)/src/port pg_config_paths.h -# When doing a VPATH build, copy over the .pgc, .stdout and .stderr -# files so that the driver script can find them. We have to use an -# absolute path for the targets, because otherwise make will try to -# locate the missing files using VPATH, and will find them in -# $(srcdir), but the point here is that we want to copy them from -# $(srcdir) to the build directory. - -ifdef VPATH -remaining_files_src := $(wildcard $(srcdir)/*/*.pgc) $(wildcard $(srcdir)/expected/*.c) $(wildcard $(srcdir)/expected/*.stdout) $(wildcard $(srcdir)/expected/*.stderr) -remaining_files_build := $(patsubst $(srcdir)/%, $(abs_builddir)/%, $(remaining_files_src)) - -all: $(remaining_files_build) -$(remaining_files_build): $(abs_builddir)/%: $(srcdir)/% - ln -s $< $@ -endif - -# Common options for tests. Also pick up anything passed in EXTRA_REGRESS_OPTS -REGRESS_OPTS = --dbname=ecpg1_regression,ecpg2_regression --create-role=regress_ecpg_user1,regress_ecpg_user2 $(EXTRA_REGRESS_OPTS) +# Common options for tests +# +# Need to specify expecteddir explicitly, as the inputdir is located in the +# build directory, because the files need to be compiled. Other pg_regress +# style tests have the expecteddir in the source directory. +# +# Also pick up anything passed in EXTRA_REGRESS_OPTS. +REGRESS_OPTS = --expecteddir=$(srcdir) \ + --dbname=ecpg1_regression,ecpg2_regression --create-role=regress_ecpg_user1,regress_ecpg_user2 \ + $(EXTRA_REGRESS_OPTS) check: all $(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 diff --git a/src/interfaces/ecpg/test/pg_regress_ecpg.c b/src/interfaces/ecpg/test/pg_regress_ecpg.c index f920af4560c..84e45ceebe0 100644 --- a/src/interfaces/ecpg/test/pg_regress_ecpg.c +++ b/src/interfaces/ecpg/test/pg_regress_ecpg.c @@ -164,7 +164,7 @@ ecpg_start_test(const char *testname, char *appnameenv; snprintf(inprg, sizeof(inprg), "%s/%s", inputdir, testname); - snprintf(insource, sizeof(insource), "%s.c", testname); + snprintf(insource, sizeof(insource), "%s/%s.c", inputdir, testname); /* make a version of the test name that has dashes in place of slashes */ initStringInfo(&testname_dash); @@ -177,13 +177,13 @@ ecpg_start_test(const char *testname, snprintf(expectfile_stdout, sizeof(expectfile_stdout), "%s/expected/%s.stdout", - outputdir, testname_dash.data); + expecteddir, testname_dash.data); snprintf(expectfile_stderr, sizeof(expectfile_stderr), "%s/expected/%s.stderr", - outputdir, testname_dash.data); + expecteddir, testname_dash.data); snprintf(expectfile_source, sizeof(expectfile_source), "%s/expected/%s.c", - outputdir, testname_dash.data); + expecteddir, testname_dash.data); snprintf(outfile_stdout, sizeof(outfile_stdout), "%s/results/%s.stdout", diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index 04ab513b7cb..920974c1541 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -76,6 +76,7 @@ _stringlist *dblist = NULL; bool debug = false; char *inputdir = "."; char *outputdir = "."; +char *expecteddir = "."; char *bindir = PGBINDIR; char *launcher = NULL; static _stringlist *loadextension = NULL; @@ -1989,6 +1990,7 @@ help(void) printf(_(" --debug turn on debug mode in programs that are run\n")); printf(_(" --dlpath=DIR look for dynamic libraries in DIR\n")); printf(_(" --encoding=ENCODING use ENCODING as the encoding\n")); + printf(_(" --expecteddir=DIR take expected files from DIR (default \".\")\n")); printf(_(" -h, --help show this help, then exit\n")); printf(_(" --inputdir=DIR take input files from DIR (default \".\")\n")); printf(_(" --launcher=CMD use CMD as launcher of psql\n")); @@ -2052,6 +2054,7 @@ 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}, + {"expecteddir", required_argument, NULL, 26}, {NULL, 0, NULL, 0} }; @@ -2181,6 +2184,9 @@ regression_main(int argc, char *argv[], case 25: max_concurrent_tests = atoi(optarg); break; + case 26: + expecteddir = pg_strdup(optarg); + break; default: /* getopt_long already emitted a complaint */ fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"), @@ -2220,6 +2226,7 @@ regression_main(int argc, char *argv[], inputdir = make_absolute_path(inputdir); outputdir = make_absolute_path(outputdir); + expecteddir = make_absolute_path(expecteddir); dlpath = make_absolute_path(dlpath); /* diff --git a/src/test/regress/pg_regress.h b/src/test/regress/pg_regress.h index 2143ee0e727..d8772fec8ed 100644 --- a/src/test/regress/pg_regress.h +++ b/src/test/regress/pg_regress.h @@ -53,6 +53,7 @@ extern _stringlist *dblist; extern bool debug; extern char *inputdir; extern char *outputdir; +extern char *expecteddir; extern char *launcher; extern const char *basic_diff_opts; -- 2.37.0.3.g30cc8d0f14