aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2016-12-26 20:18:22 +0100
committerGuido Günther <agx@sigxcpu.org>2016-12-26 20:18:22 +0100
commit8038a6fe8aff6128dce6ff5423a5df35fa109edd (patch)
treeb62dffedb6febe19f1ef9fa1f94555a70091e3a2
parent58271d630fef2b235f4b8971f96bbd166eccca59 (diff)
import-dsc: Improve error message if there is no dsc file
instead of spewing the exception on the console.
-rw-r--r--gbp/scripts/import_dsc.py5
-rw-r--r--tests/component/deb/test_import_dsc.py13
2 files changed, 17 insertions, 1 deletions
diff --git a/gbp/scripts/import_dsc.py b/gbp/scripts/import_dsc.py
index a6ec09b..aa88bec 100644
--- a/gbp/scripts/import_dsc.py
+++ b/gbp/scripts/import_dsc.py
@@ -59,7 +59,10 @@ def download_source(pkg, dirs, unauth):
gbp.log.info("Downloading '%s' using '%s'..." % (pkg, cmd))
gbpc.RunAtCommand(cmd, opts, shell=False)(dir=dirs['download'])
- dsc = glob.glob(os.path.join(dirs['download'], '*.dsc'))[0]
+ try:
+ dsc = glob.glob(os.path.join(dirs['download'], '*.dsc'))[0]
+ except IndexError:
+ raise GbpError("Did not find a dsc file at %s/" % dirs['download'])
return dsc
diff --git a/tests/component/deb/test_import_dsc.py b/tests/component/deb/test_import_dsc.py
index 947c2ba..a0d790c 100644
--- a/tests/component/deb/test_import_dsc.py
+++ b/tests/component/deb/test_import_dsc.py
@@ -71,6 +71,19 @@ class TestImportDsc(ComponentTestBase):
self._check_repo_state(repo, 'master', ['master'])
assert len(repo.get_commits()) == 1
+ @skipUnless(os.getenv("GBP_NETWORK_TESTS"), "network tests disabled")
+ def test_broken_download(self):
+ def _not_a_dsc(version):
+ return os.path.join(DEB_TEST_DOWNLOAD_URL,
+ 'dsc-3.0',
+ 'hello-debhelper_%s.orig.tar.gz' % version)
+
+ f = _not_a_dsc('2.6')
+ assert import_dsc(['arg0',
+ '--allow-unauthenticated',
+ f]) == 1
+ self._check_log(-1, "gbp:error: Did not find a dsc file at")
+
def test_create_branches(self):
"""Test if creating missing branches works"""
def _dsc(version):