eigenclass logo
MAIN  Index  Search  Changes  PageRank  Login

rcov 0.2.0: speedy, prettier, more convenient code coverage

I'm releasing version 0.2.0 of the rcov code coverage tool for Ruby. Visible changes since 0.1.0:

  • improved HTML output (cleaner and more readable) --- using xx under the hood
  • textual output: execution counts or code decorated with ANSI sequences
  • more convenient interface: run several scripts/tests in one go, argument propagation...

It can be downloaded from here.


Code coverage summary
Detailed code coverage information
Bogo-profile mode
Decorated text output
Execution count textual output
$ rcov --no-html -t b.rb 
                                                                      |      2
a, b, c = (1..3).to_a                                                 |      2
10.times do                                                           |      1
  a += 1                                                              |     10
  20.times do |i|                                                     |     10
    b += i                                                            |    200
    b.times do                                                        |    200
      c += (j = (b-a).abs) > 0 ? j : 0                                | 738800
    end                                                               |      0
  end                                                                 |      0
end                                                                   |      0

() threedaymonk 2006-03-01 (Wed) 06:20:32

I found that multi-line hashes are recognised in full as long as the last item has a trailing comma, but multi-line strings confuse rcov.

mfp 2006-03-01 (Wed) 16:05:17

The heuristics are less than perfect. That code will be worked on in a subsequent version, probably adding a number of test cases...

windows install - Chris (2006-02-27 (Mon) 18:41:22)

Can't get this to install on windows.

Only output of "ruby setup.rb is"

rm -f InstalledFiles

"ruby setup.rb show" outputs

prefix               c:/dev/ruby
bindir               $prefix/bin
libdir               $prefix/lib
datadir              $prefix/share
mandir               $prefix/man
sysconfdir           $prefix/etc
localstatedir        c:/var
libruby              c:/dev/ruby/lib/ruby
librubyver           c:/dev/ruby/lib/ruby/1.8
librubyverarch       c:/dev/ruby/lib/ruby/1.8/i386-mswin32
siteruby             c:/dev/ruby/lib/ruby/site_ruby
siterubyver          c:/dev/ruby/lib/ruby/site_ruby/1.8
siterubyverarch      c:/dev/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt
rbdir                $siterubyver
sodir                $siterubyverarch
rubypath             c:/dev/ruby/bin/ruby.exe
rubyprog             c:/dev/ruby/bin/ruby.exe
makeprog             nmake
shebang              ruby
without-ext          no

What am I missing? There is no rcov install in my ruby/bin irectory, correctly configured above.

mfp 2006-02-28 (Tue) 05:32:30

I see you're on win32; do you have a working C toolchain (i.e. are you able to build extensions normally)? If not, just try

 ruby setup.rb all --without-ext

and buy large amounts of your favorite caffeinated beverage to enjoy it while rcov yourprog.rb is running --- there's a 100X speed hit if you use rcov without the rcovrt extension. Alternatively, just copy bin/rcov to the desired destination (it's self-contained).

Now, if you can build other extensions, that's a wholly different story, and we'd have to look at the generated Makefile, etc...

Chris 2006-02-28 (Tue) 13:34:19

Tried the --without-ext option, the files were installed including rcov to the bin. However, when 'rcov' is typed on the command line, its not recognized as a ruby file, and is not executed. Renaming rcov in the bin directory to rcov.rb does the trick, and everything works. I do have gcc installed, but have not attempted to build other extensions. Thanks, this looks like a very useful tool...

mfp 2006-02-28 (Tue) 14:27:51

hmm the default one-click install (assuming you are using that) requires MSVC to build extensions (the configuration stored in rbconfig.rb is specific to that toolchain), so it wouldn't work with GCC + GNU make. I'll think about the file extension issue. Thanks for the feedback!

Great! - riffraff (25-02-2006 (Sab) 08:49:08)

I had "write ANSIConsoleFormatter for rcov" in my todo list, it seems you read my mind :)

Why don't you put this on rubyforge or something, so that you can use the shared public issue tracking system?

mfp 2006-02-25 (Sat) 09:19:41

I really dislike Rubyforge's (GForge's) BTS; I'd rather use a mix of Hiki's bug tracking system and rubybugs...

slumos 2006-02-25 (Sat) 16:13:31

What's a 'xx'? (p.s. A single-line comment field is the coolest idea I've seen in a long time.)

mfp 2006-02-25 (Sat) 17:44:59

xx is yet another lib for easy html/xhtml/xml generation, see ruby-talk:176847. As for the comment line: really? I thought single-line would encourage lively discussion, but most people seem to find this system confusing.

riffraff 26-02-2006 (Dom) 05:20:52

I second the idea that this comment system rocks and I agree that GForge's BTS is bad, but I meant it was better than nothing

mfp 2006-02-26 (Sun) 05:33:14

hehe I was just restyling the forms as you posted this. As for the BTS, I'll see what can be done with rubybugs+quickml+hiki's BTS. In the meantime plz post here m(_ _)m thx for the patience

gettalong 2006-02-26 (Sun) 06:19:15

This new version of rcov rocks!!! I have used the 0.1.0 till now and it was okay, but the speed/new look of rcov 0.2.0, simply amazing! Good work!

c version of rcov requires Ruby 1.8.3 or above - zev (2006-03-28 (Tue) 22:55:30)

In order to build the c version of rcov you need to use ruby 1.8.3 or above.

eric 2006-04-02 (Dimanche) 14:14:50

I really have troubles building the extension on windows. Would that be possible for you to compile it and to put a link to it on your site, please?

mfp 2006-04-02 (Sun) 17:39:06

Sorry, I don't have a win32 box... But I'm fairly confident I can cross-compile it with mingw, and the resulting extension would work with the ruby-mswin32 binaries and the one-click-installer 1.8.4-rc16; stay tuned.

eric 2006-04-04 (Mardi) 03:50:17

By the way, I have another issue. I have very long file names for my project and creating a file with a too long name fails under windows. So in the file_name method I had to truncate the file name to [0..100] to make rcov work. What would be an elegant solution to that issue?

eric 2006-04-04 (Mardi) 04:19:54

A mistake... the file_name method should return "base[base.size-100.min(base.size)..base.size]". Moreover, one of my classes gets only a 50% coverage and when I click on it in the html report, the code is duplicated. Any idea?

mfp 2006-04-04 (Tue) 09:56:36

OK, I cross-compiled the extension, you can get it here. As for overly long file names, I'll implement some cmdline option to truncate them. Could you show the code that gets "duplicated", or the HTML report? (I'm not sure I see what you mean)