aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems/test_gem_util.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-06 02:58:35 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-06 02:58:35 +0000
commit7112c6a1c15b26eebf0c020dfee7abd30eebde2d (patch)
tree16e0369e6aa7aee5bbbf79ba3d5ceacb53084534 /test/rubygems/test_gem_util.rb
parenteb537609ba0de060c6633dc3e7dd9ba5e85c6d1b (diff)
downloadruby-7112c6a1c15b26eebf0c020dfee7abd30eebde2d.tar.gz
Merge RubyGems-2.7.5 from upstream.
Please see its details: http://blog.rubygems.org/2018/02/06/2.7.5-released.html git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_util.rb')
-rw-r--r--test/rubygems/test_gem_util.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/test/rubygems/test_gem_util.rb b/test/rubygems/test_gem_util.rb
index dc85d25586..80dbff4b9e 100644
--- a/test/rubygems/test_gem_util.rb
+++ b/test/rubygems/test_gem_util.rb
@@ -5,7 +5,7 @@ require 'rubygems/util'
class TestGemUtil < Gem::TestCase
def test_class_popen
- skip "MJIT executes process and it's caught by Process.wait(-1)" if RubyVM::MJIT.enabled?
+ skip "MJIT executes process and it's caught by Process.wait(-1)" if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled?
assert_equal "0\n", Gem::Util.popen(Gem.ruby, '-e', 'p 0')
assert_raises Errno::ECHILD do
@@ -30,6 +30,28 @@ class TestGemUtil < Gem::TestCase
loop { break if enum.next.nil? } # exhaust the enumerator
end
+ def test_traverse_parents_does_not_crash_on_permissions_error
+ skip 'skipped on MS Windows (chmod has no effect)' if win_platform?
+
+ FileUtils.mkdir_p 'd/e/f'
+ # remove 'execute' permission from "e" directory and make it
+ # impossible to cd into it and its children
+ FileUtils.chmod(0666, 'd/e')
+
+ paths = Gem::Util.traverse_parents('d/e/f').to_a
+
+ assert_equal File.join(@tempdir, 'd'), paths[0]
+ assert_equal @tempdir, paths[1]
+ # File.expand_path with macOS returns `/private` prefix.
+ if RUBY_PLATFORM !~ /darwin/
+ assert_equal Dir.tmpdir, paths[2]
+ assert_equal '/', paths[3]
+ end
+ ensure
+ # restore default permissions, allow the directory to be removed
+ FileUtils.chmod(0775, 'd/e') unless win_platform?
+ end
+
def test_linked_list_find
list = [1,2,3,4,5].inject(Gem::List.new(0)) { |m,o|
Gem::List.new o, m