test_utils: add test_which_all

This commit is contained in:
Xu Cheng 2016-01-02 23:16:08 +08:00
parent 66c0b06d72
commit 17a57f529b

View File

@ -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