From 3ae76d8c1e7ca0cbe09af8bb98c67751b4e0572a Mon Sep 17 00:00:00 2001 From: Greg Becker Date: Mon, 4 May 2020 23:10:25 -0700 Subject: bugfix: config:install_hash_length ignored (#15919) --- lib/spack/spack/directory_layout.py | 1 + lib/spack/spack/test/config_values.py | 41 +++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 lib/spack/spack/test/config_values.py (limited to 'lib') diff --git a/lib/spack/spack/directory_layout.py b/lib/spack/spack/directory_layout.py index a2e871ee1a..0f4c9663ba 100644 --- a/lib/spack/spack/directory_layout.py +++ b/lib/spack/spack/directory_layout.py @@ -190,6 +190,7 @@ class YamlDirectoryLayout(DirectoryLayout): "{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( diff --git a/lib/spack/spack/test/config_values.py b/lib/spack/spack/test/config_values.py new file mode 100644 index 0000000000..ff97f26db4 --- /dev/null +++ b/lib/spack/spack/test/config_values.py @@ -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 -- cgit v1.2.3-60-g2f50