Skip to content

Commit 3aae056

Browse files
authored
Merge pull request #22040 from Homebrew/fix-requirement-which-override
Fix requirement which override
2 parents 8a940b2 + 0d49975 commit 3aae056

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

Library/Homebrew/requirement.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,11 @@ def infer_name
200200
""
201201
end
202202

203-
sig { params(cmd: String).returns(T.nilable(Pathname)) }
204-
def which(cmd)
205-
super(cmd, PATH.new(ORIGINAL_PATHS))
203+
sig { override.params(cmd: String, path: PATH::Elements).returns(T.nilable(Pathname)) }
204+
def which(cmd, path = PATH.new(ORIGINAL_PATHS))
205+
super
206206
end
207+
public :which
207208

208209
class << self
209210
include BuildEnvironment::DSL

Library/Homebrew/test/requirement_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,20 @@
154154
requirement.modify_build_environment
155155
end
156156
end
157+
158+
describe "#satisfy with block calling #which and :build_env set to false" do
159+
let(:klass) do
160+
Class.new(described_class) do
161+
satisfy(build_env: false) do
162+
which("sh")
163+
end
164+
end
165+
end
166+
167+
it "does not raise an error" do
168+
expect { requirement.satisfied? }.not_to raise_error
169+
end
170+
end
157171
end
158172

159173
describe "#build?" do

0 commit comments

Comments
 (0)