aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorXu Cheng2016-01-02 23:16:08 +0800
committerXu Cheng2016-01-03 21:00:11 +0800
commit17a57f529b4df5f4de6a2e8d41394422290c4522 (patch)
treece8a3015efdbe47f19487ae9f99b2e7290d9a4f5 /Library
parent66c0b06d72bb55e1ac288a69336ae858095e5c32 (diff)
downloadbrew-17a57f529b4df5f4de6a2e8d41394422290c4522.tar.bz2
test_utils: add test_which_all
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/test_utils.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_utils.rb b/Library/Homebrew/test/test_utils.rb
index fe6bab2b9..a64e81fa2 100644
--- a/Library/Homebrew/test/test_utils.rb
+++ b/Library/Homebrew/test/test_utils.rb
@@ -42,6 +42,20 @@ class UtilTests < Homebrew::TestCase
which(File.basename(cmd), "~~#{File::PATH_SEPARATOR}#{File.dirname(cmd)}")
end
+ def test_which_all
+ (@dir/"bar/baz").mkpath
+ cmd1 = @dir/"foo"
+ cmd2 = @dir/"bar/foo"
+ cmd3 = @dir/"bar/baz/foo"
+ FileUtils.touch cmd2
+ [cmd1, cmd3].each do |cmd|
+ FileUtils.touch cmd
+ cmd.chmod 0744
+ end
+ assert_equal [cmd3, cmd1],
+ which_all("foo", "#{@dir}/bar/baz:#{@dir}/baz:#{@dir}:~baduserpath")
+ end
+
def test_popen_read
out = Utils.popen_read("/bin/sh", "-c", "echo success").chomp
assert_equal "success", out