ruby-changes:61085
From: Josef <ko1@a...>
Date: Fri, 8 May 2020 14:13:57 +0900 (JST)
Subject: [ruby-changes:61085] a0c4d14acf (master): [rubygems/rubygems] Fix symlink RubyGems test problems for non-admin user.
https://git.ruby-lang.org/ruby.git/commit/?id=a0c4d14acf From a0c4d14acfa17877d6c1d58e5960513f152b493c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20=C5=A0im=C3=A1nek?= <josef.simanek@g...> Date: Sun, 19 Apr 2020 00:50:28 +0200 Subject: [rubygems/rubygems] Fix symlink RubyGems test problems for non-admin user. https://github.com/rubygems/rubygems/commit/75f672ff0e diff --git a/lib/rubygems/installer_test_case.rb b/lib/rubygems/installer_test_case.rb index 5a3ce75..68200d7 100644 --- a/lib/rubygems/installer_test_case.rb +++ b/lib/rubygems/installer_test_case.rb @@ -230,4 +230,21 @@ class Gem::InstallerTestCase < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer_test_case.rb#L230 :user_install => user) end + @@symlink_supported = nil + + # This is needed for Windows environment without symlink support enabled (the default + # for non admin) to be able to skip test for features using symlinks. + def symlink_supported? + if @@symlink_supported.nil? + begin + File.symlink("", "") + rescue Errno::ENOENT, Errno::EEXIST + @@symlink_supported = true + rescue NotImplementedError, SystemCallError + @@symlink_supported = false + end + end + @@symlink_supported + end + end diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 34759a8..8020a42 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -3,24 +3,6 @@ require 'rubygems/installer_test_case' https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_installer.rb#L3 class TestGemInstaller < Gem::InstallerTestCase - @@symlink_supported = nil - - # Our CI does not currently hit the "symlink not supported" case, but this is - # needed for Windows developers without symlink support enabled (the default - # for non admin) to be able to run the tests successfully - def symlink_supported? - if @@symlink_supported.nil? - begin - File.symlink("", "") - rescue Errno::ENOENT, Errno::EEXIST - @@symlink_supported = true - rescue NotImplementedError, SystemCallError - @@symlink_supported = false - end - end - @@symlink_supported - end - def setup super common_installer_setup @@ -2097,7 +2079,13 @@ gem 'other', version https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_installer.rb#L2079 assert_path_exists installed_exec wrapper = File.read installed_exec - refute_match %r{generated by RubyGems}, wrapper + + if symlink_supported? + refute_match %r{generated by RubyGems}, wrapper + else # when symlink not supported, it warns and fallbacks back to installing wrapper + assert_match %r{Unable to use symlinks, installing wrapper}, @ui.error + assert_match %r{generated by RubyGems}, wrapper + end end def test_default_gem_with_wrappers diff --git a/test/rubygems/test_gem_uninstaller.rb b/test/rubygems/test_gem_uninstaller.rb index 9a98c1e..9229fee 100644 --- a/test/rubygems/test_gem_uninstaller.rb +++ b/test/rubygems/test_gem_uninstaller.rb @@ -154,6 +154,8 @@ class TestGemUninstaller < Gem::InstallerTestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_uninstaller.rb#L154 end def test_remove_symlinked_gem_home + skip "Symlinks not supported or not enabled" unless symlink_supported? + Dir.mktmpdir("gem_home") do |dir| symlinked_gem_home = "#{dir}/#{File.basename(@gemhome)}" -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/