ruby-changes:33738
From: nagachika <ko1@a...>
Date: Mon, 5 May 2014 02:19:26 +0900 (JST)
Subject: [ruby-changes:33738] nagachika:r45819 (ruby_2_1): merge revision(s) r45298, r45311: [Backport #9518]
nagachika 2014-05-05 02:19:20 +0900 (Mon, 05 May 2014) New Revision: 45819 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45819 Log: merge revision(s) r45298,r45311: [Backport #9518] test/ruby/envutil.rb: compare RSS to check memory leak * test/ruby/envutil.rb (Test::Test#assert_no_memory_leak): compare also RSS if available. * test/ruby/memory_status.rb (Memory::Status.parse): read string form of an instance. Modified directories: branches/ruby_2_1/ Modified files: branches/ruby_2_1/test/ruby/envutil.rb branches/ruby_2_1/test/ruby/memory_status.rb branches/ruby_2_1/version.h Index: ruby_2_1/version.h =================================================================== --- ruby_2_1/version.h (revision 45818) +++ ruby_2_1/version.h (revision 45819) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1 #define RUBY_VERSION "2.1.2" #define RUBY_RELEASE_DATE "2014-05-05" -#define RUBY_PATCHLEVEL 89 +#define RUBY_PATCHLEVEL 90 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 5 Index: ruby_2_1/test/ruby/memory_status.rb =================================================================== --- ruby_2_1/test/ruby/memory_status.rb (revision 45818) +++ ruby_2_1/test/ruby/memory_status.rb (revision 45819) @@ -1,5 +1,3 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/memory_status.rb#L1 -require_relative "envutil" - module Memory keys = [] vals = [] @@ -110,5 +108,20 @@ module Memory https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/memory_status.rb#L108 def initialize _update end + + def to_s + status = each_pair.map {|n,v| + "#{n}:#{v}" + } + "{#{status.join(",")}}" + end + + def self.parse(str) + status = allocate + str.scan(/(?:\A\{|\G,)(#{members.join('|')}):(\d+)(?=,|\}\z)/) do + status[$1] = $2.to_i + end + status + end end end Index: ruby_2_1/test/ruby/envutil.rb =================================================================== --- ruby_2_1/test/ruby/envutil.rb (revision 45818) +++ ruby_2_1/test/ruby/envutil.rb (revision 45819) @@ -373,6 +373,7 @@ eom https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/envutil.rb#L373 end def assert_no_memory_leak(args, prepare, code, message=nil, limit: 1.5, **opt) + require_relative 'memory_status' token = "\e[7;1m#{$$.to_s}:#{Time.now.strftime('%s.%L')}:#{rand(0x10000).to_s(16)}:\e[m" token_dump = token.dump token_re = Regexp.quote(token) @@ -385,16 +386,23 @@ eom https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/envutil.rb#L386 ] args.unshift(envs) if envs cmd = [ - 'END {STDERR.puts '"#{token_dump}"'"FINAL=#{Memory::Status.new.size}"}', + 'END {STDERR.puts '"#{token_dump}"'"FINAL=#{Memory::Status.new}"}', prepare, - 'STDERR.puts('"#{token_dump}"'"START=#{$initial_size = Memory::Status.new.size}")', + 'STDERR.puts('"#{token_dump}"'"START=#{$initial_status = Memory::Status.new}")', + '$initial_size = $initial_status.size', code, + 'GC.start', ].join("\n") _, err, status = EnvUtil.invoke_ruby(args, cmd, true, true, **opt) - before = err.sub!(/^#{token_re}START=(\d+)\n/, '') && $1.to_i - after = err.sub!(/^#{token_re}FINAL=(\d+)\n/, '') && $1.to_i + before = err.sub!(/^#{token_re}START=(\{.*\})\n/, '') && Memory::Status.parse($1) + after = err.sub!(/^#{token_re}FINAL=(\{.*\})\n/, '') && Memory::Status.parse($1) assert_equal([true, ""], [status.success?, err], message) - assert_operator(after.fdiv(before), :<, limit, message) + ([:size, :rss] & after.members).each do |n| + b = before[n] + a = after[n] + next unless a > 0 and b > 0 + assert_operator(a.fdiv(b), :<, limit, message(message) {"#{n}: #{b} => #{a}"}) + end end def assert_is_minus_zero(f) Property changes on: ruby_2_1 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r45298,45311 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/