Skip to content

Commit

Permalink
Make coverage work in 1.8, 1.9 and jruby for both
Browse files Browse the repository at this point in the history
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 5c80a9c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
41 changes: 29 additions & 12 deletions Rakefile
Expand Up @@ -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
Expand Down Expand Up @@ -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

#------------------------------------------------------------------------------
Expand Down Expand Up @@ -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' )

Expand Down
6 changes: 6 additions & 0 deletions spec/spec_helper.rb
@@ -1,3 +1,8 @@
if RUBY_VERSION >= '1.9.2' then
require 'simplecov'
SimpleCov.start if ENV['COVERAGE']
end

require "rspec/autorun"
require 'qup'

Expand All @@ -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.