Issue #16776 has been updated by marcandre (Marc-Andre Lafortune).
I'm not super familiar with `TracePoint`, but at first sight `DeepCover` sh=
ouldn't generate any extra callbacks as the instrumenting is minimal, typic=
ally adding `$tracker[42] +=3D 1` and taking care to never change the line =
numbers.
So it should work even with `TracePoint` enabled and shouldn't impact your =
tests. I tested quickly with DeepCover's clone mode and confirm that your t=
est suite appear to pass :-)
----------------------------------------
Bug #16776: Regression in coverage library
https://bugs.ruby-lang.org/issues/16776#change-85071
* Author: deivid (David Rodr=EDguez)
* Status: Open
* Priority: Normal
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
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=3D>[1=
, 1, nil]}`, showing that the body of the "foo" method was run once. Howeve=
r, on newer rubies, it prints `{:lines=3D>[1, 0, nil]}`, which is incorrect=
because the "foo" method body has actually been run once.
This is the repro script:
```ruby
# frozen_string_literal: true
require "coverage"
Coverage.start(lines: true)
code =3D <<~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 =3D Coverage.result
puts res[File.expand_path("foo.rb")]
```
-- =
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>