ruby-changes:21292
From: ayumin <ko1@a...>
Date: Tue, 27 Sep 2011 03:37:42 +0900 (JST)
Subject: [ruby-changes:21292] ayumin:r33340 (trunk): * test/psych/test_yamldbm.rb (require): fix #setup and #terdown.
ayumin 2011-09-27 03:37:26 +0900 (Tue, 27 Sep 2011) New Revision: 33340 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33340 Log: * test/psych/test_yamldbm.rb (require): fix #setup and #terdown. [Bug #5370] [ruby-core:39730] * test/syck/test_yamldbm.rb (require): ditto. Modified files: trunk/ChangeLog trunk/test/psych/test_yamldbm.rb trunk/test/syck/test_yamldbm.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 33339) +++ ChangeLog (revision 33340) @@ -1,3 +1,9 @@ +Tue Sep 27 03:32:27 2011 Ayumu AIZAWA <ayumu.aizawa@g...> + + * 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@r...> * lib/webrick/httputils.rb: Add MIME Type definition of .js and .svg. Index: test/psych/test_yamldbm.rb =================================================================== --- test/psych/test_yamldbm.rb (revision 33339) +++ test/psych/test_yamldbm.rb (revision 33340) @@ -1,21 +1,30 @@ # -*- 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 @yamldbm.store('a','b') @yamldbm.store('c','d') Index: test/syck/test_yamldbm.rb =================================================================== --- test/syck/test_yamldbm.rb (revision 33339) +++ test/syck/test_yamldbm.rb (revision 33340) @@ -1,21 +1,30 @@ # -*- 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 @yamldbm.store('a','b') @yamldbm.store('c','d') -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/