зеркало из https://github.com/github/ruby.git
* test/lib/leakchecker.rb: Check environment variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
aaf2d070a8
Коммит
31eb193883
|
@ -1,3 +1,7 @@
|
|||
Thu Mar 12 22:59:53 2015 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* test/lib/leakchecker.rb: Check environment variables.
|
||||
|
||||
Thu Mar 12 05:54:27 2015 Eric Wong <e@80x24.org>
|
||||
|
||||
* ext/socket/init.c (rsock_s_accept_nonblock):
|
||||
|
|
|
@ -3,13 +3,15 @@ class LeakChecker
|
|||
@fd_info = find_fds
|
||||
@tempfile_info = find_tempfiles
|
||||
@thread_info = find_threads
|
||||
@env_info = find_env
|
||||
end
|
||||
|
||||
def check(test_name)
|
||||
leaked1 = check_fd_leak(test_name)
|
||||
leaked2 = check_thread_leak(test_name)
|
||||
leaked3 = check_tempfile_leak(test_name)
|
||||
GC.start if leaked1 || leaked2 || leaked3
|
||||
leaked4 = check_env(test_name)
|
||||
GC.start if leaked1 || leaked2 || leaked3 || leaked4
|
||||
end
|
||||
|
||||
def find_fds
|
||||
|
@ -161,6 +163,35 @@ class LeakChecker
|
|||
return leaked
|
||||
end
|
||||
|
||||
def find_env
|
||||
ENV.to_h
|
||||
end
|
||||
|
||||
def check_env(test_name)
|
||||
old_env = @env_info
|
||||
new_env = ENV.to_h
|
||||
return false if old_env == new_env
|
||||
(old_env.keys | new_env.keys).sort.each {|k|
|
||||
if old_env.has_key?(k)
|
||||
if new_env.has_key?(k)
|
||||
if old_env[k] != new_env[k]
|
||||
puts "Environment variable changed: #{test_name} : #{k.inspect} changed : #{old_env[k].inspect} -> #{new_env[k].inspect}"
|
||||
end
|
||||
else
|
||||
puts "Environment variable changed: #{test_name} : #{k.inspect} deleted"
|
||||
end
|
||||
else
|
||||
if new_env.has_key?(k)
|
||||
puts "Environment variable changed: #{test_name} : #{k.inspect} added"
|
||||
else
|
||||
flunk "unreachable"
|
||||
end
|
||||
end
|
||||
}
|
||||
@env_info = new_env
|
||||
return true
|
||||
end
|
||||
|
||||
def puts(*a)
|
||||
MiniTest::Unit.output.puts(*a)
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче