From 21efd0803cc1eae9912fdd12bd5ed440959c75ff Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Tue, 22 Jan 2013 14:33:33 -0600 Subject: Infer path to be added for requirements that search PATH When a requirement is specified like: satisfy { which "foo" } There is no reason that we should inject all of ENV.userpaths! into the build environment. Instead, infer the directory to be added to PATH from the Pathname that is returned. This is another step towards condensing the "which program" requirements down into a one-liner DSL element. --- Library/Homebrew/test/test_requirement.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'Library/Homebrew/test') diff --git a/Library/Homebrew/test/test_requirement.rb b/Library/Homebrew/test/test_requirement.rb index 0319e9e25..e8803ed92 100644 --- a/Library/Homebrew/test/test_requirement.rb +++ b/Library/Homebrew/test/test_requirement.rb @@ -74,4 +74,17 @@ class RequirementTests < Test::Unit::TestCase assert req.satisfied? end + + def test_infers_path_from_satisfy_result + which_path = Pathname.new("/foo/bar/baz") + req = Class.new(Requirement) do + satisfy { which_path } + end.new + + ENV.expects(:with_build_environment).yields.returns(which_path) + ENV.expects(:userpaths!) + ENV.expects(:append).with("PATH", which_path.parent, ":") + + req.modify_build_environment + end end -- cgit v1.2.3