summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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: