Permalink
Browse files

Use simplecov instead of rcov for coverage testing on 1.9+

Rcov never worked well on 1.9, and the latest version doesn't
support 1.9+ at all.  SimpleCov uses ruby 1.9+'s native coverage
library, and appears to work well.
  • Loading branch information...
1 parent f5d6963 commit 55867494bfcf2de68f4c85e77a38cae3f55c4bf1 @jeremyevans committed Feb 25, 2013
View
@@ -1,5 +1,7 @@
=== HEAD
+* Use simplecov instead of rcov for coverage testing on 1.9+ (jeremyevans)
+
* Make the Database#quote_identifier method public (jeremyevans)
* Make PostgreSQL metadata parsing handle tables with the same name in multiple schemas (jeremyevans)
View
@@ -125,10 +125,18 @@ begin
spec_with_cov = lambda do |name, files, d, &b|
spec.call(name, files, d)
- t = spec.call("#{name}_cov", files, "#{d} with coverage")
- t.rcov = true
- t.rcov_opts = File.read("spec/rcov.opts").split("\n")
- b.call(t) if b
+ if RUBY_VERSION < '1.9'
+ t = spec.call("#{name}_cov", files, "#{d} with coverage")
+ t.rcov = true
+ t.rcov_opts = File.read("spec/rcov.opts").split("\n")
+ b.call(t) if b
+ else
+ desc "#{d} with coverage"
+ task "#{name}_cov" do
+ ENV['COVERAGE'] = '1'
+ Rake::Task[name].invoke
+ end
+ end
t
end
@@ -1,5 +1,11 @@
require 'rubygems'
require 'logger'
+
+if ENV['COVERAGE']
+ require File.join(File.dirname(File.expand_path(__FILE__)), "../sequel_coverage")
+ SimpleCov.sequel_coverage(:group=>%r{lib/sequel/adapters})
+end
+
unless Object.const_defined?('Sequel')
$:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/"))
require 'sequel/no_core_ext'
@@ -1,5 +1,10 @@
require 'rubygems'
+if ENV['COVERAGE']
+ require File.join(File.dirname(File.expand_path(__FILE__)), "../sequel_coverage")
+ SimpleCov.sequel_coverage(:filter=>%r{lib/sequel/(\w+\.rb|(dataset|database|model|connection_pool)/\w+\.rb|adapters/mock\.rb)\z})
+end
+
unless Object.const_defined?('Sequel')
$:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/"))
SEQUEL_NO_CORE_EXTENSIONS = true
@@ -1,5 +1,10 @@
require 'rubygems'
+if ENV['COVERAGE']
+ require File.join(File.dirname(File.expand_path(__FILE__)), "sequel_coverage")
+ SimpleCov.sequel_coverage(:filter=>%r{lib/sequel/extensions/core_extensions\.rb\z})
+end
+
unless Object.const_defined?('Sequel') && Sequel.const_defined?('Model')
$:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/"))
require 'sequel/no_core_ext'
@@ -8,6 +8,11 @@
end
end
+if ENV['COVERAGE']
+ require File.join(File.dirname(File.expand_path(__FILE__)), "../sequel_coverage")
+ SimpleCov.sequel_coverage(:filter=>%r{lib/sequel/(extensions|plugins)/\w+\.rb\z})
+end
+
unless Object.const_defined?('Sequel') && Sequel.const_defined?('Model')
$:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/"))
require 'sequel/no_core_ext'
@@ -1,5 +1,11 @@
require 'rubygems'
require 'logger'
+
+if ENV['COVERAGE']
+ require File.join(File.dirname(File.expand_path(__FILE__)), "../sequel_coverage")
+ SimpleCov.sequel_coverage(:group=>%r{lib/sequel/adapters})
+end
+
unless Object.const_defined?('Sequel')
$:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/"))
require 'sequel/no_core_ext'
@@ -0,0 +1,15 @@
+require 'coverage'
+require 'simplecov'
+
+def SimpleCov.sequel_coverage(opts = {})
+ start do
+ add_filter "/spec/"
+ add_group('Missing-Revelent'){|src| src.filename =~ opts[:group] && src.covered_percent < 100} if opts[:group]
+ add_group('Missing'){|src| src.covered_percent < 100}
+ add_group('Covered'){|src| src.covered_percent == 100}
+ add_filter{|src| src.filename !~ opts[:filter]} if opts[:filter]
+ yield self if block_given?
+ end
+end
+
+ENV.delete('COVERAGE')

0 comments on commit 5586749

Please sign in to comment.