From 06c8a2458fbbf382011928190b576db1918c853f Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryzbyj@telsasoft.com>
Date: Fri, 25 Feb 2022 17:23:26 -0600
Subject: [PATCH 2/7] s!also remove PATH.

This essentially reverts commit f4ce6c4d3a30ec3a12c7f64b90a6fc82887ddd7b

XXX: also set PATH=bindir ?
---
 src/Makefile.global.in                 |  6 +++---
 src/test/perl/PostgreSQL/Test/Utils.pm | 10 ++++++++++
 src/tools/msvc/vcregress.pl            |  4 ----
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 92649d0193..c0e5661338 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -440,7 +440,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):$(CURDIR):$$PATH" \
+	PATH="$(abs_top_builddir)/tmp_install$(bindir):$$PATH" \
 	$(call add_to_path,$(strip $(ld_library_path_var)),$(abs_top_builddir)/tmp_install$(libdir)) \
 	$(with_temp_install_extra)
 
@@ -451,7 +451,7 @@ define prove_installcheck
 rm -rf '$(CURDIR)'/tmp_check
 $(MKDIR_P) '$(CURDIR)'/tmp_check
 cd $(srcdir) && \
-   PATH="$(bindir):$(CURDIR):$$PATH" \
+   PATH="$(bindir):$$PATH" \
    PGPORT='6$(DEF_PGPORT)' top_builddir='$(CURDIR)/$(top_builddir)' \
    PG_SUBDIR='$(CURDIR)' \
    PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' \
@@ -462,7 +462,7 @@ define prove_installcheck
 rm -rf '$(CURDIR)'/tmp_check
 $(MKDIR_P) '$(CURDIR)'/tmp_check
 cd $(srcdir) && \
-   PATH="$(bindir):$(CURDIR):$$PATH" \
+   PATH="$(bindir):$$PATH" \
    PGPORT='6$(DEF_PGPORT)' top_builddir='$(top_builddir)' \
    PG_SUBDIR='$(CURDIR)' \
    PG_REGRESS='$(top_builddir)/src/test/regress/pg_regress' \
diff --git a/src/test/perl/PostgreSQL/Test/Utils.pm b/src/test/perl/PostgreSQL/Test/Utils.pm
index 0e2abb6c9e..41c373fadd 100644
--- a/src/test/perl/PostgreSQL/Test/Utils.pm
+++ b/src/test/perl/PostgreSQL/Test/Utils.pm
@@ -190,6 +190,16 @@ INIT
 
 	$ENV{TESTDIR} = $test_dir;
 
+	if ($PostgreSQL::Test::Utils::windows_os &&
+		$Config{osname} eq 'MSWin32')
+	{
+		$ENV{PATH} =~ s!;!;$test_dir;!;
+	}
+	else
+	{
+		$ENV{PATH} =~ s!:!:$test_dir:!;
+	}
+
 	# Determine output directories, and create them.
 	$tmp_check = "$test_dir/tmp_check";
 	$log_path = "$tmp_check/log";
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index e805a9f8f6..74aa572d2f 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -261,10 +261,6 @@ sub tap_check
 	$ENV{PG_REGRESS}    = "$topdir/$Config/pg_regress/pg_regress";
 	$ENV{REGRESS_SHLIB} = "$topdir/src/test/regress/regress.dll";
 
-	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);
 	my $status = $? >> 8;
-- 
2.17.1

