Merge pull request #17212 from Homebrew/skip-tests-that-require-core-if-not-tapped

dev-cmd/tests: skip tests that require core if it's not tapped
This commit is contained in:
Mike McQuaid 2024-05-03 09:20:23 +01:00 committed by GitHub
commit e944830b1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 2 deletions

View File

@ -13,7 +13,7 @@ RSpec.describe Homebrew::Cmd::Prefix do
.and be_a_success .and be_a_success
end end
it "prints the prefix for a Formula", :integration_test do it "prints the prefix for a Formula", :integration_test, :needs_homebrew_core do
expect { brew_sh "--prefix", "wget" } expect { brew_sh "--prefix", "wget" }
.to output("#{ENV.fetch("HOMEBREW_PREFIX")}/opt/wget\n").to_stdout .to output("#{ENV.fetch("HOMEBREW_PREFIX")}/opt/wget\n").to_stdout
.and not_to_output.to_stderr .and not_to_output.to_stderr

View File

@ -160,6 +160,11 @@ RSpec.configure do |config|
skip "Requires network connection." unless ENV["HOMEBREW_TEST_ONLINE"] skip "Requires network connection." unless ENV["HOMEBREW_TEST_ONLINE"]
end end
config.before(:each, :needs_homebrew_core) do
core_tap_path = "#{ENV.fetch("HOMEBREW_LIBRARY")}/Taps/homebrew/homebrew-core"
skip "Requires homebrew/core to be tapped." unless Dir.exist?(core_tap_path)
end
config.before do |example| config.before do |example|
next if example.metadata.key?(:needs_network) next if example.metadata.key?(:needs_network)
next if example.metadata.key?(:needs_utils_curl) next if example.metadata.key?(:needs_utils_curl)

View File

@ -2,7 +2,7 @@
RSpec.shared_examples "formulae exist" do |array| RSpec.shared_examples "formulae exist" do |array|
array.each do |f| array.each do |f|
it "#{f} formula exists" do it "#{f} formula exists", :needs_homebrew_core do
core_tap = Pathname("#{HOMEBREW_LIBRARY_PATH}/../Taps/homebrew/homebrew-core") core_tap = Pathname("#{HOMEBREW_LIBRARY_PATH}/../Taps/homebrew/homebrew-core")
formula_paths = core_tap.glob("Formula/**/#{f}.rb") formula_paths = core_tap.glob("Formula/**/#{f}.rb")
alias_path = core_tap/"Aliases/#{f}" alias_path = core_tap/"Aliases/#{f}"