Remove --disable-gems in assert_in_out_err

assert_in_out_err adds --disable=gems so we don't need to add
--disable-gems in the args list.
This commit is contained in:
Peter Zhu 2023-08-26 19:31:46 -04:00
Родитель caf48487ca
Коммит 91de37c23e
7 изменённых файлов: 54 добавлений и 56 удалений

Просмотреть файл

@ -22,8 +22,7 @@ class TestBugReporter < Test::Unit::TestCase
tmpdir = Dir.mktmpdir
no_core = "Process.setrlimit(Process::RLIMIT_CORE, 0); " if defined?(Process.setrlimit) && defined?(Process::RLIMIT_CORE)
args = ["--disable-gems", "-r-test-/bug_reporter",
"-C", tmpdir]
args = ["-r-test-/bug_reporter", "-C", tmpdir]
args.push("--yjit") if yjit_enabled? # We want the printed description to match this process's RUBY_DESCRIPTION
args.unshift({"RUBY_ON_BUG" => nil})
stdin = "#{no_core}register_sample_bug_reporter(12345); Process.kill :SEGV, $$"

Просмотреть файл

@ -233,7 +233,7 @@ EOT
def test_gc
if respond_to?(:assert_in_out_err) && !(RUBY_PLATFORM =~ /java/)
assert_in_out_err(%w[-rjson --disable-gems], <<-EOS, [], [])
assert_in_out_err(%w[-rjson], <<-EOS, [], [])
bignum_too_long_to_embed_as_string = 1234567890123456789012345
expect = bignum_too_long_to_embed_as_string.to_s
GC.stress = true

Просмотреть файл

@ -228,12 +228,12 @@ class TestGc < Test::Unit::TestCase
def test_latest_gc_info
omit 'stress' if GC.stress
assert_separately %w[--disable-gem], __FILE__, __LINE__, <<-'eom'
GC.start
count = GC.stat(:heap_free_slots) + GC.stat(:heap_allocatable_pages) * GC::INTERNAL_CONSTANTS[:HEAP_PAGE_OBJ_LIMIT]
count.times{ "a" + "b" }
assert_equal :newobj, GC.latest_gc_info[:gc_by]
eom
assert_separately([], __FILE__, __LINE__, <<-'RUBY')
GC.start
count = GC.stat(:heap_free_slots) + GC.stat(:heap_allocatable_pages) * GC::INTERNAL_CONSTANTS[:HEAP_PAGE_OBJ_LIMIT]
count.times{ "a" + "b" }
assert_equal :newobj, GC.latest_gc_info[:gc_by]
RUBY
GC.latest_gc_info(h = {}) # allocate hash and rehearsal
GC.start
@ -335,7 +335,7 @@ class TestGc < Test::Unit::TestCase
end
def test_stress_compile_send
assert_in_out_err(%w[--disable-gems], <<-EOS, [], [], "")
assert_in_out_err([], <<-EOS, [], [], "")
GC.stress = true
begin
eval("A::B.c(1, 1, d: 234)")
@ -345,7 +345,7 @@ class TestGc < Test::Unit::TestCase
end
def test_singleton_method
assert_in_out_err(%w[--disable-gems], <<-EOS, [], [], "[ruby-dev:42832]")
assert_in_out_err([], <<-EOS, [], [], "[ruby-dev:42832]")
GC.stress = true
10.times do
obj = Object.new
@ -357,7 +357,7 @@ class TestGc < Test::Unit::TestCase
end
def test_singleton_method_added
assert_in_out_err(%w[--disable-gems], <<-EOS, [], [], "[ruby-dev:44436]")
assert_in_out_err([], <<-EOS, [], [], "[ruby-dev:44436]")
class BasicObject
undef singleton_method_added
def singleton_method_added(mid)
@ -404,7 +404,7 @@ class TestGc < Test::Unit::TestCase
"RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR" => "0.4",
}
# always full GC when RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR < 1.0
assert_in_out_err([env, "--disable-gems", "-e", "GC.start; 1000_000.times{Object.new}; p(GC.stat[:minor_gc_count] < GC.stat[:major_gc_count])"], "", ['true'], //, "")
assert_in_out_err([env, "-e", "GC.start; 1000_000.times{Object.new}; p(GC.stat[:minor_gc_count] < GC.stat[:major_gc_count])"], "", ['true'], //, "")
end
env = {
@ -505,19 +505,19 @@ class TestGc < Test::Unit::TestCase
def test_profiler_clear
omit "for now"
assert_separately %w[--disable-gem], __FILE__, __LINE__, <<-'eom', timeout: 30
GC::Profiler.enable
assert_separately([], __FILE__, __LINE__, <<-'RUBY', timeout: 30)
GC::Profiler.enable
GC.start
assert_equal(1, GC::Profiler.raw_data.size)
GC::Profiler.clear
assert_equal(0, GC::Profiler.raw_data.size)
GC.start
assert_equal(1, GC::Profiler.raw_data.size)
GC::Profiler.clear
assert_equal(0, GC::Profiler.raw_data.size)
200.times{ GC.start }
assert_equal(200, GC::Profiler.raw_data.size)
GC::Profiler.clear
assert_equal(0, GC::Profiler.raw_data.size)
eom
200.times{ GC.start }
assert_equal(200, GC::Profiler.raw_data.size)
GC::Profiler.clear
assert_equal(0, GC::Profiler.raw_data.size)
RUBY
end
def test_profiler_total_time
@ -531,34 +531,34 @@ class TestGc < Test::Unit::TestCase
end
def test_finalizing_main_thread
assert_in_out_err(%w[--disable-gems], <<-EOS, ["\"finalize\""], [], "[ruby-dev:46647]")
assert_in_out_err([], <<-EOS, ["\"finalize\""], [], "[ruby-dev:46647]")
ObjectSpace.define_finalizer(Thread.main) { p 'finalize' }
EOS
end
def test_expand_heap
assert_separately %w[--disable-gem], __FILE__, __LINE__, <<-'eom'
GC.start
base_length = GC.stat[:heap_eden_pages]
(base_length * 500).times{ 'a' }
GC.start
base_length = GC.stat[:heap_eden_pages]
(base_length * 500).times{ 'a' }
GC.start
assert_in_epsilon base_length, (v = GC.stat[:heap_eden_pages]), 1/8r,
"invalid heap expanding (base_length: #{base_length}, GC.stat[:heap_eden_pages]: #{v})"
assert_separately([], __FILE__, __LINE__, <<~'RUBY')
GC.start
base_length = GC.stat[:heap_eden_pages]
(base_length * 500).times{ 'a' }
GC.start
base_length = GC.stat[:heap_eden_pages]
(base_length * 500).times{ 'a' }
GC.start
assert_in_epsilon base_length, (v = GC.stat[:heap_eden_pages]), 1/8r,
"invalid heap expanding (base_length: #{base_length}, GC.stat[:heap_eden_pages]: #{v})"
a = []
(base_length * 500).times{ a << 'a'; nil }
GC.start
assert_operator base_length, :<, GC.stat[:heap_eden_pages] + 1
eom
a = []
(base_length * 500).times{ a << 'a'; nil }
GC.start
assert_operator base_length, :<, GC.stat[:heap_eden_pages] + 1
RUBY
end
def test_thrashing_for_young_objects
# This test prevents bugs like [Bug #18929]
assert_separately %w[--disable-gem], __FILE__, __LINE__, <<-'RUBY'
assert_separately([], __FILE__, __LINE__, <<-'RUBY')
# Grow the heap
@ary = 100_000.times.map { Object.new }
@ -648,11 +648,11 @@ class TestGc < Test::Unit::TestCase
end
def test_finalizer_passed_object_id
assert_in_out_err(%w[--disable-gems], <<-EOS, ["true"], [])
assert_in_out_err([], <<~RUBY, ["true"], [])
o = Object.new
obj_id = o.object_id
ObjectSpace.define_finalizer(o, ->(id){ p id == obj_id })
EOS
RUBY
end
def test_verify_internal_consistency

Просмотреть файл

@ -193,7 +193,7 @@ class TestRequire < Test::Unit::TestCase
File.write(req, "p :ok\n")
assert_file.exist?(req)
req[/.rb$/i] = ""
assert_in_out_err(['--disable-gems'], <<-INPUT, %w(:ok), [])
assert_in_out_err([], <<-INPUT, %w(:ok), [])
require "#{req}"
require "#{req}"
INPUT
@ -681,7 +681,7 @@ class TestRequire < Test::Unit::TestCase
Dir.mktmpdir {|tmp|
Dir.chdir(tmp) {
open("foo.rb", "w") {}
assert_in_out_err([{"RUBYOPT"=>nil}, '--disable-gems'], "#{<<~"begin;"}\n#{<<~"end;"}", %w(:ok), [], bug7158)
assert_in_out_err([{"RUBYOPT"=>nil}], "#{<<~"begin;"}\n#{<<~"end;"}", %w(:ok), [], bug7158)
begin;
$:.replace([IO::NULL])
a = Object.new
@ -709,7 +709,7 @@ class TestRequire < Test::Unit::TestCase
Dir.mktmpdir {|tmp|
Dir.chdir(tmp) {
open("foo.rb", "w") {}
assert_in_out_err([{"RUBYOPT"=>nil}, '--disable-gems'], "#{<<~"begin;"}\n#{<<~"end;"}", %w(:ok), [], bug7158)
assert_in_out_err([{"RUBYOPT"=>nil}], "#{<<~"begin;"}\n#{<<~"end;"}", %w(:ok), [], bug7158)
begin;
$:.replace([IO::NULL])
a = Object.new
@ -739,7 +739,7 @@ class TestRequire < Test::Unit::TestCase
open("foo.rb", "w") {}
Dir.mkdir("a")
open(File.join("a", "bar.rb"), "w") {}
assert_in_out_err(['--disable-gems'], "#{<<~"begin;"}\n#{<<~"end;"}", %w(:ok), [], bug7383)
assert_in_out_err([], "#{<<~"begin;"}\n#{<<~"end;"}", %w(:ok), [], bug7383)
begin;
$:.replace([IO::NULL])
$:.#{add} "#{tmp}"
@ -963,7 +963,7 @@ class TestRequire < Test::Unit::TestCase
def test_require_with_public_method_missing
# [Bug #19793]
assert_separately(["-W0", "--disable-gems", "-rtempfile"], __FILE__, __LINE__, <<~RUBY)
assert_separately(["-W0", "-rtempfile"], __FILE__, __LINE__, <<~RUBY)
GC.stress = true
class Object

Просмотреть файл

@ -135,12 +135,12 @@ class TestRubyOptions < Test::Unit::TestCase
end
def test_debug
assert_in_out_err(["--disable-gems", "-de", "p $DEBUG"], "", %w(true), [])
assert_in_out_err(["-de", "p $DEBUG"], "", %w(true), [])
assert_in_out_err(["--disable-gems", "--debug", "-e", "p $DEBUG"],
assert_in_out_err(["--debug", "-e", "p $DEBUG"],
"", %w(true), [])
assert_in_out_err(["--disable-gems", "--debug-", "-e", "p $DEBUG"], "", %w(), /invalid option --debug-/)
assert_in_out_err(["--debug-", "-e", "p $DEBUG"], "", %w(), /invalid option --debug-/)
end
q = Regexp.method(:quote)
@ -211,9 +211,9 @@ class TestRubyOptions < Test::Unit::TestCase
assert_in_out_err(%w(--disable foobarbazqux -e) + [""], "", [],
/unknown argument for --disable: `foobarbazqux'/)
assert_in_out_err(%w(--disable), "", [], /missing argument for --disable/)
assert_in_out_err(%w(--disable-gems -e) + ['p defined? Gem'], "", ["nil"], [])
assert_in_out_err(%w(-e) + ['p defined? Gem'], "", ["nil"], [])
assert_in_out_err(%w(--disable-did_you_mean -e) + ['p defined? DidYouMean'], "", ["nil"], [])
assert_in_out_err(%w(--disable-gems -e) + ['p defined? DidYouMean'], "", ["nil"], [])
assert_in_out_err(%w(-e) + ['p defined? DidYouMean'], "", ["nil"], [])
end
def test_kanji

Просмотреть файл

@ -395,7 +395,7 @@ class TestThread < Test::Unit::TestCase
end
INPUT
assert_in_out_err(%w(--disable-gems -d), <<-INPUT, %w(false 2), %r".+")
assert_in_out_err(%w(-d), <<-INPUT, %w(false 2), %r".+")
p Thread.abort_on_exception
begin
t = Thread.new { raise }

Просмотреть файл

@ -209,8 +209,7 @@ puts Tempfile.new('foo').path
def test_tempfile_finalizer_does_not_run_if_unlinked
bug8768 = '[ruby-core:56521] [Bug #8768]'
args = %w(--disable-gems -rtempfile)
assert_in_out_err(args, <<-'EOS') do |(filename), (error)|
assert_in_out_err(%w(-rtempfile), <<-'EOS') do |(filename), (error)|
tmp = Tempfile.new('foo')
puts tmp.path
tmp.close