summaryrefslogtreecommitdiff
path: root/lib/spack/spack/test/config_values.py
blob: 4de5c4dee8a29a2c67161130c0dc3cad31cd8e1b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright 2013-2021 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,
                                 tmpdir):
    # spack.store.layout caches initial config values, so we monkeypatch
    mutable_config.set('config:install_hash_length', 5)
    mutable_config.set('config:install_tree', {'root': str(tmpdir)})
    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, tmpdir):
    # spack.store.layout caches initial config values, so we monkeypatch
    mutable_config.set('config:install_hash_length', 5)
    mutable_config.set(
        'config:install_tree',
        {
            'root': str(tmpdir),
            'projections': {
                'all': '{name}-{HASH}'
            }
        }
    )
    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