[#97678] [Ruby master Feature#16752] :private param for const_set — bughitgithub@...
Issue #16752 has been reported by bughit (bug hit).
5 messages
2020/04/02
[ruby-core:97859] [Ruby master Bug#16776] Regression in coverage library
From:
mame@...
Date:
2020-04-12 14:01:14 UTC
List:
ruby-core #97859
Issue #16776 has been updated by mame (Yusuke Endoh).
IMO, TracePoint hooks should have a priority. A TracePoint hook that is first enabled should monitor a hook code that is second enabled:
```ruby
1: TracePoint.new(:line) do |tp|
2: p [:parent, tp]
3: end.enable do
4: TracePoint.new(:line) do |tp|
5: p [:child, tp]
6: end.enable do
7: p :main
8: end
9: end
```
```
$ ruby t.rb
[:parent, #<TracePoint:line@t.rb:4>]
[:parent, #<TracePoint:line@<internal:trace_point>:96 in `new'>]
[:parent, #<TracePoint:line@<internal:trace_point>:196 in `enable'>]
[:child, #<TracePoint:line@t.rb:7>]
[:parent, #<TracePoint:line@t.rb:7>]
:main
```
I expect `[:parent, #<TracePoint:line@t.rb:5>]` before `[:child, #<TracePoint:line@t.rb:7>]`. @ko1, what do you think?
----------------------------------------
Bug #16776: Regression in coverage library
https://bugs.ruby-lang.org/issues/16776#change-85084
* Author: deivid (David Rodr刕uez)
* 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=>[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:
```ruby
# 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")]
```
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>