Skip to content

Commit b6a0d46

Browse files
committed
meson: Prevent installation of test files during main install
Previously, meson installed modules under src/test/modules/ as part of a normal installation, even though these files are only meant for use by tests. This is because there is no way to set up up the build system to install extra things only when told. This patch fixes that with a workaround: We don't install these modules as part of meson install, but we create a new "test" that runs before the real tests whose action it is to install these files. The installation is done by manual copies using a small helper script. Author: Nazir Bilal Yavuz <byavuz81@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/2a039e8e-f31f-31e8-afe7-bab3130ad2de%40enterprisedb.com
1 parent b1307b8 commit b6a0d46

File tree

29 files changed

+139
-151
lines changed

29 files changed

+139
-151
lines changed

meson.build

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2801,6 +2801,10 @@ backend_code = declare_dependency(
28012801
dependencies: os_deps + backend_both_deps + backend_deps,
28022802
)
28032803

2804+
# install these files only during test, not main install
2805+
test_install_data = []
2806+
test_install_libs = []
2807+
28042808
# src/backend/meson.build defines backend_mod_code used for extension
28052809
# libraries.
28062810

@@ -2821,6 +2825,10 @@ subdir('doc/src/sgml')
28212825

28222826
generated_sources_ac += {'': ['GNUmakefile']}
28232827

2828+
# After processing src/test, add test_install_libs to the testprep_targets
2829+
# to build them
2830+
testprep_targets += test_install_libs
2831+
28242832

28252833
# If there are any files in the source directory that we also generate in the
28262834
# build directory, they might get preferred over the newly generated files,
@@ -2903,14 +2911,36 @@ meson_install_args = meson_args + ['install'] + {
29032911
'muon': []
29042912
}[meson_impl]
29052913

2914+
# setup tests should be run first,
2915+
# so define priority for these
2916+
setup_tests_priority = 100
29062917
test('tmp_install',
29072918
meson_bin, args: meson_install_args ,
29082919
env: {'DESTDIR':test_install_destdir},
2909-
priority: 100,
2920+
priority: setup_tests_priority,
29102921
timeout: 300,
29112922
is_parallel: false,
29122923
suite: ['setup'])
29132924

2925+
# get full paths of test_install_libs to copy them
2926+
test_install_libs_fp = []
2927+
foreach lib: test_install_libs
2928+
test_install_libs_fp += lib.full_path()
2929+
endforeach
2930+
2931+
install_test_files = files('src/tools/install_test_files')
2932+
test('install_test_files',
2933+
python, args: [
2934+
install_test_files,
2935+
'--datadir', test_install_location / contrib_data_args['install_dir'],
2936+
'--libdir', test_install_location / dir_lib_pkg,
2937+
'--install-data', test_install_data,
2938+
'--install-libs', test_install_libs_fp,
2939+
],
2940+
priority: setup_tests_priority,
2941+
is_parallel: false,
2942+
suite: ['setup'])
2943+
29142944
test_result_dir = meson.build_root() / 'testrun'
29152945

29162946

src/backend/meson.build

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,19 @@ backend_mod_code = declare_dependency(
180180
dependencies: backend_mod_deps,
181181
)
182182

183+
# normal extension modules
183184
pg_mod_args = default_mod_args + {
184185
'dependencies': [backend_mod_code],
185186
'cpp_args': pg_mod_cpp_args,
186187
'link_depends': pg_mod_link_depend,
187188
}
188189

190+
# extension modules that shouldn't be installed by default, as they're only
191+
# for testing
192+
pg_test_mod_args = pg_mod_args + {
193+
'install': false
194+
}
195+
189196

190197

191198
# Shared modules that, on some system, link against the server binary. Only

src/test/modules/delay_execution/meson.build

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Copyright (c) 2022-2023, PostgreSQL Global Development Group
22

3-
# FIXME: prevent install during main install, but not during test :/
4-
53
delay_execution_sources = files(
64
'delay_execution.c',
75
)
@@ -14,9 +12,9 @@ endif
1412

1513
delay_execution = shared_module('delay_execution',
1614
delay_execution_sources,
17-
kwargs: pg_mod_args,
15+
kwargs: pg_test_mod_args,
1816
)
19-
testprep_targets += delay_execution
17+
test_install_libs += delay_execution
2018

2119
tests += {
2220
'name': 'delay_execution',

src/test/modules/dummy_index_am/meson.build

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Copyright (c) 2022-2023, PostgreSQL Global Development Group
22

3-
# FIXME: prevent install during main install, but not during test :/
4-
53
dummy_index_am_sources = files(
64
'dummy_index_am.c',
75
)
@@ -14,14 +12,13 @@ endif
1412

1513
dummy_index_am = shared_module('dummy_index_am',
1614
dummy_index_am_sources,
17-
kwargs: pg_mod_args,
15+
kwargs: pg_test_mod_args,
1816
)
19-
testprep_targets += dummy_index_am
17+
test_install_libs += dummy_index_am
2018

21-
install_data(
19+
test_install_data += files(
2220
'dummy_index_am.control',
2321
'dummy_index_am--1.0.sql',
24-
kwargs: contrib_data_args,
2522
)
2623

2724
tests += {

src/test/modules/dummy_seclabel/meson.build

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Copyright (c) 2022-2023, PostgreSQL Global Development Group
22

3-
# FIXME: prevent install during main install, but not during test :/
4-
53
dummy_seclabel_sources = files(
64
'dummy_seclabel.c',
75
)
@@ -14,14 +12,13 @@ endif
1412

1513
dummy_seclabel = shared_module('dummy_seclabel',
1614
dummy_seclabel_sources,
17-
kwargs: pg_mod_args,
15+
kwargs: pg_test_mod_args,
1816
)
19-
testprep_targets += dummy_seclabel
17+
test_install_libs += dummy_seclabel
2018

21-
install_data(
19+
test_install_data += files(
2220
'dummy_seclabel.control',
2321
'dummy_seclabel--1.0.sql',
24-
kwargs: contrib_data_args,
2522
)
2623

2724
tests += {

src/test/modules/plsample/meson.build

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Copyright (c) 2022-2023, PostgreSQL Global Development Group
22

3-
# FIXME: prevent install during main install, but not during test :/
4-
53
plsample_sources = files(
64
'plsample.c',
75
)
@@ -14,16 +12,14 @@ endif
1412

1513
plsample = shared_module('plsample',
1614
plsample_sources,
17-
kwargs: pg_mod_args,
15+
kwargs: pg_test_mod_args,
1816
)
19-
testprep_targets += plsample
17+
test_install_libs += plsample
2018

21-
install_data(
19+
test_install_data += files(
2220
'plsample.control',
2321
'plsample--1.0.sql',
24-
kwargs: contrib_data_args,
2522
)
26-
2723
tests += {
2824
'name': 'plsample',
2925
'sd': meson.current_source_dir(),

src/test/modules/spgist_name_ops/meson.build

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Copyright (c) 2022-2023, PostgreSQL Global Development Group
22

3-
# FIXME: prevent install during main install, but not during test :/
4-
53
spgist_name_ops_sources = files(
64
'spgist_name_ops.c',
75
)
@@ -14,16 +12,14 @@ endif
1412

1513
spgist_name_ops = shared_module('spgist_name_ops',
1614
spgist_name_ops_sources,
17-
kwargs: pg_mod_args,
15+
kwargs: pg_test_mod_args,
1816
)
19-
testprep_targets += spgist_name_ops
17+
test_install_libs += spgist_name_ops
2018

21-
install_data(
19+
test_install_data += files(
2220
'spgist_name_ops.control',
2321
'spgist_name_ops--1.0.sql',
24-
kwargs: contrib_data_args,
2522
)
26-
2723
tests += {
2824
'name': 'spgist_name_ops',
2925
'sd': meson.current_source_dir(),

src/test/modules/ssl_passphrase_callback/meson.build

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ if not ssl.found()
44
subdir_done()
55
endif
66

7-
# FIXME: prevent install during main install, but not during test :/
8-
97
ssl_passphrase_callback_sources = files(
108
'ssl_passphrase_func.c',
119
)
@@ -18,11 +16,11 @@ endif
1816

1917
ssl_passphrase_callback = shared_module('ssl_passphrase_func',
2018
ssl_passphrase_callback_sources,
21-
kwargs: pg_mod_args + {
19+
kwargs: pg_test_mod_args + {
2220
'dependencies': [ssl, pg_mod_args['dependencies']],
2321
},
2422
)
25-
testprep_targets += ssl_passphrase_callback
23+
test_install_libs += ssl_passphrase_callback
2624

2725
# Targets to generate or remove the ssl certificate and key. Need to be copied
2826
# to the source afterwards. Normally not needed.

src/test/modules/test_bloomfilter/meson.build

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Copyright (c) 2022-2023, PostgreSQL Global Development Group
22

3-
# FIXME: prevent install during main install, but not during test :/
4-
53
test_bloomfilter_sources = files(
64
'test_bloomfilter.c',
75
)
@@ -14,14 +12,13 @@ endif
1412

1513
test_bloomfilter = shared_module('test_bloomfilter',
1614
test_bloomfilter_sources,
17-
kwargs: pg_mod_args,
15+
kwargs: pg_test_mod_args,
1816
)
19-
testprep_targets += test_bloomfilter
17+
test_install_libs += test_bloomfilter
2018

21-
install_data(
19+
test_install_data += files(
2220
'test_bloomfilter.control',
2321
'test_bloomfilter--1.0.sql',
24-
kwargs: contrib_data_args,
2522
)
2623

2724
tests += {

src/test/modules/test_copy_callbacks/meson.build

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Copyright (c) 2022-2023, PostgreSQL Global Development Group
22

3-
# FIXME: prevent install during main install, but not during test :/
4-
53
test_copy_callbacks_sources = files(
64
'test_copy_callbacks.c',
75
)
@@ -14,14 +12,13 @@ endif
1412

1513
test_copy_callbacks = shared_module('test_copy_callbacks',
1614
test_copy_callbacks_sources,
17-
kwargs: pg_mod_args,
15+
kwargs: pg_test_mod_args,
1816
)
19-
testprep_targets += test_copy_callbacks
17+
test_install_libs += test_copy_callbacks
2018

21-
install_data(
19+
test_install_data += files(
2220
'test_copy_callbacks.control',
2321
'test_copy_callbacks--1.0.sql',
24-
kwargs: contrib_data_args,
2522
)
2623

2724
tests += {

src/test/modules/test_custom_rmgrs/meson.build

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Copyright (c) 2022-2023, PostgreSQL Global Development Group
22

3-
# FIXME: prevent install during main install, but not during test :/
4-
53
test_custom_rmgrs_sources = files(
64
'test_custom_rmgrs.c',
75
)
@@ -14,14 +12,13 @@ endif
1412

1513
test_custom_rmgrs = shared_module('test_custom_rmgrs',
1614
test_custom_rmgrs_sources,
17-
kwargs: pg_mod_args,
15+
kwargs: pg_test_mod_args,
1816
)
19-
testprep_targets += test_custom_rmgrs
17+
test_install_libs += test_custom_rmgrs
2018

21-
install_data(
19+
test_install_data += files(
2220
'test_custom_rmgrs.control',
2321
'test_custom_rmgrs--1.0.sql',
24-
kwargs: contrib_data_args,
2522
)
2623

2724
tests += {

src/test/modules/test_ddl_deparse/meson.build

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Copyright (c) 2022-2023, PostgreSQL Global Development Group
22

3-
# FIXME: prevent install during main install, but not during test :/
4-
53
test_ddl_deparse_sources = files(
64
'test_ddl_deparse.c',
75
)
@@ -14,14 +12,13 @@ endif
1412

1513
test_ddl_deparse = shared_module('test_ddl_deparse',
1614
test_ddl_deparse_sources,
17-
kwargs: pg_mod_args,
15+
kwargs: pg_test_mod_args,
1816
)
19-
testprep_targets += test_ddl_deparse
17+
test_install_libs += test_ddl_deparse
2018

21-
install_data(
19+
test_install_data += files(
2220
'test_ddl_deparse.control',
2321
'test_ddl_deparse--1.0.sql',
24-
kwargs: contrib_data_args,
2522
)
2623

2724
tests += {

src/test/modules/test_extensions/meson.build

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Copyright (c) 2022-2023, PostgreSQL Global Development Group
22

3-
# FIXME: prevent install during main install, but not during test :/
4-
install_data(
3+
test_install_data += files(
54
'test_ext1--1.0.sql',
65
'test_ext1.control',
76
'test_ext2--1.0.sql',
@@ -31,7 +30,6 @@ install_data(
3130
'test_ext_evttrig--1.0--2.0.sql',
3231
'test_ext_evttrig--1.0.sql',
3332
'test_ext_evttrig.control',
34-
kwargs: contrib_data_args,
3533
)
3634

3735
tests += {

src/test/modules/test_ginpostinglist/meson.build

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Copyright (c) 2022-2023, PostgreSQL Global Development Group
22

3-
# FIXME: prevent install during main install, but not during test :/
4-
53
test_ginpostinglist_sources = files(
64
'test_ginpostinglist.c',
75
)
@@ -14,14 +12,13 @@ endif
1412

1513
test_ginpostinglist = shared_module('test_ginpostinglist',
1614
test_ginpostinglist_sources,
17-
kwargs: pg_mod_args,
15+
kwargs: pg_test_mod_args,
1816
)
19-
testprep_targets += test_ginpostinglist
17+
test_install_libs += test_ginpostinglist
2018

21-
install_data(
19+
test_install_data += files(
2220
'test_ginpostinglist.control',
2321
'test_ginpostinglist--1.0.sql',
24-
kwargs: contrib_data_args,
2522
)
2623

2724
tests += {

0 commit comments

Comments
 (0)