bugfix: Add dependents when initializing spec from yaml (#15220)

The new build process, introduced in #13100 , relies on a spec's dependents in addition to their dependencies. Loading a spec from a yaml file was not initializing the dependents.

- [x] populate dependents when loading from yaml
This commit is contained in:
Tamara Dahlgren 2020-02-26 18:49:29 -08:00 committed by GitHub
parent ebd248b27e
commit ed15adbb9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 12 deletions

View File

@ -1919,9 +1919,7 @@ def from_dict(data):
yaml_deps = node[name]['dependencies'] yaml_deps = node[name]['dependencies']
for dname, dhash, dtypes in Spec.read_yaml_dep_specs(yaml_deps): for dname, dhash, dtypes in Spec.read_yaml_dep_specs(yaml_deps):
# Fill in dependencies by looking them up by name in deps dict deps[name]._add_dependency(deps[dname], dtypes)
deps[name]._dependencies[dname] = DependencySpec(
deps[name], deps[dname], dtypes)
return spec return spec

View File

@ -15,15 +15,15 @@
@pytest.fixture() @pytest.fixture()
def concretize_scope(config, tmpdir): def concretize_scope(mutable_config, tmpdir):
"""Adds a scope for concretization preferences""" """Adds a scope for concretization preferences"""
tmpdir.ensure_dir('concretize') tmpdir.ensure_dir('concretize')
config.push_scope( mutable_config.push_scope(
ConfigScope('concretize', str(tmpdir.join('concretize')))) ConfigScope('concretize', str(tmpdir.join('concretize'))))
yield yield
config.pop_scope() mutable_config.pop_scope()
spack.repo.path._provider_index = None spack.repo.path._provider_index = None
@ -84,16 +84,24 @@ def test_preferred_variants(self):
'mpileaks', debug=True, opt=True, shared=False, static=False 'mpileaks', debug=True, opt=True, shared=False, static=False
) )
def test_preferred_compilers(self, mutable_mock_repo): def test_preferred_compilers(self):
"""Test preferred compilers are applied correctly """Test preferred compilers are applied correctly
""" """
update_packages('mpileaks', 'compiler', ['clang@3.3']) # Need to make sure the test uses an available compiler
spec = concretize('mpileaks') compiler_list = spack.compilers.all_compiler_specs()
assert spec.compiler == spack.spec.CompilerSpec('clang@3.3') assert compiler_list
update_packages('mpileaks', 'compiler', ['gcc@4.5.0']) # Try the first available compiler
compiler = str(compiler_list[0])
update_packages('mpileaks', 'compiler', [compiler])
spec = concretize('mpileaks') spec = concretize('mpileaks')
assert spec.compiler == spack.spec.CompilerSpec('gcc@4.5.0') assert spec.compiler == spack.spec.CompilerSpec(compiler)
# Try the last available compiler
compiler = str(compiler_list[-1])
update_packages('mpileaks', 'compiler', [compiler])
spec = concretize('mpileaks')
assert spec.compiler == spack.spec.CompilerSpec(compiler)
def test_preferred_target(self, mutable_mock_repo): def test_preferred_target(self, mutable_mock_repo):
"""Test preferred compilers are applied correctly """Test preferred compilers are applied correctly