From 9322a29d7f359cbcf378408e0080ea2b030b0d5b Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 15 Dec 2023 18:28:00 +0100 Subject: [PATCH] Skip pkg-config-dependent tests if it's missing --- unittests/linuxliketests.py | 1 + unittests/machinefiletests.py | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py index 271822962902..2328107caac8 100644 --- a/unittests/linuxliketests.py +++ b/unittests/linuxliketests.py @@ -928,6 +928,7 @@ def test_build_rpath_pkgconfig(self): install_rpath = get_rpath(os.path.join(self.installdir, 'usr/bin/progcxx')) self.assertEqual(install_rpath, 'baz:/foo/dummy') + @skipIfNoPkgconfig def test_global_rpath(self): if is_cygwin(): raise SkipTest('Windows PE/COFF binaries do not use RPATH') diff --git a/unittests/machinefiletests.py b/unittests/machinefiletests.py index c3802618df20..22341cb9a000 100644 --- a/unittests/machinefiletests.py +++ b/unittests/machinefiletests.py @@ -215,9 +215,12 @@ def test_python_module(self): # We not have python2, check for it for v in ['2', '2.7', '-2.7']: - rc = subprocess.call(['pkg-config', '--cflags', f'python{v}'], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL) + try: + rc = subprocess.call(['pkg-config', '--cflags', f'python{v}'], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL) + except FileNotFoundError: + raise SkipTest('Not running Python 2 tests because pkg-config not found.') if rc == 0: break else: