summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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: