From d4d264eb33c86790db6fefd4f0e495dbb64e11b0 Mon Sep 17 00:00:00 2001 From: Ondrej Nosek Date: Tue, 2 Jan 2018 21:06:08 +0100 Subject: [PATCH] Improve logging for unsigned packages Relates: https://pagure.io/pungi/issue/820 Signed-off-by: Ondrej Nosek --- pungi/phases/pkgset/pkgsets.py | 5 ++++- tests/test_pkgset_pkgsets.py | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pungi/phases/pkgset/pkgsets.py b/pungi/phases/pkgset/pkgsets.py index 52badcc9..021ee619 100644 --- a/pungi/phases/pkgset/pkgsets.py +++ b/pungi/phases/pkgset/pkgsets.py @@ -124,10 +124,13 @@ class PackageSetBase(kobo.log.LoggingBase): self.log_debug("Package set: worker threads stopped (RPMs)") if self._invalid_sigkey_rpms: + def nvr_formatter(package_info): + # joins NVR parts of the package with '-' character. + return '-'.join((package_info['name'], package_info['version'], package_info['release'])) raise RuntimeError( "RPM(s) not found for sigs: %s. Check log for details. Unsigned packages:\n%s" % ( self.sigkey_ordering, - '\n'.join([rpminfo['name'] for rpminfo in self._invalid_sigkey_rpms]))) + '\n'.join(sorted(set([nvr_formatter(rpminfo) for rpminfo in self._invalid_sigkey_rpms]))))) return self.rpms_by_arch diff --git a/tests/test_pkgset_pkgsets.py b/tests/test_pkgset_pkgsets.py index 7850619b..2c5d00e0 100644 --- a/tests/test_pkgset_pkgsets.py +++ b/tests/test_pkgset_pkgsets.py @@ -10,6 +10,7 @@ except ImportError: import unittest import json import tempfile +import re sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) @@ -259,9 +260,10 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase): self.koji_wrapper.koji_proxy.mock_calls, [mock.call.listTaggedRPMS('f25', event=None, inherit=True, latest=True)]) - self.assertRegexpMatches( - str(ctx.exception), - r'^RPM\(s\) not found for sigs: .+Check log for details.+') + figure = re.compile( + r'^RPM\(s\) not found for sigs: .+Check log for details.+bash-4\.3\.42-4\.fc24.+bash-debuginfo-4\.3\.42-4\.fc24$', + re.DOTALL) + self.assertRegexpMatches(str(ctx.exception), figure) def test_can_not_find_any_package(self): pkgset = pkgsets.KojiPackageSet(self.koji_wrapper, ['cafebabe', None], arches=['x86_64'])