Clear all tap caches before each test.

This commit is contained in:
Markus Reiter 2024-02-20 15:11:15 +01:00
parent ab27efbd9d
commit 9cfc7ef9bd
No known key found for this signature in database
GPG Key ID: 245293B51702655B
4 changed files with 7 additions and 9 deletions

View File

@ -1,13 +1,13 @@
# frozen_string_literal: true
RSpec.describe Cask::CaskLoader::FromTapLoader do
let(:tap) { CoreCaskTap.instance }
let(:cask_name) { "testball" }
let(:cask_full_name) { "homebrew/cask/#{cask_name}" }
let(:cask_path) { CoreCaskTap.instance.cask_dir/"#{cask_name}.rb" }
let(:cask_path) { tap.cask_dir/"#{cask_name}.rb" }
describe "#load" do
before do
CoreCaskTap.instance.clear_cache
cask_path.parent.mkpath
cask_path.write <<~RUBY
cask '#{cask_name}' do
@ -25,7 +25,7 @@ RSpec.describe Cask::CaskLoader::FromTapLoader do
end
context "with sharded Cask directory" do
let(:cask_path) { CoreCaskTap.instance.cask_dir/cask_name[0]/"#{cask_name}.rb" }
let(:cask_path) { tap.cask_dir/cask_name[0]/"#{cask_name}.rb" }
it "returns a Cask" do
expect(described_class.new(cask_full_name).load(config: nil)).to be_a(Cask::Cask)

View File

@ -84,8 +84,6 @@ RSpec.describe Cask::CaskLoader, :cask do
before do
(old_tap.path/"tap_migrations.json").write tap_migrations.to_json
old_tap.clear_cache
default_tap.clear_cache
end
it "does not warn when loading the short token" do
@ -112,7 +110,6 @@ RSpec.describe Cask::CaskLoader, :cask do
# (default_tap.path/"tap_migrations.json").write({
# token => old_tap.name,
# }.to_json)
# default_tap.clear_cache
# end
#
# it "stops recursing" do

View File

@ -547,8 +547,6 @@ RSpec.describe Formulary do
before do
old_tap.path.mkpath
(old_tap.path/"tap_migrations.json").write tap_migrations.to_json
old_tap.clear_cache
default_tap.clear_cache
end
it "does not warn when loading the short token" do
@ -575,7 +573,6 @@ RSpec.describe Formulary do
# (default_tap.path/"tap_migrations.json").write({
# token => old_tap.name,
# }.to_json)
# default_tap.clear_cache
# end
#
# it "stops recursing" do

View File

@ -203,6 +203,7 @@ RSpec.configure do |config|
Homebrew.raise_deprecation_exceptions = true
Formulary.clear_cache
Tap.each(&:clear_cache)
Tap.clear_cache
DependencyCollector.clear_cache
Formula.clear_cache
@ -249,6 +250,9 @@ RSpec.configure do |config|
rescue SystemExit => e
example.example.set_exception(e)
ensure
# This depends on `HOMEBREW_NO_INSTALL_FROM_API`.
Tap.each(&:clear_cache)
ENV.replace(@__env)
Context.current = Context::ContextStruct.new