eigenclass logo
MAIN  Index  Search  Changes  PageRank  Login

rcov 0.5.0: cross-referenced reports (code coverage and callsite info), RubyGems, Rant support, improved heuristics

Yet another release of the rcov code coverage tool for Ruby. The one big feature introduced in this release is the ability to generate cross-referenced reports showing where methods are called from. This should prove useful when you're trying to optimize your program, or even when just trying to understand what is going on.

As anticipated in the teaser I posted a few days ago, cross-referenced reports look like this:

/hiki/cross_refs_teaser.png

You can find a sample cross-referenced report at http://eigenclass.org/static/rcov-sample-report-crossref/.

As usual, there are also some improvements in the heuristics (many multi-line quoted strings work now), a few additional features, more polishing of the existing ones and a bunch of bugfixes.

This release is the first to include RubyGems packages: both a binary one for Win32 and a platform-independent one for all those with a compiler, (or a lot of patience, if willing to run rcov in pure-Ruby mode).

Visible changes

Features

  • ability to create cross-referenced reports, indicating where methods are called from (--callsites)
  • more refinements in the heuristics: now several kinds of multi-line quoted strings are handled properly
  • --include-file to specify files not to be ignored in the report(s)
  • implemented a task generator for Rant

Bugfixes

  • corrected the LOC counts in the XHTML summaries
  • pure-Ruby tracing module works again; was broken in 0.4.0
  • RcovTask#ruby_opts fixed; they were being passed to rcov instead of ruby
  • solved the DOCTYPE issue (it'd get put at the end of the file under some Ruby versions)

Minor enhancements

  • slightly more readable XHTML reports, esp. for IE
  • text reports fit in 79 columns so they look OK with cmd.exe
  • try to guide the user when all files were considered "uninteresting" by rcov
  • the output_dir is preserved in RcovTasks when the user specifies --profile via the RCOVOPTS env. var.

Thanks

David Roberts

  • reported confusing behavior when all files are ignored because they match a regexp in the reject list
  • tested the RubyGems package for win32

John-Mason Shackelford:

  • reported an important bug in the pure-Ruby tracer module, which broke it altogether in 0.4.0
  • suggested a change in the CSS to make XHTML reports more readable under IE

Dave Burt:

  • reported an issue with text reports under cmd.exe (should use < 80 cols)

Download

The latest release is, as always, available in rcov: code coverage for Ruby.


Problem with sql statements - Economysizegeek (2006-06-11 (Sun) 19:19:59)

rcov doesnt understand any after line 88 (so sarting at the where clause)

<pre>

86  @story_pages, @stories = paginate :stories,
87            :conditions => ["id NOT IN (SELECT story_id 
88                                        FROM story_votes
89                                        WHERE user_id = ?)
90                         AND id NOT IN (SELECT story_id
91                                       FROM stories_users
92         WHERE user_id = ?)", @user.id,@user.id],
93         :order_by => "created_at DESC",:per_page => 10

</pre>


buggy reports in 0.5.0.1 - Jamie (2006-06-04 (Sun) 16:34:08)

Marking issues with 0.5.0.1:

Blank lines at end of file are marked red.

The following code is run, but line 70 is red.

   69   def after_create
   This method was called by:
   
        15   vendor/rails/activerecord/lib/active_record/callbacks.rb:348 in 'callback'
   
   70     @phone_numbers_to_update.each do |number|
   71       number.contact_id = self.id
   72       number.save
   73     end unless @phone_numbers_to_update.nil?
   74   end

mfp 2006-06-05 (Mon) 10:39:08

Thanks. The first problem (comment blocks at EOF not marked) got fixed a few days ago. I'm looking into the 2nd.

PS: you can leave your email address to receive your free rcov snapshot (just finished implementing something very interesting IMHO :).

mfp 2006-06-10 (Sat) 03:39:36

Sorry, cannot reproduce this (I'm missing some info).

I've just implemented --report-cov-bug to make bug reporting easier.


Thanks for the bug reports - mfp (2006-06-01 (Thr) 01:09:09)

I'm looking into them. Getting all these cases recognized without false positives (code not run but considered covered) can get quite tricky, but a priori they seem doable. Stuff involving multiline quoted strings with interpolation would be much harder (probably impossible without a parser).

mfp 2006-06-01 (Thr) 02:01:52

Fixed them all :-) Thanks again for reporting them!


Hmm... mysterious markup for comments? - Coda Hale (2006-05-31 (Wed) 17:30:14)

Let's try this again:

Lines 3 and 14 of the following code are obviously executed, but are not marked as such:

  1 blah = Array.new
  2 10.times do
  3   blah << lambda do |f|
  4     puts "I should say #{f}!"
  5   end
  6 end
  7 blah.each do |b|
  8   b.call('HELLO!')
  9 end
 10 
 11 blee = [1, 2, 3]
 12 blee.map! do |e|
 13   [e, e]
 14 end.flatten!
 15 p blee

Thank you *so* much for this tool!


Another buggy test case: - Coda Hale (2006-05-31 (Wed) 17:29:18)

edited by mfp > reformatted

Lines 3 and 14 of the following code are obviously executed, but are not marked as such:

 1 blah = Array.new
 2 10.times do
 3   blah << lambda do |f|
 4     puts "I should say #{f}!"
 5   end
 6 end
 7 blah.each do |b|
 8   b.call('HELLO!')
 9 end
10 
11 blee = [1, 2, 3]
12 blee.map! do |e|
13   [e, e]
14 end.flatten!
15 p blee

Thank you *so* much for this tool!


Small bugs - Alex Wayne (2006-05-31 (Wed) 15:43:15)

Trying again

  99     @review = Review.new({
 100       :product_id => params[:id],
 101       :user       => current_user
 102     }.merge(params[:review]))      #red
 103     @review.save
 25   def to_s
 26     <<-EOF               #red
 27       #{name}
 28       #{street}          #red
 29       #{city}, #{state}  #red
 30       #{zip}             #red
 31     EOF                  #red
 32   end

Small bugs - Alex Wayne (2006-05-31 (Wed) 15:41:54)

edited by mfp > reformatted

Awesome work so far but it is marking a few lines as non-executed when they definetaly executed.

Here only line #102 is red, and the rest of the file is fine.

 99     @review = Review.new({
100       :product_id => params[:id],
101       :user       => current_user
102     }.merge(params[:review]))      #red
103     @review.save

And here 26 and 28-31 are red, and the rest are green:

25   def to_s
26     <<-EOF               #red
27       #{name}
28       #{street}          #red
29       #{city}, #{state}  #red
30       #{zip}             #red
31     EOF                  #red
32   end

Last modified:2006/05/30 03:34:40
Keyword(s):[blog] [ruby] [frontpage] [rcov] [0.5.0] [release]
References:[rcov: code coverage for Ruby]