Add module build directory to the PATH for TAP tests
authorAndrew Dunstan <[email protected]>
Fri, 22 Oct 2021 13:11:52 +0000 (09:11 -0400)
committerAndrew Dunstan <[email protected]>
Fri, 22 Oct 2021 13:49:07 +0000 (09:49 -0400)
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

src/Makefile.global.in
src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl
src/tools/msvc/vcregress.pl

index a1da1ea4eeb82dccca7ab4fe500186da534a17a1..533c12fef956e4daa571f9874a6ede5a3555d919 100644 (file)
@@ -438,7 +438,7 @@ ld_library_path_var = LD_LIBRARY_PATH
 # need something more here. If not defined then the expansion does
 # nothing.
 with_temp_install = \
-       PATH="$(abs_top_builddir)/tmp_install$(bindir):$$PATH" \
+       PATH="$(abs_top_builddir)/tmp_install$(bindir):$(CURDIR):$$PATH" \
        $(call add_to_path,$(strip $(ld_library_path_var)),$(abs_top_builddir)/tmp_install$(libdir)) \
        $(with_temp_install_extra)
 
@@ -449,8 +449,8 @@ define prove_installcheck
 rm -rf '$(CURDIR)'/tmp_check
 $(MKDIR_P) '$(CURDIR)'/tmp_check
 cd $(srcdir) && \
-   TESTDIR='$(CURDIR)' PATH="$(bindir):$$PATH" PGPORT='6$(DEF_PGPORT)' \
-   top_builddir='$(CURDIR)/$(top_builddir)' \
+   TESTDIR='$(CURDIR)' PATH="$(bindir):$(CURDIR):$$PATH" \
+   PGPORT='6$(DEF_PGPORT)' top_builddir='$(CURDIR)/$(top_builddir)' \
    PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' \
    $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
 endef
@@ -459,8 +459,8 @@ define prove_installcheck
 rm -rf '$(CURDIR)'/tmp_check
 $(MKDIR_P) '$(CURDIR)'/tmp_check
 cd $(srcdir) && \
-   TESTDIR='$(CURDIR)' PATH="$(bindir):$$PATH" PGPORT='6$(DEF_PGPORT)' \
-   top_builddir='$(top_builddir)' \
+   TESTDIR='$(CURDIR)' PATH="$(bindir):$(CURDIR):$$PATH" \
+   PGPORT='6$(DEF_PGPORT)' top_builddir='$(top_builddir)' \
    PG_REGRESS='$(top_builddir)/src/test/regress/pg_regress' \
    $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
 endef
index 6721edfa719a05e2a2ac066c1e58f0c1ec5734a3..7f648b19a26140f0dc685dc57fb32e6e207496e8 100644 (file)
@@ -14,9 +14,8 @@ $node->init;
 $node->start;
 
 my $numrows = 700;
-my $libpq_pipeline = "$ENV{TESTDIR}/libpq_pipeline";
 
-my ($out, $err) = run_command([ $libpq_pipeline, 'tests' ]);
+my ($out, $err) = run_command([ 'libpq_pipeline', 'tests' ]);
 die "oops: $err" unless $err eq '';
 my @tests = split(/\s+/, $out);
 
@@ -39,8 +38,8 @@ for my $testname (@tests)
        # Execute the test
        $node->command_ok(
                [
-                       $libpq_pipeline, @extraargs,
-                       $testname,       $node->connstr('postgres')
+                       'libpq_pipeline', @extraargs,
+                       $testname,        $node->connstr('postgres')
                ],
                "libpq_pipeline $testname");
 
index 35e8f67f013902a1e232a5c0959b583af605e7b1..fc826da3ff2f54eed84bbd075a523c4d01527560 100644 (file)
@@ -248,6 +248,9 @@ sub tap_check
        $ENV{REGRESS_SHLIB} = "$topdir/src/test/regress/regress.dll";
 
        $ENV{TESTDIR} = "$dir";
+       my $module = basename $dir;
+       # add the module build dir as the second element in the PATH
+       $ENV{PATH} =~ s!;!;$topdir/$Config/$module;!;
 
        rmtree('tmp_check');
        system(@args);