From 2c2b0d4ec1bc3ede33b056e24dea011edc69bd5f Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Wed, 22 Apr 2020 14:37:42 +0900 Subject: [PATCH] [rubygems/rubygems] Make the test suite pass under `umask 077` Some tests had failed under `umask 077` mode. As far as I investigated, there is no actual bug. All failures were caused by tests that create a wrong-permission file or expect wrong permission. This changeset fixes the tests. https://github.com/rubygems/rubygems/commit/078213e527 --- test/rubygems/test_gem_commands_build_command.rb | 9 +++++++-- test/rubygems/test_gem_installer.rb | 2 +- test/rubygems/test_gem_specification.rb | 15 ++++++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb index ca9f8b66c9..9dfba75cf5 100644 --- a/test/rubygems/test_gem_commands_build_command.rb +++ b/test/rubygems/test_gem_commands_build_command.rb @@ -17,8 +17,13 @@ class TestGemCommandsBuildCommand < Gem::TestCase readme_file = File.join(@tempdir, 'README.md') - File.open readme_file, 'w' do |f| - f.write 'My awesome gem' + begin + umask_orig = File.umask(2) + File.open readme_file, 'w' do |f| + f.write 'My awesome gem' + end + ensure + File.umask(umask_orig) end @gem = util_spec 'some_gem' do |s| diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 89fcecb68d..34759a8fd0 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -2200,7 +2200,7 @@ gem 'other', version end def mask - 0100755 & (~File.umask) + 0100755 end end diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 1df7d71d8e..1848e52e16 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -3823,12 +3823,17 @@ end FileUtils.mkdir_p "test" FileUtils.mkdir_p "bin" - FileUtils.touch File.join("ext", "a", "extconf.rb") - FileUtils.touch File.join("lib", "code.rb") - FileUtils.touch File.join("test", "suite.rb") + begin + umask_orig = File.umask(2) + FileUtils.touch File.join("ext", "a", "extconf.rb") + FileUtils.touch File.join("lib", "code.rb") + FileUtils.touch File.join("test", "suite.rb") - File.open "bin/exec", "w", 0755 do |fp| - fp.puts "#!#{Gem.ruby}" + File.open "bin/exec", "w", 0755 do |fp| + fp.puts "#!#{Gem.ruby}" + end + ensure + File.umask(umask_orig) end end end