mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
memory_status.rb: independent of MiniTest
* test/lib/memory_status.rb: make Memory::Status independent of MiniTest::Skip. * test/lib/test/unit/assertions.rb (assert_no_memory_leak): skip if Memory::Status is not available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b3f4db9227
commit
e1e223a874
3 changed files with 27 additions and 12 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Wed Mar 9 13:22:49 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* test/lib/memory_status.rb: make Memory::Status independent of
|
||||||
|
MiniTest::Skip.
|
||||||
|
|
||||||
|
* test/lib/test/unit/assertions.rb (assert_no_memory_leak): skip
|
||||||
|
if Memory::Status is not available.
|
||||||
|
|
||||||
Wed Mar 9 09:19:55 2016 Rei Odaira <Rei.Odaira@gmail.com>
|
Wed Mar 9 09:19:55 2016 Rei Odaira <Rei.Odaira@gmail.com>
|
||||||
|
|
||||||
* test/io/wait/test_io_wait.rb (test_wait_readwrite_timeout):
|
* test/io/wait/test_io_wait.rb (test_wait_readwrite_timeout):
|
||||||
|
|
|
@ -58,13 +58,12 @@ module Memory
|
||||||
yield :size, info.PagefileUsage
|
yield :size, info.PagefileUsage
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
when (require_relative 'find_executable'
|
||||||
PAT = /^\s*(\d+)\s+(\d+)$/
|
pat = /^\s*(\d+)\s+(\d+)$/
|
||||||
require_relative 'find_executable'
|
pscmd = EnvUtil.find_executable("ps", "-ovsz=", "-orss=", "-p", $$.to_s) {|out| pat =~ out})
|
||||||
if PSCMD = EnvUtil.find_executable("ps", "-ovsz=", "-orss=", "-p", $$.to_s) {|out| PAT =~ out}
|
pscmd.pop
|
||||||
PSCMD.pop
|
PAT = pat
|
||||||
end
|
PSCMD = pscmd
|
||||||
raise MiniTest::Skip, "ps command not found" unless PSCMD
|
|
||||||
|
|
||||||
keys << :size << :rss
|
keys << :size << :rss
|
||||||
def self.read_status
|
def self.read_status
|
||||||
|
@ -73,19 +72,25 @@ module Memory
|
||||||
yield :rss, $2.to_i*1024
|
yield :rss, $2.to_i*1024
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
def self.read_status
|
||||||
|
raise NotImplementedError, "unsupported platform"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if !keys.empty?
|
||||||
Status = Struct.new(*keys)
|
Status = Struct.new(*keys)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class Status
|
if defined?(Memory::Status)
|
||||||
|
class Memory::Status
|
||||||
def _update
|
def _update
|
||||||
Memory.read_status do |key, val|
|
Memory.read_status do |key, val|
|
||||||
self[key] = val
|
self[key] = val
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
class Status
|
|
||||||
Header = members.map {|k| k.to_s.upcase.rjust(6)}.join('')
|
Header = members.map {|k| k.to_s.upcase.rjust(6)}.join('')
|
||||||
Format = "%6d"
|
Format = "%6d"
|
||||||
|
|
||||||
|
@ -131,7 +136,7 @@ module Memory
|
||||||
]
|
]
|
||||||
_, err, status = EnvUtil.invoke_ruby(args, "exit(0)", true, true)
|
_, err, status = EnvUtil.invoke_ruby(args, "exit(0)", true, true)
|
||||||
if status.exitstatus == 0 && err.to_s.empty? then
|
if status.exitstatus == 0 && err.to_s.empty? then
|
||||||
NO_MEMORY_LEAK_ENVS = envs
|
Memory::NO_MEMORY_LEAK_ENVS = envs
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end #case RUBY_PLATFORM
|
end #case RUBY_PLATFORM
|
||||||
|
|
|
@ -638,6 +638,8 @@ eom
|
||||||
|
|
||||||
def assert_no_memory_leak(args, prepare, code, message=nil, limit: 2.0, rss: false, **opt)
|
def assert_no_memory_leak(args, prepare, code, message=nil, limit: 2.0, rss: false, **opt)
|
||||||
require_relative '../../memory_status'
|
require_relative '../../memory_status'
|
||||||
|
raise MiniTest::Skip, "unsupported platform" unless defined?(Memory::Status)
|
||||||
|
|
||||||
token = "\e[7;1m#{$$.to_s}:#{Time.now.strftime('%s.%L')}:#{rand(0x10000).to_s(16)}:\e[m"
|
token = "\e[7;1m#{$$.to_s}:#{Time.now.strftime('%s.%L')}:#{rand(0x10000).to_s(16)}:\e[m"
|
||||||
token_dump = token.dump
|
token_dump = token.dump
|
||||||
token_re = Regexp.quote(token)
|
token_re = Regexp.quote(token)
|
||||||
|
|
Loading…
Reference in a new issue