Use tmpdir instead of tempfile for creating temporary repos in the test suite.

This commit is contained in:
Bart Kamphorst
2020-03-13 17:07:15 +01:00
parent e1a13aef1f
commit 4d549b1660
+4 -5
View File
@@ -6,6 +6,7 @@ require 'mocha/setup'
require 'fileutils' require 'fileutils'
require 'minitest/reporters' require 'minitest/reporters'
require 'twitter_cldr' require 'twitter_cldr'
require 'tmpdir'
# Silence locale validation warning # Silence locale validation warning
require 'i18n' require 'i18n'
@@ -42,13 +43,11 @@ end
def cloned_testpath(path, bare = false) def cloned_testpath(path, bare = false)
repo = File.expand_path(testpath(path)) repo = File.expand_path(testpath(path))
tmp = Tempfile.new(self.class.name) tmpdir = Dir.mktmpdir(self.class.name)
path = tmp.path
bare = bare ? "--bare" : "" bare = bare ? "--bare" : ""
tmp.close(true)
redirect = Gem.win_platform? ? '' : '2>/dev/null' redirect = Gem.win_platform? ? '' : '2>/dev/null'
%x{git clone #{bare} #{repo} #{path} #{redirect}} %x{git clone #{bare} '#{repo}' #{tmpdir} #{redirect}}
path tmpdir
end end
def commit_details def commit_details