Project

General

Profile

Actions

Bug #15476

closed

Branch coverage: Failing to load trivial sample when branch coverage is on

Added by MaxLap (Maxime Lapointe) over 5 years ago. Updated over 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
[ruby-core:90764]

Description

The following will fail (for the second #load) on 2.6.0
I assume this is Ruby removing useless code, and the branch coverage code handling it incorrectly.

require 'tempfile'
f = Tempfile.new(['ruby', '.rb'])
f.write(<<-RUBY)
  nil&.map { |i| i }
RUBY
f.close

require 'coverage'

load f.path
puts 'Without coverage worked'
Coverage.start(branches: true)
load f.path
puts 'With coverage worked'

This problem was not present in 2.5, but appeared in 2.6

Actions #1

Updated by MaxLap (Maxime Lapointe) over 5 years ago

  • ruby -v changed from 2.6.0 to ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]

Updated by MaxLap (Maxime Lapointe) over 5 years ago

Sorry, forgot to include the error message:

/tmp/ruby20181227-3429-1ubxjqu.rb:1:in `<top (required)>': no implicit conversion of false into Integer (TypeError)
Actions #3

Updated by mame (Yusuke Endoh) over 5 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r66670.


compile.c: support branch coverage for a&.foo = 1

[Bug #15476]

Updated by mame (Yusuke Endoh) over 5 years ago

  • Status changed from Closed to Open

Sorry, I wrote a wrong ticket number.

Actions #5

Updated by mame (Yusuke Endoh) over 5 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r66676.


compile.c (iseq_set_sequence): fix branch coverage table

Not only TRACE_ELEMENT but also INSN_ELEMENT may have events.
The old pc2branchindex was created using only events of TRACE_ELEMENTs.
This change uses events of INSN_ELEMENTs too for pc2branchindex table.

[Bug #15476]

Actions #6

Updated by nagachika (Tomoyuki Chikanaga) over 5 years ago

  • Backport changed from 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN to 2.4: DONTNEED, 2.5: DONTNEED, 2.6: REQUIRED

Updated by naruse (Yui NARUSE) over 5 years ago

  • Backport changed from 2.4: DONTNEED, 2.5: DONTNEED, 2.6: REQUIRED to 2.4: DONTNEED, 2.5: DONTNEED, 2.6: DONE

ruby_2_6 r66813 merged revision(s) 66670,66676.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0