Skip to content

Commit 184ec1a

Browse files
committed
meson: prereq: regress: allow to specify director containing expected files
This is needed for ecpg tests, so tests don't have to be generated in the source directory. Author: Reviewed-By: Discussion: https://postgr.es/m/ Backpatch:
1 parent f14cc4b commit 184ec1a

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

src/interfaces/ecpg/test/pg_regress_ecpg.c

Lines changed: 30 additions & 4 deletions
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,39 @@ 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);
181+
if (!file_exists(expectfile_stdout))
182+
snprintf(expectfile_stdout, sizeof(expectfile_stdout),
183+
"%s/expected/%s.stdout",
184+
outputdir, testname_dash.data);
185+
if (!file_exists(expectfile_stdout))
186+
snprintf(expectfile_stdout, sizeof(expectfile_stdout),
187+
"%s/expected/%s.stdout",
188+
inputdir, testname_dash.data);
189+
181190
snprintf(expectfile_stderr, sizeof(expectfile_stderr),
182191
"%s/expected/%s.stderr",
183-
outputdir, testname_dash.data);
192+
expecteddir, testname_dash.data);
193+
if (!file_exists(expectfile_stderr))
194+
snprintf(expectfile_stderr, sizeof(expectfile_stderr),
195+
"%s/expected/%s.stderr",
196+
outputdir, testname_dash.data);
197+
if (!file_exists(expectfile_stderr))
198+
snprintf(expectfile_stderr, sizeof(expectfile_stderr),
199+
"%s/expected/%s.stderr",
200+
inputdir, testname_dash.data);
201+
184202
snprintf(expectfile_source, sizeof(expectfile_source),
185203
"%s/expected/%s.c",
186-
outputdir, testname_dash.data);
204+
expecteddir, testname_dash.data);
205+
if (!file_exists(expectfile_source))
206+
snprintf(expectfile_source, sizeof(expectfile_source),
207+
"%s/expected/%s.c",
208+
outputdir, testname_dash.data);
209+
if (!file_exists(expectfile_source))
210+
snprintf(expectfile_source, sizeof(expectfile_source),
211+
"%s/expected/%s.c",
212+
inputdir, testname_dash.data);
187213

188214
snprintf(outfile_stdout, sizeof(outfile_stdout),
189215
"%s/results/%s.stdout",

src/test/regress/pg_regress.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ _stringlist *dblist = NULL;
7676
bool debug = false;
7777
char *inputdir = ".";
7878
char *outputdir = ".";
79+
char *expecteddir = ".";
7980
char *bindir = PGBINDIR;
8081
char *launcher = NULL;
8182
static _stringlist *loadextension = NULL;
@@ -1989,6 +1990,7 @@ help(void)
19891990
printf(_(" --debug turn on debug mode in programs that are run\n"));
19901991
printf(_(" --dlpath=DIR look for dynamic libraries in DIR\n"));
19911992
printf(_(" --encoding=ENCODING use ENCODING as the encoding\n"));
1993+
printf(_(" --expecteddir=DIR take expected files from DIR (default \".\")\n"));
19921994
printf(_(" -h, --help show this help, then exit\n"));
19931995
printf(_(" --inputdir=DIR take input files from DIR (default \".\")\n"));
19941996
printf(_(" --launcher=CMD use CMD as launcher of psql\n"));
@@ -2052,6 +2054,7 @@ regression_main(int argc, char *argv[],
20522054
{"load-extension", required_argument, NULL, 22},
20532055
{"config-auth", required_argument, NULL, 24},
20542056
{"max-concurrent-tests", required_argument, NULL, 25},
2057+
{"expecteddir", required_argument, NULL, 26},
20552058
{NULL, 0, NULL, 0}
20562059
};
20572060

@@ -2181,6 +2184,9 @@ regression_main(int argc, char *argv[],
21812184
case 25:
21822185
max_concurrent_tests = atoi(optarg);
21832186
break;
2187+
case 26:
2188+
expecteddir = pg_strdup(optarg);
2189+
break;
21842190
default:
21852191
/* getopt_long already emitted a complaint */
21862192
fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"),
@@ -2220,6 +2226,7 @@ regression_main(int argc, char *argv[],
22202226

22212227
inputdir = make_absolute_path(inputdir);
22222228
outputdir = make_absolute_path(outputdir);
2229+
expecteddir = make_absolute_path(expecteddir);
22232230
dlpath = make_absolute_path(dlpath);
22242231

22252232
/*

src/test/regress/pg_regress.h

Lines changed: 1 addition & 0 deletions
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)