From 56ecd42ebd9c8c5d5a7fd882dc1fd3bf9bb7b503 Mon Sep 17 00:00:00 2001 From: apainintheneck Date: Fri, 3 May 2024 00:32:50 -0700 Subject: [PATCH] dev-cmd/tests: skip tests that require core if it's not tapped There were a few tests which require core to be tapped and fail if it isn't. This is annoying if someone is trying to contribute to the project and they're using the JSON API instead of having the core repo tapped locally. I'm just skipping these because it's the simplest thing to do. The tests that failed are mostly rubocop tests so it's fine if they only run on CI. --- Library/Homebrew/test/cmd/--prefix_spec.rb | 2 +- Library/Homebrew/test/spec_helper.rb | 5 +++++ .../support/helper/spec/shared_examples/formulae_exist.rb | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/test/cmd/--prefix_spec.rb b/Library/Homebrew/test/cmd/--prefix_spec.rb index 9ee10f6bef004..48efc0f51b070 100644 --- a/Library/Homebrew/test/cmd/--prefix_spec.rb +++ b/Library/Homebrew/test/cmd/--prefix_spec.rb @@ -13,7 +13,7 @@ .and be_a_success 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" } .to output("#{ENV.fetch("HOMEBREW_PREFIX")}/opt/wget\n").to_stdout .and not_to_output.to_stderr diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index 2dd6dc134d4b6..4287f45a1c340 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -160,6 +160,11 @@ skip "Requires network connection." unless ENV["HOMEBREW_TEST_ONLINE"] 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| next if example.metadata.key?(:needs_network) next if example.metadata.key?(:needs_utils_curl) diff --git a/Library/Homebrew/test/support/helper/spec/shared_examples/formulae_exist.rb b/Library/Homebrew/test/support/helper/spec/shared_examples/formulae_exist.rb index 8b39d54fc81ac..184c34b541a6e 100644 --- a/Library/Homebrew/test/support/helper/spec/shared_examples/formulae_exist.rb +++ b/Library/Homebrew/test/support/helper/spec/shared_examples/formulae_exist.rb @@ -2,7 +2,7 @@ RSpec.shared_examples "formulae exist" do |array| 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") formula_paths = core_tap.glob("Formula/**/#{f}.rb") alias_path = core_tap/"Aliases/#{f}"