From 2abe537285eea3fe1b2c8823a21e394681b0ebd9 Mon Sep 17 00:00:00 2001
From: Andrew Dunstan <andrew@dunslane.net>
Date: Wed, 10 Jun 2026 18:05:05 -0400
Subject: [PATCH v15 5/5] Check for FFI::Platypus when TAP tests are enabled

PostgreSQL::Test::Session, used throughout the TAP test framework,
requires FFI::Platypus, but neither build system checked for it at
configure time; a missing module surfaced as hundreds of individual
test failures instead.  Add the module to config/check_modules.pl,
which both configure and meson already run when TAP tests are
requested, requiring at least version 1.00 (PostgreSQL::PqFFI uses
the api => 1 interface and record_layout_1).  Mention the new
requirement in the documentation and in src/test/perl/README.

The generated configure was re-created with Autoconf 2.69.
---
 config/check_modules.pl        |  5 +++++
 configure                      |  3 ++-
 configure.ac                   |  2 +-
 doc/src/sgml/installation.sgml |  6 ++++--
 doc/src/sgml/regress.sgml      |  7 ++++---
 src/test/perl/README           | 14 ++++++++------
 6 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/config/check_modules.pl b/config/check_modules.pl
index c659b7aadeb..e4deab6e3d7 100644
--- a/config/check_modules.pl
+++ b/config/check_modules.pl
@@ -13,6 +13,10 @@ use Config;
 
 use IPC::Run 0.79;
 
+# PostgreSQL::Test::Session needs api => 1 and record_layout_1,
+# which arrived in FFI::Platypus 1.00.
+use FFI::Platypus 1.00;
+
 # Test::More and Time::HiRes are supposed to be part of core Perl,
 # but some distros omit them in a minimal installation.
 use Test::More 0.98;
@@ -20,6 +24,7 @@ use Time::HiRes 1.52;
 
 # While here, we might as well report exactly what versions we found.
 diag("IPC::Run::VERSION: $IPC::Run::VERSION");
+diag("FFI::Platypus::VERSION: $FFI::Platypus::VERSION");
 diag("Test::More::VERSION: $Test::More::VERSION");
 diag("Time::HiRes::VERSION: $Time::HiRes::VERSION");
 
diff --git a/configure b/configure
index 5f77f3cac29..804062fa9d1 100755
--- a/configure
+++ b/configure
@@ -1551,7 +1551,8 @@ Optional Features:
   --enable-profiling      build with profiling enabled
   --enable-coverage       build with coverage testing instrumentation
   --enable-dtrace         build with DTrace support
-  --enable-tap-tests      enable TAP tests (requires Perl and IPC::Run)
+  --enable-tap-tests      enable TAP tests (requires Perl, IPC::Run and
+                          FFI::Platypus)
   --enable-injection-points
                           enable injection points (for testing)
   --enable-depend         turn on automatic dependency tracking
diff --git a/configure.ac b/configure.ac
index 61cee42daa7..0ba011c0bce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -229,7 +229,7 @@ AC_SUBST(enable_dtrace)
 # TAP tests
 #
 PGAC_ARG_BOOL(enable, tap-tests, no,
-              [enable TAP tests (requires Perl and IPC::Run)])
+              [enable TAP tests (requires Perl, IPC::Run and FFI::Platypus)])
 AC_SUBST(enable_tap_tests)
 AC_ARG_VAR(PG_TEST_EXTRA,
            [enable selected extra tests (overridden at runtime by PG_TEST_EXTRA environment variable)])
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index b345a105674..8120b75264b 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -1599,7 +1599,8 @@ build-postgresql:
        <listitem>
         <para>
          Enable tests using the Perl TAP tools.  This requires a Perl
-         installation and the Perl module <literal>IPC::Run</literal>.
+         installation and the Perl modules <literal>IPC::Run</literal>
+         and <literal>FFI::Platypus</literal>.
          See <xref linkend="regress-tap"/> for more information.
         </para>
        </listitem>
@@ -3169,7 +3170,8 @@ ninja install
       <listitem>
        <para>
         Enable tests using the Perl TAP tools.  Defaults to auto and requires
-        a Perl installation and the Perl module <literal>IPC::Run</literal>.
+        a Perl installation and the Perl modules <literal>IPC::Run</literal>
+        and <literal>FFI::Platypus</literal>.
         See <xref linkend="regress-tap"/> for more information.
        </para>
       </listitem>
diff --git a/doc/src/sgml/regress.sgml b/doc/src/sgml/regress.sgml
index c74941bfbf2..63e7104de5d 100644
--- a/doc/src/sgml/regress.sgml
+++ b/doc/src/sgml/regress.sgml
@@ -954,9 +954,10 @@ make check PROVE_TESTS='t/001_test1.pl t/003_test3.pl'
    </para>
 
    <para>
-    The TAP tests require the Perl module <literal>IPC::Run</literal>.
-    This module is available from
-    <ulink url="https://metacpan.org/dist/IPC-Run">CPAN</ulink>
+    The TAP tests require the Perl modules
+    <ulink url="https://metacpan.org/dist/IPC-Run"><literal>IPC::Run</literal></ulink> and
+    <ulink url="https://metacpan.org/dist/FFI-Platypus"><literal>FFI::Platypus</literal></ulink>.
+    These modules are available from CPAN
     or an operating system package.
     They also require <productname>PostgreSQL</productname> to be
     configured with the option <option>--enable-tap-tests</option>.
diff --git a/src/test/perl/README b/src/test/perl/README
index af037a8091c..92886688c64 100644
--- a/src/test/perl/README
+++ b/src/test/perl/README
@@ -103,11 +103,12 @@ Avoid using any bleeding-edge Perl features.  We have buildfarm animals
 running Perl versions as old as 5.14, so your tests will be expected
 to pass on that.
 
-Also, do not use any non-core Perl modules except IPC::Run.  Or, if you
-must do so for a particular test, arrange to skip the test when the needed
-module isn't present.  If unsure, you can consult Module::CoreList to find
-out whether a given module is part of the Perl core, and which module
-versions shipped with which Perl releases.
+Also, do not use any non-core Perl modules except IPC::Run and
+FFI::Platypus.  Or, if you must do so for a particular test, arrange to
+skip the test when the needed module isn't present.  If unsure, you can
+consult Module::CoreList to find out whether a given module is part of
+the Perl core, and which module versions shipped with which Perl
+releases.
 
 One way to test for compatibility with old Perl versions is to use
 perlbrew; see http://perlbrew.pl .  After installing that, do
@@ -118,6 +119,7 @@ perlbrew; see http://perlbrew.pl .  After installing that, do
     perlbrew install-cpanm
     cpanm install Test::Simple@0.98
     cpanm install IPC::Run@0.79
+    cpanm install FFI::Platypus@1.00
     cpanm install ExtUtils::MakeMaker@6.50  # downgrade
 
 TIP: if Test::Simple's utf8 regression test hangs up, try setting a
@@ -131,4 +133,4 @@ running tests.  To verify that the right Perl was found:
 Due to limitations of cpanm, this recipe doesn't exactly duplicate the
 module list of older buildfarm animals.  The discrepancies should seldom
 matter, but if you want to be sure, bypass cpanm and instead manually
-install the desired versions of Test::Simple and IPC::Run.
+install the desired versions of Test::Simple, IPC::Run and FFI::Platypus.
-- 
2.43.0

