From 8bfc205a878fb154185e07253f539ec503fc808f Mon Sep 17 00:00:00 2001 From: Alyssa Ross <hi@alyssa.is> Date: Tue, 15 Nov 2016 17:44:02 +0000 Subject: [PATCH] tab: clear Formula.installed cache when created. 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. --- Library/Homebrew/tab.rb | 4 ++++ Library/Homebrew/test/keg_test.rb | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 1cabacefdd..6b274b1438 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_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 -- GitLab