from gbp.scripts.buildpackage_rpm import main as gbp_rpm
from obs_service_gbp import LOGGER, gbplog
-from obs_service_gbp_utils import GbpServiceError, fork_call, sanitize_uid_gid
-from obs_service_gbp_utils import write_treeish_meta
+from obs_service_gbp_utils import GbpServiceError, GbpChildBTError, fork_call
+from obs_service_gbp_utils import sanitize_uid_gid, write_treeish_meta
from gbp_repocache import CachedRepo, CachedRepoError
import gbp_repocache
for fname in os.listdir(tmp_out):
shutil.move(os.path.join(tmp_out, fname),
os.path.join(args.outdir, fname))
+ except GbpChildBTError as err:
+ LOGGER.error('Unhandled exception in GBP:\n'
+ '%s', err.prettyprint_tb())
+ LOGGER.error('Failed to export packaging files')
+ return 1
except GbpServiceError as err:
LOGGER.error('Internal service error when trying to run GBP: %s', err)
LOGGER.error('This is most likely a configuration error (or a BUG)!')
import grp
import json
+import mock
import os
import stat
from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611
from tests import UnitTestsBase
+class FakeGbpError(Exception):
+ """Exception for testing gbp crashes"""
+ pass
+
+def _mock_gbp():
+ """Fake gbp main function for testing"""
+ raise FakeGbpError()
+
+
class TestService(UnitTestsBase):
"""Base class for unit tests"""
s_rwx = stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC
eq_(service(['--url', self.orig_repo.path, '--deb=yes',
'--revision=source']), 3)
+ @mock.patch('obs_service_gbp.command.gbp_deb', _mock_gbp)
+ def test_deb_crash(self):
+ """Test crash in git-buildpackage"""
+ eq_(service(['--url', self.orig_repo.path, '--revision=deb']), 1)
+
+ @mock.patch('obs_service_gbp.command.gbp_rpm', _mock_gbp)
+ def test_rpm_crash(self):
+ """Test crash in git-buildpackage-rpm"""
+ eq_(service(['--url', self.orig_repo.path, '--revision=rpm']), 1)
+
def test_options_outdir(self):
"""Test the --outdir option"""
outdir = os.path.join(self.tmpdir, 'outdir')