From b08d457dfda4e03c16cde1a1ea28a614b1e3a10e Mon Sep 17 00:00:00 2001 From: scheibelp Date: Fri, 6 Oct 2017 14:23:28 -0700 Subject: Don't check package.installed in _mark_concrete if value=True (#5634) * spec and spec.package.spec can refer to different objects in the database. When these two instances of spec differ in terms of the value of the 'concrete' property, Spec._mark_concrete can fail when checking Spec.package.installed (which requires package.spec to be concrete). This skips the check for spec.package.installed when _mark_concrete is called with 'True' (in other words, when the database is marking all specs as being concrete). * add test to confirm this fixes #5293 --- lib/spack/spack/spec.py | 2 +- lib/spack/spack/test/database.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 24da1af564..ea00e1723d 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -1888,7 +1888,7 @@ class Spec(object): unless there is a need to force a spec to be concrete. """ for s in self.traverse(deptype_query=all): - if s.concrete and s.package.installed: + if (not value) and s.concrete and s.package.installed: continue s._normal = value s._concrete = value diff --git a/lib/spack/spack/test/database.py b/lib/spack/spack/test/database.py index 131730e40f..bc7354a4b4 100644 --- a/lib/spack/spack/test/database.py +++ b/lib/spack/spack/test/database.py @@ -32,6 +32,7 @@ import os.path import pytest import spack import spack.store +from spack.test.conftest import MockPackageMultiRepo from spack.util.executable import Executable from llnl.util.tty.colify import colify @@ -380,6 +381,22 @@ def test_110_no_write_with_exception_on_install(database): assert install_db.query('cmake', installed=any) == [] +def test_115_reindex_with_packages_not_in_repo(database, refresh_db_on_exit): + install_db = database.mock.db + + saved_repo = spack.repo + # Dont add any package definitions to this repository, the idea is that + # packages should not have to be defined in the repository once they are + # installed + mock_repo = MockPackageMultiRepo([]) + try: + spack.repo = mock_repo + spack.store.db.reindex(spack.store.layout) + _check_db_sanity(install_db) + finally: + spack.repo = saved_repo + + def test_external_entries_in_db(database): install_db = database.mock.db -- cgit v1.2.3-60-g2f50