Permalink
Browse files

Make coverage work in 1.8, 1.9 and jruby for both

Use Rcov for 1.8 in both mri and jruby, and simplecov for coverage in 1.9
  • Loading branch information...
copiousfreetime committed May 17, 2012
1 parent 60cb0d6 commit 5c80a9c2666d27c04b0b47b17703f25dfd0cc936
Showing with 35 additions and 12 deletions.
  1. +29 −12 Rakefile
  2. +6 −0 spec/spec_helper.rb
View
@@ -56,7 +56,7 @@ task :develop => "develop:default"
begin
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new( :test ) do |t|
- t.ruby_opts = %w[ -w ]
+ #t.ruby_opts = %w[ -w ]
t.rspec_opts = %w[ --color --format documentation ]
end
task :default => :test
@@ -86,17 +86,30 @@ end
# Coverage - optional code coverage, rcov for 1.8 and simplecov for 1.9, so
# for the moment only rcov is listed.
#------------------------------------------------------------------------------
-begin
- require 'rcov/rcovtask'
- Rcov::RcovTask.new do |t|
- t.libs << 'spec'
- t.pattern = 'spec/**/*_spec.rb'
- t.verbose = true
- t.rcov_opts << "-x ^/" # remove all the global files
- t.rcov_opts << "--sort coverage" # so we see the worst files at the top
+if RUBY_VERSION < "1.9.2"
+ begin
+ require 'rcov/rcovtask'
+ Rcov::RcovTask.new( :coverage ) do |t|
+ t.libs << 'spec'
+ t.pattern = 'spec/**/*_spec.rb'
+ t.verbose = true
+ t.rcov_opts << "-x ^/" # remove all the global files
+ t.rcov_opts << "--sort coverage" # so we see the worst files at the top
+ end
+ rescue LoadError
+ Util.task_warning( 'rcov' )
+ end
+else
+ begin
+ require 'simplecov'
+ desc "Run tests with code coverage"
+ task :coverage do
+ ENV['COVERAGE'] = 'true'
+ Rake::Task[:test].execute
+ end
+ rescue LoadError
+ Util.task_warning( 'simplecov' )
end
-rescue LoadError
- Util.task_warning( 'rcov' )
end
#------------------------------------------------------------------------------
@@ -163,7 +176,11 @@ This.gemspec = Gem::Specification.new do |spec|
# The Development Dependencies
spec.add_development_dependency( 'rake' , '~> 0.9.2.2')
- spec.add_development_dependency( 'rcov' , '~> 1.0.0' )
+ if RUBY_VERSION < "1.9.2" then
+ spec.add_development_dependency( 'rcov' , '~> 0.9.11' )
+ else
+ spec.add_development_dependency( 'simplecov', '~> 0.6.4' )
+ end
spec.add_development_dependency( 'rspec' , '~> 2.8.0' )
spec.add_development_dependency( 'rdoc' , '~> 3.12' )
View
@@ -1,3 +1,8 @@
+if RUBY_VERSION >= '1.9.2' then
+ require 'simplecov'
+ SimpleCov.start if ENV['COVERAGE']
+end
+
require "rspec/autorun"
require 'qup'
@@ -24,3 +29,4 @@ def temp_dir( token, unique_id = Process.pid )
end
end
end
+

0 comments on commit 5c80a9c

Please sign in to comment.