[前][次][番号順一覧][スレッド一覧]

ruby-changes:58749

From: Nobuyoshi <ko1@a...>
Date: Tue, 12 Nov 2019 18:05:17 +0900 (JST)
Subject: [ruby-changes:58749] 3bf8ffad71 (master): Added assertions for realpath and realdirpath

https://git.ruby-lang.org/ruby.git/commit/?id=3bf8ffad71

From 3bf8ffad714efa98949e25095f1c5e2844318958 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Tue, 12 Nov 2019 18:02:28 +0900
Subject: Added assertions for realpath and realdirpath

It is said that realpath(3) and realdirpath(3) on some platforms
may return a relative path.

diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb
index f0a8d67..f984a8f 100644
--- a/test/ruby/test_file.rb
+++ b/test/ruby/test_file.rb
@@ -252,6 +252,10 @@ class TestFile < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file.rb#L252
       tst = realdir + (File::SEPARATOR*3 + ".")
       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
         bug2961 = '[ruby-core:28653]'
         assert_equal(realdir, File.realpath(realdir.tr(File::SEPARATOR, File::ALT_SEPARATOR)), bug2961)
@@ -318,6 +322,8 @@ class TestFile < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file.rb#L322
       assert_equal(realdir, File.realdirpath(tst))
       assert_equal(realdir, File.realdirpath(".", 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
       result = File.realdirpath("bar", "//:/foo")
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]