diff options
-rw-r--r-- | lib/spack/spack/solver/asp.py | 6 | ||||
-rw-r--r-- | lib/spack/spack/test/concretize.py | 38 |
2 files changed, 44 insertions, 0 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index 7b082382db..6ec041e89b 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -1659,6 +1659,12 @@ class SpackSolverSetup(object): # be dependencies (don't tell it about the others) h = spec.dag_hash() if spec.name in possible and h not in self.seen_hashes: + try: + # Only consider installed packages for repo we know + spack.repo.path.repo_for_pkg(spec) + except spack.repo.UnknownNamespaceError: + return + # this indicates that there is a spec like this installed self.gen.fact(fn.installed_hash(spec.name, h)) diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index 32b94257bc..984f3e9b01 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -204,6 +204,28 @@ class Changing(Package): return _changing_pkg +@pytest.fixture() +def additional_repo_with_c(tmpdir_factory, mutable_mock_repo): + """Add a repository with a simple package""" + repo_dir = tmpdir_factory.mktemp('myrepo') + repo_dir.join('repo.yaml').write(""" +repo: + namespace: myrepo +""", ensure=True) + packages_dir = repo_dir.ensure('packages', dir=True) + package_py = """ +class C(Package): + homepage = "http://www.example.com" + url = "http://www.example.com/root-1.0.tar.gz" + + version(1.0, sha256='abcde') +""" + packages_dir.join('c', 'package.py').write(package_py, ensure=True) + repo = spack.repo.Repo(str(repo_dir)) + mutable_mock_repo.put_first(repo) + return repo + + # This must use the mutable_config fixture because the test # adjusting_default_target_based_on_compiler uses the current_host fixture, # which changes the config. @@ -1607,3 +1629,19 @@ class TestConcretize(object): new_root = Spec('root').concretized() assert not new_root['changing'].satisfies('@1.0') + + @pytest.mark.regression('28259') + def test_reuse_with_unknown_namespace_dont_raise( + self, additional_repo_with_c, mutable_mock_repo + ): + s = Spec('c').concretized() + assert s.namespace == 'myrepo' + s.package.do_install(fake=True, explicit=True) + + # TODO: To mock repo removal we need to recreate the RepoPath + mutable_mock_repo.remove(additional_repo_with_c) + spack.repo.path = spack.repo.RepoPath(*spack.repo.path.repos) + + with spack.config.override("concretizer:reuse", True): + s = Spec('c').concretized() + assert s.namespace == 'builtin.mock' |