test_file_exhaustive.rb: others home
* test/ruby/test_file_exhaustive.rb (test_expand_path_home_dir_string): add assertions for other user's home directory path. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3176b04d22
commit
c0035ed351
@ -475,10 +475,12 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||||||
ENV["HOME"] = home
|
ENV["HOME"] = home
|
||||||
end
|
end
|
||||||
|
|
||||||
|
UnknownUserHome = "~foo_bar_baz_unknown_user_wahaha".freeze
|
||||||
|
|
||||||
def test_expand_path_home
|
def test_expand_path_home
|
||||||
assert_kind_of(String, File.expand_path("~")) if ENV["HOME"]
|
assert_kind_of(String, File.expand_path("~")) if ENV["HOME"]
|
||||||
assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha") }
|
assert_raise(ArgumentError) { File.expand_path(UnknownUserHome) }
|
||||||
assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha", "/") }
|
assert_raise(ArgumentError) { File.expand_path(UnknownUserHome, "/") }
|
||||||
begin
|
begin
|
||||||
bug3630 = '[ruby-core:31537]'
|
bug3630 = '[ruby-core:31537]'
|
||||||
home = ENV["HOME"]
|
home = ENV["HOME"]
|
||||||
@ -510,6 +512,9 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||||||
|
|
||||||
assert_equal File.join(new_home, "foo"), File.expand_path("foo", "~"), bug8034
|
assert_equal File.join(new_home, "foo"), File.expand_path("foo", "~"), bug8034
|
||||||
assert_equal File.join(new_home, "bar", "foo"), File.expand_path("foo", "~/bar"), bug8034
|
assert_equal File.join(new_home, "bar", "foo"), File.expand_path("foo", "~/bar"), bug8034
|
||||||
|
|
||||||
|
assert_raise(ArgumentError) { File.expand_path(".", UnknownUserHome) }
|
||||||
|
assert_nothing_raised(ArgumentError) { File.expand_path("/", UnknownUserHome) }
|
||||||
ensure
|
ensure
|
||||||
ENV["HOME"] = home
|
ENV["HOME"] = home
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user