aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlyssa Ross2016-11-15 17:44:02 +0000
committerAlyssa Ross2016-11-17 14:26:00 +0000
commit8bfc205a878fb154185e07253f539ec503fc808f (patch)
tree65a80ece45bd74a50635123a5682e1d439fe15dc
parente6933b90dc750dc9aadb3bfb6acf1bf395942d57 (diff)
downloadbrew-8bfc205a878fb154185e07253f539ec503fc808f.tar.bz2
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.
-rw-r--r--Library/Homebrew/tab.rb4
-rw-r--r--Library/Homebrew/test/keg_test.rb1
2 files changed, 4 insertions, 1 deletions
diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb
index 1cabacefd..6b274b143 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 fdc739c9d..2c91027e5 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