On 23.02.23 19:06, Nazir Bilal Yavuz wrote:
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.

Looks good to me. I did a small pass over it to adjust some namings. For example, I renamed test_install_files to test_install_data, so it's consistent with the overall meson naming:

-install_data(
+test_install_data += files(

Let me know if you have any concerns about this version. Otherwise, I'm happy to commit it.
From 661a0f5741b7f368f0f99921d819fd8dcf6b0431 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Wed, 1 Mar 2023 20:03:36 +0100
Subject: [PATCH v4] 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_test_files                  | 28 ++++++++++++++++
 29 files changed, 139 insertions(+), 151 deletions(-)
 create mode 100644 src/tools/install_test_files

diff --git a/meson.build b/meson.build
index 26be83afb6..87cb974ad7 100644
--- a/meson.build
+++ b/meson.build
@@ -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'
 
 
diff --git a/src/backend/meson.build b/src/backend/meson.build
index 4fdd209b82..ccfc382fcf 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 a7165d7506..9f33b19cb7 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 4e02a34f18..86bbc641bc 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_data += 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 2a6a114b91..a804caf569 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_data += 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 99acf8f658..44fa107595 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_data += 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 76405055c4..c8b7a6efb4 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_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(),
diff --git a/src/test/modules/ssl_passphrase_callback/meson.build 
b/src/test/modules/ssl_passphrase_callback/meson.build
index de016b0280..c2a022b4f1 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 924966bb1e..5353958eeb 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_data += 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 20b052ec86..849b58e7c4 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_data += 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 3e887af4bc..a826efe1af 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_data += 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 f23e246aca..dfd31df124 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_data += 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 45597ddc23..c3af3e1721 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_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 += {
diff --git a/src/test/modules/test_ginpostinglist/meson.build 
b/src/test/modules/test_ginpostinglist/meson.build
index 3afb7b1b7e..338296267c 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_data += 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 7223435a27..7aa7bf8001 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_data += 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 7992535975..646ab4ab00 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_data += 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 054dda3646..9c69a1eaf9 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 9cd664e81c..0dcbd788c1 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_data += 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 fa0e691d79..8b5881735c 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_data += 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 b90046b79b..8f61050c29 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_data += 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 7f5e523449..5ec87269b2 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_data += 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 3e42e4caad..47a921da90 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_data += 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 486d586dc8..bb0557078b 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_data += 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 7adf23ed77..382e9933e6 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 52b3c5b58c..f24a2ba7f7 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_data += 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 707897e6b0..ecf64ed4a9 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_data += 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 f6ffe947eb..a8cdfdeb36 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_data += 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 6a0584d415..a045c00c1f 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_test_files b/src/tools/install_test_files
new file mode 100644
index 0000000000..e6ecdae10f
--- /dev/null
+++ b/src/tools/install_test_files
@@ -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)
-- 
2.39.2

Reply via email to