зеркало из https://github.com/github/ruby.git
[rubygems/rubygems] Fix symlink RubyGems test problems for non-admin user.
https://github.com/rubygems/rubygems/commit/75f672ff0e
This commit is contained in:
Родитель
3315ce6904
Коммит
a0c4d14acf
|
@ -230,4 +230,21 @@ class Gem::InstallerTestCase < Gem::TestCase
|
|||
: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
|
||||
|
|
|
@ -3,24 +3,6 @@ require 'rubygems/installer_test_case'
|
|||
|
||||
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
|
|||
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
|
||||
|
|
|
@ -154,6 +154,8 @@ class TestGemUninstaller < Gem::InstallerTestCase
|
|||
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)}"
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче