1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2017-12-12 21:32:13 +00:00
parent 3f2305f15b
commit c895b54f14

View file

@ -5,6 +5,7 @@ class LeakChecker
@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
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
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)