env: add test to ensure config precedence is high-to-low
This commit is contained in:
parent
66aa3426ac
commit
36623a27fd
@ -377,9 +377,12 @@ def repo(self):
|
|||||||
def included_config_scopes(self):
|
def included_config_scopes(self):
|
||||||
"""List of included configuration scopes from the environment.
|
"""List of included configuration scopes from the environment.
|
||||||
|
|
||||||
Scopes are in order from lowest to highest precedence, i.e., the
|
Scopes are listed in the YAML file in order from highest to
|
||||||
order they should be pushed on the stack, but the opposite of the
|
lowest precedence, so configuration from earlier scope will take
|
||||||
order they appaer in the spack.yaml file.
|
precedence over later ones.
|
||||||
|
|
||||||
|
This routine returns them in the order they should be pushed onto
|
||||||
|
the internal scope stack (so, in reverse, from lowest to highest).
|
||||||
"""
|
"""
|
||||||
scopes = []
|
scopes = []
|
||||||
|
|
||||||
|
@ -428,6 +428,46 @@ def test_env_config_precedence():
|
|||||||
x.satisfies('libelf@0.8.12') for x in e._get_environment_specs())
|
x.satisfies('libelf@0.8.12') for x in e._get_environment_specs())
|
||||||
|
|
||||||
|
|
||||||
|
def test_included_config_precedence():
|
||||||
|
test_config = """\
|
||||||
|
env:
|
||||||
|
include:
|
||||||
|
- ./high-config.yaml # this one should take precedence
|
||||||
|
- ./low-config.yaml
|
||||||
|
specs:
|
||||||
|
- mpileaks
|
||||||
|
"""
|
||||||
|
spack.package_prefs.PackagePrefs.clear_caches()
|
||||||
|
|
||||||
|
_env_create('test', StringIO(test_config))
|
||||||
|
e = ev.read('test')
|
||||||
|
|
||||||
|
with open(os.path.join(e.path, 'high-config.yaml'), 'w') as f:
|
||||||
|
f.write("""\
|
||||||
|
packages:
|
||||||
|
libelf:
|
||||||
|
version: [0.8.10] # this should override libelf version below
|
||||||
|
""")
|
||||||
|
|
||||||
|
with open(os.path.join(e.path, 'low-config.yaml'), 'w') as f:
|
||||||
|
f.write("""\
|
||||||
|
packages:
|
||||||
|
mpileaks:
|
||||||
|
version: [2.2]
|
||||||
|
libelf:
|
||||||
|
version: [0.8.12]
|
||||||
|
""")
|
||||||
|
|
||||||
|
ev.prepare_config_scope(e)
|
||||||
|
e.concretize()
|
||||||
|
|
||||||
|
assert any(
|
||||||
|
x.satisfies('mpileaks@2.2') for x in e._get_environment_specs())
|
||||||
|
|
||||||
|
assert any(
|
||||||
|
[x.satisfies('libelf@0.8.10') for x in e._get_environment_specs()])
|
||||||
|
|
||||||
|
|
||||||
def test_bad_env_yaml_format(tmpdir):
|
def test_bad_env_yaml_format(tmpdir):
|
||||||
filename = str(tmpdir.join('spack.yaml'))
|
filename = str(tmpdir.join('spack.yaml'))
|
||||||
with open(filename, 'w') as f:
|
with open(filename, 'w') as f:
|
||||||
|
Loading…
Reference in New Issue
Block a user