Patrick Hurley
2006-Mar-16 21:30 UTC
[Rails] Re: [ANN] rcov 0.2.0 - code coverage tool for Ruby
On 3/14/06, David Holroyd <ruby-talk@badgers-in-foil.co.uk> wrote:> On Wed, Mar 15, 2006 at 02:23:04AM +0900, Mauricio Fernandez wrote: > > On Tue, Mar 14, 2006 at 09:27:14AM +0900, David Holroyd wrote: > > > On Wed, Mar 01, 2006 at 01:31:11AM +0900, Mauricio Fernandez wrote: > > > > Source code, additional information, screenshots... available at > > > > > > > > http://eigenclass.org/hiki.rb?rcov > > > > > > Fabulous! > > > > > > I would like to get coverage for my test cases too. Could this be > > > accomodated (without tweaking @ignore_files in the source)? > > > > It will be possible in the next release; in the meantime, could you use the > > following patch? > > I am doing, and it looks good. > > Thank you! > dave > > -- > http://david.holroyd.me.uk/ > >Just want to join the chorus of thank you. This is perfect. I found a blog entry (http://asplake.blogspot.com/2006/01/revert-that-rakefile.html) and worked it over a little into the file below which I put in lib/tasks/rcov.rake in a rails project. It works great. Thanks pth require ''rake/clean'' RBINDIR = Config::CONFIG[''bindir''] RBIN = "#{RBINDIR}/rcov" if File.exists?(RBIN) # output goes to subdirectories of this one RCOV_OUT = "coverage" # "rake clobber" to remove output directory (along with other generated stuff) CLOBBER.include(RCOV_OUT) # don''t report coverage on these files RCOV_EXCLUDE = %w(boot.rb environment.rb vendor/rails test/functional test/unit).join('','') # RCOV command, run as though from the commandline. Amend as required or perhaps move to config/environment.rb? RCOV = "#{RBINDIR}/ruby #{RBIN} --exclude #{RCOV_EXCLUDE} --output #{RCOV_OUT}" desc "generate a coverage report for unit and functional tests together in #{RCOV_OUT}/index.html" task :rcov do rm_rf RCOV_OUT sh "#{RCOV} test/unit/*.rb test/functional/*.rb" end namespace :rcov do desc "generate a unit test coverage report in #{RCOV_OUT}/index.html" task :units do sh "#{RCOV} test/unit/*.rb" end desc "generate a functional test coverage report in #{RCOV_OUT}/index.html" task :coverage_functional do sh "#{RCOV} test/functional/*.rb" end end end
Christian Neukirchen
2006-Mar-17 14:46 UTC
[Rails] Re: [ANN] rcov 0.2.0 - code coverage tool for Ruby
"Patrick Hurley" <phurley@gmail.com> writes:> task :rcov do > rm_rf RCOV_OUT > sh "#{RCOV} test/unit/*.rb test/functional/*.rb" > end> task :units do > sh "#{RCOV} test/unit/*.rb" > end> task :coverage_functional do > sh "#{RCOV} test/functional/*.rb" > endWouldn''t it be better if you used rake''s "ruby" method instead of "sh" to call another Ruby script? -- Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org