diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-25 04:06:50 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-25 04:06:50 +0000 |
commit | 7ec4a44762e63b75120ecc5154a00828c8f31b01 (patch) | |
tree | 3121babc149fe568f45db08661b1ee56e11d659c /test/ruby/test_dir.rb | |
parent | dda113e3ff954064f718c73a114bb01361b5d205 (diff) | |
download | ruby-7ec4a44762e63b75120ecc5154a00828c8f31b01.tar.gz |
file.c: split rb_home_dir
* dir.c (dir_s_home): use rb_home_dir_of and rb_default_home_dir.
* file.c (rb_home_dir_of): split from rb_home_dir() for the home
directry of the given user, and the user name is a VALUE, not a bare
pointer. should raise if the user does not exist.
* file.c (rb_default_home_dir): split from rb_home_dir() for the home
directry of the current user.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_dir.rb')
-rw-r--r-- | test/ruby/test_dir.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb index d8e94727cd..91fbf35c45 100644 --- a/test/ruby/test_dir.rb +++ b/test/ruby/test_dir.rb @@ -217,4 +217,26 @@ class TestDir < Test::Unit::TestCase bug8597 = '[ruby-core:55764] [Bug #8597]' assert_empty(Dir.glob(File.join(@root, "<")), bug8597) end + + def test_home + env_home = ENV["HOME"] + env_logdir = ENV["LOGDIR"] + ENV.delete("HOME") + ENV.delete("LOGDIR") + + assert_raise(ArgumentError) { Dir.home } + assert_raise(ArgumentError) { Dir.home("") } + ENV["HOME"] = @nodir + assert_nothing_raised(ArgumentError) { + assert_equal(@nodir, Dir.home) + assert_equal(@nodir, Dir.home("")) + } + %W[no:such:user \u{7559 5b88}:\u{756a}].each do |user| + assert_raise_with_message(ArgumentError, /#{user}/) {Dir.home(user)} + end + ensure + ENV["HOME"] = env_home + ENV["LOGDIR"] = env_logdir + end + end |