def _check_remove_and_add_package(database, spec): """Remove a spec from the DB, then add it and make sure everything's still ok once it is added. This checks that it was removed, that it's back when added again, and that ref counts are consistent. """ original = database.query() database._check_ref_counts() # Remove spec concrete_spec = database.remove(spec) database._check_ref_counts() remaining = database.query() # ensure spec we removed is gone assert len(original) - 1 == len(remaining) assert all(s in original for s in remaining) assert concrete_spec not in remaining # add it back and make sure everything is ok. database.add(concrete_spec, spack.store.layout) installed = database.query() assert concrete_spec in installed assert installed == original # sanity check against direcory layout and check ref counts. _check_db_sanity(database) database._check_ref_counts()
def test_080_root_ref_counts(database): rec = database.get_record('mpileaks ^mpich') # Remove a top-level spec from the DB database.remove('mpileaks ^mpich') # record no longer in DB assert database.query('mpileaks ^mpich', installed=any) == [] # record's deps have updated ref_counts assert database.get_record('callpath ^mpich').ref_count == 0 assert database.get_record('mpich').ref_count == 1 # Put the spec back database.add(rec.spec, spack.store.layout) # record is present again assert len(database.query('mpileaks ^mpich', installed=any)) == 1 # dependencies have ref counts updated assert database.get_record('callpath ^mpich').ref_count == 1 assert database.get_record('mpich').ref_count == 2