[前][次][番号順一覧][スレッド一覧]

ruby-changes:37868

From: akr <ko1@a...>
Date: Thu, 12 Mar 2015 23:01:32 +0900 (JST)
Subject: [ruby-changes:37868] akr:r49949 (trunk): * test/lib/leakchecker.rb: Check environment variables.

akr	2015-03-12 23:01:00 +0900 (Thu, 12 Mar 2015)

  New Revision: 49949

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49949

  Log:
    * test/lib/leakchecker.rb: Check environment variables.

  Modified files:
    trunk/ChangeLog
    trunk/test/lib/leakchecker.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49948)
+++ ChangeLog	(revision 49949)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Mar 12 22:59:53 2015  Tanaka Akira  <akr@f...>
+
+	* test/lib/leakchecker.rb: Check environment variables.
+
 Thu Mar 12 05:54:27 2015  Eric Wong  <e@8...>
 
 	* ext/socket/init.c (rsock_s_accept_nonblock):
Index: test/lib/leakchecker.rb
===================================================================
--- test/lib/leakchecker.rb	(revision 49948)
+++ test/lib/leakchecker.rb	(revision 49949)
@@ -3,13 +3,15 @@ class LeakChecker https://github.com/ruby/ruby/blob/trunk/test/lib/leakchecker.rb#L3
     @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 https://github.com/ruby/ruby/blob/trunk/test/lib/leakchecker.rb#L163
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]