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.
$ rcov --no-html -t b.rb ================================================================================ ./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
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.
The heuristics are less than perfect. That code will be worked on in a subsequent version, probably adding a number of test cases...
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.
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...
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...
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!
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?
What's a 'xx'? (p.s. A single-line comment field is the coolest idea I've seen in a long time.)
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.
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
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
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!
In order to build the c version of rcov you need to use ruby 1.8.3 or above.
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?
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.
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?
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?
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)
- 28 http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/181885
- 20 http://www.artima.com/forums/flat.jsp?forum=123&thread=149694
- 16 http://www.daionet.gr.jp/~knok/diary/?200603a
- 13 http://www.artima.com/buzz/community.jsp?forum=123
- 10 http://anarchaia.org
- 8 http://chneukirchen.org/anarchaia
- 7 http://planetruby.0x42.net
- 5 http://chneukirchen.org/anarchaia/archive/2006/02/25.html
- 4 http://rubyriver.org
- 3 http://anarchaia.org/archive/2006/02.html