From 96399a0c5f29762f3633474617e9d982dbbfcfa9 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 17 Oct 2013 10:51:35 +0000 Subject: [PATCH] envutil.rb: improve assert_no_memory_leak * test/ruby/envutil.rb (assert_no_memory_leak): allow envirionment variables keyword options. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/envutil.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index 41ba7ecf1b..1ae54d5fdb 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -334,23 +334,25 @@ eom 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)