Skip to content

Commit d1d192a

Browse files
committed
meson: prevent installation of test files during main install
Author: Nazir Bilal Yavuz <[email protected]> Author: Andres Freund <[email protected]>
1 parent 1ae498a commit d1d192a

File tree

28 files changed

+138
-139
lines changed

28 files changed

+138
-139
lines changed

meson.build

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2834,6 +2834,10 @@ backend_code = declare_dependency(
28342834
dependencies: os_deps + backend_both_deps + backend_deps,
28352835
)
28362836

2837+
# install these files only during test, not main install
2838+
test_install_files = []
2839+
test_install_libs = []
2840+
28372841
# src/backend/meson.build defines backend_mod_code used for extension
28382842
# libraries.
28392843

@@ -2854,6 +2858,10 @@ subdir('doc/src/sgml')
28542858

28552859
generated_sources_ac += {'': ['GNUmakefile']}
28562860

2861+
# After processing src/test, add test_install_libs to the testprep_targets
2862+
# to build them
2863+
testprep_targets += test_install_libs
2864+
28572865

28582866
# If there are any files in the source directory that we also generate in the
28592867
# build directory, they might get preferred over the newly generated files,
@@ -2944,14 +2952,36 @@ meson_install_args = meson_args + ['install'] + {
29442952
'muon': []
29452953
}[meson_impl]
29462954

2955+
# setup tests should be run first,
2956+
# so define priority for these
2957+
setup_tests_priority = 100
29472958
test('tmp_install',
29482959
meson_bin, args: meson_install_args ,
29492960
env: {'DESTDIR':test_install_destdir},
2950-
priority: 100,
2961+
priority: setup_tests_priority,
29512962
timeout: 300,
29522963
is_parallel: false,
29532964
suite: ['setup'])
29542965

2966+
# get full paths of test_install_libs to copy them
2967+
test_install_libs_fp = []
2968+
foreach lib: test_install_libs
2969+
test_install_libs_fp += lib.full_path()
2970+
endforeach
2971+
2972+
install_additional_files = files('src/test/install_additional_files')
2973+
test('install_additional_files',
2974+
python, args: [
2975+
install_additional_files,
2976+
'--sharedir', test_install_location / contrib_data_args['install_dir'],
2977+
'--libdir', test_install_location / dir_lib_pkg,
2978+
'--install_files', test_install_files,
2979+
'--install_libs', test_install_libs_fp,
2980+
],
2981+
priority: setup_tests_priority,
2982+
is_parallel: false,
2983+
suite: ['setup'])
2984+
29552985
test_result_dir = meson.build_root() / 'testrun'
29562986

29572987

src/backend/meson.build

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

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

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

189196

190197
###############################################################

src/test/install_additional_files

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python3
2+
3+
import argparse
4+
import shutil
5+
import os
6+
7+
parser = argparse.ArgumentParser()
8+
9+
parser.add_argument('--sharedir', help='installationpath of file', type=str)
10+
parser.add_argument('--libdir', help='installation path of libs', type=str)
11+
parser.add_argument('--install_files', help='list of files to be installed', type=str, nargs='*')
12+
parser.add_argument('--install_libs', help='list of libs to be installed', type=str, nargs='*')
13+
14+
args = parser.parse_args()
15+
16+
def copy_files(src_list: list, dest: str):
17+
# check if dir exists
18+
try:
19+
os.makedirs(dest)
20+
except OSError as e:
21+
if not os.path.isdir(dest):
22+
raise
23+
24+
# check if the src is dir or file
25+
# then call the correct function
26+
for src in src_list:
27+
if os.path.isdir(src):
28+
shutil.copytree(src, dest)
29+
else:
30+
shutil.copy2(src, dest)
31+
32+
copy_files(args.install_files, args.sharedir)
33+
copy_files(args.install_libs, args.libdir)

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_files += 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_files += 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_files += 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_files += 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_files += files(
2220
'test_bloomfilter.control',
2321
'test_bloomfilter--1.0.sql',
24-
kwargs: contrib_data_args,
2522
)
2623

2724
tests += {

0 commit comments

Comments
 (0)