diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 5ffe433746..7fe00cb45a 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1337,10 +1337,14 @@ class Formula end end - # Clear caches of .racks and .installed. - # @private - def self.clear_cache + # Clear cache of .racks + def self.clear_racks_cache @racks = nil + end + + # Clear caches of .racks and .installed. + def self.clear_installed_formulae_cache + clear_racks_cache @installed = nil end diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 1cabacefdd..3bb7d8b624 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -317,6 +317,10 @@ class Tab < OpenStruct end def write + # If this is a new installation, the cache of installed formulae + # will no longer be valid. + Formula.clear_installed_formulae_cache unless tabfile.exist? + CACHE[tabfile] = self tabfile.atomic_write(to_json) end diff --git a/Library/Homebrew/test/keg_test.rb b/Library/Homebrew/test/keg_test.rb index fdc739c9d8..2c91027e5b 100644 --- a/Library/Homebrew/test/keg_test.rb +++ b/Library/Homebrew/test/keg_test.rb @@ -327,7 +327,6 @@ class InstalledDependantsTests < LinkTests f = stub_formula_name(name) keg = super Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write - Formula.clear_cache keg end diff --git a/Library/Homebrew/test/uninstall_test.rb b/Library/Homebrew/test/uninstall_test.rb index 70a6943531..06b067886b 100644 --- a/Library/Homebrew/test/uninstall_test.rb +++ b/Library/Homebrew/test/uninstall_test.rb @@ -34,13 +34,11 @@ class UninstallTests < Homebrew::TestCase end def test_check_for_testball_f2s_when_developer - skip "Flaky test" assert_match "Warning", handle_unsatisfied_dependents refute_predicate Homebrew, :failed? end def test_check_for_dependents_when_not_developer - skip "Flaky test" run_as_not_developer do assert_match "Error", handle_unsatisfied_dependents assert_predicate Homebrew, :failed?