1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/test_tmpdir.rb
nobu 6f8bce9eff tmpdir.rb: not expand tilde
* lib/tmpdir.rb (Dir::Tmpname#create): deal with a prefix name which
  starts with tilde as a plain name, not expanding as home directory.
  [ruby-core:50793] [Bug #7547]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-12 12:40:51 +00:00

32 lines
843 B
Ruby

require 'test/unit'
require 'tmpdir'
class TestTmpdir < Test::Unit::TestCase
def test_world_writable
skip "no meaning on this platform" if /mswin|mingw/ =~ RUBY_PLATFORM
Dir.mktmpdir do |tmpdir|
# ToDo: fix for parallel test
olddir, ENV["TMPDIR"] = ENV["TMPDIR"], tmpdir
begin
assert_equal(tmpdir, Dir.tmpdir)
File.chmod(0777, tmpdir)
assert_not_equal(tmpdir, Dir.tmpdir)
File.chmod(01777, tmpdir)
assert_equal(tmpdir, Dir.tmpdir)
ensure
ENV["TMPDIR"] = olddir
end
end
end
def test_no_homedir
bug7547 = '[ruby-core:50793]'
home, ENV["HOME"] = ENV["HOME"], nil
dir = assert_nothing_raised(bug7547) do
break Dir.mktmpdir("~")
end
assert_match(/\A~/, File.basename(dir), bug7547)
ensure
ENV["HOME"] = home
end
end