pkgconfig: Move pc file checks to run_unittests.py

pull/2757/head
Xavier Claessens 7 years ago
parent f9c9e80d4a
commit 2881db7379
  1. 30
      run_unittests.py
  2. 39
      test cases/common/51 pkgconfig-gen/meson.build

@ -1912,6 +1912,36 @@ class LinuxlikeTests(BasePlatformTests):
self.assertEqual(foo_dep.get_pkgconfig_variable('foo', {}), 'bar')
self.assertPathEqual(foo_dep.get_pkgconfig_variable('datadir', {}), '/usr/data')
def test_pkgconfig_gen_deps(self):
'''
Test that generated pkg-config files correctly handle dependencies
'''
testdir = os.path.join(self.common_test_dir, '51 pkgconfig-gen')
self.init(testdir)
os.environ['PKG_CONFIG_LIBDIR'] = self.privatedir
cmd = ['pkg-config', 'dependency-test']
out = self._run(cmd + ['--print-requires']).strip().split()
self.assertEqual(sorted(out), sorted(['libexposed']))
out = self._run(cmd + ['--print-requires-private']).strip().split()
self.assertEqual(sorted(out), sorted(['libfoo']))
out = self._run(cmd + ['--cflags-only-other']).strip().split()
self.assertEqual(sorted(out), sorted(['-pthread', '-DCUSTOM']))
out = self._run(cmd + ['--libs-only-l', '--libs-only-other']).strip().split()
self.assertEqual(sorted(out), sorted(['-pthread', '-lcustom',
'-llibmain', '-llibexposed']))
out = self._run(cmd + ['--libs-only-l', '--libs-only-other', '--static']).strip().split()
self.assertEqual(sorted(out), sorted(['-pthread', '-lcustom',
'-llibmain', '-llibexposed',
'-llibinternal', '-lcustom2',
'-lfoo']))
def test_vala_c_warnings(self):
'''
Test that no warnings are emitted for C code generated by Vala. This

@ -12,11 +12,6 @@ if v.version_compare('<0.29')
error('MESON_SKIP_TEST: pkg-config version \'' + v + '\' too old')
endif
envcmd = find_program('env', required: false)
if not envcmd.found()
error('MESON_SKIP_TEST: env command not found')
endif
pkgg = import('pkgconfig')
lib = shared_library('simple', 'simple.c')
@ -35,11 +30,9 @@ pkgg.generate(
libraries_private : [lib, '-lz'],
)
pkgconfig_env = 'PKG_CONFIG_PATH=' + meson.current_build_dir() + '/meson-private'
test('pkgconfig-validation', pkgconfig,
args: ['--validate', 'simple'],
env: [ pkgconfig_env ])
env: [ 'PKG_CONFIG_PATH=' + meson.current_build_dir() + '/meson-private' ])
# Test that name_prefix='' and name='libfoo' results in '-lfoo'
lib2 = shared_library('libfoo', 'simple.c',
@ -86,33 +79,3 @@ pkgg.generate(libraries : [main_lib, exposed_lib, threads_dep , custom_dep],
filebase : 'dependency-test',
description : 'A dependency test.'
)
msg = 'Generated pc file doesn\'t have expected @0@: @1@'
out = run_command(envcmd, '-', pkgconfig_env, pkgconfig, 'dependency-test', '--print-requires').stdout().strip().split()
assert(out.contains('libexposed'), msg.format('requires', out))
assert(out.length() == 1, msg.format('requires', out))
out = run_command(envcmd, '-', pkgconfig_env, pkgconfig, 'dependency-test', '--print-requires-private').stdout().strip().split()
assert(out.contains('libfoo'), msg.format('requires.private', out))
assert(out.length() == 1, msg.format('requires.private', out))
out = run_command(envcmd, '-', pkgconfig_env, pkgconfig, 'dependency-test', '--cflags-only-other').stdout().strip().split()
assert(out.contains('-pthread'), msg.format('cflags', out))
assert(out.contains('-DCUSTOM'), msg.format('cflags', out))
assert(out.length() == 2, msg.format('cflags', out))
out = run_command(envcmd, '-', pkgconfig_env, pkgconfig, 'dependency-test', '--libs-only-l', '--libs-only-other').stdout().strip().split()
assert(out.contains('-pthread'), msg.format('libs', out))
assert(out.contains('-lcustom'), msg.format('libs', out))
assert(out.contains('-llibmain'), msg.format('libs', out))
assert(out.length() == 4, msg.format('libs', out))
out = run_command(envcmd, '-', pkgconfig_env, pkgconfig, 'dependency-test', '--libs-only-l', '--libs-only-other', '--static').stdout().strip().split()
assert(out.contains('-pthread'), msg.format('libs.private', out))
assert(out.contains('-lcustom'), msg.format('libs.private', out))
assert(out.contains('-llibmain'), msg.format('libs.private', out))
assert(out.contains('-llibinternal'), msg.format('libs.private', out))
assert(out.contains('-lcustom2'), msg.format('libs.private', out))
assert(out.contains('-lfoo'), msg.format('libs.private', out))
assert(out.length() == 7, msg.format('libs.private', out))

Loading…
Cancel
Save