remove catch-all exception handling in buildcache command (#15185)

* remove catch-all exception handling in buildcache command

* fix test
This commit is contained in:
Omar Padron 2020-02-25 15:10:50 -05:00 committed by GitHub
parent 676eb56ab2
commit 8d750db9de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 7 deletions

View file

@ -366,13 +366,9 @@ def _createtarball(env, spec_yaml, packages, directory, key, no_deps, force,
for spec in specs: for spec in specs:
tty.msg('creating binary cache file for package %s ' % spec.format()) tty.msg('creating binary cache file for package %s ' % spec.format())
try:
bindist.build_tarball(spec, outdir, force, rel, bindist.build_tarball(spec, outdir, force, rel,
unsigned, allow_root, signkey, unsigned, allow_root, signkey,
not no_rebuild_index) not no_rebuild_index)
except Exception as e:
tty.warn('%s' % e)
pass
def createtarball(args): def createtarball(args):

View file

@ -3,6 +3,7 @@
# #
# SPDX-License-Identifier: (Apache-2.0 OR MIT) # SPDX-License-Identifier: (Apache-2.0 OR MIT)
import errno
import platform import platform
import pytest import pytest
@ -11,6 +12,7 @@
import spack.binary_distribution import spack.binary_distribution
buildcache = spack.main.SpackCommand('buildcache') buildcache = spack.main.SpackCommand('buildcache')
install = spack.main.SpackCommand('install')
@pytest.fixture() @pytest.fixture()
@ -41,3 +43,16 @@ def test_buildcache_list_duplicates(mock_get_specs, capsys):
output = buildcache('list', 'mpileaks', '@2.3') output = buildcache('list', 'mpileaks', '@2.3')
assert output.count('mpileaks') == 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)

View file

@ -205,6 +205,8 @@ def push_to_url(
# needs to be done in separate steps. # needs to be done in separate steps.
shutil.copy2(local_file_path, remote_file_path) shutil.copy2(local_file_path, remote_file_path)
os.remove(local_file_path) os.remove(local_file_path)
else:
raise
elif remote_url.scheme == 's3': elif remote_url.scheme == 's3':
if extra_args is None: if extra_args is None: