def test_run_or_fail_when_fails_raises_system_exit(self, subprocess_mock): subprocess_mock.call.return_value = 1 with self.assertRaises(SystemExit) as cm: Util.run_or_fail(["a", "b", "c"], "2") self.assertEqual(cm.exception.code, 'Exit 1: Command "a b c" failed.\n')
def build(self): self._prepare_rpm_build_dir() build_flags = self._build_rpm_build_flags() spec_file_path = os.path.join(self.rpm_build_dir, "SPECS", self.name + ".spec") command_str = "rpmbuild -bb %s %s" % (spec_file_path, build_flags) cmd = ['/bin/bash', '-c', command_str] Util.run_or_fail(cmd, cwd=self.rpm_build_dir)
def generate_changelog(self): new_version = f'{self.gpdb_upstream_version}-{self.debian_revision}' cmd = [ 'dch', '--create', '--package', self.package_name, '--newversion', new_version, self.release_message ] Util.run_or_fail(cmd, cwd=self.source_dir) cmd = ['dch', '--release', 'ignored message'] Util.run_or_fail(cmd, cwd=self.source_dir)
def publish(self): cmd = ['dput', self.ppa_repo, self.source_package.changes()] Util.run_or_fail(cmd)
def build_source(self): # -S should be equivalent to the long option `--build=source` but it is not # -sa forces the inclusion of the original source (no long-opt) cmd = ['debuild', '-S', '-sa'] Util.run_or_fail(cmd, cwd=self.source_package.dir())
def build_binary(self): cmd = ['debuild', '--unsigned-changes', '--unsigned-source', '--build=binary'] Util.run_or_fail(cmd, cwd=self.source_package.dir())
def test_run_or_fail_when_successful_works(self, subprocess_mock): subprocess_mock.call.return_value = 0 Util.run_or_fail("test-cmd", "test-cwd") subprocess_mock.call.assert_called_with("test-cmd", cwd="test-cwd")