summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-13 03:34:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-13 03:34:11 +0000
commit826cdd67a043b520c70cc9fcf66028603a130560 (patch)
tree2bb62b3e1c3222e1216788affb8553d2b9f449ed /test/ruby
parent7e82db2e1e3b3c101988d6b01564529944cdef95 (diff)
assert_warn, assert_warning
* test/ruby/envutil.rb (assert_warn): add optional message argument. * test/ruby/envutil.rb (assert_warning): moved from test_io_m17n.rb git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/envutil.rb9
-rw-r--r--test/ruby/test_io_m17n.rb12
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) {