aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2018-01-13 18:23:44 +0200
committerNirbheek Chauhan <nirbheek@centricular.com>2018-02-20 23:22:00 +0530
commitc21b1a58cd0a473fbed33a0f345d0368896453cb (patch)
tree99514636c1d0822c834911afdfde8736623d7154
parentd41af0c7407d7e2c1d12f4220e05488283d363b5 (diff)
downloadmeson-c21b1a58cd0a473fbed33a0f345d0368896453cb.zip
meson-c21b1a58cd0a473fbed33a0f345d0368896453cb.tar.gz
meson-c21b1a58cd0a473fbed33a0f345d0368896453cb.tar.bz2
unit tests: external deps are added to pc files only if found
https://github.com/mesonbuild/meson/issues/2911 was broken after 0.44, but we add this test here anyway to ensure it doesn't break accidentally.
-rwxr-xr-xrun_unittests.py7
-rw-r--r--test cases/unit/22 unfound pkgconfig/meson.build15
-rw-r--r--test cases/unit/22 unfound pkgconfig/some.c3
3 files changed, 25 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py
index c2babfb..3240381 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -455,6 +455,7 @@ class BasePlatformTests(unittest.TestCase):
# In case the directory is inside a symlinked directory, find the real
# path otherwise we might not find the srcdir from inside the builddir.
self.builddir = os.path.realpath(tempfile.mkdtemp())
+ self.privatedir = os.path.join(self.builddir, 'meson-private')
self.logdir = os.path.join(self.builddir, 'meson-logs')
self.prefix = '/usr'
self.libdir = os.path.join(self.prefix, 'lib')
@@ -1974,6 +1975,12 @@ class LinuxlikeTests(BasePlatformTests):
self.assertEqual(foo_dep.get_pkgconfig_variable('foo', {}), 'bar')
self.assertPathEqual(foo_dep.get_pkgconfig_variable('datadir', {}), '/usr/data')
+ def test_pkg_unfound(self):
+ testdir = os.path.join(self.unit_test_dir, '22 unfound pkgconfig')
+ self.init(testdir)
+ pcfile = open(os.path.join(self.privatedir, 'somename.pc')).read()
+ self.assertFalse('blub_blob_blib' in pcfile)
+
def test_vala_c_warnings(self):
'''
Test that no warnings are emitted for C code generated by Vala. This
diff --git a/test cases/unit/22 unfound pkgconfig/meson.build b/test cases/unit/22 unfound pkgconfig/meson.build
new file mode 100644
index 0000000..1285c0a
--- /dev/null
+++ b/test cases/unit/22 unfound pkgconfig/meson.build
@@ -0,0 +1,15 @@
+project('foobar', 'c')
+
+unfound = dependency('blub_blob_blib', required : false)
+
+pkgg = import('pkgconfig')
+
+l = shared_library('somename', 'some.c',
+ dependencies : unfound)
+
+pkgg.generate(
+ libraries : l,
+ name : 'somename',
+ version : '1.0.0',
+ description : 'A test library.',
+)
diff --git a/test cases/unit/22 unfound pkgconfig/some.c b/test cases/unit/22 unfound pkgconfig/some.c
new file mode 100644
index 0000000..fb765fb
--- /dev/null
+++ b/test cases/unit/22 unfound pkgconfig/some.c
@@ -0,0 +1,3 @@
+int some() {
+ return 6;
+}