Added assertions for realpath and realdirpath

It is said that realpath(3) and realdirpath(3) on some platforms
may return a relative path.
This commit is contained in:
Nobuyoshi Nakada 2019-11-12 18:02:28 +09:00
Родитель 0f2837847d
Коммит 3bf8ffad71
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4BC7D6DF58D8DF60
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -252,6 +252,10 @@ class TestFile < Test::Unit::TestCase
tst = realdir + (File::SEPARATOR*3 + ".") tst = realdir + (File::SEPARATOR*3 + ".")
assert_equal(realdir, File.realpath(tst)) assert_equal(realdir, File.realpath(tst))
assert_equal(realdir, File.realpath(".", tst)) assert_equal(realdir, File.realpath(".", tst))
assert_equal(realdir, Dir.chdir(realdir) {File.realpath(".")})
realpath = File.join(realdir, "test")
File.write(realpath, "")
assert_equal(realpath, Dir.chdir(realdir) {File.realpath("test")})
if File::ALT_SEPARATOR if File::ALT_SEPARATOR
bug2961 = '[ruby-core:28653]' bug2961 = '[ruby-core:28653]'
assert_equal(realdir, File.realpath(realdir.tr(File::SEPARATOR, File::ALT_SEPARATOR)), bug2961) assert_equal(realdir, File.realpath(realdir.tr(File::SEPARATOR, File::ALT_SEPARATOR)), bug2961)
@ -318,6 +322,8 @@ class TestFile < Test::Unit::TestCase
assert_equal(realdir, File.realdirpath(tst)) assert_equal(realdir, File.realdirpath(tst))
assert_equal(realdir, File.realdirpath(".", tst)) assert_equal(realdir, File.realdirpath(".", tst))
assert_equal(File.join(realdir, "foo"), File.realdirpath("foo", tst)) assert_equal(File.join(realdir, "foo"), File.realdirpath("foo", tst))
assert_equal(realdir, Dir.chdir(realdir) {File.realdirpath(".")})
assert_equal(File.join(realdir, "foo"), Dir.chdir(realdir) {File.realdirpath("foo")})
} }
begin begin
result = File.realdirpath("bar", "//:/foo") result = File.realdirpath("bar", "//:/foo")