def test_090_non_root_ref_counts(database): database.get_record('mpileaks ^mpich') database.get_record('callpath ^mpich') # "force remove" a non-root spec from the DB database.remove('callpath ^mpich') # record still in DB but marked uninstalled assert database.query('callpath ^mpich', installed=True) == [] assert len(database.query('callpath ^mpich', installed=any)) == 1 # record and its deps have same ref_counts assert database.get_record( 'callpath ^mpich', installed=any ).ref_count == 1 assert database.get_record('mpich').ref_count == 2 # remove only dependent of uninstalled callpath record database.remove('mpileaks ^mpich') # record and parent are completely gone. assert database.query('mpileaks ^mpich', installed=any) == [] assert database.query('callpath ^mpich', installed=any) == [] # mpich ref count updated properly. mpich_rec = database.get_record('mpich') assert mpich_rec.ref_count == 0
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