Hi,

Thanks for the review.

On Mon, 20 Feb 2023 at 21:44, Peter Eisentraut
<peter.eisentr...@enterprisedb.com> wrote:
>
> I tested this a bit.  It works fine.  The approach makes sense to me.
>
> The install_additional_files script could be simplified a bit.  You
> could use os.makedirs(dest, exist_ok=True) and avoid the error checking.
>    I don't think any callers try to copy a directory source, so the
> shutil.copytree() stuff isn't necessary.  Run pycodestyle over the
> script.  And let's put the script into src/tools/ like the other support
> scripts.
>

I updated the patch in line with your comments.

Regards,
Nazir Bilal Yavuz
Microsoft
From 7804aa928de7595cb89bfd7668952e1e1fe48038 Mon Sep 17 00:00:00 2001
From: Nazir Bilal Yavuz <byavu...@gmail.com>
Date: Thu, 23 Feb 2023 20:35:22 +0300
Subject: [PATCH v3] meson: prevent installation of test files during main
 install

---
 meson.build                                   | 32 ++++++++++++++++++-
 src/backend/meson.build                       |  7 ++++
 src/test/modules/delay_execution/meson.build  |  6 ++--
 src/test/modules/dummy_index_am/meson.build   |  9 ++----
 src/test/modules/dummy_seclabel/meson.build   |  9 ++----
 src/test/modules/plsample/meson.build         | 10 ++----
 src/test/modules/spgist_name_ops/meson.build  | 10 ++----
 .../ssl_passphrase_callback/meson.build       |  6 ++--
 src/test/modules/test_bloomfilter/meson.build |  9 ++----
 .../modules/test_copy_callbacks/meson.build   |  9 ++----
 .../modules/test_custom_rmgrs/meson.build     |  9 ++----
 src/test/modules/test_ddl_deparse/meson.build |  9 ++----
 src/test/modules/test_extensions/meson.build  |  4 +--
 .../modules/test_ginpostinglist/meson.build   |  9 ++----
 src/test/modules/test_integerset/meson.build  |  9 ++----
 src/test/modules/test_lfind/meson.build       |  9 ++----
 src/test/modules/test_oat_hooks/meson.build   |  6 ++--
 src/test/modules/test_parser/meson.build      |  9 ++----
 .../test_pg_db_role_setting/meson.build       |  9 ++----
 src/test/modules/test_pg_dump/meson.build     |  4 +--
 src/test/modules/test_predtest/meson.build    |  9 ++----
 src/test/modules/test_rbtree/meson.build      |  9 ++----
 src/test/modules/test_regex/meson.build       |  9 ++----
 src/test/modules/test_rls_hooks/meson.build   |  6 ++--
 src/test/modules/test_shm_mq/meson.build      |  9 ++----
 src/test/modules/test_slru/meson.build        |  9 ++----
 src/test/modules/worker_spi/meson.build       |  9 ++----
 src/test/regress/meson.build                  | 18 ++++-------
 src/tools/install_additional_files            | 28 ++++++++++++++++
 29 files changed, 139 insertions(+), 151 deletions(-)
 create mode 100644 src/tools/install_additional_files

diff --git a/meson.build b/meson.build
index f5347044526..1e4b3d5445a 100644
--- a/meson.build
+++ b/meson.build
@@ -2791,6 +2791,10 @@ backend_code = declare_dependency(
   dependencies: os_deps + backend_both_deps + backend_deps,
 )
 
+# install these files only during test, not main install
+test_install_files = []
+test_install_libs = []
+
 # src/backend/meson.build defines backend_mod_code used for extension
 # libraries.
 
@@ -2811,6 +2815,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,
@@ -2893,14 +2901,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_additional_files = files('src/tools/install_additional_files')
+test('install_additional_files',
+    python, args: [
+      install_additional_files,
+      '--sharedir', test_install_location / contrib_data_args['install_dir'],
+      '--libdir', test_install_location / dir_lib_pkg,
+      '--install_files', test_install_files,
+      '--install_libs', test_install_libs_fp,
+    ],
+    priority: setup_tests_priority,
+    is_parallel: false,
+    suite: ['setup'])
+
 test_result_dir = meson.build_root() / 'testrun'
 
 
diff --git a/src/backend/meson.build b/src/backend/meson.build
index 4fdd209b826..ccfc382fcfd 100644
--- a/src/backend/meson.build
+++ b/src/backend/meson.build
@@ -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
diff --git a/src/test/modules/delay_execution/meson.build b/src/test/modules/delay_execution/meson.build
index a7165d7506a..9f33b19cb7b 100644
--- a/src/test/modules/delay_execution/meson.build
+++ b/src/test/modules/delay_execution/meson.build
@@ -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',
diff --git a/src/test/modules/dummy_index_am/meson.build b/src/test/modules/dummy_index_am/meson.build
index 4e02a34f184..a9ae95a6576 100644
--- a/src/test/modules/dummy_index_am/meson.build
+++ b/src/test/modules/dummy_index_am/meson.build
@@ -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_files += files(
   'dummy_index_am.control',
   'dummy_index_am--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/modules/dummy_seclabel/meson.build b/src/test/modules/dummy_seclabel/meson.build
index 2a6a114b913..bf81bdacafc 100644
--- a/src/test/modules/dummy_seclabel/meson.build
+++ b/src/test/modules/dummy_seclabel/meson.build
@@ -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_files += files(
   'dummy_seclabel.control',
   'dummy_seclabel--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/modules/plsample/meson.build b/src/test/modules/plsample/meson.build
index 99acf8f6583..04ee6aa7c2b 100644
--- a/src/test/modules/plsample/meson.build
+++ b/src/test/modules/plsample/meson.build
@@ -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_files += files(
   'plsample.control',
   'plsample--1.0.sql',
-  kwargs: contrib_data_args,
 )
-
 tests += {
   'name': 'plsample',
   'sd': meson.current_source_dir(),
diff --git a/src/test/modules/spgist_name_ops/meson.build b/src/test/modules/spgist_name_ops/meson.build
index 76405055c47..99e71832cba 100644
--- a/src/test/modules/spgist_name_ops/meson.build
+++ b/src/test/modules/spgist_name_ops/meson.build
@@ -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_files += 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(),
diff --git a/src/test/modules/ssl_passphrase_callback/meson.build b/src/test/modules/ssl_passphrase_callback/meson.build
index de016b0280e..c2a022b4f10 100644
--- a/src/test/modules/ssl_passphrase_callback/meson.build
+++ b/src/test/modules/ssl_passphrase_callback/meson.build
@@ -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.
diff --git a/src/test/modules/test_bloomfilter/meson.build b/src/test/modules/test_bloomfilter/meson.build
index 924966bb1e3..65a1ed4bf2b 100644
--- a/src/test/modules/test_bloomfilter/meson.build
+++ b/src/test/modules/test_bloomfilter/meson.build
@@ -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_files += files(
   'test_bloomfilter.control',
   'test_bloomfilter--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/modules/test_copy_callbacks/meson.build b/src/test/modules/test_copy_callbacks/meson.build
index 20b052ec862..11c7c792dc3 100644
--- a/src/test/modules/test_copy_callbacks/meson.build
+++ b/src/test/modules/test_copy_callbacks/meson.build
@@ -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_files += files(
   'test_copy_callbacks.control',
   'test_copy_callbacks--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/modules/test_custom_rmgrs/meson.build b/src/test/modules/test_custom_rmgrs/meson.build
index 3e887af4bc6..ca46a869d85 100644
--- a/src/test/modules/test_custom_rmgrs/meson.build
+++ b/src/test/modules/test_custom_rmgrs/meson.build
@@ -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_files += files(
   'test_custom_rmgrs.control',
   'test_custom_rmgrs--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/modules/test_ddl_deparse/meson.build b/src/test/modules/test_ddl_deparse/meson.build
index f23e246acab..e873a0ffe1a 100644
--- a/src/test/modules/test_ddl_deparse/meson.build
+++ b/src/test/modules/test_ddl_deparse/meson.build
@@ -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_files += files(
   'test_ddl_deparse.control',
   'test_ddl_deparse--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/modules/test_extensions/meson.build b/src/test/modules/test_extensions/meson.build
index 45597ddc238..a41be26bbd9 100644
--- a/src/test/modules/test_extensions/meson.build
+++ b/src/test/modules/test_extensions/meson.build
@@ -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_files += 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 += {
diff --git a/src/test/modules/test_ginpostinglist/meson.build b/src/test/modules/test_ginpostinglist/meson.build
index 3afb7b1b7eb..6b4f830f2e6 100644
--- a/src/test/modules/test_ginpostinglist/meson.build
+++ b/src/test/modules/test_ginpostinglist/meson.build
@@ -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_files += files(
   'test_ginpostinglist.control',
   'test_ginpostinglist--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/modules/test_integerset/meson.build b/src/test/modules/test_integerset/meson.build
index 7223435a276..f2a90f580b9 100644
--- a/src/test/modules/test_integerset/meson.build
+++ b/src/test/modules/test_integerset/meson.build
@@ -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_files += files(
   'test_integerset.control',
   'test_integerset--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/modules/test_lfind/meson.build b/src/test/modules/test_lfind/meson.build
index 79925359756..50712bf9e9c 100644
--- a/src/test/modules/test_lfind/meson.build
+++ b/src/test/modules/test_lfind/meson.build
@@ -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_files += files(
   'test_lfind.control',
   'test_lfind--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/modules/test_oat_hooks/meson.build b/src/test/modules/test_oat_hooks/meson.build
index 054dda3646e..9c69a1eaf9e 100644
--- a/src/test/modules/test_oat_hooks/meson.build
+++ b/src/test/modules/test_oat_hooks/meson.build
@@ -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',
diff --git a/src/test/modules/test_parser/meson.build b/src/test/modules/test_parser/meson.build
index 9cd664e81c9..5bc62511ecd 100644
--- a/src/test/modules/test_parser/meson.build
+++ b/src/test/modules/test_parser/meson.build
@@ -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_files += files(
   'test_parser.control',
   'test_parser--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/modules/test_pg_db_role_setting/meson.build b/src/test/modules/test_pg_db_role_setting/meson.build
index fa0e691d796..8cc0cb7c755 100644
--- a/src/test/modules/test_pg_db_role_setting/meson.build
+++ b/src/test/modules/test_pg_db_role_setting/meson.build
@@ -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_files += files(
   'test_pg_db_role_setting.control',
   'test_pg_db_role_setting--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/modules/test_pg_dump/meson.build b/src/test/modules/test_pg_dump/meson.build
index b90046b79b1..055c4e27bb0 100644
--- a/src/test/modules/test_pg_dump/meson.build
+++ b/src/test/modules/test_pg_dump/meson.build
@@ -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_files += files(
   'test_pg_dump.control',
   'test_pg_dump--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/modules/test_predtest/meson.build b/src/test/modules/test_predtest/meson.build
index 7f5e5234494..8b282f8ce9f 100644
--- a/src/test/modules/test_predtest/meson.build
+++ b/src/test/modules/test_predtest/meson.build
@@ -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_files += files(
   'test_predtest.control',
   'test_predtest--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/modules/test_rbtree/meson.build b/src/test/modules/test_rbtree/meson.build
index 3e42e4caadb..3271ef53ed6 100644
--- a/src/test/modules/test_rbtree/meson.build
+++ b/src/test/modules/test_rbtree/meson.build
@@ -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_files += files(
   'test_rbtree.control',
   'test_rbtree--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/modules/test_regex/meson.build b/src/test/modules/test_regex/meson.build
index 486d586dc8d..8d4c90ad956 100644
--- a/src/test/modules/test_regex/meson.build
+++ b/src/test/modules/test_regex/meson.build
@@ -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_files += files(
   'test_regex.control',
   'test_regex--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/modules/test_rls_hooks/meson.build b/src/test/modules/test_rls_hooks/meson.build
index 7adf23ed779..382e9933e6e 100644
--- a/src/test/modules/test_rls_hooks/meson.build
+++ b/src/test/modules/test_rls_hooks/meson.build
@@ -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',
diff --git a/src/test/modules/test_shm_mq/meson.build b/src/test/modules/test_shm_mq/meson.build
index 52b3c5b58ce..c74232b3ecd 100644
--- a/src/test/modules/test_shm_mq/meson.build
+++ b/src/test/modules/test_shm_mq/meson.build
@@ -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_files += files(
   'test_shm_mq.control',
   'test_shm_mq--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/modules/test_slru/meson.build b/src/test/modules/test_slru/meson.build
index 707897e6b02..3d3f741a9a8 100644
--- a/src/test/modules/test_slru/meson.build
+++ b/src/test/modules/test_slru/meson.build
@@ -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_files += files(
   'test_slru.control',
   'test_slru--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/modules/worker_spi/meson.build b/src/test/modules/worker_spi/meson.build
index f6ffe947eb8..f5f6fe5c452 100644
--- a/src/test/modules/worker_spi/meson.build
+++ b/src/test/modules/worker_spi/meson.build
@@ -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_files += files(
   'worker_spi.control',
   'worker_spi--1.0.sql',
-  kwargs: contrib_data_args,
 )
 
 tests += {
diff --git a/src/test/regress/meson.build b/src/test/regress/meson.build
index 6a0584d415f..a045c00c1f6 100644
--- a/src/test/regress/meson.build
+++ b/src/test/regress/meson.build
@@ -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_additional_files b/src/tools/install_additional_files
new file mode 100644
index 00000000000..069a0510dd6
--- /dev/null
+++ b/src/tools/install_additional_files
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+
+import argparse
+import shutil
+import os
+
+parser = argparse.ArgumentParser()
+
+parser.add_argument('--sharedir', help='installationpath of file', type=str)
+parser.add_argument('--libdir', help='installation path of libs', type=str)
+parser.add_argument('--install_files', help='list of files to be installed',
+                    type=str, nargs='*')
+parser.add_argument('--install_libs', help='list of libs to be installed',
+                    type=str, nargs='*')
+
+args = parser.parse_args()
+
+
+def copy_files(src_list: list, dest: str):
+    # check if dir exists
+    os.makedirs(dest, exist_ok=True)
+
+    for src in src_list:
+        shutil.copy2(src, dest)
+
+
+copy_files(args.install_files, args.sharedir)
+copy_files(args.install_libs, args.libdir)
-- 
2.39.2

Reply via email to