diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-12-24 11:21:28 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-12-24 23:49:27 +0900 |
commit | 4378de02f9c2c494ae1302c59625e2d126b23f3e (patch) | |
tree | afdc31209a6531892fa7da7ad60d8b11d376604c | |
parent | d0f5dc9eac78ecade459b740ed08795c8df6d129 (diff) |
Test of environment variables order for HOME on Windows
-rw-r--r-- | test/ruby/test_dir.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb index c81f17e8e6..63ef99f159 100644 --- a/test/ruby/test_dir.rb +++ b/test/ruby/test_dir.rb @@ -521,6 +521,24 @@ class TestDir < Test::Unit::TestCase assert_include(Dir.glob(wild, File::FNM_SHORTNAME), long, bug10819) assert_empty(entries - Dir.glob("#{wild}/Common*", File::FNM_SHORTNAME), bug10819) end + + def test_home_windows + setup_envs(%w[HOME USERPROFILE HOMEDRIVE HOMEPATH]) + + ENV['HOME'] = "C:\\ruby\\home" + assert_equal("C:/ruby/home", Dir.home) + + ENV['USERPROFILE'] = "C:\\ruby\\userprofile" + assert_equal("C:/ruby/home", Dir.home) + ENV.delete('HOME') + assert_equal("C:/ruby/userprofile", Dir.home) + + ENV['HOMEDRIVE'] = "C:" + ENV['HOMEPATH'] = "\\ruby\\homepath" + assert_equal("C:/ruby/userprofile", Dir.home) + ENV.delete('USERPROFILE') + assert_equal("C:/ruby/homepath", Dir.home) + end end def test_home |