diff --git a/doc/configuration.rst b/doc/configuration.rst index 08bebbc7..3555afaf 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -1092,6 +1092,8 @@ Options **createiso_max_size_is_strict** (*list*) -- Set the value to ``True`` to turn the warning from ``createiso_max_size`` into a hard error that will abort the compose. + If there are multiple matches in the mapping, the check will be strict if + at least one match says so. Format: ``[(variant_uid_regex, {arch|*: bool})]`` diff --git a/pungi/phases/test.py b/pungi/phases/test.py index 03f33de3..abd1f7c7 100644 --- a/pungi/phases/test.py +++ b/pungi/phases/test.py @@ -182,7 +182,7 @@ def check_size_limit(compose, variant, arch, img): msg = "ISO %s is too big. Expected max %dB, got %dB" % ( img.path, limit, img.size ) - if is_strict: + if any(is_strict): raise RuntimeError(msg) else: compose.log_warning(msg) diff --git a/tests/test_test_phase.py b/tests/test_test_phase.py index adcd0998..679ef15e 100644 --- a/tests/test_test_phase.py +++ b/tests/test_test_phase.py @@ -202,6 +202,27 @@ class TestCheckImageSanity(PungiTestCase): "ISO Client/i386/iso/image.iso is too big. Expected max 10B, got 20B", ) + @mock.patch("pungi.phases.test.check_sanity", new=mock.Mock()) + def test_too_big_iso_not_strict(self): + compose = DummyCompose( + self.topdir, + { + "createiso_max_size": [(".*", {"*": 10})], + "createiso_max_size_is_strict": [(".*", {"*": False})], + }, + ) + compose.image.format = 'iso' + compose.image.bootable = False + compose.image.size = 20 + + test_phase.check_image_sanity(compose) + + warnings = [call[0][0] for call in compose.log_warning.call_args_list] + self.assertIn( + "ISO Client/i386/iso/image.iso is too big. Expected max 10B, got 20B", + warnings, + ) + @mock.patch("pungi.phases.test.check_sanity", new=mock.Mock()) def test_too_big_unified(self): compose = DummyCompose(self.topdir, {})