Aliases capture_output to capture_io for test-unit compatiblity.

This commit is contained in:
Hiroshi SHIBATA 2019-08-08 17:19:23 +09:00
parent 1ad0f4e593
commit b39efb163d
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2
5 changed files with 6 additions and 9 deletions

View File

@ -34,12 +34,8 @@ class TestBenchmark < Test::Unit::TestCase
end end
end end
def capture_output
capture_io { yield }.first.gsub(/[ \-]\d\.\d{6}/, ' --time--')
end
def capture_bench_output(type, *args, &block) def capture_bench_output(type, *args, &block)
capture_output { bench(type, *args, &block) } capture_output { bench(type, *args, &block) }.first.gsub(/[ \-]\d\.\d{6}/, ' --time--')
end end
def test_tms_outputs_nicely def test_tms_outputs_nicely
@ -85,7 +81,7 @@ BENCH
def test_bm_returns_an_Array_of_the_times_with_the_labels def test_bm_returns_an_Array_of_the_times_with_the_labels
[:bm, :bmbm].each do |meth| [:bm, :bmbm].each do |meth|
capture_io do capture_output do
results = bench(meth) results = bench(meth)
assert_instance_of(Array, results) assert_instance_of(Array, results)
assert_equal(labels.size, results.size) assert_equal(labels.size, results.size)

View File

@ -104,7 +104,7 @@ class TestCSVInterfaceRead < Test::Unit::TestCase
end end
def test_open_encoding_nonexistent def test_open_encoding_nonexistent
_output, error = capture_io do _output, error = capture_output do
CSV.open(@input.path, encoding: "nonexistent") do CSV.open(@input.path, encoding: "nonexistent") do
end end
end end

View File

@ -68,7 +68,7 @@ module TestIRB
"_\n", "_\n",
]) ])
irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input) irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
out, err = capture_io do out, err = capture_output do
irb.eval_input irb.eval_input
end end
assert_empty err assert_empty err

View File

@ -45,7 +45,7 @@ module TestWEBrick
:Logger => WEBrick::Log.new(log_ary, WEBrick::BasicLog::WARN), :Logger => WEBrick::Log.new(log_ary, WEBrick::BasicLog::WARN),
:AccessLog => [[access_log_ary, ""]] :AccessLog => [[access_log_ary, ""]]
}.update(config)) }.update(config))
server = capture_io {break klass.new(config)} server = capture_output {break klass.new(config)}
server_thread = server.start server_thread = server.start
server_thread2 = Thread.new { server_thread2 = Thread.new {
server_thread.join server_thread.join

View File

@ -480,6 +480,7 @@ module MiniTest
return captured_stdout.string, captured_stderr.string return captured_stdout.string, captured_stderr.string
end end
alias capture_output capture_io
## ##
# Captures $stdout and $stderr into strings, using Tempfile to # Captures $stdout and $stderr into strings, using Tempfile to