summaryrefslogtreecommitdiff
path: root/test/dbm
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-28 16:51:41 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-28 16:51:41 +0000
commita9c2a18cc796fa59d5d696ef9d99d41b1149a242 (patch)
treef86ea8a92bf4dcf23b500dff988e8225aed8177a /test/dbm
parent228728325ee08b31944cffb35126222d1671c01e (diff)
don't generate temporary files under current directory.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/dbm')
-rw-r--r--test/dbm/test_dbm.rb25
1 files changed, 14 insertions, 11 deletions
diff --git a/test/dbm/test_dbm.rb b/test/dbm/test_dbm.rb
index 776c8ead78..c0d3bb42bf 100644
--- a/test/dbm/test_dbm.rb
+++ b/test/dbm/test_dbm.rb
@@ -1,4 +1,5 @@
require 'test/unit'
+require 'tmpdir'
begin
require 'dbm'
@@ -27,17 +28,19 @@ if defined? DBM
SYSTEM = uname_s
def setup
- @path = "tmptest_dbm_"
+ @tmpdir = Dir.tmpdir
+ @prefix = "tmptest_dbm_#{$$}"
+ @path = "#{@tmpdir}/#{@prefix}_"
assert_instance_of(DBM, @dbm = DBM.new(@path))
# prepare to make readonly DBM file
- DBM.open("tmptest_dbm_rdonly") {|dbm|
+ DBM.open("#{@tmpdir}/#{@prefix}_rdonly") {|dbm|
dbm['foo'] = 'FOO'
}
- File.chmod(0400, *Dir.glob("tmptest_dbm_rdonly.*"))
+ File.chmod(0400, *Dir.glob("#{@tmpdir}/#{@prefix}_rdonly.*"))
- assert_instance_of(DBM, @dbm_rdonly = DBM.new("tmptest_dbm_rdonly", nil))
+ assert_instance_of(DBM, @dbm_rdonly = DBM.new("#{@tmpdir}/#{@prefix}_rdonly", nil))
end
def teardown
assert_nil(@dbm.close)
@@ -45,8 +48,8 @@ if defined? DBM
ObjectSpace.each_object(DBM) do |obj|
obj.close unless obj.closed?
end
- File.delete *Dir.glob("tmptest_dbm*").to_a
- p Dir.glob("tmptest_dbm*") if $DEBUG
+ File.delete *Dir.glob("#{@tmpdir}/#{@prefix}*").to_a
+ p Dir.glob("#{@tmpdir}/#{@prefix}*") if $DEBUG
end
def check_size(expect, dbm=@dbm)
@@ -73,21 +76,21 @@ if defined? DBM
def test_s_new_has_no_block
# DBM.new ignore the block
foo = true
- assert_instance_of(DBM, dbm = DBM.new("tmptest_dbm") { foo = false })
+ assert_instance_of(DBM, dbm = DBM.new("#{@tmpdir}/#{@prefix}") { foo = false })
assert_equal(foo, true)
assert_nil(dbm.close)
end
def test_s_open_no_create
- assert_nil(dbm = DBM.open("tmptest_dbm", nil))
+ assert_nil(dbm = DBM.open("#{@tmpdir}/#{@prefix}", nil))
ensure
dbm.close if dbm
end
def test_s_open_with_block
- assert_equal(DBM.open("tmptest_dbm") { :foo }, :foo)
+ assert_equal(DBM.open("#{@tmpdir}/#{@prefix}") { :foo }, :foo)
end
def test_close
- assert_instance_of(DBM, dbm = DBM.open("tmptest_dbm"))
+ assert_instance_of(DBM, dbm = DBM.open("#{@tmpdir}/#{@prefix}"))
assert_nil(dbm.close)
# closed DBM file
@@ -498,7 +501,7 @@ if defined? DBM
TMPROOT = "#{Dir.tmpdir}/ruby-dbm.#{$$}"
def setup
- Dir.mkdir TMPROOT
+ Dir.mkdir TMPROOT, 0755
end
def teardown