Skip to content

Commit 3d1aec2

Browse files
committed
Make PG_TEST_EXTRA env var override the "meson setup" option
"meson test" used to ignore the PG_TEST_EXTRA environment variable, which meant that in order to run additional tests, you had to run "meson setup -DPG_TEST_EXTRA=...". That's somewhat expensive, and not consistent with autoconf builds. Allow PG_TEST_EXTRA environment variable to override the setup-time option at run time, so that you can do "PG_TEST_EXTRA=... meson test". To implement this, the configuration time value is passed as an extra "--pg-test-extra" argument to testwrap instead of adding it to the test environment. If the environment variable is set at the time of running test, testwrap uses the value from the environment variable and ignores the --pg-test-extra option. Now that "meson test" obeys the environment variable, we can remove it from the "meson setup" steps in the CI script. It will now be picked up from the environment variable like with "make check". Author: Nazir Bilal Yavuzk, Ashutosh Bapat Reviewed-by: Ashutosh Bapat with inputs from Tom Lane and Andrew Dunstan
1 parent 5b0c46e commit 3d1aec2

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
lines changed

.cirrus.tasks.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ task:
175175
--buildtype=debug \
176176
-Dcassert=true -Dinjection_points=true \
177177
-Duuid=bsd -Dtcl_version=tcl86 -Ddtrace=auto \
178-
-DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
179178
-Dextra_lib_dirs=/usr/local/lib -Dextra_include_dirs=/usr/local/include/ \
180179
build
181180
EOF
@@ -364,7 +363,6 @@ task:
364363
--buildtype=debug \
365364
-Dcassert=true -Dinjection_points=true \
366365
${LINUX_MESON_FEATURES} \
367-
-DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
368366
build
369367
EOF
370368
@@ -380,7 +378,6 @@ task:
380378
-Dllvm=disabled \
381379
--pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \
382380
-DPERL=perl5.36-i386-linux-gnu \
383-
-DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
384381
build-32
385382
EOF
386383
@@ -502,7 +499,6 @@ task:
502499
-Dextra_lib_dirs=/opt/local/lib \
503500
-Dcassert=true -Dinjection_points=true \
504501
-Duuid=e2fs -Ddtrace=auto \
505-
-DPG_TEST_EXTRA="$PG_TEST_EXTRA" \
506502
build
507503
508504
build_script: ninja -C build -j${BUILD_JOBS}
@@ -574,7 +570,7 @@ task:
574570
# Use /DEBUG:FASTLINK to avoid high memory usage during linking
575571
configure_script: |
576572
vcvarsall x64
577-
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
573+
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
578574
579575
build_script: |
580576
vcvarsall x64

doc/src/sgml/installation.sgml

+7-3
Original file line numberDiff line numberDiff line change
@@ -3080,9 +3080,13 @@ ninja install
30803080
<term><option>-DPG_TEST_EXTRA=<replaceable>TEST_SUITES</replaceable></option></term>
30813081
<listitem>
30823082
<para>
3083-
Enable test suites which require special software to run. This option
3084-
accepts arguments via a whitespace-separated list. See <xref
3085-
linkend="regress-additional"/> for details.
3083+
Enable additional test suites, which are not run by default because
3084+
they are not secure to run on a multiuser system, require special
3085+
software to run, or are resource intensive. The argument is a
3086+
whitespace-separated list of tests to enable. See
3087+
<xref linkend="regress-additional"/> for details. If the
3088+
<envar>PG_TEST_EXTRA</envar> environment variable is set when the
3089+
tests are run, it overrides this setup-time option.
30863090
</para>
30873091
</listitem>
30883092
</varlistentry>

meson.build

+5-5
Original file line numberDiff line numberDiff line change
@@ -3289,11 +3289,6 @@ test_env.set('PG_REGRESS', pg_regress.full_path())
32893289
test_env.set('REGRESS_SHLIB', regress_module.full_path())
32903290
test_env.set('INITDB_TEMPLATE', test_initdb_template)
32913291

3292-
# Test suites that are not safe by default but can be run if selected
3293-
# by the user via the whitespace-separated list in variable PG_TEST_EXTRA.
3294-
# Export PG_TEST_EXTRA so it can be checked in individual tap tests.
3295-
test_env.set('PG_TEST_EXTRA', get_option('PG_TEST_EXTRA'))
3296-
32973292
# Add the temporary installation to the library search path on platforms where
32983293
# that works (everything but windows, basically). On windows everything
32993294
# library-like gets installed into bindir, solving that issue.
@@ -3357,6 +3352,11 @@ foreach test_dir : tests
33573352
testwrap,
33583353
'--basedir', meson.build_root(),
33593354
'--srcdir', test_dir['sd'],
3355+
# Some test suites are not run by default but can be run if selected by the
3356+
# user via variable PG_TEST_EXTRA. Pass configuration time value of
3357+
# PG_TEST_EXTRA as an argument to testwrap so that it can be overridden by
3358+
# run time value, if any.
3359+
'--pg-test-extra', get_option('PG_TEST_EXTRA'),
33603360
]
33613361

33623362
foreach kind, v : test_dir

meson_options.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ option('injection_points', type: 'boolean', value: false,
4747
description: 'Enable injection points')
4848

4949
option('PG_TEST_EXTRA', type: 'string', value: '',
50-
description: 'Enable selected extra tests')
50+
description: 'Enable selected extra tests. Overridden by PG_TEST_EXTRA environment variable.')
5151

5252
option('PG_GIT_REVISION', type: 'string', value: 'HEAD',
5353
description: 'git revision to be packaged by pgdist target')

src/tools/testwrap

+10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ parser.add_argument('--basedir', help='base directory of test', type=str)
1313
parser.add_argument('--testgroup', help='test group', type=str)
1414
parser.add_argument('--testname', help='test name', type=str)
1515
parser.add_argument('--skip', help='skip test (with reason)', type=str)
16+
parser.add_argument('--pg-test-extra', help='extra tests', type=str)
1617
parser.add_argument('test_command', nargs='*')
1718

1819
args = parser.parse_args()
@@ -41,6 +42,15 @@ env_dict = {**os.environ,
4142
'TESTDATADIR': os.path.join(testdir, 'data'),
4243
'TESTLOGDIR': os.path.join(testdir, 'log')}
4344

45+
46+
# The configuration time value of PG_TEST_EXTRA is supplied via arguement
47+
# --pg-test-extra. But it can be overridden by environment variable
48+
# PG_TEST_EXTRA at the time of running a test. Hence use value from arguments
49+
# only if PG_TEST_EXTRA is not set in the test environment, which already
50+
# contains all the environment variables at the time of running the test.
51+
if "PG_TEST_EXTRA" not in env_dict and args.pg_test_extra:
52+
env_dict["PG_TEST_EXTRA"] = args.pg_test_extra
53+
4454
sp = subprocess.Popen(args.test_command, env=env_dict, stdout=subprocess.PIPE)
4555
# Meson categorizes a passing TODO test point as bad
4656
# (https://github.com/mesonbuild/meson/issues/13183). Remove the TODO

0 commit comments

Comments
 (0)