aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2022-03-09 13:13:30 -0800
committerJussi Pakkanen <jpakkane@gmail.com>2022-03-22 15:15:29 +0200
commitf0b27964ca642a662b2f840ba2ee9c7012ced962 (patch)
treef5cb6576e5c96f3ef9d93a6e32a1cc545844aa55
parentb43cf097c2004b8cec9c933989943be06cf45a9d (diff)
downloadmeson-f0b27964ca642a662b2f840ba2ee9c7012ced962.zip
meson-f0b27964ca642a662b2f840ba2ee9c7012ced962.tar.gz
meson-f0b27964ca642a662b2f840ba2ee9c7012ced962.tar.bz2
tests/linuxlike: prepend rather than override PKG_CONFIG_PATH
If you rely on PKG_CONFIG_PATH to make anything work (like nixos) then these tests cannot pass without the system values appended to the override values.
-rw-r--r--unittests/linuxliketests.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py
index 957c6d4..ecb653f 100644
--- a/unittests/linuxliketests.py
+++ b/unittests/linuxliketests.py
@@ -56,6 +56,18 @@ from run_tests import (
from .baseplatformtests import BasePlatformTests
from .helpers import *
+def _prepend_pkg_config_path(path: str) -> str:
+ """Prepend a string value to pkg_config_path
+
+ :param path: The path to prepend
+ :return: The path, followed by any PKG_CONFIG_PATH already in the environment
+ """
+ pkgconf = os.environ.get('PKG_CONFIG_PATH')
+ if pkgconf:
+ return f'{path}{os.path.pathsep}{pkgconf}'
+ return path
+
+
def _clang_at_least(compiler: 'Compiler', minver: str, apple_minver: T.Optional[str]) -> bool:
"""
check that Clang compiler is at least a specified version, whether AppleClang or regular Clang
@@ -1197,7 +1209,7 @@ class LinuxlikeTests(BasePlatformTests):
testdir = os.path.join(self.unit_test_dir, '38 pkgconfig format')
self.init(testdir)
myenv = os.environ.copy()
- myenv['PKG_CONFIG_PATH'] = self.privatedir
+ myenv['PKG_CONFIG_PATH'] = _prepend_pkg_config_path(self.privatedir)
stdo = subprocess.check_output([PKG_CONFIG, '--libs-only-l', 'libsomething'], env=myenv)
deps = [b'-lgobject-2.0', b'-lgio-2.0', b'-lglib-2.0', b'-lsomething']
if is_windows() or is_cygwin() or is_osx() or is_openbsd():
@@ -1211,7 +1223,7 @@ class LinuxlikeTests(BasePlatformTests):
testdir = os.path.join(self.unit_test_dir, '50 pkgconfig csharp library')
self.init(testdir)
myenv = os.environ.copy()
- myenv['PKG_CONFIG_PATH'] = self.privatedir
+ myenv['PKG_CONFIG_PATH'] = _prepend_pkg_config_path(self.privatedir)
stdo = subprocess.check_output([PKG_CONFIG, '--libs', 'libsomething'], env=myenv)
self.assertEqual("-r/usr/lib/libsomething.dll", str(stdo.decode('ascii')).strip())
@@ -1224,7 +1236,7 @@ class LinuxlikeTests(BasePlatformTests):
testdir = os.path.join(self.unit_test_dir, '53 pkgconfig static link order')
self.init(testdir)
myenv = os.environ.copy()
- myenv['PKG_CONFIG_PATH'] = self.privatedir
+ myenv['PKG_CONFIG_PATH'] = _prepend_pkg_config_path(self.privatedir)
stdo = subprocess.check_output([PKG_CONFIG, '--libs', 'libsomething'], env=myenv)
deps = stdo.split()
self.assertLess(deps.index(b'-lsomething'), deps.index(b'-ldependency'))
@@ -1295,7 +1307,7 @@ class LinuxlikeTests(BasePlatformTests):
## New builddir for the consumer
self.new_builddir()
env = {'LIBRARY_PATH': os.path.join(installdir, self.libdir),
- 'PKG_CONFIG_PATH': os.path.join(installdir, self.libdir, 'pkgconfig')}
+ 'PKG_CONFIG_PATH': _prepend_pkg_config_path(os.path.join(installdir, self.libdir, 'pkgconfig'))}
testdir = os.path.join(self.unit_test_dir, '40 external, internal library rpath', 'built library')
# install into installdir without using DESTDIR
self.prefix = self.installdir
@@ -1348,7 +1360,7 @@ class LinuxlikeTests(BasePlatformTests):
self.new_builddir()
env = {'LIBRARY_PATH': os.path.join(installdir, self.libdir),
- 'PKG_CONFIG_PATH': os.path.join(installdir, self.libdir, 'pkgconfig')}
+ 'PKG_CONFIG_PATH': _prepend_pkg_config_path(os.path.join(installdir, self.libdir, 'pkgconfig'))}
testdir = os.path.join(self.unit_test_dir, '98 link full name','proguser')
self.init(testdir,override_envvars=env)