Skip to content

Commit

Permalink
dev-cmd/tests: skip tests that require core if it's not tapped
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
apainintheneck committed May 3, 2024
1 parent c09ef9a commit 56ecd42
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cmd/--prefix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Library/Homebrew/test/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit 56ecd42

Please sign in to comment.