ruby-changes:65035
From: Nobuyoshi <ko1@a...>
Date: Sun, 24 Jan 2021 19:30:31 +0900 (JST)
Subject: [ruby-changes:65035] 80bad36989 (master): Remove temporary directory properly
https://git.ruby-lang.org/ruby.git/commit/?id=80bad36989 From 80bad36989bbc4ad6167fe9670327f95b78089ce Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sun, 24 Jan 2021 18:26:50 +0900 Subject: Remove temporary directory properly For each `make check`, rubygems test makes "tmp" directory and some "gem_generate_index..." directories remain there. * Do not create a (fixed name) directory in the current working directory * Should remove its own temporary directory --- lib/rubygems/test_case.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index 83a3c44..2fbdd4f 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -301,9 +301,6 @@ class Gem::TestCase < Minitest::Test https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L301 def setup @orig_env = ENV.to_hash - @tmp = File.expand_path("tmp") - - FileUtils.mkdir_p @tmp ENV['GEM_VENDOR'] = nil ENV['GEMRC'] = nil @@ -312,7 +309,6 @@ class Gem::TestCase < Minitest::Test https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L309 ENV['XDG_DATA_HOME'] = nil ENV['SOURCE_DATE_EPOCH'] = nil ENV['BUNDLER_VERSION'] = nil - ENV["TMPDIR"] = @tmp @current_dir = Dir.pwd @fetcher = nil @@ -323,13 +319,10 @@ class Gem::TestCase < Minitest::Test https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L319 # capture output Gem::DefaultUserInteraction.ui = Gem::MockGemUi.new - tmpdir = File.realpath Dir.tmpdir + tmpdir = File.realpath(Dir.mktmpdir("test_rubygems_")) tmpdir.tap(&Gem::UNTAINT) - - @tempdir = File.join(tmpdir, "test_rubygems_#{$$}") - @tempdir.tap(&Gem::UNTAINT) - - FileUtils.mkdir_p @tempdir + ENV["TMPDIR"] = @tmp = File.dirname(tmpdir) + @tempdir = tmpdir @orig_SYSTEM_WIDE_CONFIG_FILE = Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/