summaryrefslogtreecommitdiff
path: root/lib/spack
diff options
context:
space:
mode:
authorOmar Padron <omar.padron@kitware.com>2020-02-25 15:10:50 -0500
committerGitHub <noreply@github.com>2020-02-25 14:10:50 -0600
commit8d750db9de9948a33d8b7d2f30c6f24a53628d25 (patch)
tree563c5f5ecf3338cde65d196cbe0537563e80b33b /lib/spack
parent676eb56ab2379e4d1b3958aad382d81cb012c560 (diff)
downloadspack-8d750db9de9948a33d8b7d2f30c6f24a53628d25.tar.gz
spack-8d750db9de9948a33d8b7d2f30c6f24a53628d25.tar.bz2
spack-8d750db9de9948a33d8b7d2f30c6f24a53628d25.tar.xz
spack-8d750db9de9948a33d8b7d2f30c6f24a53628d25.zip
remove catch-all exception handling in buildcache command (#15185)
* remove catch-all exception handling in buildcache command * fix test
Diffstat (limited to 'lib/spack')
-rw-r--r--lib/spack/spack/cmd/buildcache.py10
-rw-r--r--lib/spack/spack/test/cmd/buildcache.py15
-rw-r--r--lib/spack/spack/util/web.py2
3 files changed, 20 insertions, 7 deletions
diff --git a/lib/spack/spack/cmd/buildcache.py b/lib/spack/spack/cmd/buildcache.py
index 1d105a0c0d..f837e6b8a3 100644
--- a/lib/spack/spack/cmd/buildcache.py
+++ b/lib/spack/spack/cmd/buildcache.py
@@ -366,13 +366,9 @@ def _createtarball(env, spec_yaml, packages, directory, key, no_deps, force,
for spec in specs:
tty.msg('creating binary cache file for package %s ' % spec.format())
- try:
- bindist.build_tarball(spec, outdir, force, rel,
- unsigned, allow_root, signkey,
- not no_rebuild_index)
- except Exception as e:
- tty.warn('%s' % e)
- pass
+ bindist.build_tarball(spec, outdir, force, rel,
+ unsigned, allow_root, signkey,
+ not no_rebuild_index)
def createtarball(args):
diff --git a/lib/spack/spack/test/cmd/buildcache.py b/lib/spack/spack/test/cmd/buildcache.py
index 064daeb063..03d09b9771 100644
--- a/lib/spack/spack/test/cmd/buildcache.py
+++ b/lib/spack/spack/test/cmd/buildcache.py
@@ -3,6 +3,7 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import errno
import platform
import pytest
@@ -11,6 +12,7 @@ import spack.main
import spack.binary_distribution
buildcache = spack.main.SpackCommand('buildcache')
+install = spack.main.SpackCommand('install')
@pytest.fixture()
@@ -41,3 +43,16 @@ def test_buildcache_list_duplicates(mock_get_specs, capsys):
output = buildcache('list', 'mpileaks', '@2.3')
assert output.count('mpileaks') == 3
+
+
+def test_buildcache_create_fail_on_perm_denied(
+ install_mockery, mock_fetch, monkeypatch, tmpdir):
+ """Ensure that buildcache create fails on permission denied error."""
+ install('trivial-install-test-package')
+
+ tmpdir.chmod(0)
+ with pytest.raises(OSError) as error:
+ buildcache('create', '-d', str(tmpdir),
+ '--unsigned', 'trivial-install-test-package')
+ assert error.value.errno == errno.EACCES
+ tmpdir.chmod(0o700)
diff --git a/lib/spack/spack/util/web.py b/lib/spack/spack/util/web.py
index 4fb8c5a591..8039dc5fda 100644
--- a/lib/spack/spack/util/web.py
+++ b/lib/spack/spack/util/web.py
@@ -205,6 +205,8 @@ def push_to_url(
# needs to be done in separate steps.
shutil.copy2(local_file_path, remote_file_path)
os.remove(local_file_path)
+ else:
+ raise
elif remote_url.scheme == 's3':
if extra_args is None: