Set --formula by default on linux

This commit is contained in:
apainintheneck 2022-10-01 17:28:07 -07:00
parent 020c50e588
commit 5d27b70757
5 changed files with 24 additions and 7 deletions

View File

@ -96,6 +96,7 @@ module Homebrew
end
def only_formula_or_cask
return :formula if OS.linux? && !Homebrew::EnvConfig.developer?
return :formula if formula? && !cask?
return :cask if cask? && !formula?
end

View File

@ -118,6 +118,12 @@ describe Homebrew::CLI::NamedArgs do
expect { described_class.new("foo").to_formulae_and_casks }.to raise_error(FormulaOrCaskUnavailableError)
end
it "raises an error when formula is absent and cask is available on linux", :needs_linux do
stub_cask_loader foo_cask
expect { described_class.new("foo").to_formulae_and_casks }.to raise_error(FormulaOrCaskUnavailableError)
end
it "returns formula when formula is present and cask is unreadable" do
stub_formula_loader foo
setup_unredable_cask "foo"
@ -126,7 +132,7 @@ describe Homebrew::CLI::NamedArgs do
expect { described_class.new("foo").to_formulae_and_casks }.to output(/Failed to load cask: foo/).to_stderr
end
it "returns cask when formula is unreadable and cask is present" do
it "returns cask when formula is unreadable and cask is present", :dev_on_linux do
setup_unredable_formula "foo"
stub_cask_loader foo_cask
@ -156,7 +162,7 @@ describe Homebrew::CLI::NamedArgs do
end
describe "#to_resolved_formulae_to_casks" do
it "returns resolved formulae, as well as casks" do
it "returns resolved formulae, as well as casks", :dev_on_linux do
allow(Formulary).to receive(:resolve).and_call_original
allow(Formulary).to receive(:resolve).with("foo", any_args).and_return foo
stub_cask_loader baz, call_original: true
@ -245,7 +251,7 @@ describe Homebrew::CLI::NamedArgs do
(HOMEBREW_CELLAR/"foo/1.0").mkpath
end
it "returns kegs, as well as casks" do
it "returns kegs, as well as casks", :dev_on_linux do
stub_cask_loader baz, call_original: true
kegs, casks = described_class.new("foo", "baz").to_kegs_to_casks
@ -279,7 +285,7 @@ describe Homebrew::CLI::NamedArgs do
allow(Cask::CaskLoader).to receive(:path).and_call_original
end
it "returns taps, cask formula and existing paths" do
it "returns taps, cask formula and existing paths", :dev_on_linux do
expect(Formulary).to receive(:path).with("foo").and_return(formula_path)
expect(Cask::CaskLoader).to receive(:path).with("baz").and_return(cask_path)
@ -287,7 +293,7 @@ describe Homebrew::CLI::NamedArgs do
.to eq [Tap.fetch("homebrew/core").path, formula_path, cask_path, existing_path]
end
it "returns both cask and formula paths if they exist" do
it "returns both cask and formula paths if they exist", :dev_on_linux do
expect(Formulary).to receive(:path).with("foo").and_return(formula_path)
expect(Cask::CaskLoader).to receive(:path).with("baz").and_return(cask_path)
@ -305,6 +311,12 @@ describe Homebrew::CLI::NamedArgs do
expect(described_class.new("foo", "baz").to_paths(only: :cask)).to eq [cask_path, Cask::CaskLoader.path("baz")]
end
it "returns only formulae by default on linux", :needs_linux do
expect(Formulary).to receive(:path).with("foo").and_return(formula_path)
expect(described_class.new("foo", "baz").to_paths).to eq [formula_path, Formulary.path("baz")]
end
end
describe "#to_taps" do

View File

@ -28,7 +28,7 @@ describe "brew --cache" do
.and be_a_success
end
it "prints the cache files for a given Formula and Cask", :integration_test do
it "prints the cache files for a given Formula and Cask", :integration_test, :dev_on_linux do
expect { brew "--cache", testball, cask_path("local-caffeine") }
.to output(
%r{

View File

@ -45,7 +45,7 @@ describe "brew home" do
.and be_a_success
end
it "opens the homepages for a given formula and Cask", :integration_test do
it "opens the homepages for a given formula and Cask", :integration_test, :dev_on_linux do
setup_test_formula "testballhome"
expect { brew "home", "testballhome", local_caffeine_path, "HOMEBREW_BROWSER" => "echo" }

View File

@ -180,6 +180,10 @@ RSpec.configure do |config|
skip "Unzip is not installed." unless which("unzip")
end
config.before(:each, :dev_on_linux) do
Allow(Homebrew::EnvConfig).to receive(:developer?).and_return(true) if OS.linux?
end
config.around do |example|
def find_files
return [] unless File.exist?(TEST_TMPDIR)