summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-12 14:01:00 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-12 14:01:00 +0000
commit31eb1938832eb3a3a69c7246db151c96b589b877 (patch)
treedf549f0d865b618e0814d3b3da5d1f4a5bc0c3d9
parentaaf2d070a8351dc3118422bae478978f3d3e3966 (diff)
* test/lib/leakchecker.rb: Check environment variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--test/lib/leakchecker.rb33
2 files changed, 36 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 4dc5744..4290b01 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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):
diff --git a/test/lib/leakchecker.rb b/test/lib/leakchecker.rb
index a1093de..24f19de 100644
--- a/test/lib/leakchecker.rb
+++ b/test/lib/leakchecker.rb
@@ -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