Make sure tmp folder exists before calling Dir.tmpdir

This was guaranteed by our gitignore setup where a `tmp/` folder is
always present right after cloning the repository, but was not
guaranteed under the ruby-core setup.

This alternative approach should always work.
This commit is contained in:
David Rodríguez 2020-06-11 17:30:45 +02:00 committed by Hiroshi SHIBATA
parent 97819759de
commit f5459acd79
Notes: git 2020-06-17 21:17:31 +09:00

View file

@ -298,11 +298,14 @@ class Gem::TestCase < Minitest::Test
super super
@orig_env = ENV.to_hash @orig_env = ENV.to_hash
@tmp = File.expand_path("tmp")
Dir.mkdir @tmp
ENV['GEM_VENDOR'] = nil ENV['GEM_VENDOR'] = nil
ENV['GEMRC'] = nil ENV['GEMRC'] = nil
ENV['SOURCE_DATE_EPOCH'] = nil ENV['SOURCE_DATE_EPOCH'] = nil
ENV["TMPDIR"] = File.expand_path("tmp") ENV["TMPDIR"] = @tmp
@current_dir = Dir.pwd @current_dir = Dir.pwd
@fetcher = nil @fetcher = nil
@ -319,7 +322,7 @@ class Gem::TestCase < Minitest::Test
@tempdir = File.join(tmpdir, "test_rubygems_#{$$}") @tempdir = File.join(tmpdir, "test_rubygems_#{$$}")
@tempdir.tap(&Gem::UNTAINT) @tempdir.tap(&Gem::UNTAINT)
FileUtils.mkdir_p @tempdir FileUtils.mkdir @tempdir
@orig_SYSTEM_WIDE_CONFIG_FILE = Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE @orig_SYSTEM_WIDE_CONFIG_FILE = Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE
Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE
@ -445,7 +448,7 @@ class Gem::TestCase < Minitest::Test
Dir.chdir @current_dir Dir.chdir @current_dir
FileUtils.rm_rf @tempdir FileUtils.rm_rf @tmp
ENV.replace(@orig_env) ENV.replace(@orig_env)