summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2018-10-26 16:51:06 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2018-11-09 00:31:24 -0800
commit36623a27fd794cb16d31e4e987383895a075b7c2 (patch)
tree4e5d4d1d89473fbe0d6921ddbeb03301834c29db /lib
parent66aa3426ac845fe611bfd81f2000d5527fc8cb03 (diff)
downloadspack-36623a27fd794cb16d31e4e987383895a075b7c2.tar.gz
spack-36623a27fd794cb16d31e4e987383895a075b7c2.tar.bz2
spack-36623a27fd794cb16d31e4e987383895a075b7c2.tar.xz
spack-36623a27fd794cb16d31e4e987383895a075b7c2.zip
env: add test to ensure config precedence is high-to-low
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/environment.py9
-rw-r--r--lib/spack/spack/test/cmd/env.py40
2 files changed, 46 insertions, 3 deletions
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py
index a088906d04..8d2d3dabb1 100644
--- a/lib/spack/spack/environment.py
+++ b/lib/spack/spack/environment.py
@@ -377,9 +377,12 @@ class Environment(object):
def included_config_scopes(self):
"""List of included configuration scopes from the environment.
- Scopes are in order from lowest to highest precedence, i.e., the
- order they should be pushed on the stack, but the opposite of the
- order they appaer in the spack.yaml file.
+ Scopes are listed in the YAML file in order from highest to
+ lowest precedence, so configuration from earlier scope will take
+ 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 = []
diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py
index 1216daee2e..4f55d72451 100644
--- a/lib/spack/spack/test/cmd/env.py
+++ b/lib/spack/spack/test/cmd/env.py
@@ -428,6 +428,46 @@ packages:
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):
filename = str(tmpdir.join('spack.yaml'))
with open(filename, 'w') as f: