From 8bfc205a878fb154185e07253f539ec503fc808f Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 15 Nov 2016 17:44:02 +0000 Subject: 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(-) (limited to 'Library') 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 -- cgit v1.2.3 From 5baf16f50e71cd8224dad58350e67fceb56942a1 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 15 Nov 2016 17:54:13 +0000 Subject: Revert "uninstall: skip some flaky tests for now." This reverts commit 50c964df2ebda125366a94f0e8701eaeb0d98fa7. --- Library/Homebrew/test/uninstall_test.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/test/uninstall_test.rb b/Library/Homebrew/test/uninstall_test.rb index 70a694353..06b067886 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? -- cgit v1.2.3 From 3555206a7fe83adb5fe6f48f5e2e20400e8a6ae8 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 17 Nov 2016 14:34:04 +0000 Subject: formula: make cache clearing methods, *ahem*, clearer --- Library/Homebrew/formula.rb | 10 +++++++--- Library/Homebrew/tab.rb | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 5434d87c2..84c2fb7a7 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 6b274b143..3bb7d8b62 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -319,7 +319,7 @@ class Tab < OpenStruct def write # If this is a new installation, the cache of installed formulae # will no longer be valid. - Formula.clear_cache unless tabfile.exist? + Formula.clear_installed_formulae_cache unless tabfile.exist? CACHE[tabfile] = self tabfile.atomic_write(to_json) -- cgit v1.2.3