ruby-changes:31258
From: nobu <ko1@a...>
Date: Thu, 17 Oct 2013 19:51:40 +0900 (JST)
Subject: [ruby-changes:31258] nobu:r43337 (trunk): envutil.rb: improve assert_no_memory_leak
nobu 2013-10-17 19:51:35 +0900 (Thu, 17 Oct 2013) New Revision: 43337 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43337 Log: envutil.rb: improve assert_no_memory_leak * test/ruby/envutil.rb (assert_no_memory_leak): allow envirionment variables keyword options. Modified files: trunk/test/ruby/envutil.rb Index: test/ruby/envutil.rb =================================================================== --- test/ruby/envutil.rb (revision 43336) +++ test/ruby/envutil.rb (revision 43337) @@ -334,23 +334,25 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/envutil.rb#L334 assert_warning(*args) {$VERBOSE = false; yield} end - def assert_no_memory_leak(args, prepare, code, message=nil, limit: 1.5) + def assert_no_memory_leak(args, prepare, code, message=nil, limit: 1.5, **opt) 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) + envs = args.shift if Array === args and Hash === args.first args = [ "--disable=gems", "-r", File.expand_path("../memory_status", __FILE__), *args, "-v", "-", ] + args.unshift(envs) if envs cmd = [ 'END {STDERR.puts '"#{token_dump}"'"FINAL=#{Memory::Status.new.size}"}', prepare, 'STDERR.puts('"#{token_dump}"'"START=#{$initial_size = Memory::Status.new.size}")', code, ].join("\n") - _, err, status = EnvUtil.invoke_ruby(args, cmd, true, true) + _, 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 assert_equal([true, ""], [status.success?, err], message) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/