diff options
-rw-r--r-- | test/dbm/test_dbm.rb | 2 | ||||
-rw-r--r-- | test/gdbm/test_gdbm.rb | 4 | ||||
-rw-r--r-- | test/irb/test_workspace.rb | 1 | ||||
-rw-r--r-- | test/pathname/test_pathname.rb | 1 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_options.rb | 1 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_rdoc.rb | 1 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_rubygems_hook.rb | 2 | ||||
-rw-r--r-- | test/rubygems/test_gem.rb | 2 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_cleanup_command.rb | 2 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_install_command.rb | 1 | ||||
-rw-r--r-- | test/rubygems/test_gem_install_update_options.rb | 2 | ||||
-rw-r--r-- | test/rubygems/test_gem_installer.rb | 4 | ||||
-rw-r--r-- | test/rubygems/test_gem_rdoc.rb | 2 | ||||
-rw-r--r-- | test/rubygems/test_gem_remote_fetcher.rb | 2 | ||||
-rw-r--r-- | test/rubygems/test_gem_specification.rb | 3 | ||||
-rw-r--r-- | test/sdbm/test_sdbm.rb | 2 | ||||
-rw-r--r-- | test/test_find.rb | 4 |
17 files changed, 32 insertions, 4 deletions
diff --git a/test/dbm/test_dbm.rb b/test/dbm/test_dbm.rb index 93198fdea2..874b326404 100644 --- a/test/dbm/test_dbm.rb +++ b/test/dbm/test_dbm.rb @@ -47,6 +47,8 @@ if defined? DBM 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") diff --git a/test/gdbm/test_gdbm.rb b/test/gdbm/test_gdbm.rb index 1d69634f88..9e97eb3587 100644 --- a/test/gdbm/test_gdbm.rb +++ b/test/gdbm/test_gdbm.rb @@ -43,6 +43,8 @@ if defined? GDBM 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 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) diff --git a/test/irb/test_workspace.rb b/test/irb/test_workspace.rb index 0dd46175c8..0795b17e09 100644 --- a/test/irb/test_workspace.rb +++ b/test/irb/test_workspace.rb @@ -34,6 +34,7 @@ module TestIRB 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" diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index 5000904216..42bab36bc5 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -1336,6 +1336,7 @@ class TestPathname < Test::Unit::TestCase 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 } diff --git a/test/rdoc/test_rdoc_options.rb b/test/rdoc/test_rdoc_options.rb index 760cf9db55..400ed9a549 100644 --- a/test/rdoc/test_rdoc_options.rb +++ b/test/rdoc/test_rdoc_options.rb @@ -18,6 +18,7 @@ class TestRDocOptions < RDoc::TestCase 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 diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb index 3244238e3c..bd4794342c 100644 --- a/test/rdoc/test_rdoc_rdoc.rb +++ b/test/rdoc/test_rdoc_rdoc.rb @@ -296,6 +296,7 @@ class TestRDocRDoc < RDoc::TestCase 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 diff --git a/test/rdoc/test_rdoc_rubygems_hook.rb b/test/rdoc/test_rdoc_rubygems_hook.rb index 2fb79ff577..2664b35cbb 100644 --- a/test/rdoc/test_rdoc_rubygems_hook.rb +++ b/test/rdoc/test_rdoc_rubygems_hook.rb @@ -200,6 +200,7 @@ class TestRDocRubygemsHook < Gem::TestCase 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::TestCase 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 diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index 315aea020f..bd4c91d96d 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -463,7 +463,7 @@ class TestGem < Gem::TestCase 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 diff --git a/test/rubygems/test_gem_commands_cleanup_command.rb b/test/rubygems/test_gem_commands_cleanup_command.rb index c55e195975..a222659ead 100644 --- a/test/rubygems/test_gem_commands_cleanup_command.rb +++ b/test/rubygems/test_gem_commands_cleanup_command.rb @@ -158,7 +158,7 @@ class TestGemCommandsCleanupCommand < Gem::TestCase 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] diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb index dd86a85038..fefc5c7059 100644 --- a/test/rubygems/test_gem_commands_install_command.rb +++ b/test/rubygems/test_gem_commands_install_command.rb @@ -131,6 +131,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase 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 diff --git a/test/rubygems/test_gem_install_update_options.rb b/test/rubygems/test_gem_install_update_options.rb index e2d546307d..69a2b61041 100644 --- a/test/rubygems/test_gem_install_update_options.rb +++ b/test/rubygems/test_gem_install_update_options.rb @@ -141,6 +141,8 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase 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] diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 39095c7dee..63acc3d130 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -437,6 +437,8 @@ gem 'other', version 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 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 diff --git a/test/rubygems/test_gem_rdoc.rb b/test/rubygems/test_gem_rdoc.rb index 76ca8c45a9..3961a8e3f9 100644 --- a/test/rubygems/test_gem_rdoc.rb +++ b/test/rubygems/test_gem_rdoc.rb @@ -223,6 +223,7 @@ class TestGemRDoc < Gem::TestCase 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 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 diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb index ee5ac77717..fc51b06f1b 100644 --- a/test/rubygems/test_gem_remote_fetcher.rb +++ b/test/rubygems/test_gem_remote_fetcher.rb @@ -431,7 +431,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== 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 diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index ab3a7399af..7bfeb48d3c 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -1464,6 +1464,7 @@ dependencies: [] 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: [] @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 diff --git a/test/sdbm/test_sdbm.rb b/test/sdbm/test_sdbm.rb index 7b2d39c9a1..6cea36d3a5 100644 --- a/test/sdbm/test_sdbm.rb +++ b/test/sdbm/test_sdbm.rb @@ -108,6 +108,7 @@ class TestSDBM < Test::Unit::TestCase 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 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") diff --git a/test/test_find.rb b/test/test_find.rb index d4d958859d..01b1fcc121 100644 --- a/test/test_find.rb +++ b/test/test_find.rb @@ -104,6 +104,8 @@ class TestFind < Test::Unit::TestCase 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 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 } |