eigenclass logo
MAIN  Index  Search  Changes  PageRank  Login

rcov 0.6.0: "differential code coverage", full (faster) cross-referenced reports, vim integration

Cross-referenced code coverage reports, which were recently introduced, have been expanded to indicate where methods are called from and which methods were called for each line of code. In addition to that, cross-referenced report generation is now over 4 times faster for applications with deep call stacks (such as Rails apps). As usual, here's a fully cross-referenced report generated by rcov 0.6.0.

The latest rcov release also features a new differential coverage mode (--text-coverage-diff/-D) which will tell you when you've added new code that was not covered by the tests. You can save the current coverage status with --save (for instance on commit), and running rcov with the -D option will tell you which uncovered code has been introduced since the last save (it'll also tell you when code which was covered isn't anymore):

   !!!!! Uncovered code introduced in app/models/article.rb
   
   ### app/models/article.rb:44
 
        # Find all articles on a certain date
        def self.find_all_by_date(year, month = nil, day = nil)
   !!     from, to = self.time_delta(year, month, day)
   !!     Article.find(:all, :conditions => ["articles.created_at BETWEEN ? AND ? AND articles.published != 0", from, to], :order => 'articles.created_at DESC', :include => [:categories, :trackbacks, :comments])
   !!   end
      
        # Find one article on a certain date
        def self.find_by_date(year, month, day)  
   !!     find_all_by_date(year, month, day).first
   !!   end
 
        # Finds one article which was posted on a certain date and matches the supplied dashed-title
        def self.find_by_permalink(year, month, day, title)

rcov 0.6.0 ships with a compiler plugin for vim (contributions for other editors/IDEs welcome).

Download

Either install from the sources or using RubyGems (gem install rcov). A binary package for win32 is available.

User-visible changes since 0.5.0

Features

  • differential coverage report: --text-coverage-diff (-D) and --save. Tells you when you've added new code that was not covered by the tests and when code that used to be covered isn't anymore. Integration with vim (contributions for other editors/IDEs welcome).
  • fully cross-referenced reports, indicating where methods are called from and which methods were called for each line (--xrefs)
  • cross-referenced report generation is now over 4 times faster for applications with deep call stacks (such as Rails apps)

Bugfixes

  • comments at EOF are marked now
  • better handling of multiline hashes/arrays
  • better handling of end/}: support chained method calls and more expressions on the same line
  • better handling of heredocs with interpolation

Minor enhancements

  • more readable --text-coverage
  • set whether comments are "run" by default instead of attaching them to the following block of code (--[no-]comments)
  • --report-cov-bug can be used to report bugs in the coverage analysis

Thanks

Alex Wayne
  • reported problem with heredocs: they were not being marked as a whole if the "header" wasn't reported by Ruby.
  • reported problem with the last line of literal data structs not being covered if there was stuff after the end delimiter
Coda Hale
  • reported problem with blocks were the first line is not being marked and ditto for the last line when end/} is followed by more stuff
Tim Shadel
  • reported that the last comment block was not being marked even when it was the last thing in the file

Incorrect argument order when constructing ruby_opts list in RcovTask.define - Ryan Kinderman (2006-07-07 (Fri) 15:14:38)

Incorrect argument order when constructing ruby_opts list in RcovTask.define. The -I switch should come before the script name (fix by putting line 116 before line 115). This problem only reveals itself when specifying an alternate value for ENV['RCOVPATH'], in which case the case statement on line 109 falls to the 'else' condition, which does not prepend the '-S' switch to the path to rcov.

mfp 2006-07-09 (Sun) 04:55:58

rcov also accepts -I, so it'd work normally, unless your need $LOAD_PATH to apply to rcov's sources themselves... actually this should be useful for my unit tests too, so I'm applying the fix you specified. Thank you.


more block problems - Coda Hale (2006-06-12 (Mon) 15:28:57)

I know, this wouldn't be a problem if I could keep from sticking method calls on the end of blocks, but it's just so darn purty.

rcov doesn't register this as full C0:

 def woo
   results = { 1 => [1, 2, 3, 4], 2 => [1, 2, 3, 4], 3 => [1, 2, 3, 4], 4 => [1, 2, 3, 4]}
   [1, 2, 3, 4].to_a.map do |carrier|
        results[carrier].sort{ |a, b| b.to_s <=> a.to_s }
    end.flatten.compact
 end
 p woo

Lines 5 and 6 are marked unexecuted.

mfp 2006-06-12 (Mon) 16:27:53

hmmm I thought I'd fixed this; I'm looking into it tomorrow.


Last modified:2006/06/12 03:22:17
Keyword(s):[blog] [ruby] [frontpage] [rcov] [0.6.0] [release] [code] [coverage]
References:[rcov: code coverage for Ruby]