meson: Prevent installation of test files during main install
authorPeter Eisentraut <peter@eisentraut.org>
Fri, 3 Mar 2023 06:18:20 +0000 (07:18 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Fri, 3 Mar 2023 06:45:52 +0000 (07:45 +0100)
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

29 files changed:
meson.build
src/backend/meson.build
src/test/modules/delay_execution/meson.build
src/test/modules/dummy_index_am/meson.build
src/test/modules/dummy_seclabel/meson.build
src/test/modules/plsample/meson.build
src/test/modules/spgist_name_ops/meson.build
src/test/modules/ssl_passphrase_callback/meson.build
src/test/modules/test_bloomfilter/meson.build
src/test/modules/test_copy_callbacks/meson.build
src/test/modules/test_custom_rmgrs/meson.build
src/test/modules/test_ddl_deparse/meson.build
src/test/modules/test_extensions/meson.build
src/test/modules/test_ginpostinglist/meson.build
src/test/modules/test_integerset/meson.build
src/test/modules/test_lfind/meson.build
src/test/modules/test_oat_hooks/meson.build
src/test/modules/test_parser/meson.build
src/test/modules/test_pg_db_role_setting/meson.build
src/test/modules/test_pg_dump/meson.build
src/test/modules/test_predtest/meson.build
src/test/modules/test_rbtree/meson.build
src/test/modules/test_regex/meson.build
src/test/modules/test_rls_hooks/meson.build
src/test/modules/test_shm_mq/meson.build
src/test/modules/test_slru/meson.build
src/test/modules/worker_spi/meson.build
src/test/regress/meson.build
src/tools/install_test_files [new file with mode: 0644]

index 26be83afb61896b805f7434deb2fb8e0a25305b0..87cb974ad7c330586da33e70ed7ddd80cf0ce354 100644 (file)
@@ -2801,6 +2801,10 @@ backend_code = declare_dependency(
   dependencies: os_deps + backend_both_deps + backend_deps,
 )
 
+# install these files only during test, not main install
+test_install_data = []
+test_install_libs = []
+
 # src/backend/meson.build defines backend_mod_code used for extension
 # libraries.
 
@@ -2821,6 +2825,10 @@ subdir('doc/src/sgml')
 
 generated_sources_ac += {'': ['GNUmakefile']}
 
+# After processing src/test, add test_install_libs to the testprep_targets
+# to build them
+testprep_targets += test_install_libs
+
 
 # If there are any files in the source directory that we also generate in the
 # build directory, they might get preferred over the newly generated files,
@@ -2903,14 +2911,36 @@ meson_install_args = meson_args + ['install'] + {
     'muon': []
 }[meson_impl]
 
+# setup tests should  be run first,
+# so define priority for these
+setup_tests_priority = 100
 test('tmp_install',
     meson_bin, args: meson_install_args ,
     env: {'DESTDIR':test_install_destdir},
-    priority: 100,
+    priority: setup_tests_priority,
     timeout: 300,
     is_parallel: false,
     suite: ['setup'])
 
+# get full paths of test_install_libs to copy them
+test_install_libs_fp = []
+foreach lib: test_install_libs
+  test_install_libs_fp += lib.full_path()
+endforeach
+
+install_test_files = files('src/tools/install_test_files')
+test('install_test_files',
+    python, args: [
+      install_test_files,
+      '--datadir', test_install_location / contrib_data_args['install_dir'],
+      '--libdir', test_install_location / dir_lib_pkg,
+      '--install-data', test_install_data,
+      '--install-libs', test_install_libs_fp,
+    ],
+    priority: setup_tests_priority,
+    is_parallel: false,
+    suite: ['setup'])
+
 test_result_dir = meson.build_root() / 'testrun'
 
 
index 4fdd209b826cd1b32c0cdf60a3b56f990155fc72..ccfc382fcfd1576579d22bfcd11d6f0c15ccf4c2 100644 (file)
@@ -180,12 +180,19 @@ backend_mod_code = declare_dependency(
   dependencies: backend_mod_deps,
 )
 
+# normal extension modules
 pg_mod_args = default_mod_args + {
   'dependencies': [backend_mod_code],
   'cpp_args': pg_mod_cpp_args,
   'link_depends': pg_mod_link_depend,
 }
 
+# extension modules that shouldn't be installed by default, as they're only
+# for testing
+pg_test_mod_args = pg_mod_args + {
+  'install': false
+}
+
 
 
 # Shared modules that, on some system, link against the server binary. Only
index a7165d7506ac3dd49038800a608445db7c5227ac..9f33b19cb7bef6bb43c77999b23bdbde9d92d7b4 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 delay_execution_sources = files(
   'delay_execution.c',
 )
@@ -14,9 +12,9 @@ endif
 
 delay_execution = shared_module('delay_execution',
   delay_execution_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += delay_execution
+test_install_libs += delay_execution
 
 tests += {
   'name': 'delay_execution',
index 4e02a34f184e85a7f2f1ca6cc48f05f216755af7..86bbc641bc50f7f55392601d3452186a0222c1cd 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 dummy_index_am_sources = files(
   'dummy_index_am.c',
 )
@@ -14,14 +12,13 @@ endif
 
 dummy_index_am = shared_module('dummy_index_am',
   dummy_index_am_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += dummy_index_am
+test_install_libs += dummy_index_am
 
-install_data(
+test_install_data += files(
   'dummy_index_am.control',
   'dummy_index_am--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index 2a6a114b913a2412a9bffdb3011bf4aa8d44c493..a804caf56975b4607973df1dd4aa86347be0d86b 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 dummy_seclabel_sources = files(
   'dummy_seclabel.c',
 )
@@ -14,14 +12,13 @@ endif
 
 dummy_seclabel = shared_module('dummy_seclabel',
   dummy_seclabel_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += dummy_seclabel
+test_install_libs += dummy_seclabel
 
-install_data(
+test_install_data += files(
   'dummy_seclabel.control',
   'dummy_seclabel--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index 99acf8f65839b1f79893153d6347fdbcf819f027..44fa107595f71d3f06b353fd81aaee4cb7fa9ef2 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 plsample_sources = files(
   'plsample.c',
 )
@@ -14,16 +12,14 @@ endif
 
 plsample = shared_module('plsample',
   plsample_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += plsample
+test_install_libs += plsample
 
-install_data(
+test_install_data += files(
   'plsample.control',
   'plsample--1.0.sql',
-  kwargs: contrib_data_args,
 )
-
 tests += {
   'name': 'plsample',
   'sd': meson.current_source_dir(),
index 76405055c47ce807078da018393cfae58ef71970..c8b7a6efb4a79f16948af6849e1d7b20692beab8 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 spgist_name_ops_sources = files(
   'spgist_name_ops.c',
 )
@@ -14,16 +12,14 @@ endif
 
 spgist_name_ops = shared_module('spgist_name_ops',
   spgist_name_ops_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += spgist_name_ops
+test_install_libs += spgist_name_ops
 
-install_data(
+test_install_data += files(
   'spgist_name_ops.control',
   'spgist_name_ops--1.0.sql',
-  kwargs: contrib_data_args,
 )
-
 tests += {
   'name': 'spgist_name_ops',
   'sd': meson.current_source_dir(),
index de016b0280e857e72f72f500c5da2af1099d97b8..c2a022b4f10c73d935684c506b259895f9ea11ae 100644 (file)
@@ -4,8 +4,6 @@ if not ssl.found()
   subdir_done()
 endif
 
-# FIXME: prevent install during main install, but not during test :/
-
 ssl_passphrase_callback_sources = files(
   'ssl_passphrase_func.c',
 )
@@ -18,11 +16,11 @@ endif
 
 ssl_passphrase_callback = shared_module('ssl_passphrase_func',
   ssl_passphrase_callback_sources,
-  kwargs: pg_mod_args + {
+  kwargs: pg_test_mod_args + {
     'dependencies': [ssl, pg_mod_args['dependencies']],
   },
 )
-testprep_targets += ssl_passphrase_callback
+test_install_libs += ssl_passphrase_callback
 
 # Targets to generate or remove the ssl certificate and key. Need to be copied
 # to the source afterwards. Normally not needed.
index 924966bb1e3373011c664387c20ae3f5b8df63af..5353958eeb5f8444c18b736ce686fbf47176f31c 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 test_bloomfilter_sources = files(
   'test_bloomfilter.c',
 )
@@ -14,14 +12,13 @@ endif
 
 test_bloomfilter = shared_module('test_bloomfilter',
   test_bloomfilter_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += test_bloomfilter
+test_install_libs += test_bloomfilter
 
-install_data(
+test_install_data += files(
   'test_bloomfilter.control',
   'test_bloomfilter--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index 20b052ec862fd7afe4dce7346d21a331361b34dc..849b58e7c4a63317391e51b23bfc8b945a8b2327 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 test_copy_callbacks_sources = files(
   'test_copy_callbacks.c',
 )
@@ -14,14 +12,13 @@ endif
 
 test_copy_callbacks = shared_module('test_copy_callbacks',
   test_copy_callbacks_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += test_copy_callbacks
+test_install_libs += test_copy_callbacks
 
-install_data(
+test_install_data += files(
   'test_copy_callbacks.control',
   'test_copy_callbacks--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index 3e887af4bc6a316dabde4ac8697d8738907c95c4..a826efe1af736f3ea3799622c5fb0274b5813729 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 test_custom_rmgrs_sources = files(
   'test_custom_rmgrs.c',
 )
@@ -14,14 +12,13 @@ endif
 
 test_custom_rmgrs = shared_module('test_custom_rmgrs',
   test_custom_rmgrs_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += test_custom_rmgrs
+test_install_libs += test_custom_rmgrs
 
-install_data(
+test_install_data += files(
   'test_custom_rmgrs.control',
   'test_custom_rmgrs--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index f23e246acabf5d2fb70110bcd335b35ce03adfab..dfd31df12435dcb50fd85e28549dd711dc4ca7dd 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 test_ddl_deparse_sources = files(
   'test_ddl_deparse.c',
 )
@@ -14,14 +12,13 @@ endif
 
 test_ddl_deparse = shared_module('test_ddl_deparse',
   test_ddl_deparse_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += test_ddl_deparse
+test_install_libs += test_ddl_deparse
 
-install_data(
+test_install_data += files(
   'test_ddl_deparse.control',
   'test_ddl_deparse--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index 45597ddc238a10d076b502c1c50d5cd88ab8d62a..c3af3e1721477eaf69f75b0ee4e3d301daf22bda 100644 (file)
@@ -1,7 +1,6 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-install_data(
+test_install_data += files(
   'test_ext1--1.0.sql',
   'test_ext1.control',
   'test_ext2--1.0.sql',
@@ -31,7 +30,6 @@ install_data(
   'test_ext_evttrig--1.0--2.0.sql',
   'test_ext_evttrig--1.0.sql',
   'test_ext_evttrig.control',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index 3afb7b1b7eb08e2d2ef3a5510df3e370e5df160f..338296267ca9d87db85133d6e422131bcca12993 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 test_ginpostinglist_sources = files(
   'test_ginpostinglist.c',
 )
@@ -14,14 +12,13 @@ endif
 
 test_ginpostinglist = shared_module('test_ginpostinglist',
   test_ginpostinglist_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += test_ginpostinglist
+test_install_libs += test_ginpostinglist
 
-install_data(
+test_install_data += files(
   'test_ginpostinglist.control',
   'test_ginpostinglist--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index 7223435a2760f32bf8e33cef3ca5fd346382ac92..7aa7bf800196b4dec5083fc658b1d8a6d4e99dcf 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 test_integerset_sources = files(
   'test_integerset.c',
 )
@@ -14,14 +12,13 @@ endif
 
 test_integerset = shared_module('test_integerset',
   test_integerset_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += test_integerset
+test_install_libs += test_integerset
 
-install_data(
+test_install_data += files(
   'test_integerset.control',
   'test_integerset--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index 79925359756b175226e2bada04866aea7e40545a..646ab4ab002bb763b30aa418f80bbe72b200f5b5 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 test_lfind_sources = files(
   'test_lfind.c',
 )
@@ -14,14 +12,13 @@ endif
 
 test_lfind = shared_module('test_lfind',
   test_lfind_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += test_lfind
+test_install_libs += test_lfind
 
-install_data(
+test_install_data += files(
   'test_lfind.control',
   'test_lfind--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index 054dda3646e6654f10b901efb6891a384f73a6c5..9c69a1eaf9ee62921b6b252cbaf79b44efef3851 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 test_oat_hooks_sources = files(
   'test_oat_hooks.c',
 )
@@ -14,9 +12,9 @@ endif
 
 test_oat_hooks = shared_module('test_oat_hooks',
   test_oat_hooks_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += test_oat_hooks
+test_install_libs += test_oat_hooks
 
 tests += {
   'name': 'test_oat_hooks',
index 9cd664e81c9f23458516f68d22492df30c0e4a12..0dcbd788c1cde14a45196c4a8e5433625eb00e94 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 test_parser_sources = files(
   'test_parser.c',
 )
@@ -14,14 +12,13 @@ endif
 
 test_parser = shared_module('test_parser',
   test_parser_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += test_parser
+test_install_libs += test_parser
 
-install_data(
+test_install_data += files(
   'test_parser.control',
   'test_parser--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index fa0e691d796553087326f3759b04d07d87514712..8b5881735c6262dd476c9f391d0d186c9f2378e5 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 test_pg_db_role_setting_sources = files(
   'test_pg_db_role_setting.c',
 )
@@ -14,14 +12,13 @@ endif
 
 test_pg_db_role_setting = shared_module('test_pg_db_role_setting',
   test_pg_db_role_setting_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += test_pg_db_role_setting
+test_install_libs += test_pg_db_role_setting
 
-install_data(
+test_install_data += files(
   'test_pg_db_role_setting.control',
   'test_pg_db_role_setting--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index b90046b79b1628276d2fa44b94be914912581055..8f61050c29801b286e6bfb74404639f0d52112a6 100644 (file)
@@ -1,10 +1,8 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-install_data(
+test_install_data += files(
   'test_pg_dump.control',
   'test_pg_dump--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index 7f5e5234494f297e3610d09f4c9eb2cbe52d8b26..5ec87269b20864730dc0d973e340c6de126b5c62 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 test_predtest_sources = files(
   'test_predtest.c',
 )
@@ -14,14 +12,13 @@ endif
 
 test_predtest = shared_module('test_predtest',
   test_predtest_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += test_predtest
+test_install_libs += test_predtest
 
-install_data(
+test_install_data += files(
   'test_predtest.control',
   'test_predtest--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index 3e42e4caadbd7292fd5a5404129f8690a97044c6..47a921da90c2ce5f11942f624c9c4a8955ffd3ce 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 test_rbtree_sources = files(
   'test_rbtree.c',
 )
@@ -14,14 +12,13 @@ endif
 
 test_rbtree = shared_module('test_rbtree',
   test_rbtree_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += test_rbtree
+test_install_libs += test_rbtree
 
-install_data(
+test_install_data += files(
   'test_rbtree.control',
   'test_rbtree--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index 486d586dc8da8a4133f036799e86b5a9d925fb6b..bb0557078b574780fb36a9c0ab9e6dda1b40efa9 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 test_regex_sources = files(
   'test_regex.c',
 )
@@ -14,14 +12,13 @@ endif
 
 test_regex = shared_module('test_regex',
   test_regex_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += test_regex
+test_install_libs += test_regex
 
-install_data(
+test_install_data += files(
   'test_regex.control',
   'test_regex--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index 7adf23ed7790ca659eb063ba3a795a02ffbec792..382e9933e6efd28f3a14a97b0d69fbf30ece92eb 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 test_rls_hooks_sources = files(
   'test_rls_hooks.c',
 )
@@ -14,9 +12,9 @@ endif
 
 test_rls_hooks = shared_module('test_rls_hooks',
   test_rls_hooks_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += test_rls_hooks
+test_install_libs += test_rls_hooks
 
 tests += {
   'name': 'test_rls_hooks',
index 52b3c5b58ce2b3adbc6184bc8425d2f01d2bc2e6..f24a2ba7f7a5e010b390d50aa01421439a0587da 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 test_shm_mq_sources = files(
   'setup.c',
   'test.c',
@@ -16,14 +14,13 @@ endif
 
 test_shm_mq = shared_module('test_shm_mq',
   test_shm_mq_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += test_shm_mq
+test_install_libs += test_shm_mq
 
-install_data(
+test_install_data += files(
   'test_shm_mq.control',
   'test_shm_mq--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index 707897e6b02d8e448e4dcffd0958a1903697ac05..ecf64ed4a94aa7734193560485146050455a9437 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 test_slru_sources = files(
   'test_slru.c',
 )
@@ -14,14 +12,13 @@ endif
 
 test_slru = shared_module('test_slru',
   test_slru_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += test_slru
+test_install_libs += test_slru
 
-install_data(
+test_install_data += files(
   'test_slru.control',
   'test_slru--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index f6ffe947eb871fa67dfcf78341b92006dcaf88ce..a8cdfdeb36b8b3c188f6a217f0117a4613584b2a 100644 (file)
@@ -1,7 +1,5 @@
 # Copyright (c) 2022-2023, PostgreSQL Global Development Group
 
-# FIXME: prevent install during main install, but not during test :/
-
 test_worker_spi_sources = files(
   'worker_spi.c',
 )
@@ -14,14 +12,13 @@ endif
 
 test_worker_spi = shared_module('worker_spi',
   test_worker_spi_sources,
-  kwargs: pg_mod_args,
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += test_worker_spi
+test_install_libs += test_worker_spi
 
-install_data(
+test_install_data += files(
   'worker_spi.control',
   'worker_spi--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
index 6a0584d415f3db240fa25dac07b4c7730156ff99..a045c00c1f652d856f68b19ab609a613439bdf71 100644 (file)
@@ -39,11 +39,9 @@ bin_targets += pg_regress
 
 regress_module = shared_module('regress',
   ['regress.c'],
-  kwargs: pg_mod_args + {
-    'install': false,
-  },
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += regress_module
+test_install_libs += regress_module
 
 # Get some extra C modules from contrib/spi but mark them as not to be
 # installed.
@@ -51,20 +49,16 @@ testprep_targets += regress_module
 
 autoinc_regress = shared_module('autoinc',
   ['../../../contrib/spi/autoinc.c'],
-  kwargs: pg_mod_args + {
-    'install': false,
-  },
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += autoinc_regress
+test_install_libs += autoinc_regress
 
 refint_regress = shared_module('refint',
   ['../../../contrib/spi/refint.c'],
   c_args: refint_cflags,
-  kwargs: pg_mod_args + {
-    'install': false,
-  },
+  kwargs: pg_test_mod_args,
 )
-testprep_targets += refint_regress
+test_install_libs += refint_regress
 
 
 tests += {
diff --git a/src/tools/install_test_files b/src/tools/install_test_files
new file mode 100644 (file)
index 0000000..e6ecdae
--- /dev/null
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+
+# Helper to install additional files into the temporary installation
+# for tests, beyond those that are installed by meson/ninja install.
+
+import argparse
+import shutil
+import os
+
+parser = argparse.ArgumentParser()
+
+parser.add_argument('--datadir', type=str)
+parser.add_argument('--libdir', type=str)
+parser.add_argument('--install-data', type=str, nargs='*')
+parser.add_argument('--install-libs', type=str, nargs='*')
+
+args = parser.parse_args()
+
+
+def copy_files(src_list: list, dest: str):
+    os.makedirs(dest, exist_ok=True)
+
+    for src in src_list:
+        shutil.copy2(src, dest)
+
+
+copy_files(args.install_data, args.datadir)
+copy_files(args.install_libs, args.libdir)