mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ext/coverage/: add the oneshot mode
This patch introduces "oneshot_lines" mode for `Coverage.start`, which checks "whether each line was executed at least once or not", instead of "how many times each line was executed". A hook for each line is fired at most once, and after it is fired, the hook flag was removed; it runs with zero overhead. See [Feature #15022] in detail. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fadde099e6
commit
47ea999b46
8 changed files with 312 additions and 36 deletions
14
ext/coverage/lib/coverage.rb
Normal file
14
ext/coverage/lib/coverage.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
require "coverage.so"
|
||||
|
||||
module Coverage
|
||||
def self.line_stub(file)
|
||||
lines = File.foreach(file).map { nil }
|
||||
iseqs = [RubyVM::InstructionSequence.compile_file(file)]
|
||||
until iseqs.empty?
|
||||
iseq = iseqs.pop
|
||||
iseq.trace_points.each {|n, _| lines[n - 1] = 0 }
|
||||
iseq.each_child {|child| iseqs << child }
|
||||
end
|
||||
lines
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue