Hi,

On 2023-03-07 15:47:54 -0500, Andrew Dunstan wrote:
> On 2023-03-07 Tu 14:37, Andres Freund wrote:
> > The failures are like this:
> > 
> > +ERROR:  extension "dummy_index_am" is not available
> > +DETAIL:  Could not open extension control file 
> > "/home/bf/bf-build/piculet-meson/HEAD/inst/share/postgresql/extension/dummy_index_am.control":
> >  No such file or directory.
> > +HINT:  The extension must first be installed on the system where 
> > PostgreSQL is running.
> > 
> > I assume this is in an interaction with b6a0d469cae.
> > 
> > 
> > I think we need a install-test-modules or such that installs into the normal
> > directory.
> > 
> 
> Exactly.

Here's a prototype for that.

It adds an install-test-files target, Because we want to install into a normal
directory, I removed the necessary munging of the target paths from
meson.build and moved it into install-test-files. I also added DESTDIR
support, so that installing can redirect the directory if desired. That's used
for the tmp_install/ installation now.

I didn't like the number of arguments necessary for install_test_files, so I
changed it to use

--install target list of files

which makes it easier to use for further directories, if/when we need them.

Greetings,

Andres Freund
>From fe6c77903696ccf03b618fb6f91119a12bea4a2f Mon Sep 17 00:00:00 2001
From: Andres Freund <and...@anarazel.de>
Date: Tue, 7 Mar 2023 16:14:18 -0800
Subject: [PATCH v1] meson: Add target for installing test files & improve
 install_test_files

---
 meson.build                  | 32 ++++++++++++++++++--------------
 src/tools/install_test_files | 25 +++++++++++++++----------
 2 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/meson.build b/meson.build
index 87cb974ad7c..6ce24207fb5 100644
--- a/meson.build
+++ b/meson.build
@@ -2830,6 +2830,22 @@ generated_sources_ac += {'': ['GNUmakefile']}
 testprep_targets += test_install_libs
 
 
+# command to install files used for tests, which aren't installed by default
+install_test_files = files('src/tools/install_test_files')
+install_test_files_args = [
+  install_test_files,
+  '--prefix', dir_prefix,
+  '--install', contrib_data_dir, test_install_data,
+  '--install', dir_lib_pkg, test_install_libs,
+]
+
+# Target installing files required for installcheck of various modules
+run_target('install-test-files',
+  command: [python] + install_test_files_args,
+  depends: testprep_targets,
+)
+
+
 # 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,
 # e.g. because of a #include "file", which always will search in the current
@@ -2922,21 +2938,9 @@ test('tmp_install',
     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,
-    ],
+    python,
+    args: install_test_files_args + ['--destdir', test_install_destdir],
     priority: setup_tests_priority,
     is_parallel: false,
     suite: ['setup'])
diff --git a/src/tools/install_test_files b/src/tools/install_test_files
index e6ecdae10f8..8e0b36a74d1 100644
--- a/src/tools/install_test_files
+++ b/src/tools/install_test_files
@@ -6,23 +6,28 @@
 import argparse
 import shutil
 import os
+from pathlib import PurePath
 
 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='*')
+parser.add_argument('--destdir', type=str, default=os.environ.get('DESTDIR', None))
+parser.add_argument('--prefix', type=str)
+parser.add_argument('--install', type=str, nargs='+', action='append')
 
 args = parser.parse_args()
 
+def copy_files(prefix: str, destdir: str, targetdir: str, src_list: list):
+    if not os.path.isabs(targetdir):
+        targetdir = os.path.join(prefix, targetdir)
 
-def copy_files(src_list: list, dest: str):
-    os.makedirs(dest, exist_ok=True)
+    if destdir is not None:
+        # copy of meson's logic for joining destdir and install paths
+        targetdir = str(PurePath(destdir, *PurePath(targetdir).parts[1:]))
+
+    os.makedirs(targetdir, exist_ok=True)
 
     for src in src_list:
-        shutil.copy2(src, dest)
+        shutil.copy2(src, targetdir)
 
-
-copy_files(args.install_data, args.datadir)
-copy_files(args.install_libs, args.libdir)
+for installs in args.install:
+    copy_files(args.prefix, args.destdir, installs[0], installs[1:])
-- 
2.38.0

Reply via email to