Actions
Bug #16776
openRegression in coverage library
Description
Hi!
I noticed a regression in the coverage library. I tried to write a minimal program to show it, hopefully it gives some clues or where the issue might lie.
In ruby 2.5.8 and earlier, the following program would print {:lines=>[1, 1, nil]}
, showing that the body of the "foo" method was run once. However, on newer rubies, it prints {:lines=>[1, 0, nil]}
, which is incorrect because the "foo" method body has actually been run once.
This is the repro script:
# frozen_string_literal: true
require "coverage"
Coverage.start(lines: true)
code = <<~RUBY
def foo
"LOL"
end
RUBY
File.open("foo.rb", "w") { |f| f.write(code) }
require_relative "foo"
TracePoint.new(:line) do |_tp|
foo
end.enable do
sleep 0
end
res = Coverage.result
puts res[File.expand_path("foo.rb")]
Actions