summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGreg Becker <becker33@llnl.gov>2019-08-06 12:53:41 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2019-08-06 12:53:41 -0700
commit3b4d6ddc03e2bf93cbc70f54e795d085ef44ee60 (patch)
tree1a10f3abffb8daef1f12a869821b33a043846e5d /lib
parentd488d04ed3c0de43e56947d0d3b8a66e0033f5fd (diff)
downloadspack-3b4d6ddc03e2bf93cbc70f54e795d085ef44ee60.tar.gz
spack-3b4d6ddc03e2bf93cbc70f54e795d085ef44ee60.tar.bz2
spack-3b4d6ddc03e2bf93cbc70f54e795d085ef44ee60.tar.xz
spack-3b4d6ddc03e2bf93cbc70f54e795d085ef44ee60.zip
stacks: fix reference handling in env.write() (#12096)
* stacks: Fix env.write to properly write references * stacks: regression test for 12095
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/environment.py6
-rw-r--r--lib/spack/spack/test/cmd/env.py23
2 files changed, 27 insertions, 2 deletions
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py
index a854800601..0e59cba746 100644
--- a/lib/spack/spack/environment.py
+++ b/lib/spack/spack/environment.py
@@ -1235,9 +1235,11 @@ class Environment(object):
# Remove any specs in yaml that are not in internal representation
for ayl in active_yaml_lists:
# If it's not a string, it's a matrix. Those can't have changed
+ # If it is a string that starts with '$', it's a reference.
+ # Those also can't have changed.
ayl[name][:] = [s for s in ayl.setdefault(name, [])
- if not isinstance(s, six.string_types) or
- Spec(s) in speclist.specs]
+ if (not isinstance(s, six.string_types)) or
+ s.startswith('$') or Spec(s) in speclist.specs]
# Put the new specs into the first active list from the yaml
new_specs = [entry for entry in speclist.yaml_list
diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py
index 80b00bab1d..c7f1c75579 100644
--- a/lib/spack/spack/test/cmd/env.py
+++ b/lib/spack/spack/test/cmd/env.py
@@ -965,6 +965,29 @@ env:
assert Spec('callpath') in test.user_specs
+@pytest.mark.regression('12095')
+def test_stack_yaml_definitions_write_reference(tmpdir):
+ filename = str(tmpdir.join('spack.yaml'))
+ with open(filename, 'w') as f:
+ f.write("""\
+env:
+ definitions:
+ - packages: [mpileaks, callpath]
+ - indirect: [$packages]
+ specs:
+ - $packages
+""")
+ with tmpdir.as_cwd():
+ env('create', 'test', './spack.yaml')
+
+ with ev.read('test'):
+ concretize()
+ test = ev.read('test')
+
+ assert Spec('mpileaks') in test.user_specs
+ assert Spec('callpath') in test.user_specs
+
+
def test_stack_yaml_add_to_list(tmpdir):
filename = str(tmpdir.join('spack.yaml'))
with open(filename, 'w') as f: