Add tests for spack external dependencies, plus fixes for issues found by those tests.

This commit is contained in:
Matthew LeGendre
2015-10-05 11:30:48 -07:00
parent e4d2ba30b5
commit 18f0b24a7f
8 changed files with 191 additions and 5 deletions

View File

@@ -85,8 +85,8 @@ def _valid_virtuals_and_externals(self, spec):
provider_cmp = partial(spack.pkgsort.provider_compare, spec_w_preferred_providers.name, spec.name)
packages = sorted(providers, cmp=provider_cmp)
else:
if not spec_externals(spec) or spec.external:
return None
if spec.external:
return False
packages = [spec]
# For each candidate package, if it has externals add those to the candidates
@@ -129,7 +129,7 @@ def concretize_virtual_and_external(self, spec):
#Try a looser ABI matching
candidate = next((c for c in candidates if spack.abi.compatible(c[0], other_spec, loose=True)), None)
if not candidate:
#Pick the first choice
#No ABI matches. Pick the top choice based on the orignal preferences.
candidate = candidates[0]
external = candidate[1]
candidate_spec = candidate[0]
@@ -144,10 +144,11 @@ def concretize_virtual_and_external(self, spec):
if not spec.external and external:
spec.external = external
changed = True
#If we're external then trim the dependencies
if external and spec.dependencies:
changed = True
spec.depencencies = DependencyMap()
spec.dependencies = DependencyMap()
return changed

View File

@@ -1022,7 +1022,7 @@ def _normalize_helper(self, visited, spec_deps, provider_index):
# if we descend into a virtual spec, there's nothing more
# to normalize. Concretize will finish resolving it later.
if self.virtual:
if self.virtual or self.external:
return False
# Combine constraints from package deps with constraints from

View File

@@ -192,3 +192,31 @@ def test_compiler_inheritance(self):
# TODO: not exactly the syntax I would like.
self.assertTrue(spec['libdwarf'].compiler.satisfies('clang'))
self.assertTrue(spec['libelf'].compiler.satisfies('clang'))
def test_external_package(self):
spec = Spec('externaltool')
spec.concretize()
self.assertEqual(spec['externaltool'].external, '/path/to/external_tool')
self.assertFalse('externalprereq' in spec)
self.assertTrue(spec['externaltool'].compiler.satisfies('gcc'))
def test_nobuild_package(self):
got_error = False
spec = Spec('externaltool%clang')
try:
spec.concretize()
except spack.concretize.NoBuildError:
got_error = True
self.assertTrue(got_error)
def test_external_and_virtual(self):
spec = Spec('externaltest')
spec.concretize()
self.assertTrue(spec['externaltool'].external, '/path/to/external_tool')
self.assertTrue(spec['stuff'].external, '/path/to/external_virtual_gcc')
self.assertTrue(spec['externaltool'].compiler.satisfies('gcc'))
self.assertTrue(spec['stuff'].compiler.satisfies('gcc'))