[前][次][番号順一覧][スレッド一覧]

ruby-changes:61750

From: David <ko1@a...>
Date: Wed, 17 Jun 2020 21:17:30 +0900 (JST)
Subject: [ruby-changes:61750] f5459acd79 (master): Make sure tmp folder exists before calling `Dir.tmpdir`

https://git.ruby-lang.org/ruby.git/commit/?id=f5459acd79

From f5459acd79c30dbea3062e48fb2b12d510c5b868 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Thu, 11 Jun 2020 17:30:45 +0200
Subject: 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.

diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index 76c783d..bb8355f 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -298,11 +298,14 @@ class Gem::TestCase < Minitest::Test https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L298
     super
 
     @orig_env = ENV.to_hash
+    @tmp = File.expand_path("tmp")
+
+    Dir.mkdir @tmp
 
     ENV['GEM_VENDOR'] = nil
     ENV['GEMRC'] = nil
     ENV['SOURCE_DATE_EPOCH'] = nil
-    ENV["TMPDIR"] = File.expand_path("tmp")
+    ENV["TMPDIR"] = @tmp
 
     @current_dir = Dir.pwd
     @fetcher     = nil
@@ -319,7 +322,7 @@ class Gem::TestCase < Minitest::Test https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L322
     @tempdir = File.join(tmpdir, "test_rubygems_#{$$}")
     @tempdir.tap(&Gem::UNTAINT)
 
-    FileUtils.mkdir_p @tempdir
+    FileUtils.mkdir @tempdir
 
     @orig_SYSTEM_WIDE_CONFIG_FILE = Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE
     Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE
@@ -445,7 +448,7 @@ class Gem::TestCase < Minitest::Test https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L448
 
     Dir.chdir @current_dir
 
-    FileUtils.rm_rf @tempdir
+    FileUtils.rm_rf @tmp
 
     ENV.replace(@orig_env)
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]