From 6cc4937aec6596bff58fc946b4b00c7b546e494a Mon Sep 17 00:00:00 2001 From: hsbt Date: Mon, 28 Mar 2016 02:02:37 +0000 Subject: * lib/rubygems/test_case.rb: Fix test on Windows for inconsistent temp path. https://github.com/rubygems/rubygems/pull/1554 [Bug #12193][ruby-core:74431] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/rubygems/test_case.rb | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index a4191f1f1d..685267f540 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Mar 28 11:02:31 2016 Hiroshi Shirosaki + + * lib/rubygems/test_case.rb: Fix test on Windows for inconsistent temp path. + https://github.com/rubygems/rubygems/pull/1554 + [Bug #12193][ruby-core:74431] + Mon Mar 28 08:19:49 2016 Nobuyoshi Nakada * sprintf.c (rb_str_format): refactor floating point format of diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index 0864f33478..bde4ed6713 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -252,6 +252,17 @@ class Gem::TestCase < MiniTest::Unit::TestCase @tempdir.untaint end + # This makes the tempdir consistent on Windows. + # Dir.tmpdir may return short path name, but Dir[Dir.tmpdir] returns long + # path name. https://bugs.ruby-lang.org/issues/10819 + # File.expand_path or File.realpath doesn't convert path name to long path + # name. Only Dir[] (= Dir.glob) works. + # Short and long path name is specific to Windows filesystem. + if win_platform? + @tempdir = Dir[@tempdir][0] + @tempdir.untaint + end + @gemhome = File.join @tempdir, 'gemhome' @userhome = File.join @tempdir, 'userhome' ENV["GEM_SPEC_CACHE"] = File.join @tempdir, 'spec_cache' -- cgit v1.2.3