[前][次][番号順一覧][スレッド一覧]

ruby-changes:49642

From: mame <ko1@a...>
Date: Wed, 10 Jan 2018 19:39:15 +0900 (JST)
Subject: [ruby-changes:49642] mame:r61758 (trunk): skip some tests so that no failure occurs in root privilege

mame	2018-01-10 19:39:09 +0900 (Wed, 10 Jan 2018)

  New Revision: 61758

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61758

  Log:
    skip some tests so that no failure occurs in root privilege
    
    Some tests had failed on `sudo make test-all`, mainly because root can
    access any files regardless of permission.  This change adds `skip`
    guards into such tests.
    
    Note that almost all tests in which `skip` guards is added, already have
    "windows" guard.  This is because there is no support to avoid read
    access by owner on Windows.

  Modified files:
    trunk/test/dbm/test_dbm.rb
    trunk/test/gdbm/test_gdbm.rb
    trunk/test/irb/test_workspace.rb
    trunk/test/pathname/test_pathname.rb
    trunk/test/rdoc/test_rdoc_options.rb
    trunk/test/rdoc/test_rdoc_rdoc.rb
    trunk/test/rdoc/test_rdoc_rubygems_hook.rb
    trunk/test/rubygems/test_gem.rb
    trunk/test/rubygems/test_gem_commands_cleanup_command.rb
    trunk/test/rubygems/test_gem_commands_install_command.rb
    trunk/test/rubygems/test_gem_install_update_options.rb
    trunk/test/rubygems/test_gem_installer.rb
    trunk/test/rubygems/test_gem_rdoc.rb
    trunk/test/rubygems/test_gem_remote_fetcher.rb
    trunk/test/rubygems/test_gem_specification.rb
    trunk/test/sdbm/test_sdbm.rb
    trunk/test/test_find.rb
Index: test/irb/test_workspace.rb
===================================================================
--- test/irb/test_workspace.rb	(revision 61757)
+++ test/irb/test_workspace.rb	(revision 61758)
@@ -34,6 +34,7 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_workspace.rb#L34
 
     def test_code_around_binding_with_existing_unreadable_file
       skip 'chmod cannot make file unreadable on windows' if windows?
+      skip 'skipped in root privilege' if Process.uid == 0
 
       Tempfile.create do |f|
         code = "IRB::WorkSpace.new(binding)\n"
Index: test/rdoc/test_rdoc_rubygems_hook.rb
===================================================================
--- test/rdoc/test_rdoc_rubygems_hook.rb	(revision 61757)
+++ test/rdoc/test_rdoc_rubygems_hook.rb	(revision 61758)
@@ -200,6 +200,7 @@ class TestRDocRubygemsHook < Gem::TestCa https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_rubygems_hook.rb#L200
 
   def test_remove_unwritable
     skip 'chmod not supported' if Gem.win_platform?
+    skip 'skipped in root privilege' if Process.uid == 0
     FileUtils.mkdir_p @a.base_dir
     FileUtils.chmod 0, @a.base_dir
 
@@ -228,6 +229,7 @@ class TestRDocRubygemsHook < Gem::TestCa https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_rubygems_hook.rb#L229
 
   def test_setup_unwritable
     skip 'chmod not supported' if Gem.win_platform?
+    skip 'skipped in root privilege' if Process.uid == 0
     FileUtils.mkdir_p @a.doc_dir
     FileUtils.chmod 0, @a.doc_dir
 
Index: test/rdoc/test_rdoc_options.rb
===================================================================
--- test/rdoc/test_rdoc_options.rb	(revision 61757)
+++ test/rdoc/test_rdoc_options.rb	(revision 61758)
@@ -18,6 +18,7 @@ class TestRDocOptions < RDoc::TestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_options.rb#L18
 
   def test_check_files
     skip "assumes UNIX permission model" if /mswin|mingw/ =~ RUBY_PLATFORM
+    skip "skipped in root privilege" if Process.uid == 0
 
     out, err = capture_io do
       temp_dir do
Index: test/rdoc/test_rdoc_rdoc.rb
===================================================================
--- test/rdoc/test_rdoc_rdoc.rb	(revision 61757)
+++ test/rdoc/test_rdoc_rdoc.rb	(revision 61758)
@@ -296,6 +296,7 @@ class TestRDocRDoc < RDoc::TestCase https://github.com/ruby/ruby/blob/trunk/test/rdoc/test_rdoc_rdoc.rb#L296
 
   def test_parse_file_forbidden
     skip 'chmod not supported' if Gem.win_platform?
+    skip 'skipped in root privilege' if Process.uid == 0
 
     @rdoc.store = RDoc::Store.new
 
Index: test/test_find.rb
===================================================================
--- test/test_find.rb	(revision 61757)
+++ test/test_find.rb	(revision 61758)
@@ -104,6 +104,8 @@ class TestFind < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_find.rb#L104
 
   def test_unreadable_dir
     skip "no meaning test on Windows" if /mswin|mingw/ =~ RUBY_PLATFORM
+    skip if Process.uid == 0 # because root can read anything
+
     Dir.mktmpdir {|d|
       Dir.mkdir(dir = "#{d}/dir")
       File.open("#{dir}/foo", "w"){}
@@ -157,6 +159,8 @@ class TestFind < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_find.rb#L159
         assert_equal([d, dir, file], a)
 
         skip "no meaning test on Windows" if /mswin|mingw/ =~ RUBY_PLATFORM
+        skip "skipped because root can read anything" if Process.uid == 0
+
         a = []
         assert_raise_with_message(Errno::EACCES, /#{Regexp.quote(file)}/) do
           Find.find(d, ignore_error: false) {|f| a << f }
Index: test/dbm/test_dbm.rb
===================================================================
--- test/dbm/test_dbm.rb	(revision 61757)
+++ test/dbm/test_dbm.rb	(revision 61758)
@@ -47,6 +47,8 @@ if defined? DBM https://github.com/ruby/ruby/blob/trunk/test/dbm/test_dbm.rb#L47
     end
 
     def test_delete_rdonly
+      skip("skipped because root can read anything") if Process.uid == 0
+
       if /^CYGWIN_9/ !~ SYSTEM
         assert_raise(DBMError) {
           @dbm_rdonly.delete("foo")
Index: test/gdbm/test_gdbm.rb
===================================================================
--- test/gdbm/test_gdbm.rb	(revision 61757)
+++ test/gdbm/test_gdbm.rb	(revision 61758)
@@ -43,6 +43,8 @@ if defined? GDBM https://github.com/ruby/ruby/blob/trunk/test/gdbm/test_gdbm.rb#L43
     end
 
     def test_delete_rdonly
+      skip("skipped because root can open anything") if Process.uid == 0
+
       if /^CYGWIN_9/ !~ SYSTEM
         assert_raise(GDBMError) {
           @gdbm_rdonly.delete("foo")
@@ -211,6 +213,8 @@ if defined? GDBM https://github.com/ruby/ruby/blob/trunk/test/gdbm/test_gdbm.rb#L213
     end if defined? GDBM::NOLOCK # gdbm 1.8.0 specific
 
     def test_s_open_error
+    skip if Process.uid == 0 # because root can open anything
+
       assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}", 0))
       assert_raise(Errno::EACCES, Errno::EWOULDBLOCK) {
         GDBM.open("#{@tmpdir}/#{@prefix}", 0)
Index: test/sdbm/test_sdbm.rb
===================================================================
--- test/sdbm/test_sdbm.rb	(revision 61757)
+++ test/sdbm/test_sdbm.rb	(revision 61758)
@@ -108,6 +108,7 @@ class TestSDBM < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/sdbm/test_sdbm.rb#L108
 
   def test_s_open_error
     skip "doesn't support to avoid read access by owner on Windows" if /mswin|mingw/ =~ RUBY_PLATFORM
+    skip "skipped because root can open anything" if Process.uid == 0
     assert_instance_of(SDBM, sdbm = SDBM.open("#{@tmpdir}/#{@prefix}", 0))
     assert_raise(Errno::EACCES) {
       SDBM.open("#{@tmpdir}/#{@prefix}", 0)
@@ -519,6 +520,7 @@ class TestSDBM < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/sdbm/test_sdbm.rb#L520
   end
 
   def test_readonly
+    skip "skipped because root can read anything" if /mswin|mingw/ !~ RUBY_PLATFORM && Process.uid == 0
     @sdbm["bar"] = "baz"
     @sdbm.close
     File.chmod(0444, @path + ".dir")
Index: test/pathname/test_pathname.rb
===================================================================
--- test/pathname/test_pathname.rb	(revision 61757)
+++ test/pathname/test_pathname.rb	(revision 61758)
@@ -1336,6 +1336,7 @@ class TestPathname < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/pathname/test_pathname.rb#L1336
         assert_equal([Pathname("d"), Pathname("d/x")], a)
 
         skip "no meaning test on Windows" if /mswin|mingw/ =~ RUBY_PLATFORM
+        skip 'skipped in root privilege' if Process.uid == 0
         a = [];
         assert_raise_with_message(Errno::EACCES, %r{d/x}) do
           Pathname(".").find(ignore_error: false) {|v| a << v }
Index: test/rubygems/test_gem_installer.rb
===================================================================
--- test/rubygems/test_gem_installer.rb	(revision 61757)
+++ test/rubygems/test_gem_installer.rb	(revision 61758)
@@ -437,6 +437,8 @@ gem 'other', version https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_installer.rb#L437
 
     if win_platform?
       skip('test_generate_bin_script_no_perms skipped on MS Windows')
+    elsif Process.uid == 0
+      skip('test_generate_bin_script_no_perms skipped in root privilege')
     else
       FileUtils.chmod 0000, util_inst_bindir
 
@@ -529,6 +531,8 @@ gem 'other', version https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_installer.rb#L531
 
     if win_platform?
       skip('test_generate_bin_symlink_no_perms skipped on MS Windows')
+    elsif Process.uid == 0
+      skip('test_user_install_disabled_read_only test skipped in root privilege')
     else
       FileUtils.chmod 0000, util_inst_bindir
 
Index: test/rubygems/test_gem_specification.rb
===================================================================
--- test/rubygems/test_gem_specification.rb	(revision 61757)
+++ test/rubygems/test_gem_specification.rb	(revision 61758)
@@ -1464,6 +1464,7 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1464
 
   def test_build_extensions_extensions_dir_unwritable
     skip 'chmod not supported' if Gem.win_platform?
+    skip 'skipped in root privilege' if Process.uid == 0
 
     ext_spec
 
@@ -1489,7 +1490,7 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1490
     @ext.build_extensions
     refute_path_exists @ext.extension_dir
   ensure
-    unless ($DEBUG or win_platform?) then
+    unless ($DEBUG or win_platform? or Process.uid == 0) then
       FileUtils.chmod 0755, File.join(@ext.base_dir, 'extensions')
       FileUtils.chmod 0755, @ext.base_dir
     end
Index: test/rubygems/test_gem_remote_fetcher.rb
===================================================================
--- test/rubygems/test_gem_remote_fetcher.rb	(revision 61757)
+++ test/rubygems/test_gem_remote_fetcher.rb	(revision 61758)
@@ -431,7 +431,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_remote_fetcher.rb#L431
     assert File.exist?(a1_cache_gem)
   end
 
-  unless win_platform? # File.chmod doesn't work
+  unless win_platform? || Process.uid == 0 # File.chmod doesn't work
     def test_download_local_read_only
       FileUtils.mv @a1_gem, @tempdir
       local_path = File.join @tempdir, @a1.file_name
Index: test/rubygems/test_gem_rdoc.rb
===================================================================
--- test/rubygems/test_gem_rdoc.rb	(revision 61757)
+++ test/rubygems/test_gem_rdoc.rb	(revision 61758)
@@ -223,6 +223,7 @@ class TestGemRDoc < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_rdoc.rb#L223
 
   def test_remove_unwritable
     skip 'chmod not supported' if Gem.win_platform?
+    skip 'skipped in root privilege' if Process.uid == 0
     FileUtils.mkdir_p @a.base_dir
     FileUtils.chmod 0, @a.base_dir
 
@@ -251,6 +252,7 @@ class TestGemRDoc < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_rdoc.rb#L252
 
   def test_setup_unwritable
     skip 'chmod not supported' if Gem.win_platform?
+    skip 'skipped in root privilege' if Process.uid == 0
     FileUtils.mkdir_p @a.doc_dir
     FileUtils.chmod 0, @a.doc_dir
 
Index: test/rubygems/test_gem_commands_cleanup_command.rb
===================================================================
--- test/rubygems/test_gem_commands_cleanup_command.rb	(revision 61757)
+++ test/rubygems/test_gem_commands_cleanup_command.rb	(revision 61758)
@@ -158,7 +158,7 @@ class TestGemCommandsCleanupCommand < Ge https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_cleanup_command.rb#L158
     assert_path_exists @a_1_1.gem_dir
   ensure
     FileUtils.chmod 0755, @gemhome
-  end unless win_platform?
+  end unless win_platform? || Process.uid == 0
 
   def test_execute_dry_run
     @cmd.options[:args] = %w[a]
Index: test/rubygems/test_gem_install_update_options.rb
===================================================================
--- test/rubygems/test_gem_install_update_options.rb	(revision 61757)
+++ test/rubygems/test_gem_install_update_options.rb	(revision 61758)
@@ -141,6 +141,8 @@ class TestGemInstallUpdateOptions < Gem: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_install_update_options.rb#L141
   def test_user_install_disabled_read_only
     if win_platform?
       skip('test_user_install_disabled_read_only test skipped on MS Windows')
+    elsif Process.uid == 0
+      skip('test_user_install_disabled_read_only test skipped in root privilege')
     else
       @cmd.handle_options %w[--no-user-install]
 
Index: test/rubygems/test_gem_commands_install_command.rb
===================================================================
--- test/rubygems/test_gem_commands_install_command.rb	(revision 61757)
+++ test/rubygems/test_gem_commands_install_command.rb	(revision 61758)
@@ -131,6 +131,7 @@ class TestGemCommandsInstallCommand < Ge https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_install_command.rb#L131
 
   def test_execute_no_user_install
     skip 'skipped on MS Windows (chmod has no effect)' if win_platform?
+    skip 'skipped in root privilege' if Process.uid == 0
 
     specs = spec_fetcher do |fetcher|
       fetcher.gem 'a', 2
Index: test/rubygems/test_gem.rb
===================================================================
--- test/rubygems/test_gem.rb	(revision 61757)
+++ test/rubygems/test_gem.rb	(revision 61758)
@@ -463,7 +463,7 @@ class TestGem < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L463
     assert File.directory?(util_cache_dir)
   end
 
-  unless win_platform? then # only for FS that support write protection
+  unless win_platform? || Process.uid == 0 then # only for FS that support write protection
     def test_self_ensure_gem_directories_write_protected
       gemdir = File.join @tempdir, "egd"
       FileUtils.rm_r gemdir rescue nil

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]