Formulary: use variations hash when installing from API
This commit is contained in:
parent
89cf96fffa
commit
7392f9811e
@ -136,6 +136,11 @@ module Formulary
|
||||
class_s = Formulary.class_s(name)
|
||||
json_formula = Homebrew::API::Formula.all_formulae[name]
|
||||
|
||||
bottle_tag = Utils::Bottles.tag.to_s
|
||||
if json_formula.key?("variations") && json_formula["variations"].key?(bottle_tag)
|
||||
json_formula = json_formula.merge(json_formula["variations"][bottle_tag])
|
||||
end
|
||||
|
||||
klass = Class.new(::Formula) do
|
||||
desc json_formula["desc"]
|
||||
homepage json_formula["homepage"]
|
||||
|
||||
@ -260,6 +260,16 @@ describe Formulary do
|
||||
}
|
||||
end
|
||||
|
||||
let(:variations_json) do
|
||||
{
|
||||
"variations" => {
|
||||
Utils::Bottles.tag.to_s => {
|
||||
"dependencies" => ["dep", "variations_dep"],
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
allow(described_class).to receive(:loader_for).and_return(described_class::FormulaAPILoader.new(formula_name))
|
||||
end
|
||||
@ -303,6 +313,16 @@ describe Formulary do
|
||||
formula.install
|
||||
}.to raise_error("Cannot build from source from abstract formula.")
|
||||
end
|
||||
|
||||
it "returns a Formula with variations when given a name", :needs_macos do
|
||||
allow(Homebrew::API::Formula).to receive(:all_formulae).and_return formula_json_contents(variations_json)
|
||||
allow(Utils::Bottles).to receive(:tag).and_return(:arm64_monterey)
|
||||
|
||||
formula = described_class.factory(formula_name)
|
||||
expect(formula).to be_kind_of(Formula)
|
||||
expect(formula.deps.count).to eq 5
|
||||
expect(formula.deps.map(&:name).include?("variations_dep")).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user