mirror of
https://github.com/ruby/ruby.git
synced 2025-09-18 18:13:58 +02:00
merge revision(s) 61501,61758: [Backport #14481]
fix concurrent test. * test/rubygems/test_require.rb (test_concurrent_require): Synchronizations should be in ensure clause. Sometimes `require` fails (not sure why) and latch is not released. Such case introduces unlimited awaiting. This patch soleve this problem. 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@62834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d11ce2be2e
commit
332938df51
19 changed files with 46 additions and 26 deletions
|
@ -47,6 +47,8 @@ if defined? DBM
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_delete_rdonly
|
def test_delete_rdonly
|
||||||
|
skip("skipped because root can read anything") if Process.uid == 0
|
||||||
|
|
||||||
if /^CYGWIN_9/ !~ SYSTEM
|
if /^CYGWIN_9/ !~ SYSTEM
|
||||||
assert_raise(DBMError) {
|
assert_raise(DBMError) {
|
||||||
@dbm_rdonly.delete("foo")
|
@dbm_rdonly.delete("foo")
|
||||||
|
|
|
@ -43,6 +43,8 @@ if defined? GDBM
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_delete_rdonly
|
def test_delete_rdonly
|
||||||
|
skip("skipped because root can open anything") if Process.uid == 0
|
||||||
|
|
||||||
if /^CYGWIN_9/ !~ SYSTEM
|
if /^CYGWIN_9/ !~ SYSTEM
|
||||||
assert_raise(GDBMError) {
|
assert_raise(GDBMError) {
|
||||||
@gdbm_rdonly.delete("foo")
|
@gdbm_rdonly.delete("foo")
|
||||||
|
@ -211,6 +213,8 @@ if defined? GDBM
|
||||||
end if defined? GDBM::NOLOCK # gdbm 1.8.0 specific
|
end if defined? GDBM::NOLOCK # gdbm 1.8.0 specific
|
||||||
|
|
||||||
def test_s_open_error
|
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_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}", 0))
|
||||||
assert_raise(Errno::EACCES, Errno::EWOULDBLOCK) {
|
assert_raise(Errno::EACCES, Errno::EWOULDBLOCK) {
|
||||||
GDBM.open("#{@tmpdir}/#{@prefix}", 0)
|
GDBM.open("#{@tmpdir}/#{@prefix}", 0)
|
||||||
|
|
|
@ -34,6 +34,7 @@ module TestIRB
|
||||||
|
|
||||||
def test_code_around_binding_with_existing_unreadable_file
|
def test_code_around_binding_with_existing_unreadable_file
|
||||||
skip 'chmod cannot make file unreadable on windows' if windows?
|
skip 'chmod cannot make file unreadable on windows' if windows?
|
||||||
|
skip 'skipped in root privilege' if Process.uid == 0
|
||||||
|
|
||||||
Tempfile.create do |f|
|
Tempfile.create do |f|
|
||||||
code = "IRB::WorkSpace.new(binding)\n"
|
code = "IRB::WorkSpace.new(binding)\n"
|
||||||
|
|
|
@ -1336,6 +1336,7 @@ class TestPathname < Test::Unit::TestCase
|
||||||
assert_equal([Pathname("d"), Pathname("d/x")], a)
|
assert_equal([Pathname("d"), Pathname("d/x")], a)
|
||||||
|
|
||||||
skip "no meaning test on Windows" if /mswin|mingw/ =~ RUBY_PLATFORM
|
skip "no meaning test on Windows" if /mswin|mingw/ =~ RUBY_PLATFORM
|
||||||
|
skip 'skipped in root privilege' if Process.uid == 0
|
||||||
a = [];
|
a = [];
|
||||||
assert_raise_with_message(Errno::EACCES, %r{d/x}) do
|
assert_raise_with_message(Errno::EACCES, %r{d/x}) do
|
||||||
Pathname(".").find(ignore_error: false) {|v| a << v }
|
Pathname(".").find(ignore_error: false) {|v| a << v }
|
||||||
|
|
|
@ -18,6 +18,7 @@ class TestRDocOptions < RDoc::TestCase
|
||||||
|
|
||||||
def test_check_files
|
def test_check_files
|
||||||
skip "assumes UNIX permission model" if /mswin|mingw/ =~ RUBY_PLATFORM
|
skip "assumes UNIX permission model" if /mswin|mingw/ =~ RUBY_PLATFORM
|
||||||
|
skip "skipped in root privilege" if Process.uid == 0
|
||||||
|
|
||||||
out, err = capture_io do
|
out, err = capture_io do
|
||||||
temp_dir do
|
temp_dir do
|
||||||
|
|
|
@ -296,6 +296,7 @@ class TestRDocRDoc < RDoc::TestCase
|
||||||
|
|
||||||
def test_parse_file_forbidden
|
def test_parse_file_forbidden
|
||||||
skip 'chmod not supported' if Gem.win_platform?
|
skip 'chmod not supported' if Gem.win_platform?
|
||||||
|
skip 'skipped in root privilege' if Process.uid == 0
|
||||||
|
|
||||||
@rdoc.store = RDoc::Store.new
|
@rdoc.store = RDoc::Store.new
|
||||||
|
|
||||||
|
|
|
@ -200,6 +200,7 @@ class TestRDocRubygemsHook < Gem::TestCase
|
||||||
|
|
||||||
def test_remove_unwritable
|
def test_remove_unwritable
|
||||||
skip 'chmod not supported' if Gem.win_platform?
|
skip 'chmod not supported' if Gem.win_platform?
|
||||||
|
skip 'skipped in root privilege' if Process.uid == 0
|
||||||
FileUtils.mkdir_p @a.base_dir
|
FileUtils.mkdir_p @a.base_dir
|
||||||
FileUtils.chmod 0, @a.base_dir
|
FileUtils.chmod 0, @a.base_dir
|
||||||
|
|
||||||
|
@ -228,6 +229,7 @@ class TestRDocRubygemsHook < Gem::TestCase
|
||||||
|
|
||||||
def test_setup_unwritable
|
def test_setup_unwritable
|
||||||
skip 'chmod not supported' if Gem.win_platform?
|
skip 'chmod not supported' if Gem.win_platform?
|
||||||
|
skip 'skipped in root privilege' if Process.uid == 0
|
||||||
FileUtils.mkdir_p @a.doc_dir
|
FileUtils.mkdir_p @a.doc_dir
|
||||||
FileUtils.chmod 0, @a.doc_dir
|
FileUtils.chmod 0, @a.doc_dir
|
||||||
|
|
||||||
|
|
|
@ -463,7 +463,7 @@ class TestGem < Gem::TestCase
|
||||||
assert File.directory?(util_cache_dir)
|
assert File.directory?(util_cache_dir)
|
||||||
end
|
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
|
def test_self_ensure_gem_directories_write_protected
|
||||||
gemdir = File.join @tempdir, "egd"
|
gemdir = File.join @tempdir, "egd"
|
||||||
FileUtils.rm_r gemdir rescue nil
|
FileUtils.rm_r gemdir rescue nil
|
||||||
|
|
|
@ -158,7 +158,7 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
|
||||||
assert_path_exists @a_1_1.gem_dir
|
assert_path_exists @a_1_1.gem_dir
|
||||||
ensure
|
ensure
|
||||||
FileUtils.chmod 0755, @gemhome
|
FileUtils.chmod 0755, @gemhome
|
||||||
end unless win_platform?
|
end unless win_platform? || Process.uid == 0
|
||||||
|
|
||||||
def test_execute_dry_run
|
def test_execute_dry_run
|
||||||
@cmd.options[:args] = %w[a]
|
@cmd.options[:args] = %w[a]
|
||||||
|
|
|
@ -131,6 +131,7 @@ class TestGemCommandsInstallCommand < Gem::TestCase
|
||||||
|
|
||||||
def test_execute_no_user_install
|
def test_execute_no_user_install
|
||||||
skip 'skipped on MS Windows (chmod has no effect)' if win_platform?
|
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|
|
specs = spec_fetcher do |fetcher|
|
||||||
fetcher.gem 'a', 2
|
fetcher.gem 'a', 2
|
||||||
|
|
|
@ -141,6 +141,8 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
|
||||||
def test_user_install_disabled_read_only
|
def test_user_install_disabled_read_only
|
||||||
if win_platform?
|
if win_platform?
|
||||||
skip('test_user_install_disabled_read_only test skipped on MS Windows')
|
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
|
else
|
||||||
@cmd.handle_options %w[--no-user-install]
|
@cmd.handle_options %w[--no-user-install]
|
||||||
|
|
||||||
|
|
|
@ -437,6 +437,8 @@ gem 'other', version
|
||||||
|
|
||||||
if win_platform?
|
if win_platform?
|
||||||
skip('test_generate_bin_script_no_perms skipped on MS Windows')
|
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
|
else
|
||||||
FileUtils.chmod 0000, util_inst_bindir
|
FileUtils.chmod 0000, util_inst_bindir
|
||||||
|
|
||||||
|
@ -529,6 +531,8 @@ gem 'other', version
|
||||||
|
|
||||||
if win_platform?
|
if win_platform?
|
||||||
skip('test_generate_bin_symlink_no_perms skipped on MS Windows')
|
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
|
else
|
||||||
FileUtils.chmod 0000, util_inst_bindir
|
FileUtils.chmod 0000, util_inst_bindir
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,7 @@ class TestGemRDoc < Gem::TestCase
|
||||||
|
|
||||||
def test_remove_unwritable
|
def test_remove_unwritable
|
||||||
skip 'chmod not supported' if Gem.win_platform?
|
skip 'chmod not supported' if Gem.win_platform?
|
||||||
|
skip 'skipped in root privilege' if Process.uid == 0
|
||||||
FileUtils.mkdir_p @a.base_dir
|
FileUtils.mkdir_p @a.base_dir
|
||||||
FileUtils.chmod 0, @a.base_dir
|
FileUtils.chmod 0, @a.base_dir
|
||||||
|
|
||||||
|
@ -251,6 +252,7 @@ class TestGemRDoc < Gem::TestCase
|
||||||
|
|
||||||
def test_setup_unwritable
|
def test_setup_unwritable
|
||||||
skip 'chmod not supported' if Gem.win_platform?
|
skip 'chmod not supported' if Gem.win_platform?
|
||||||
|
skip 'skipped in root privilege' if Process.uid == 0
|
||||||
FileUtils.mkdir_p @a.doc_dir
|
FileUtils.mkdir_p @a.doc_dir
|
||||||
FileUtils.chmod 0, @a.doc_dir
|
FileUtils.chmod 0, @a.doc_dir
|
||||||
|
|
||||||
|
|
|
@ -431,7 +431,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
|
||||||
assert File.exist?(a1_cache_gem)
|
assert File.exist?(a1_cache_gem)
|
||||||
end
|
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
|
def test_download_local_read_only
|
||||||
FileUtils.mv @a1_gem, @tempdir
|
FileUtils.mv @a1_gem, @tempdir
|
||||||
local_path = File.join @tempdir, @a1.file_name
|
local_path = File.join @tempdir, @a1.file_name
|
||||||
|
|
|
@ -1461,6 +1461,7 @@ dependencies: []
|
||||||
|
|
||||||
def test_build_extensions_extensions_dir_unwritable
|
def test_build_extensions_extensions_dir_unwritable
|
||||||
skip 'chmod not supported' if Gem.win_platform?
|
skip 'chmod not supported' if Gem.win_platform?
|
||||||
|
skip 'skipped in root privilege' if Process.uid == 0
|
||||||
|
|
||||||
ext_spec
|
ext_spec
|
||||||
|
|
||||||
|
@ -1486,7 +1487,7 @@ dependencies: []
|
||||||
@ext.build_extensions
|
@ext.build_extensions
|
||||||
refute_path_exists @ext.extension_dir
|
refute_path_exists @ext.extension_dir
|
||||||
ensure
|
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, File.join(@ext.base_dir, 'extensions')
|
||||||
FileUtils.chmod 0755, @ext.base_dir
|
FileUtils.chmod 0755, @ext.base_dir
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,18 +38,6 @@ class TestGemRequire < Gem::TestCase
|
||||||
assert require(path), "'#{path}' was already required"
|
assert require(path), "'#{path}' was already required"
|
||||||
end
|
end
|
||||||
|
|
||||||
def append_latch spec
|
|
||||||
dir = spec.gem_dir
|
|
||||||
Dir.chdir dir do
|
|
||||||
spec.files.each do |file|
|
|
||||||
File.open file, 'a' do |fp|
|
|
||||||
fp.puts "FILE_ENTERED_LATCH.release"
|
|
||||||
fp.puts "FILE_EXIT_LATCH.await"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Providing -I on the commandline should always beat gems
|
# Providing -I on the commandline should always beat gems
|
||||||
def test_dash_i_beats_gems
|
def test_dash_i_beats_gems
|
||||||
a1 = new_spec "a", "1", {"b" => "= 1"}, "lib/test_gem_require_a.rb"
|
a1 = new_spec "a", "1", {"b" => "= 1"}, "lib/test_gem_require_a.rb"
|
||||||
|
@ -80,6 +68,15 @@ class TestGemRequire < Gem::TestCase
|
||||||
Object.send :remove_const, :HELLO if Object.const_defined? :HELLO
|
Object.send :remove_const, :HELLO if Object.const_defined? :HELLO
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_sync_thread
|
||||||
|
Thread.new do
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
FILE_ENTERED_LATCH.release
|
||||||
|
FILE_EXIT_LATCH.await
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_concurrent_require
|
def test_concurrent_require
|
||||||
skip 'deadlock' if /^1\.8\./ =~ RUBY_VERSION
|
skip 'deadlock' if /^1\.8\./ =~ RUBY_VERSION
|
||||||
|
|
||||||
|
@ -91,11 +88,8 @@ class TestGemRequire < Gem::TestCase
|
||||||
|
|
||||||
install_specs a1, b1
|
install_specs a1, b1
|
||||||
|
|
||||||
append_latch a1
|
t1 = create_sync_thread{ assert_require 'a' }
|
||||||
append_latch b1
|
t2 = create_sync_thread{ assert_require 'b' }
|
||||||
|
|
||||||
t1 = Thread.new { assert_require 'a' }
|
|
||||||
t2 = Thread.new { assert_require 'b' }
|
|
||||||
|
|
||||||
# wait until both files are waiting on the exit latch
|
# wait until both files are waiting on the exit latch
|
||||||
FILE_ENTERED_LATCH.await
|
FILE_ENTERED_LATCH.await
|
||||||
|
@ -106,8 +100,6 @@ class TestGemRequire < Gem::TestCase
|
||||||
assert t1.join, "thread 1 should exit"
|
assert t1.join, "thread 1 should exit"
|
||||||
assert t2.join, "thread 2 should exit"
|
assert t2.join, "thread 2 should exit"
|
||||||
ensure
|
ensure
|
||||||
return if $! # skipping
|
|
||||||
|
|
||||||
Object.send :remove_const, :FILE_ENTERED_LATCH
|
Object.send :remove_const, :FILE_ENTERED_LATCH
|
||||||
Object.send :remove_const, :FILE_EXIT_LATCH
|
Object.send :remove_const, :FILE_EXIT_LATCH
|
||||||
end
|
end
|
||||||
|
|
|
@ -108,6 +108,7 @@ class TestSDBM < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_s_open_error
|
def test_s_open_error
|
||||||
skip "doesn't support to avoid read access by owner on Windows" if /mswin|mingw/ =~ RUBY_PLATFORM
|
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_instance_of(SDBM, sdbm = SDBM.open("#{@tmpdir}/#{@prefix}", 0))
|
||||||
assert_raise(Errno::EACCES) {
|
assert_raise(Errno::EACCES) {
|
||||||
SDBM.open("#{@tmpdir}/#{@prefix}", 0)
|
SDBM.open("#{@tmpdir}/#{@prefix}", 0)
|
||||||
|
@ -519,6 +520,7 @@ class TestSDBM < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_readonly
|
def test_readonly
|
||||||
|
skip "skipped because root can read anything" if /mswin|mingw/ !~ RUBY_PLATFORM && Process.uid == 0
|
||||||
@sdbm["bar"] = "baz"
|
@sdbm["bar"] = "baz"
|
||||||
@sdbm.close
|
@sdbm.close
|
||||||
File.chmod(0444, @path + ".dir")
|
File.chmod(0444, @path + ".dir")
|
||||||
|
|
|
@ -104,6 +104,8 @@ class TestFind < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_unreadable_dir
|
def test_unreadable_dir
|
||||||
skip "no meaning test on Windows" if /mswin|mingw/ =~ RUBY_PLATFORM
|
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.mktmpdir {|d|
|
||||||
Dir.mkdir(dir = "#{d}/dir")
|
Dir.mkdir(dir = "#{d}/dir")
|
||||||
File.open("#{dir}/foo", "w"){}
|
File.open("#{dir}/foo", "w"){}
|
||||||
|
@ -157,6 +159,8 @@ class TestFind < Test::Unit::TestCase
|
||||||
assert_equal([d, dir, file], a)
|
assert_equal([d, dir, file], a)
|
||||||
|
|
||||||
skip "no meaning test on Windows" if /mswin|mingw/ =~ RUBY_PLATFORM
|
skip "no meaning test on Windows" if /mswin|mingw/ =~ RUBY_PLATFORM
|
||||||
|
skip "skipped because root can read anything" if Process.uid == 0
|
||||||
|
|
||||||
a = []
|
a = []
|
||||||
assert_raise_with_message(Errno::EACCES, /#{Regexp.quote(file)}/) do
|
assert_raise_with_message(Errno::EACCES, /#{Regexp.quote(file)}/) do
|
||||||
Find.find(d, ignore_error: false) {|f| a << f }
|
Find.find(d, ignore_error: false) {|f| a << f }
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#define RUBY_VERSION "2.5.0"
|
#define RUBY_VERSION "2.5.0"
|
||||||
#define RUBY_RELEASE_DATE "2018-03-15"
|
#define RUBY_RELEASE_DATE "2018-03-19"
|
||||||
#define RUBY_PATCHLEVEL 40
|
#define RUBY_PATCHLEVEL 41
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2018
|
#define RUBY_RELEASE_YEAR 2018
|
||||||
#define RUBY_RELEASE_MONTH 3
|
#define RUBY_RELEASE_MONTH 3
|
||||||
#define RUBY_RELEASE_DAY 15
|
#define RUBY_RELEASE_DAY 19
|
||||||
|
|
||||||
#include "ruby/version.h"
|
#include "ruby/version.h"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue