Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_build_rpm_fail(self):
with self.assertRaises(BuildException) as be:
self.package_builder.build_rpm(self.fail_srpm,
PackageBuilderTest.distro,
PackageBuilderTest.arch,
self.srpm)
self.assertNotEqual(
be.errors,
[])
def test_rpm_build_err_parse(self):
with self.assertRaises(BuildException) as be:
PackageBuilder().build_rpm(
"", "", "", Path(""))
self.assertEqual(
sorted(be.errors),
sorted([text.decode("utf-8")
for text in MockedSubprocess.ErrorText]))
def test_build_rpm(self):
with self.assertRaises(BuildException) as be:
self.package_builder.build_rpm(self.test_srpm,
PackageBuilderTest.distro,
PackageBuilderTest.arch,
self.srpm)
self.assertEqual(
be.errors,
[])
[
"mock", "--no-clean",
"--verbose",
"--root", distro + '-' + arch,
"--rebuild", path_to_str(srpm),
"--resultdir=" + path_to_str(self.temp_dir)
],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
)
) + list(self._check_logs(self.temp_dir))
self._move_files(output_dir, self.temp_dir.glob("*.rpm"))
self.mock_logs = output_dir / "mock_logs"
self._move_files(self.mock_logs, self.temp_dir.glob("*.log"))
raise BuildException(_ret, self.build_ret_code)
May raise RuntimeError on failed recover. """
def build():
self.build_srpm()
self.build_rpm(distro, arch)
def analyse():
_files_to_pkgs.installed(self.base_dir, self.spec, self.sack)
self.write_spec()
_files_to_pkgs = FilesToPkgsPlugin()
analyse()
while True:
try:
build()
except BuildException as be:
if not self._plugin_engine.execute_mock_recover(be.errors):
if be.return_code:
raise RuntimeError(
"Build failed! See logs in '{}'"
.format(self._package_builder.mock_logs))
break
Command("rm -rf {}".format(path_to_str(self.spec_path))).execute()
analyse()