Rcov rake task problems


#1

OS = MS-WinXPproSP3 / CYGWIN_NT-5.1 1.5.25(0.156/4/2) 2008-06-12 19:34
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]
rails (2.2.2)
rake (0.8.3)
rcov (0.8.1.1.0)

I am trying to develop a rake task that will aggregate the results for
testunit, spec and cucumber tests. However, I find that I continually
run into this error:

$rake rcov --trace
(in /home/byrnejb/projects/proforma.git)
rake aborted!
undefined method rcov=' for #<Rcov::RcovTask:0x7f5bb3a8> /home/byrnejb/projects/proforma.git/lib/tasks/rcov_new.rake:26 /usr/lib/ruby/gems/1.8/gems/rcov-0.8.1.1.0/lib/rcov/rcovtask.rb:92:ininitializ
e’
/home/byrnejb/projects/proforma.git/lib/tasks/rcov_new.rake:24:in new' /home/byrnejb/projects/proforma.git/lib/tasks/rcov_new.rake:24 /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1851:inin_namespace’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:892:in namespace' /home/byrnejb/projects/proforma.git/lib/tasks/rcov_new.rake:11 /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies. rb:142:inload_without_new_constant_marking’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.
rb:142:in load' /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies. rb:521:innew_constants_in’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.
rb:142:in load' /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/rails.rb:8 /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/rails.rb:8:ineach’
/usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/rails.rb:8
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_requi re' /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
/home/byrnejb/projects/proforma.git/Rakefile:10
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2349:in load' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2349:inraw_load_rakefile’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1985:in
load_rakefile' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:instandard_exception_h
andling’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1984:in
load_rakefile' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1969:inrun’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in
standard_exception_h andling' /usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:inrun’
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31
/usr/bin/rake:19:in `load’
/usr/bin/rake:19

All the rcov tasks, including those provided cucumber and rspec, are
broken in the same fashion. I tried dropping back to an earlier version
of rcov (0.8.1.1.0) from 0.8.1.2.0 but I obtain the same error. Has
anyone any idea what might be wrong? The rake task used in this example
is:

require ‘rcov/rcovtask’
namespace :rcov do
desc “Generate code coverage with rcov”
task :coverage do
rm_f “doc/coverage/coverage.data”
rm_f “doc/coverage”
mkdir “doc/coverage”
rcov = %(rcov --rails --aggregate doc/coverage/coverage.data
–text-summary -Ilib --html -o doc/coverage test/**/*_test.rb)
system rcov
system “open doc/coverage/index.html” if PLATFORM[‘darwin’]
end
end


#2

desc “Rcov code coverage reports”
task :rcov => “rcov:all”
require ‘rcov/rcovtask’

namespace :rcov do

Rcov::RcovTask.new(:all) do
task :rcov => “rcov:testunit”
end

Rcov::RcovTask.new(:testunit) do |t|
t.libs << “test”
t.output_dir = ‘coverage’
t.test_files = FileList[‘test/**/test*.rb’]
t.verbose = true
end

end

However, this rake task works. So, the problem is in my rake task coding
and not with rcov itself.