From 31b03661e52e7b9e6e73e2bbf57d4df94a0efa2d Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 7 Sep 2021 18:56:17 +0200 Subject: [PATCH] unittests: test external dependency in summary This requires a bit of extra code because the version might change, but otherwise it fits in the existing AllPlatformTests.test_summary testcase Signed-off-by: Paolo Bonzini --- run_unittests.py | 11 ++++++++--- test cases/unit/72 summary/meson.build | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/run_unittests.py b/run_unittests.py index 4799b7a77..15312731c 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -5428,6 +5428,7 @@ class AllPlatformTests(BasePlatformTests): missing prog : NO existing prog : ''' + sys.executable + ''' missing dep : NO + external dep : YES 1.2.3 internal dep : YES Plugins @@ -5445,9 +5446,13 @@ class AllPlatformTests(BasePlatformTests): if sys.version_info < (3, 7, 0): # Dictionary order is not stable in Python <3.7, so sort the lines # while comparing - self.assertEqual(sorted(expected_lines), sorted(out_lines)) - else: - self.assertEqual(expected_lines, out_lines) + expected_lines = sorted(expected_lines) + out_lines = sorted(out_lines) + for e, o in zip(expected_lines, out_lines): + if e.startswith(' external dep'): + self.assertRegex(o, r'^ external dep : (YES [0-9.]*|NO)$') + else: + self.assertEqual(o, e) def test_meson_compile(self): """Test the meson compile command.""" diff --git a/test cases/unit/72 summary/meson.build b/test cases/unit/72 summary/meson.build index 4205d6fff..6e0f69ad3 100644 --- a/test cases/unit/72 summary/meson.build +++ b/test cases/unit/72 summary/meson.build @@ -13,6 +13,7 @@ summary({'Some boolean': false, summary({'missing prog': find_program('xyzzy', required: false), 'existing prog': import('python').find_installation(), 'missing dep': dependency('', required: false), + 'external dep': dependency('zlib', required: false), 'internal dep': declare_dependency(), }, section: 'Stuff') summary('A number', 1, section: 'Configuration')