stacks: fix reference handling in env.write() (#12096)
* stacks: Fix env.write to properly write references * stacks: regression test for 12095
This commit is contained in:
parent
d488d04ed3
commit
3b4d6ddc03
@ -1235,9 +1235,11 @@ def write(self):
|
||||
# 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
|
||||
|
@ -965,6 +965,29 @@ def test_stack_yaml_definitions(tmpdir):
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user