This will allow us to have global setup and teardown for tests.
For example, we can automatically clear caches after each test, to avoid
annoying intermittent failures like #1879 and #1886.
In #1497 I switched from Keg#to_formula for comparing kegs to formulae
to comparing the name and tap in the keg's tab to the name and tap of
the formula.
However, this fails to match if the name and tap of the formula have
changed since the keg was installed, so it's clearly better to use
Keg#to_formula where possible, and fall back to the information in the
tab when #to_formula can't be used.
This is a proper fix to the problem addressed by #1510.
The problem arises when f_kegs is nil, which can happen if the name and
tap used to install a keg don't match the name and tap currently
associated with its formula (i.e. if it's been renamed or moved).
Because of an accidental use of `=` instead of `==`, the source formula
check would be skipped when determining if a keg depended on another one
(so only the versions would be compared).
Fixed that comparison, and updated the corresponding test.
Glad I caught that!
Previously, trying to resolve the dependencies of a keg would raise an
exception if the formulae for any of the dependencies could not be found
(e.g. if it had been moved to another tap).
This commit updates the dependency finding logic to catch these
exceptions, and fall back to comparing names and taps of formulae, which
should give the correct behaviour.
Fixes#1586.
This was causing the flaky tests that #1508 started skipping.
This is the second time that `Formula.installed`'s cache has bitten
me with intermittent test failures, and I'd like it to be the last,
so I've made it so the cache is cleared automatically when a tab is
created. This _should_ mean that the cache is cleared any time it
needs to be, with the exception of when a Keg is created artificially
with no tab. I don't think there's anything I can do to automatically
handle that use-case, though.