Use EnvUtil.suppress_warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9b0ea861ab
commit
20e6b3a3b8
@ -74,46 +74,42 @@ p Foo::Bar
|
|||||||
|
|
||||||
def test_threaded_accessing_constant
|
def test_threaded_accessing_constant
|
||||||
# Suppress "warning: loading in progress, circular require considered harmful"
|
# Suppress "warning: loading in progress, circular require considered harmful"
|
||||||
old_verbose = $VERBOSE
|
EnvUtil.suppress_warning {
|
||||||
$VERBOSE = false
|
Tempfile.create(['autoload', '.rb']) {|file|
|
||||||
Tempfile.create(['autoload', '.rb']) {|file|
|
file.puts 'sleep 0.5; class AutoloadTest; X = 1; end'
|
||||||
file.puts 'sleep 0.5; class AutoloadTest; X = 1; end'
|
file.close
|
||||||
file.close
|
add_autoload(file.path)
|
||||||
add_autoload(file.path)
|
begin
|
||||||
begin
|
assert_nothing_raised do
|
||||||
assert_nothing_raised do
|
t1 = Thread.new { ::AutoloadTest::X }
|
||||||
t1 = Thread.new { ::AutoloadTest::X }
|
t2 = Thread.new { ::AutoloadTest::X }
|
||||||
t2 = Thread.new { ::AutoloadTest::X }
|
[t1, t2].each(&:join)
|
||||||
[t1, t2].each(&:join)
|
end
|
||||||
|
ensure
|
||||||
|
remove_autoload_constant
|
||||||
end
|
end
|
||||||
ensure
|
}
|
||||||
remove_autoload_constant
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
ensure
|
|
||||||
$VERBOSE = old_verbose
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_threaded_accessing_inner_constant
|
def test_threaded_accessing_inner_constant
|
||||||
# Suppress "warning: loading in progress, circular require considered harmful"
|
# Suppress "warning: loading in progress, circular require considered harmful"
|
||||||
old_verbose = $VERBOSE
|
EnvUtil.suppress_warning {
|
||||||
$VERBOSE = false
|
Tempfile.create(['autoload', '.rb']) {|file|
|
||||||
Tempfile.create(['autoload', '.rb']) {|file|
|
file.puts 'class AutoloadTest; sleep 0.5; X = 1; end'
|
||||||
file.puts 'class AutoloadTest; sleep 0.5; X = 1; end'
|
file.close
|
||||||
file.close
|
add_autoload(file.path)
|
||||||
add_autoload(file.path)
|
begin
|
||||||
begin
|
assert_nothing_raised do
|
||||||
assert_nothing_raised do
|
t1 = Thread.new { ::AutoloadTest::X }
|
||||||
t1 = Thread.new { ::AutoloadTest::X }
|
t2 = Thread.new { ::AutoloadTest::X }
|
||||||
t2 = Thread.new { ::AutoloadTest::X }
|
[t1, t2].each(&:join)
|
||||||
[t1, t2].each(&:join)
|
end
|
||||||
|
ensure
|
||||||
|
remove_autoload_constant
|
||||||
end
|
end
|
||||||
ensure
|
}
|
||||||
remove_autoload_constant
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
ensure
|
|
||||||
$VERBOSE = old_verbose
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_nameerror_when_autoload_did_not_define_the_constant
|
def test_nameerror_when_autoload_did_not_define_the_constant
|
||||||
|
Loading…
x
Reference in New Issue
Block a user