diff options
-rw-r--r-- | test/ruby/envutil.rb | 9 | ||||
-rw-r--r-- | test/ruby/test_io_m17n.rb | 12 |
2 files changed, 7 insertions, 14 deletions
diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index 69b037b4d8..f9e1060b62 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -179,9 +179,14 @@ module Test assert(status.success?, m) end - def assert_warn(msg) + def assert_warn(pat, message = nil) + message ||= proc {"warning message #{stderr.inspect} is expected to match #{pat.inspect}"} stderr = EnvUtil.verbose_warning { yield } - assert(msg === stderr, "warning message #{stderr.inspect} is expected to match #{msg.inspect}") + assert(pat === stderr, message) + end + + def assert_warning(*args) + assert_warn(*args) {$VERBOSE = false; yield} end def assert_no_memory_leak(args, prepare, code, message=nil, limit: 1.5) diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index b86dfb3274..4f01a82674 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -1,7 +1,6 @@ require 'test/unit' require 'tmpdir' require 'timeout' -require 'stringio' require_relative 'envutil' class TestIO_M17N < Test::Unit::TestCase @@ -12,17 +11,6 @@ class TestIO_M17N < Test::Unit::TestCase Encoding::UTF_8 ] - def assert_warning(pat, mesg=nil) - begin - org_stderr = $stderr - $stderr = StringIO.new(warn = '') - yield - ensure - $stderr = org_stderr - end - assert_match(pat, warn, mesg) - end - def with_tmpdir Dir.mktmpdir {|dir| Dir.chdir(dir) { |