diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-07 04:55:34 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-07 04:55:34 +0000 |
commit | 785b31bed4fbe10dd8fe92a7ef52782d2d1d1123 (patch) | |
tree | e72e793ea4c5bc6bbc4e8dfb4d56c32ac45a5b4d /test/pathname | |
parent | 8a144fdedc2df7ee87e21ad805fcbcbd18209533 (diff) |
* file.c: add optional basedir argument for realpath/realdirpath.
(realpath_internal): handle basedir.
(rb_file_s_realpath): extract basedir from argument list.
(rb_file_s_realdirpath): extract basedir from argument list.
* lib/pathname.rb (realpath): pass basedir.
(realdirpath): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/pathname')
-rw-r--r-- | test/pathname/test_pathname.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index a9f7149633..5dfd9c6e31 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -288,8 +288,8 @@ class TestPathname < Test::Unit::TestCase return true end - def realpath(path) - Pathname.new(path).realpath.to_s + def realpath(path, basedir=nil) + Pathname.new(path).realpath(basedir).to_s end def test_realpath @@ -301,6 +301,7 @@ class TestPathname < Test::Unit::TestCase File.symlink("loop", "#{dir}/loop") assert_raise(Errno::ELOOP) { realpath("#{dir}/loop") } + assert_raise(Errno::ELOOP) { realpath("#{dir}/loop", dir) } File.symlink("../#{File.basename(dir)}/./not-exist-target", "#{dir}/not-exist2") assert_raise(Errno::ENOENT) { realpath("#{dir}/not-exist2") } @@ -314,6 +315,7 @@ class TestPathname < Test::Unit::TestCase Dir.mkdir("exist") assert_equal("#{dir}/exist", realpath("exist")) + assert_raise(Errno::ELOOP) { realpath("../loop", "#{dir}/exist") } File.symlink("loop1/loop1", "loop1") assert_raise(Errno::ELOOP) { realpath("#{dir}/loop1") } |