diff --git a/pungi/phases/gather/__init__.py b/pungi/phases/gather/__init__.py index a243cd03..7ed1619f 100644 --- a/pungi/phases/gather/__init__.py +++ b/pungi/phases/gather/__init__.py @@ -87,8 +87,13 @@ class GatherPhase(PhaseBase): raise ValueError('\n'.join(errors)) def _write_manifest(self): - self.compose.log_info("Writing RPM manifest: %s" % self.manifest_file) - self.manifest.dump(self.manifest_file) + if self.compose.DEBUG and os.path.isfile(self.manifest_file): + self.compose.log_info( + "Skipping writing RPM manifest, already exists: %s" % self.manifest_file + ) + else: + self.compose.log_info("Writing RPM manifest: %s" % self.manifest_file) + self.manifest.dump(self.manifest_file) def run(self): pkg_map = gather_wrapper(self.compose, self.pkgset_phase.package_sets, diff --git a/tests/test_gather_phase.py b/tests/test_gather_phase.py index cbcb22e6..d2e492cb 100644 --- a/tests/test_gather_phase.py +++ b/tests/test_gather_phase.py @@ -854,6 +854,26 @@ class TestGatherPhase(helpers.PungiTestCase): self.assertEqual(gather_wrapper.call_args_list, []) self.assertTrue(os.path.isfile(os.path.join(self.topdir, 'compose', 'metadata', 'rpms.json'))) + @mock.patch('pungi.phases.gather.link_files') + @mock.patch('pungi.phases.gather.gather_wrapper') + def test_does_not_write_in_debug_mode(self, gather_wrapper, link_files): + pkgset_phase = mock.Mock() + compose = helpers.DummyCompose(self.topdir, {}) + compose.notifier = mock.Mock() + compose.DEBUG = True + + rpms_file = helpers.touch( + os.path.join(self.topdir, 'compose', 'metadata', 'rpms.json'), "hello" + ) + + phase = gather.GatherPhase(compose, pkgset_phase) + phase.stop() + + self.assertEqual(gather_wrapper.call_args_list, []) + self.assertTrue(os.path.isfile(rpms_file)) + with open(rpms_file) as fh: + self.assertEqual(fh.read(), "hello") + class TestGetPackagesToGather(helpers.PungiTestCase): def setUp(self):