aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFredrik Salomonsson <plattfot@posteo.net>2022-04-13 12:37:36 -0700
committerEli Schwartz <eschwartz93@gmail.com>2022-04-19 17:35:08 -0400
commitef0c38f90ab8f55ccb319c184523a326ca975f39 (patch)
tree21bd3ee4d4d1bd99bb5eef0ee981a542fdbfbc64
parent3cac527d9fffb4f47fb6c3e7cfc5e840fec06a85 (diff)
downloadmeson-ef0c38f90ab8f55ccb319c184523a326ca975f39.zip
meson-ef0c38f90ab8f55ccb319c184523a326ca975f39.tar.gz
meson-ef0c38f90ab8f55ccb319c184523a326ca975f39.tar.bz2
unittests: Add test_pkgconfig_relocatable to allplatformstests
Test that the pkgconfig prefix is actually relocatable when pkgconfig.relocatable=true and is not when pkgconfig.relocatable=false.
-rw-r--r--test cases/unit/105 pkgconfig relocatable with absolute path/meson.build15
-rw-r--r--unittests/allplatformstests.py33
2 files changed, 48 insertions, 0 deletions
diff --git a/test cases/unit/105 pkgconfig relocatable with absolute path/meson.build b/test cases/unit/105 pkgconfig relocatable with absolute path/meson.build
new file mode 100644
index 0000000..ff21286
--- /dev/null
+++ b/test cases/unit/105 pkgconfig relocatable with absolute path/meson.build
@@ -0,0 +1,15 @@
+project(
+ 'pkgconfig-relocatable-with-absolute-path',
+ version : '1.0',
+ default_options: [
+ 'pkgconfig.relocatable=true',
+ ])
+
+pkgg = import('pkgconfig')
+
+pkgg.generate(
+ name : 'libsimple',
+ version : '1.0',
+ description : 'A simple pkgconfig.',
+ install_dir: get_option('prefix')/'share/misc/pkgconfig',
+)
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index c3e78bf..8425cf5 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -1636,6 +1636,39 @@ class AllPlatformTests(BasePlatformTests):
# pkg-config and pkgconf does not respect the same order
self.assertEqual(sorted(foo_dep.get_compile_args()), sorted(cargs))
+ @skipIfNoPkgconfig
+ def test_pkgconfig_relocatable(self):
+ '''
+ Test that it generates relocatable pkgconfig when module
+ option pkgconfig.relocatable=true.
+ '''
+ testdir_rel = os.path.join(self.common_test_dir, '44 pkgconfig-gen')
+ self.init(testdir_rel, extra_args=['-Dpkgconfig.relocatable=true'])
+
+ def check_pcfile(name, *, relocatable, levels=2):
+ with open(os.path.join(self.privatedir, name), encoding='utf-8') as f:
+ pcfile = f.read()
+ # The pkgconfig module always uses posix path regardless of platform
+ prefix_rel = PurePath('${pcfiledir}', *(['..'] * levels)).as_posix()
+ (self.assertIn if relocatable else self.assertNotIn)(
+ f'prefix={prefix_rel}\n',
+ pcfile)
+
+ check_pcfile('libvartest.pc', relocatable=True)
+ check_pcfile('libvartest2.pc', relocatable=True)
+
+ self.wipe()
+ self.init(testdir_rel, extra_args=['-Dpkgconfig.relocatable=false'])
+
+ check_pcfile('libvartest.pc', relocatable=False)
+ check_pcfile('libvartest2.pc', relocatable=False)
+
+ self.wipe()
+ testdir_abs = os.path.join(self.unit_test_dir, '105 pkgconfig relocatable with absolute path')
+ self.init(testdir_abs)
+
+ check_pcfile('libsimple.pc', relocatable=True, levels=3)
+
def test_array_option_change(self):
def get_opt():
opts = self.introspect('--buildoptions')