Skip to content

Commit f4ce6c4

Browse files
committed
Add module build directory to the PATH for TAP tests
For non-MSVC builds this is make's $(CURDIR), while for MSVC builds it is $topdir/$Config/$module. The directory is added as the second element in the PATH, so that the install location takes precedence, but the added PATH element takes precedence over the rest of the PATH. The reason for this is to allow tests to find built products that are not installed, such as the libpq_pipeline test driver. The libpq_pipeline test is adjusted to take advantage of this. Based on a suggestion from Andres Freund. Backpatch to release 14. Discussion: https://postgr.es/m/4941f5a5-2d50-1a0e-6701-14c5fefe92d6@dunslane.net
1 parent b1ce6c2 commit f4ce6c4

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/Makefile.global.in

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ ld_library_path_var = LD_LIBRARY_PATH
438438
# need something more here. If not defined then the expansion does
439439
# nothing.
440440
with_temp_install = \
441-
PATH="$(abs_top_builddir)/tmp_install$(bindir):$$PATH" \
441+
PATH="$(abs_top_builddir)/tmp_install$(bindir):$(CURDIR):$$PATH" \
442442
$(call add_to_path,$(strip $(ld_library_path_var)),$(abs_top_builddir)/tmp_install$(libdir)) \
443443
$(with_temp_install_extra)
444444

@@ -449,8 +449,8 @@ define prove_installcheck
449449
rm -rf '$(CURDIR)'/tmp_check
450450
$(MKDIR_P) '$(CURDIR)'/tmp_check
451451
cd $(srcdir) && \
452-
TESTDIR='$(CURDIR)' PATH="$(bindir):$$PATH" PGPORT='6$(DEF_PGPORT)' \
453-
top_builddir='$(CURDIR)/$(top_builddir)' \
452+
TESTDIR='$(CURDIR)' PATH="$(bindir):$(CURDIR):$$PATH" \
453+
PGPORT='6$(DEF_PGPORT)' top_builddir='$(CURDIR)/$(top_builddir)' \
454454
PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' \
455455
$(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
456456
endef
@@ -459,8 +459,8 @@ define prove_installcheck
459459
rm -rf '$(CURDIR)'/tmp_check
460460
$(MKDIR_P) '$(CURDIR)'/tmp_check
461461
cd $(srcdir) && \
462-
TESTDIR='$(CURDIR)' PATH="$(bindir):$$PATH" PGPORT='6$(DEF_PGPORT)' \
463-
top_builddir='$(top_builddir)' \
462+
TESTDIR='$(CURDIR)' PATH="$(bindir):$(CURDIR):$$PATH" \
463+
PGPORT='6$(DEF_PGPORT)' top_builddir='$(top_builddir)' \
464464
PG_REGRESS='$(top_builddir)/src/test/regress/pg_regress' \
465465
$(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
466466
endef

src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
$node->start;
1515

1616
my $numrows = 700;
17-
my $libpq_pipeline = "$ENV{TESTDIR}/libpq_pipeline";
1817

19-
my ($out, $err) = run_command([ $libpq_pipeline, 'tests' ]);
18+
my ($out, $err) = run_command([ 'libpq_pipeline', 'tests' ]);
2019
die "oops: $err" unless $err eq '';
2120
my @tests = split(/\s+/, $out);
2221

@@ -39,8 +38,8 @@
3938
# Execute the test
4039
$node->command_ok(
4140
[
42-
$libpq_pipeline, @extraargs,
43-
$testname, $node->connstr('postgres')
41+
'libpq_pipeline', @extraargs,
42+
$testname, $node->connstr('postgres')
4443
],
4544
"libpq_pipeline $testname");
4645

src/tools/msvc/vcregress.pl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ sub tap_check
248248
$ENV{REGRESS_SHLIB} = "$topdir/src/test/regress/regress.dll";
249249

250250
$ENV{TESTDIR} = "$dir";
251+
my $module = basename $dir;
252+
# add the module build dir as the second element in the PATH
253+
$ENV{PATH} =~ s!;!;$topdir/$Config/$module;!;
251254

252255
rmtree('tmp_check');
253256
system(@args);

0 commit comments

Comments
 (0)