Bugs: Browse | Submit New | Admin

[#17276] bug in --aggregate handling

Date:
2008-01-21 14:25
Priority:
3
Submitted By:
Tomas Pospisek (tpo)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
bug in --aggregate handling

Detailed description
I'm getting

/var/lib/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb:654:in `aggregate_data': undefined method `+' for nil:NilClass
(NoMethodError)
  from /usr/lib/ruby/1.8/test/unit.rb:285:in `each_with_index'
  from /var/lib/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb:654:in `aggregate_data'
  from /var/lib/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb:652:in `aggregate_data'
  from /var/lib/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb:490:in `raw_data_relative'
  from /var/lib/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb:431:in `remove_hook'
  from /var/lib/gems/1.8/gems/rcov-0.8.1.2.0/lib/rcov.rb:618:in `remove_hook'
  from /usr/local/bin/rcov:418
  from /usr/lib/ruby/1.8/test/unit.rb:285

In the following code from rcov.rb:

  def aggregate_data(aggregated_data, delta)
    delta.each_pair do |file, cov_arr|
      dest = (aggregated_data[file] ||= Array.new(cov_arr.size, 0))
      cov_arr.each_with_index{|x,i| dest[i] += x }
    end
  end

dest[i] happens to be nil. I worked around the problem like this:

  def aggregate_data(aggregated_data, delta)
    delta.each_pair do |file, cov_arr|
      dest = (aggregated_data[file] ||= Array.new(cov_arr.size, 0))
      cov_arr.each_with_index { |x,i|
        unless x.nil?
          if dest[i].nil?
            dest[i] = x
          else
            dest[i] += x
          end
        end
      }
      #cov_arr.each_with_index{|x,i| dest[i] += x }
    end
  end

Since I don't grok the code I also added a check for x.nil?. I don't know tho if it can happen and thus if it makes
sense.

I like rcov!
*t

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item