summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-12 21:51:53 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-12 21:51:53 +0000
commitc32ce5fc27075d64e0509fee5e6703098aa617c4 (patch)
tree758d3def264844f83ffbf04ddd6316b9dfec7779
parentc895b54f14c7654bcd53a1683b8df3244156f7d9 (diff)
Do not change Encoding.default_internal in assert_raise_with_message
* It is not thread-safe: if two threads call it concurrently, the default_internal Encoding might not be restored, which causes many problems. The same applies for $VERBOSE, which might also not be restored to its original value but to the new value instead. This happens because reading the original value might capture the value already changed by EnvUtil.with_default_internal in another Thread. One solution could be to capture the value of these globals before running the test. * Reverts part of r54522. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/lib/test/unit/assertions.rb9
1 files changed, 3 insertions, 6 deletions
diff --git a/test/lib/test/unit/assertions.rb b/test/lib/test/unit/assertions.rb
index fda2299eb0..9bb8686e1f 100644
--- a/test/lib/test/unit/assertions.rb
+++ b/test/lib/test/unit/assertions.rb
@@ -133,13 +133,10 @@ module Test
raise TypeError, "Expected #{expected.inspect} to be a kind of String or Regexp, not #{expected.class}"
end
- ex = m = nil
- EnvUtil.with_default_internal(expected.encoding) do
- ex = assert_raise(exception, msg || proc {"Exception(#{exception}) with message matches to #{expected.inspect}"}) do
- yield
- end
- m = ex.message
+ ex = assert_raise(exception, msg || proc {"Exception(#{exception}) with message matches to #{expected.inspect}"}) do
+ yield
end
+ m = ex.message
msg = message(msg, "") {"Expected Exception(#{exception}) was raised, but the message doesn't match"}
if assert == :assert_equal