bugfix: config:install_hash_length ignored (#15919)

This commit is contained in:
Greg Becker 2020-05-04 23:10:25 -07:00 committed by GitHub
parent b9ed788589
commit 3ae76d8c1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 0 deletions

View File

@ -190,6 +190,7 @@ def __init__(self, root, **kwargs):
"{architecture}/"
"{compiler.name}-{compiler.version}/"
"{name}-{version}-{hash}")
self.path_scheme = self.path_scheme.lower()
if self.hash_len is not None:
if re.search(r'{hash:\d+}', self.path_scheme):
raise InvalidDirectoryLayoutParametersError(

View File

@ -0,0 +1,41 @@
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import spack.spec
def test_set_install_hash_length(mock_packages, mutable_config, monkeypatch):
# spack.store.layout caches initial config values, so we monkeypatch
mutable_config.set('config:install_hash_length', 5)
monkeypatch.setattr(spack.store, 'store', spack.store._store())
spec = spack.spec.Spec('libelf').concretized()
prefix = spec.prefix
hash = prefix.rsplit('-')[-1]
assert len(hash) == 5
mutable_config.set('config:install_hash_length', 9)
monkeypatch.setattr(spack.store, 'store', spack.store._store())
spec = spack.spec.Spec('libelf').concretized()
prefix = spec.prefix
hash = prefix.rsplit('-')[-1]
assert len(hash) == 9
def test_set_install_hash_length_upper_case(mock_packages, mutable_config,
monkeypatch):
# spack.store.layout caches initial config values, so we monkeypatch
mutable_config.set('config:install_path_scheme', '{name}-{HASH}')
mutable_config.set('config:install_hash_length', 5)
monkeypatch.setattr(spack.store, 'store', spack.store._store())
spec = spack.spec.Spec('libelf').concretized()
prefix = spec.prefix
hash = prefix.rsplit('-')[-1]
assert len(hash) == 5