# Re: rcov 0.5.0: code coverage + callsite info, RubyGems, Ran

**URL:** <https://www.ruby-forum.com/t/re-rcov-0-5-0-code-coverage-callsite-info-rubygems-ran/95362>\
**Category:** Ruby\
**Created:** [May 30, 2006, 1:42pm UTC](https://www.ruby-forum.com/t/re-rcov-0-5-0-code-coverage-callsite-info-rubygems-ran/95362 "2006-05-30T13:42:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [May 30, 2006, 1:42pm UTC](https://www.ruby-forum.com/t/re-rcov-0-5-0-code-coverage-callsite-info-rubygems-ran/95362/1 "2006-05-30T13:42:18Z")

</div>

fr Mauricio:

# Source code, additional information, screenshots… available at

# [eigenclass.org](http://eigenclass.org/hiki.rb?rcov)

# Release information:

# [eigenclass.org](http://eigenclass.org/hiki.rb?rcov+0.5.0)

rcov is really very useful.  
Thank you for sharing rcov.

# Sample cross-referenced report generated by rcov:

# [eigenclass.org](http://eigenclass.org/static/rcov-sample-report-crossref/)

uber cool.  
i think the only thing lacking is a web-based editor that hooks to rcov.  
Wherein you can click on any source, edit it, rerun rcov analysis again,  
all just using a browser…

# 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), so

# gem install rcov

# should work.

tested and runs great in windows and linux.  
but i would still love to see a pure ruby rcov (even if it may be slow).

kind regards -botp

---

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [May 30, 2006, 2:19pm UTC](https://www.ruby-forum.com/t/re-rcov-0-5-0-code-coverage-callsite-info-rubygems-ran/95362/2 "2006-05-30T14:19:18Z")

</div>

On May 30, 2006, at 1:40 PM, Peña, Botp wrote:

> > On May 30, 2006, at 11:56 AM, Mauricio F. wrote:  
> > Sample cross-referenced report generated by rcov:  
> > [http://eigenclass.org/static/rcov-sample-report-crossref/](http://eigenclass.org/static/rcov-sample-report-crossref/)
> 
> uber cool.  
> i think the only thing lacking is a web-based editor that hooks to  
> rcov. Wherein you can click on any source, edit it, rerun rcov  
> analysis again, all just using a browser…

I think a way to open up the file in an external editor would be  
better. This could be done to work with TextMate easily using its  
[URL scheme](http://macromates.com/textmate/manual/). I’m not sure about other editors. Maybe an --editor-  
links option, which accepts one of: TextMate, ?.

using\_textmate\_from\_terminal.html#url\_scheme\_html

– Daniel

---

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [May 30, 2006, 7:33pm UTC](https://www.ruby-forum.com/t/re-rcov-0-5-0-code-coverage-callsite-info-rubygems-ran/95362/3 "2006-05-30T19:33:24Z")

</div>

On Tue, May 30, 2006 at 08:40:33PM +0900, Peña, Botp wrote:

> > Sample cross-referenced report generated by rcov:  
> > [http://eigenclass.org/static/rcov-sample-report-crossref/](http://eigenclass.org/static/rcov-sample-report-crossref/)
> 
> uber cool.  
> i think the only thing lacking is a web-based editor that hooks to rcov.  
> Wherein you can click on any source, edit it, rerun rcov analysis again, all  
> just using a browser…

Attractive at first sight, but on second thought I don’t think anybody  
would  
enjoy editing with a browser (unless running an embedded vim or browsing  
with  
emacs) 🙂 I’ll think about integration with the user’s editor of  
choice.

> > 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), so  
> > gem install rcov  
> > should work.
> 
> tested and runs great in windows and linux.  
> but i would still love to see a pure ruby rcov (even if it may be slow).

Actually, rcov _will_ run in pure-Ruby mode if it cannot load rcovrt.  
If you install it from the tarball with  
ruby setup.rb --without-ext  
or using RubyGems and the compilation fails, it’ll fall back to  
pure-Ruby and  
give you a warning:

batsman@tux-chan:~/src/rcov/examples$ rcov --version  
bash: rcov: command not found  
batsman@tux-chan:~/src/rcov/examples$ make=bogus-command-foo gem install  
rcov  
Attempting local installation of ‘rcov’  
Local gem file not found: rcov\*.gem  
Attempting remote installation of ‘rcov’  
Select which gem to install for your platform (i686-linux)

1. rcov 0.5.0.1 (ruby)
2. rcov 0.5.0.1 (mswin32)
3. Cancel installation

> 1  
> Building native extensions. This could take a while…  
> /home/batsman/usr/lib/ruby/1.8/fileutils.rb:243: command not found:  
> bogus-command-foo  
> /home/batsman/usr/lib/ruby/1.8/fileutils.rb:243: command not found:  
> bogus-command-foo install  
> ruby extconf.rb install rcov  
> creating Makefile

bogus-command-foo

bogus-command-foo install  
Successfully installed rcov-0.5.0.1  
Installing RDoc documentation for rcov-0.5.0.1…  
batsman@tux-chan:~/src/rcov/examples$ rcov --version  
rcov 0.5.0 2006-05-30  
batsman@tux-chan:~/src/rcov/examples$ rcov --text-coverage --no-html  
–no-color a.rb

Since the rcovrt extension couldn’t be loaded, rcov will run in  
pure-Ruby  
mode, which is about two orders of magnitude slower.

If you’re on win32, you can find a pre-built extension (usable with  
recent  
One Click Installer and mswin32 builds) at  
[eigenclass.org](http://eigenclass.org/hiki.rb?rcov) .

# blergh yep Done: 56

# a.rb

srand(0)  
c = 0  
d = 1  
10.times do |i|  
if rand % (i + 10)  
c += i  
d += 1  
end  
end  
puts “blergh”  
if c \> 4\*d  
# stuff  
puts “yep”

## else

## puts “nope”

## # more stuff

## end

puts “Done: #{c+d}”

---

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [June 1, 2006, 1:13am UTC](https://www.ruby-forum.com/t/re-rcov-0-5-0-code-coverage-callsite-info-rubygems-ran/95362/4 "2006-06-01T01:13:56Z")

</div>

On May 31, 2006, at 6:16 PM, Chris McGrath wrote:

> > 
> 
> himself)  
> Maybe this is what you mean (I don’t know ZenTest), but how hot would  
> it be if someone made an eclipse plugin that did it as a continual  
> background task (like, did it per file every time you saved) and  
> popped up little “Attention” icons next to files and underlined the  
> parts of code that weren’t getting hit by unit testing. _drools_

But in the mean time rcov is frickin hot!  
-Mat

---

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [June 1, 2006, 12:19am UTC](https://www.ruby-forum.com/t/re-rcov-0-5-0-code-coverage-callsite-info-rubygems-ran/95362/5 "2006-06-01T00:19:05Z")

</div>

On 30 May 2006, at 13:40, Peña, Botp wrote:

> fr Mauricio:
> 
> # Source code, additional information, screenshots… available at
> 
> # [eigenclass.org](http://eigenclass.org/hiki.rb?rcov)
> 
> # Release information:
> 
> # [eigenclass.org](http://eigenclass.org/hiki.rb?rcov+0.5.0)
> 
> rcov is really very useful.  
> Thank you for sharing rcov.

Seconded! I love it. Thank you bery much. My candidate for the “I  
want a Pony awards is” Some king of mashup between rcov, rake and  
ZenTest. I’d like something so that running tests became something  
akin to making a build in a static language, rcov would tell autotest  
what tests it needed to re-run based on the profiling information and  
whine heavily when you have code that’s called isn’t under test.

/me hopes the lazyweb will provide! (and wishes he had proper time  
himself)

Chris

---

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [June 1, 2006, 3:28pm UTC](https://www.ruby-forum.com/t/re-rcov-0-5-0-code-coverage-callsite-info-rubygems-ran/95362/6 "2006-06-01T15:28:36Z")

</div>

On Jun 1, 2006, at 4:56 AM, Mauricio F. wrote:

> (in /home/batsman/src/rcov/head)  
> 39 tests, 415 assertions, 0 failures, 0 errors  
> if (!is\_code?(lastidx) || /^ **END** $/ =~ @lines[-1]) && !  
> line = @lines[i]
> 
> It’s in my repository, and it will be in rcov 0.6.0.

Bravo! What’s your encore gonna be?  
I’m no expert in eclipse plugins. And actually the editor is a  
little hard to plug from what I understand. But if there’s a way to  
get those !! lines in a lightweight machine readable format, it  
shouldn’t be _too_ hard to implement the functionality I was talking  
about.  
-Mat

---

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [June 1, 2006, 10:58am UTC](https://www.ruby-forum.com/t/re-rcov-0-5-0-code-coverage-callsite-info-rubygems-ran/95362/7 "2006-06-01T10:58:37Z")

</div>

On Thu, Jun 01, 2006 at 08:10:47AM +0900, Mat S. wrote:

> Maybe this is what you mean (I don’t know ZenTest), but how hot would  
> it be if someone made an eclipse plugin that did it as a continual  
> background task (like, did it per file every time you saved) and  
> popped up little “Attention” icons next to files and underlined the  
> parts of code that weren’t getting hit by unit testing. _drools_

I don’t know about eclipse, but I implemented this yesterday:

$ rake rcov RCOVOPTS="–save"  
[…]

/me edits lib/rcov.rb

… some time later:

$ rake rcov RCOVOPTS="–text-coverage-diff --no-color"  
(in /home/batsman/src/rcov/head)  
rm -r coverage  
/home/batsman/usr/bin/ruby -Ilib:ext/rcovrt “bin/rcov”  
–text-coverage-diff --no-color -o “coverage”  
“test/test\_CodeCoverageAnalyzer.rb” “test/test\_FileStatistics.rb”  
“test/test\_CallSiteAnalyzer.rb”  
Loaded suite bin/rcov  
Started  
…  
Finished in 1.163085 seconds.

39 tests, 415 assertions, 0 failures, 0 errors

================================================================================  
!!! Uncovered code introduced in lib/rcov.rb

### lib/rcov.rb:207

```
 def precompute_coverage(comments_run_by_default = true)
   changed = false
   lastidx = lines.size - 1
   if (!is_code?(lastidx) || /^ __END__ $/ =~ @lines[-1]) && 

```

!@coverage[lastidx]  
!! # mark the last block of comments  
!! @coverage[lastidx] ||= :inferred  
!! (lastidx-1).downto(0) do |i|  
!! break if is\_code?(i)  
!! @coverage[i] ||= :inferred  
!! end  
!! end  
(0…lines.size).each do |i|  
next if @coverage[i]  
line = @lines[i]

It’s in my repository, and it will be in rcov 0.6.0.

---

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [June 1, 2006, 7:44pm UTC](https://www.ruby-forum.com/t/re-rcov-0-5-0-code-coverage-callsite-info-rubygems-ran/95362/8 "2006-06-01T19:44:45Z")

</div>

On Thu, Jun 01, 2006 at 10:25:11PM +0900, Mat S. wrote:

> > ==========  
> > !!! Uncovered code introduced in lib/rcov.rb
> > 
> > ### lib/rcov.rb:207

[…]

> > It’s in my repository, and it will be in rcov 0.6.0.
> 
> Bravo! What’s your encore gonna be?

_chuckle_ You just gave me one idea. I’ve got a piece of paper on my  
desk  
where I’ve written about a dozen things I want to implement (I’ve  
crossed out  
4 so far); I add a couple every once in a while. I’m keeping them more  
or less  
secret for the time being, but I’ll send a snapshot (tarball and/or  
RubyGems  
packages) of rcov’s HEAD branch with the new stuff to whoever reports a  
new  
bug in rcov 🙂

(Reports for bugs I’ve already fixed in HEAD will be requited with a  
somewhat  
less fresh snapshot 😉

> I’m no expert in eclipse plugins. And actually the editor is a  
> little hard to plug from what I understand. But if there’s a way to  
> get those !! lines in a lightweight machine readable format, it  
> shouldn’t be _too_ hard to implement the functionality I was talking  
> about.

I wrote --text-coverage-diff with that in mind (although not exactly the  
way  
you described it). Actually, I was planning some vim integration using  
errorformat…
