Test of environment variables order for HOME on Windows

This commit is contained in:
Nobuyoshi Nakada 2022-12-24 11:21:28 +09:00
parent d0f5dc9eac
commit 4378de02f9
No known key found for this signature in database
GPG Key ID: 7CD2805BFA3770C6

View File

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