From 2865b450e05f7e9e80f4af6c0c29d0bd4014840d Mon Sep 17 00:00:00 2001 From: ayumin Date: Tue, 27 Sep 2011 19:44:02 +0000 Subject: * test/psych/test_yamlstore.rb: use tmpdir for tmpfile. * test/syck/test_yamlstore.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/psych/test_yamlstore.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'test/psych') diff --git a/test/psych/test_yamlstore.rb b/test/psych/test_yamlstore.rb index e99ba30dab..d607013ada 100644 --- a/test/psych/test_yamlstore.rb +++ b/test/psych/test_yamlstore.rb @@ -1,18 +1,26 @@ require 'test/unit' require 'yaml/store' +require 'tmpdir' + Psych::Store = YAML::Store unless defined?(Psych::Store) module Psych class YAMLStoreTest < Test::Unit::TestCase def setup @engine, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'psych' - @yamlstore_file = "yamlstore.tmp.#{Process.pid}" + @dir = Dir.mktmpdir("rubytest-file") + File.chown(-1, Process.gid, @dir) + @yamlstore_file = make_tmp_filename("yamlstore") @yamlstore = YAML::Store.new(@yamlstore_file) end def teardown YAML::ENGINE.yamler = @engine - File.unlink(@yamlstore_file) rescue nil + FileUtils.remove_entry_secure @dir + end + + def make_tmp_filename(prefix) + @dir + "/" + prefix + File.basename(__FILE__) + ".#{$$}.test" end def test_opening_new_file_in_readonly_mode_should_result_in_empty_values -- cgit v1.2.3