summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorayumin <ayumin@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-26 18:37:26 +0000
committerayumin <ayumin@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-26 18:37:26 +0000
commit375d9f9112f9ebb352536fed9cb263bfcc9ebbcd (patch)
treef41914c930c5ee0b576c99aa9d9d9a0b1b50408a
parent7b6677f1e60d6a4c4e8927550ba775321a389ce6 (diff)
* test/psych/test_yamldbm.rb (require): fix #setup and #terdown.
[Bug #5370] [ruby-core:39730] * test/syck/test_yamldbm.rb (require): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--test/psych/test_yamldbm.rb13
-rw-r--r--test/syck/test_yamldbm.rb15
3 files changed, 29 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 1964d66472..fb39f0a05e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Sep 27 03:32:27 2011 Ayumu AIZAWA <ayumu.aizawa@gmail.com>
+
+ * test/psych/test_yamldbm.rb (require): fix #setup and #terdown.
+ [Bug #5370] [ruby-core:39730]
+ * test/syck/test_yamldbm.rb (require): ditto.
+
Mon Sep 26 11:27:38 2011 NARUSE, Yui <naruse@ruby-lang.org>
* lib/webrick/httputils.rb: Add MIME Type definition of .js and .svg.
diff --git a/test/psych/test_yamldbm.rb b/test/psych/test_yamldbm.rb
index f1e4425686..6dfe23c57f 100644
--- a/test/psych/test_yamldbm.rb
+++ b/test/psych/test_yamldbm.rb
@@ -1,19 +1,28 @@
# -*- coding: UTF-8 -*-
require 'test/unit'
require 'yaml/dbm'
+require 'tmpdir'
Psych::DBM = YAML::DBM unless defined?(Psych::DBM)
module Psych
class YAMLDBMTest < Test::Unit::TestCase
def setup
@engine, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'psych'
- @yamldbm_file = "yamldbm.tmp.#{Process.pid}"
+ @dir = Dir.mktmpdir("rubytest-file")
+ File.chown(-1, Process.gid, @dir)
+ @yamldbm_file = make_tmp_filename("yamldbm")
@yamldbm = YAML::DBM.new(@yamldbm_file)
end
def teardown
YAML::ENGINE.yamler = @engine
- File.unlink(@yamldbm_file + '.db') rescue nil
+ @yamldbm.clear
+ @yamldbm.close
+ FileUtils.remove_entry_secure @dir
+ end
+
+ def make_tmp_filename(prefix)
+ @dir + "/" + prefix + File.basename(__FILE__) + ".#{$$}.test"
end
def test_store
diff --git a/test/syck/test_yamldbm.rb b/test/syck/test_yamldbm.rb
index 12b3b18eca..01a2df678b 100644
--- a/test/syck/test_yamldbm.rb
+++ b/test/syck/test_yamldbm.rb
@@ -1,19 +1,28 @@
# -*- coding: UTF-8 -*-
require 'test/unit'
require 'yaml/dbm'
+require 'tmpdir'
Syck::DBM = YAML::DBM unless defined?(Syck::DBM)
module Syck
class YAMLDBMTest < Test::Unit::TestCase
def setup
- @engine, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'syck'
- @yamldbm_file = "yamldbm.tmp.#{Process.pid}"
+ @engine, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'psych'
+ @dir = Dir.mktmpdir("rubytest-file")
+ File.chown(-1, Process.gid, @dir)
+ @yamldbm_file = make_tmp_filename("yamldbm")
@yamldbm = YAML::DBM.new(@yamldbm_file)
end
def teardown
YAML::ENGINE.yamler = @engine
- File.unlink(@yamldbm_file + '.db') rescue nil
+ @yamldbm.clear
+ @yamldbm.close
+ FileUtils.remove_entry_secure @dir
+ end
+
+ def make_tmp_filename(prefix)
+ @dir + "/" + prefix + File.basename(__FILE__) + ".#{$$}.test"
end
def test_store