From: Mauricio Fernandez Date: 2006-09-05T06:57:59+09:00 Subject: Re: using rcov in already running program On Tue, Sep 05, 2006 at 03:00:07AM +0900, Suraj N. Kurapati wrote: > Mauricio Fernandez wrote: > > On Mon, Sep 04, 2006 at 05:15:24PM +0900, Suraj N. Kurapati wrote: > > I've never used rcov with an embedded Ruby interpreter, but something like > > this should work: > [code snipped] > [...] > > > rcov/runner.rb seems a good idea and I'd want to add it to the next release; > > do you have any suggestions regarding the interface or the default options? > > Yes, I would like a mechanism to pass the regular rcov command-line > options to the embedded rcov runner. I'm thinking that this can be > done either by setting the global ARGV array or maybe a RCOV_ARGV > array before loading the runner: > > RCOV_ARGV = ['--html', '--no-color', '--save', 'coverage.html'] > require 'rcov/runner' What about something like this? require 'rcov/runner' # if nothing else is done, it generates a plain text report, no HTML # Rcov::Runner.generate formatter [, options] is used to specify which # reports are to be generated. The possible options will be explained in the # RDoc documentation. Rcov::Runner.generate Rcov::HTMLCoverage, :color => false Rcov::Runner.generate Rcov::TextCoverageDiff, :coverage_diff_mode => :record, :coverage_diff_file => "coverage.data" Passing options with an ARGV feels clunky to me (I never liked that part of RDoc's API). > > Dumping a textual report like the above one seems to make sense as it is akin > > to Test::Unit's output. > > This is sufficient, but I would like to see the more detailed HTML > report as well, so I can know where coverage needs improvement. I think I'll either move xx (currently embedded in bin/rcov) to a separate file or rewrite the XHTML generation code using erb (since everybody's got it). XHTML reports could then be created as shown above. -- Mauricio Fernandez - http://eigenclass.org - singular Ruby