diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2019-01-02 12:41:38 -0500 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-01-05 21:44:53 +0200 |
commit | 83964f64fa193669ad7543c618568b115c2b212b (patch) | |
tree | 24aeaedde1065b35df136b369cd8273354b5ebf8 /run_unittests.py | |
parent | 1aca899a63ef287c6fb06e5383f6355b5e75d6d2 (diff) | |
download | meson-83964f64fa193669ad7543c618568b115c2b212b.zip meson-83964f64fa193669ad7543c618568b115c2b212b.tar.gz meson-83964f64fa193669ad7543c618568b115c2b212b.tar.bz2 |
pkgconfig: Fix flag deduplication
This is a regression introduced by 2cbf7caf5, generated pkg-config files
have many duplicated '-pthread' flags.
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-x | run_unittests.py | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/run_unittests.py b/run_unittests.py index 46f93e7..9259b03 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3657,26 +3657,30 @@ class LinuxlikeTests(BasePlatformTests): privatedir2 = self.privatedir os.environ['PKG_CONFIG_LIBDIR'] = os.pathsep.join([privatedir1, privatedir2]) - cmd = ['pkg-config', 'dependency-test'] + self._run(['pkg-config', 'dependency-test', '--validate']) - out = self._run(cmd + ['--print-requires']).strip().split('\n') - self.assertEqual(sorted(out), sorted(['libexposed'])) - - out = self._run(cmd + ['--print-requires-private']).strip().split('\n') - self.assertEqual(sorted(out), sorted(['libfoo >= 1.0'])) - - out = self._run(cmd + ['--cflags-only-other']).strip().split() - self.check_pkg_flags_are_same(out, ['-pthread', '-DCUSTOM']) - - out = self._run(cmd + ['--libs-only-l', '--libs-only-other']).strip().split() - self.check_pkg_flags_are_same(out, ['-pthread', '-lcustom', - '-llibmain', '-llibexposed']) - - out = self._run(cmd + ['--libs-only-l', '--libs-only-other', '--static']).strip().split() - self.check_pkg_flags_are_same(out, ['-pthread', '-lcustom', - '-llibmain', '-llibexposed', - '-llibinternal', '-lcustom2', - '-lfoo']) + # pkg-config strips some duplicated flags so we have to parse the + # generated file ourself. + expected = { + 'Requires': 'libexposed', + 'Requires.private': 'libfoo >= 1.0', + 'Libs': '-L${libdir} -llibmain -pthread -lcustom', + 'Libs.private': '-lcustom2 -L${libdir} -llibinternal', + 'Cflags': '-I${includedir} -pthread -DCUSTOM', + } + if is_osx() or is_haiku(): + expected['Cflags'] = expected['Cflags'].replace('-pthread ', '') + with open(os.path.join(privatedir2, 'dependency-test.pc')) as f: + matched_lines = 0 + for line in f: + parts = line.split(':', 1) + if parts[0] in expected: + key = parts[0] + val = parts[1].strip() + expected_val = expected[key] + self.assertEqual(expected_val, val) + matched_lines += 1 + self.assertEqual(len(expected), matched_lines) cmd = ['pkg-config', 'requires-test'] out = self._run(cmd + ['--print-requires']).strip().split('\n') @@ -3686,11 +3690,6 @@ class LinuxlikeTests(BasePlatformTests): out = self._run(cmd + ['--print-requires-private']).strip().split('\n') self.assertEqual(sorted(out), sorted(['libexposed', 'libfoo >= 1.0', 'libhello'])) - def check_pkg_flags_are_same(self, output, expected): - if is_osx() or is_haiku(): - expected = [x for x in expected if x != '-pthread'] - self.assertEqual(sorted(output), sorted(expected)) - def test_pkg_unfound(self): testdir = os.path.join(self.unit_test_dir, '23 unfound pkgconfig') self.init(testdir) |