ruby-changes:49076
From: eregon <ko1@a...>
Date: Wed, 13 Dec 2017 06:32:19 +0900 (JST)
Subject: [ruby-changes:49076] eregon:r61191 (trunk): Check that global encodings are not changed in test-all
eregon 2017-12-13 06:32:13 +0900 (Wed, 13 Dec 2017) New Revision: 61191 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61191 Log: Check that global encodings are not changed in test-all * Check that Encoding.default_internal and Encoding.default_external are the same before and after every test. Modified files: trunk/test/lib/leakchecker.rb Index: test/lib/leakchecker.rb =================================================================== --- test/lib/leakchecker.rb (revision 61190) +++ test/lib/leakchecker.rb (revision 61191) @@ -5,6 +5,7 @@ class LeakChecker https://github.com/ruby/ruby/blob/trunk/test/lib/leakchecker.rb#L5 @tempfile_info = find_tempfiles @thread_info = find_threads @env_info = find_env + @encoding_info = find_encodings end def check(test_name) @@ -12,7 +13,8 @@ class LeakChecker https://github.com/ruby/ruby/blob/trunk/test/lib/leakchecker.rb#L13 check_fd_leak(test_name), check_thread_leak(test_name), check_tempfile_leak(test_name), - check_env(test_name) + check_env(test_name), + check_encodings(test_name), ] GC.start if leaks.any? end @@ -197,6 +199,26 @@ class LeakChecker https://github.com/ruby/ruby/blob/trunk/test/lib/leakchecker.rb#L199 return true end + def find_encodings + [Encoding.default_internal, Encoding.default_external] + end + + def check_encodings(test_name) + old_internal, old_external = @encoding_info + new_internal, new_external = find_encodings + leaked = false + if new_internal != old_internal + leaked = true + puts "Encoding.default_internal changed: #{test_name} : #{old_internal.inspect} to #{new_internal.inspect}" + end + if new_external != old_external + leaked = true + puts "Encoding.default_external changed: #{test_name} : #{old_external.inspect} to #{new_external.inspect}" + end + @encoding_info = [new_internal, new_external] + return leaked + end + def puts(*a) output = MiniTest::Unit.output if defined?(output.set_encoding) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/