Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Test coverage checking when test driver is separate from the tested program.

Reply
Thread Tools

Test coverage checking when test driver is separate from the tested program.

 
 
Tomasz Wegrzanowski
Guest
Posts: n/a
 
      08-22-2006
Hello,

I have a program compiler.rb, that compiles something.
The test driver is a separate program, that runs compiler.rb, then feeds
the results to a virtual machine, and checks if it gets expected results.

Now I'd like to verify that every single line of compiler.rb is
covered by tests.
How can I make rcov merge information from multiple runs of compiler.rb ?

--
Tomasz Wegrzanowski [ http://t-a-w.blogspot.com/ ]

 
Reply With Quote
 
 
 
 
Mauricio Fernandez
Guest
Posts: n/a
 
      08-23-2006
On Wed, Aug 23, 2006 at 08:32:09AM +0900, Tomasz Wegrzanowski wrote:
> I have a program compiler.rb, that compiles something.
> The test driver is a separate program, that runs compiler.rb, then feeds
> the results to a virtual machine, and checks if it gets expected results.
>
> Now I'd like to verify that every single line of compiler.rb is
> covered by tests.
> How can I make rcov merge information from multiple runs of compiler.rb ?


You can use the --aggregate option, which was added in 0.7.0.
Essentially, you just have to run your program using rcov with the
--aggregate FILE option:
rm -f coverage.data
rcov -t --no-html --aggregate coverage.data bin/compiler.rb -- -args --to --compiler.rb bar.src
rcov --aggregate coverage.data bin/compiler.rb -- -some --other --args foo.src

You can skip HTML report generation in all but the last run with --no-html;
the -t (text summary) option stops rcov from complaining about the lack of
files to analyze.

There's some additional information about how to do it both manually and with a
Rake task at
http://eigenclass.org/hiki.rb?rcov+0.7.0

Note that --aggregate is fairly slow since all the execution count and
coverage information must be saved in the specified file, as well as the code
that was loaded (since in a later execution different files could be
loaded/parsed).

--
Mauricio Fernandez - http://eigenclass.org - singular Ruby

 
Reply With Quote
 
 
 
 
Mauricio Fernandez
Guest
Posts: n/a
 
      08-23-2006
On Wed, Aug 23, 2006 at 08:08:27PM +0900, Mauricio Fernandez wrote:
> On Wed, Aug 23, 2006 at 08:32:09AM +0900, Tomasz Wegrzanowski wrote:
> > I have a program compiler.rb, that compiles something.
> > The test driver is a separate program, that runs compiler.rb, then feeds
> > the results to a virtual machine, and checks if it gets expected results.
> >
> > Now I'd like to verify that every single line of compiler.rb is
> > covered by tests.
> > How can I make rcov merge information from multiple runs of compiler.rb ?

>
> You can use the --aggregate option, which was added in 0.7.0.

[...]

Sorry, I misread the first paragraph and answered somewhat aside of the
question.

In the case you describe, you could create a small wrapper that would look
more or less like this:

#!/usr/bin/env ruby

system("rcov", "--aggregate", "coverage.data", "--no-html", "-t",
"compiler.rb", "--", *ARGV)
exit $?.exitstatus

Then you could select which script (the wrapper or the actual compiler.rb) is
to be executed with a symlink.
Alternatively, you could change the driver to select the script or execute
rcov with the appropriate arguments directly, but at that point you'd have to
implement some way to specify whether rcov is to be used or not, if you want
to allow both.

Hope this helps.

--
Mauricio Fernandez - http://eigenclass.org - singular Ruby

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Coverage checker: Coverage.py or pycover or ? python@bdurham.com Python 0 05-25-2008 01:20 PM
Code coverage & Functional coverage tutorials Raj VHDL 4 02-21-2008 12:32 PM
coverage.py: "Statement coverage is the weakest measure of code coverage" Ben Finney Python 7 10-30-2007 01:43 PM
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x8fc Thread 0x934 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 0 03-24-2006 02:22 PM
test test test test test test test Computer Support 2 07-02-2003 06:02 PM



Advertisments