From c32ce5fc27075d64e0509fee5e6703098aa617c4 Mon Sep 17 00:00:00 2001 From: eregon Date: Tue, 12 Dec 2017 21:51:53 +0000 Subject: 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 --- test/lib/test/unit/assertions.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'test/lib') 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 -- cgit v1.2.3