Skip to content

Instantly share code, notes, and snippets.

@ayumin
Created September 26, 2011 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayumin/1242798 to your computer and use it in GitHub Desktop.
Save ayumin/1242798 to your computer and use it in GitHub Desktop.
[psych] test_yamldbm.rb failures/warnings on Win7/Arch
--- test/psych/test_yamldbm.rb
+++ 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)
+ @hardlinkfile = @dir + "/" + prefix + File.basename(__FILE__) + ".#{$$}.test"
end
def test_store
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment