On Thu, Sep 12, 2024 at 4:28 PM Nazir Bilal Yavuz <byavu...@gmail.com> wrote:
> >
> > Once this is done, I think we can mark this CF entry as RFC.
>
> Thanks for the changes. I applied all of them in respective patches.

Thanks a lot. PFA the patchset with

1. Improved comment related to PG_TEST_EXTRA in meson.build. More on
the improvement in the commit message of patch 0002, which should be
merged into 0001.
2. You have written comprehensive commit messages. I elaborated on
them a bit. I have left your version in the commit message for
committer to pick up appropriate one.

Marking the entry as RFC.

-- 
Best Wishes,
Ashutosh Bapat
From f345f5dbbd0324a1b7389e046caefecab4c357fc Mon Sep 17 00:00:00 2001
From: Ashutosh Bapat <ashutosh.bapat....@gmail.com>
Date: Fri, 13 Sep 2024 10:58:40 +0530
Subject: [PATCH 3/4] Improve comment about configuration time PG_TEST_EXTRA

The comment mentioned "not safe" and "while-space separate list" which are not
relevant to the code in meson.build file. The purpose mentioned in the comment
has already gone stale; the variable is used for tests which take longer but are
otherwise safe. And the content may change in the future. This code should just
make the value of the variable available to the tests irrespective of its
purpose and content. Improved the comment to mention how the PG_TEST_EXTRA is
passed to tests instead of the variable's content and purpose.

Ashutosh Bapat
---
 meson.build | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/meson.build b/meson.build
index 9d1d8847af3..24a25a72bd1 100644
--- a/meson.build
+++ b/meson.build
@@ -3385,11 +3385,10 @@ foreach test_dir : tests
     testwrap,
     '--basedir', meson.build_root(),
     '--srcdir', test_dir['sd'],
-    # Test suites that are not safe by default but can be run if selected
-    # by the user via the whitespace-separated list in variable PG_TEST_EXTRA.
-    # Export PG_TEST_EXTRA so it can be checked in individual tap tests.
-    # This configure option is overridden by PG_TEST_EXTRA environment variable
-    # if it exists.
+    # Some test suites are not run by default but can be run if selected by the
+    # user via variable PG_TEST_EXTRA. Pass configuration time value of
+    # PG_TEST_EXTRA as an argument to testwrap so that it can be overridden by
+    # run time value, if any.
     '--pg-test-extra', get_option('PG_TEST_EXTRA'),
   ]
 
-- 
2.34.1

From 8c518478ed1457ce227914009183b88ad56738c9 Mon Sep 17 00:00:00 2001
From: Nazir Bilal Yavuz <byavu...@gmail.com>
Date: Wed, 11 Sep 2024 15:41:27 +0300
Subject: [PATCH 2/4] Runtime value of PG_TEST_EXTRA in Meson

Tests run using Meson ignore the value of environment variable
PG_TEST_EXTRA at the time of running tests and use the configuration
time value. In order to run the tests not specified in configuration
time PG_TEST_EXTRA, one needs to reconfigure which is costly. Allow
runtime value of PG_TEST_EXTRA to override the configuration time value.
In order to do this the configuration time value is passed as argument
"--pg-test-extra" to testwrap instead of adding it to the test
environment. If the environment variable is set at the time of running
test, its value is used. Otherwise value passed as the argument is used.

Meson builds use the same value of PG_TEST_EXTRA at the configuration
time and at the time of running the tests. Hence remove it from meson
setup command so as to treat both Meson and Make builds the same way in
CI.

--- original commit message by Nazir Bilal Yavuz
Make PG_TEST_EXTRA env variable override its Meson configure option

Since PG_TEST_EXTRA configure option is set while configuring Meson,
each change on PG_TEST_EXTRA needs reconfigure and this is costly. So,
first try to use PG_TEST_EXTRA from environment. If it does not exist,
then try to use it from its configure option in Meson builds.

After the above change, Meson builds are able to get PG_TEST_EXTRA from
environment and this overrides the configure option. PG_TEST_EXTRA
environment variable is set at the top of the .cirrus.tasks.yml file. So,
PG_TEXT_EXTRA in configure scripts became useless and were removed
because of that.
---- original commit message by Nazir Bilal Yavuz ends

Author: Nazir Bilal Yavuz <byavu...@gmail.com>
Reviewed by: Ashutosh Bapat with inputs from Tom Lane and Andrew Dunstan
---
 .cirrus.tasks.yml              |  6 +-----
 doc/src/sgml/installation.sgml |  6 ++++--
 meson.build                    | 11 ++++++-----
 meson_options.txt              |  2 +-
 src/tools/testwrap             | 10 ++++++++++
 5 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/.cirrus.tasks.yml b/.cirrus.tasks.yml
index 90cb95c8681..fc413eb11ef 100644
--- a/.cirrus.tasks.yml
+++ b/.cirrus.tasks.yml
@@ -175,7 +175,6 @@ task:
         --buildtype=debug \
         -Dcassert=true -Dinjection_points=true \
         -Duuid=bsd -Dtcl_version=tcl86 -Ddtrace=auto \
-        -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
         -Dextra_lib_dirs=/usr/local/lib -Dextra_include_dirs=/usr/local/include/ \
         build
     EOF
@@ -364,7 +363,6 @@ task:
             --buildtype=debug \
             -Dcassert=true -Dinjection_points=true \
             ${LINUX_MESON_FEATURES} \
-            -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
             build
         EOF
 
@@ -380,7 +378,6 @@ task:
             -Dllvm=disabled \
             --pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \
             -DPERL=perl5.36-i386-linux-gnu \
-            -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
             build-32
         EOF
 
@@ -502,7 +499,6 @@ task:
       -Dextra_lib_dirs=/opt/local/lib \
       -Dcassert=true -Dinjection_points=true \
       -Duuid=e2fs -Ddtrace=auto \
-      -DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
       build
 
   build_script: ninja -C build -j${BUILD_JOBS}
@@ -574,7 +570,7 @@ task:
   # Use /DEBUG:FASTLINK to avoid high memory usage during linking
   configure_script: |
     vcvarsall x64
-    meson setup --backend ninja --buildtype debug -Dc_link_args=/DEBUG:FASTLINK -Dcassert=true -Dinjection_points=true -Db_pch=true -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=%TAR% -DPG_TEST_EXTRA="%PG_TEST_EXTRA%" build
+    meson setup --backend ninja --buildtype debug -Dc_link_args=/DEBUG:FASTLINK -Dcassert=true -Dinjection_points=true -Db_pch=true -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=%TAR% build
 
   build_script: |
     vcvarsall x64
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index ff9abd4649d..7c481e07e98 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -3073,8 +3073,10 @@ ninja install
       <listitem>
        <para>
         Enable test suites which require special software to run.  This option
-        accepts arguments via a whitespace-separated list.  See <xref
-        linkend="regress-additional"/> for details.
+        accepts arguments via a whitespace-separated list.  Please note that
+        this configure option is overridden by PG_TEST_EXTRA environment
+        variable if it is set.  See <xref linkend="regress-additional"/> for
+        details.
        </para>
       </listitem>
      </varlistentry>
diff --git a/meson.build b/meson.build
index 4764b09266e..9d1d8847af3 100644
--- a/meson.build
+++ b/meson.build
@@ -3322,11 +3322,6 @@ test_env.set('PG_REGRESS', pg_regress.full_path())
 test_env.set('REGRESS_SHLIB', regress_module.full_path())
 test_env.set('INITDB_TEMPLATE', test_initdb_template)
 
-# Test suites that are not safe by default but can be run if selected
-# by the user via the whitespace-separated list in variable PG_TEST_EXTRA.
-# Export PG_TEST_EXTRA so it can be checked in individual tap tests.
-test_env.set('PG_TEST_EXTRA', get_option('PG_TEST_EXTRA'))
-
 # Add the temporary installation to the library search path on platforms where
 # that works (everything but windows, basically). On windows everything
 # library-like gets installed into bindir, solving that issue.
@@ -3390,6 +3385,12 @@ foreach test_dir : tests
     testwrap,
     '--basedir', meson.build_root(),
     '--srcdir', test_dir['sd'],
+    # Test suites that are not safe by default but can be run if selected
+    # by the user via the whitespace-separated list in variable PG_TEST_EXTRA.
+    # Export PG_TEST_EXTRA so it can be checked in individual tap tests.
+    # This configure option is overridden by PG_TEST_EXTRA environment variable
+    # if it exists.
+    '--pg-test-extra', get_option('PG_TEST_EXTRA'),
   ]
 
   foreach kind, v : test_dir
diff --git a/meson_options.txt b/meson_options.txt
index b9421557606..38935196394 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -47,7 +47,7 @@ option('injection_points', type: 'boolean', value: false,
   description: 'Enable injection points')
 
 option('PG_TEST_EXTRA', type: 'string', value: '',
-  description: 'Enable selected extra tests')
+  description: 'Enable selected extra tests. Overridden by PG_TEST_EXTRA environment variable.')
 
 option('PG_GIT_REVISION', type: 'string', value: 'HEAD',
   description: 'git revision to be packaged by pgdist target')
diff --git a/src/tools/testwrap b/src/tools/testwrap
index 9a270beb72d..8ae8fb79ba7 100755
--- a/src/tools/testwrap
+++ b/src/tools/testwrap
@@ -13,6 +13,7 @@ parser.add_argument('--basedir', help='base directory of test', type=str)
 parser.add_argument('--testgroup', help='test group', type=str)
 parser.add_argument('--testname', help='test name', type=str)
 parser.add_argument('--skip', help='skip test (with reason)', type=str)
+parser.add_argument('--pg-test-extra', help='extra tests', type=str)
 parser.add_argument('test_command', nargs='*')
 
 args = parser.parse_args()
@@ -41,6 +42,15 @@ env_dict = {**os.environ,
             'TESTDATADIR': os.path.join(testdir, 'data'),
             'TESTLOGDIR': os.path.join(testdir, 'log')}
 
+
+# The configuration time value of PG_TEST_EXTRA is supplied via arguement
+# --pg-test-extra. But it can be overridden by environment variable
+# PG_TEST_EXTRA at the time of running a test. Hence use value from arguments
+# only if PG_TEST_EXTRA is not set in the test environment, which already
+# contains all the environment variables at the time of running the test.
+if "PG_TEST_EXTRA" not in env_dict and args.pg_test_extra:
+    env_dict["PG_TEST_EXTRA"] = args.pg_test_extra
+
 sp = subprocess.Popen(args.test_command, env=env_dict, stdout=subprocess.PIPE)
 # Meson categorizes a passing TODO test point as bad
 # (https://github.com/mesonbuild/meson/issues/13183).  Remove the TODO
-- 
2.34.1

From e1aba24cdd01da33169d7e7769b91a98a1f6a125 Mon Sep 17 00:00:00 2001
From: Jacob Champion <jacob.champ...@enterprisedb.com>
Date: Wed, 11 Sep 2024 15:46:33 +0300
Subject: [PATCH 4/4] Add PG_TEST_EXTRA configure option to the Make builds

The Meson builds have PG_TEST_EXTRA as a configure-time variable, which
was not available in the Make builds. To ensure both build systems are
in sync, PG_TEST_EXTRA is now added as a configure-time variable. It can
be set like this:
./configure PG_TEST_EXTRA="kerberos, ssl, ..."

Note that to preserve the old behavior, this configure-time variable is
overridden by the PG_TEST_EXTRA environment variable.

Author: Jacob Champion <jacob.champ...@enterprisedb.com>
Reviewed by: Ashutosh Bapat, Nazir Bilal Yavuz with inputs from Tom Lane
and Andrew Dunstan
---
 configure              |  4 ++++
 configure.ac           |  2 ++
 src/Makefile.global.in | 10 ++++++++++
 src/test/Makefile      |  5 -----
 4 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 53c8a1f2bad..31e547816f3 100755
--- a/configure
+++ b/configure
@@ -764,6 +764,7 @@ LDFLAGS
 CFLAGS
 CC
 enable_injection_points
+PG_TEST_EXTRA
 enable_tap_tests
 enable_dtrace
 DTRACEFLAGS
@@ -880,6 +881,7 @@ enable_largefile
       ac_precious_vars='build_alias
 host_alias
 target_alias
+PG_TEST_EXTRA
 CC
 CFLAGS
 LDFLAGS
@@ -1587,6 +1589,8 @@ Optional Packages:
   --with-openssl          obsolete spelling of --with-ssl=openssl
 
 Some influential environment variables:
+  PG_TEST_EXTRA
+              enable selected extra tests
   CC          C compiler command
   CFLAGS      C compiler flags
   LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
diff --git a/configure.ac b/configure.ac
index 6a35b2880bf..cd63ed803af 100644
--- a/configure.ac
+++ b/configure.ac
@@ -236,6 +236,8 @@ AC_SUBST(enable_dtrace)
 PGAC_ARG_BOOL(enable, tap-tests, no,
               [enable TAP tests (requires Perl and IPC::Run)])
 AC_SUBST(enable_tap_tests)
+AC_ARG_VAR(PG_TEST_EXTRA,
+           [Enable selected extra tests. Overridden by PG_TEST_EXTRA environment variable.])
 
 #
 # Injection points
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 42f50b49761..4859343153b 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -642,6 +642,16 @@ submake-libpgfeutils: | submake-generated-headers
 #
 # Testing support
 
+# Store any configure-time setting for PG_TEST_EXTRA, but let environment
+# variables override it to maintain the historical behavior of the tests.
+# (Standard `=` assignment would require devs to use a commandline option.)
+# This is skipped in PGXS mode to keep the setting from escaping into other
+# projects' builds.
+ifndef PGXS
+PG_TEST_EXTRA ?= @PG_TEST_EXTRA@
+export PG_TEST_EXTRA
+endif
+
 ifneq ($(USE_MODULE_DB),)
   PL_TESTDB = pl_regression_$(NAME)
   ifneq ($(MODULE_big),)
diff --git a/src/test/Makefile b/src/test/Makefile
index dbd3192874d..fc42f1db2b9 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -27,11 +27,6 @@ ifeq ($(with_ssl),openssl)
 SUBDIRS += ssl
 endif
 
-# Test suites that are not safe by default but can be run if selected
-# by the user via the whitespace-separated list in variable PG_TEST_EXTRA.
-# Export PG_TEST_EXTRA to check it in individual tap tests.
-export PG_TEST_EXTRA
-
 # We don't build or execute these by default, but we do want "make
 # clean" etc to recurse into them.  (We must filter out those that we
 # have conditionally included into SUBDIRS above, else there will be
-- 
2.34.1

Reply via email to