Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rcov (0.9.9 java) - coverage aggregation issue #76

Open
leckylao opened this issue May 24, 2011 · 8 comments
Open

rcov (0.9.9 java) - coverage aggregation issue #76

leckylao opened this issue May 24, 2011 · 8 comments

Comments

@leckylao
Copy link

Hi,

I am using jruby-1.6.1 with rcov (0.9.9 java) to run coverage report for my cucumber features and rspec tests. Everything works fine except it's not aggregating the data in the report. And there's no errors.

All the tests pass. And It's not aggregating the data as I can tell by seeing the controller get higher coverage with cucumber but later get dropped in the final report.

Here's the code. Please help.

desc 'Measures Cucumber features coverage using rcov'
Cucumber::Rake::Task.new(:cucumber) do |t|
  t.rcov = true
  t.rcov_opts = %w{--aggregate report/coverage.data --text-report --rails}
  t.rcov_opts << "-o report/coverage-cucumber-#{Time.now.strftime("%d_%m_%Y_%I_%M_%p")}"
end

desc 'Measures Rspec coverage using rcov'
Spec::Rake::SpecTask.new(:rspec) do |t|
  t.spec_files = FileList['spec/**/*_spec.rb']
  t.rcov = true
  t.rcov_opts = %w{--aggregate report/coverage.data --text-report --rails}
  t.rcov_dir = "report/coverage-rspec-#{Time.now.strftime("%d_%m_%Y_%I_%M_%p")}"
end

desc "Run unit tests, specs and features to generate aggregated coverage"
task :all do |t|
  rm "report/coverage.data" if File.exist?("report/coverage.data")
  Rake::Task["rcov:cucumber"].invoke
  Rake::Task["rcov:rspec"].invoke
end
@tatyree
Copy link

tatyree commented Jul 12, 2011

I'm seeing exactly the same thing with Jruby 1.6.2 and 0.9.9. I've created a example app to illustrate the problem. You can clone it here:

git clone git://github.com/tatyree/rcov_issues.git

I've included the coverage reports from my last run, which I think was cucubmer_first. I've also included screenshots of example outputs from both runs. If you don't want to clone the example, you can see them in the README:

Basically, it just doesn't seem to be aggregating the results at all. Whichever set of tests get run last are the ones the coverage report is based on.

@tatyree
Copy link

tatyree commented Jul 12, 2011

I just checked it on 1.8.7 and it behaves as expected: 100% coverage regardless of the run order.

@afournier
Copy link

+1 -- I'm seeing this too.

@ZsoltFabok
Copy link

+1 with plain ruby 1.8.7 patch 334

@abedra
Copy link
Contributor

abedra commented Jan 20, 2012

I cloned the repo and ran both tasks. For both runs I only get 63.6% coverage, no matter which task I use.

@tomgi
Copy link

tomgi commented Feb 1, 2012

+1

@evilrich
Copy link

I have the same problem with rcov and JRuby (tested 1.6.4 and 1.6.7 recently).

Some quick investigation shows the problem is with loading the aggregate data (the gzipped, marshal serialization). Attempting to load the aggregate data outside of rcov with

require 'rubygems'
gem 'rcov'
require 'rcov'
require 'zlib'

file = 'aggr.rcov'
Zlib::GzipReader.open(file) {|gz| old_data = Marshal.load(gz) }

leads to

ArgumentError: dump format error(p)
      load at org/jruby/RubyMarshal.java:148
  __file__ at load_aggr.rb:7
    (root) at load_aggr.rb:7

As a test, I hacked the rcov script to not gzip the marshalled data, and it then works correctly.

@evilrich
Copy link

As a temporary work-around for those that need this feature in JRuby right now (like me), I have forked version 0.9.11 of rcov and disabled gzipping of aggregate data. See the jruby_tmp branch at https://github.com/evilrich/rcov. You can use this, for example, by specifying in your Gemfile:

gem 'rcov', '0.9.11.1', :git => "git://github.com/evilrich/rcov.git", :branch => 'jruby_tmp'

When I have some more time, I intend to investigate further the problem with gzip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants