Skip to content

Commit 664ec99

Browse files
committed
use rcov under ruby 1.8, simplecov under ruby 1.9
1 parent eb69e91 commit 664ec99

File tree

4 files changed

+50
-3
lines changed

4 files changed

+50
-3
lines changed

Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
source "http://rubygems.org"
22

33
gemspec
4+
5+
6+
gem 'rcov', :platform => :mri_18
7+
gem 'simplecov', :platform => :mri_19
8+
gem 'simplecov-rcov', :platform => :mri_19

Rakefile

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,40 @@ namespace :test do
4141
task :coverage do
4242
rm_f "coverage"
4343
rm_f "coverage.data"
44-
system("rcov --aggregate coverage.data --text-summary -Ilib:test/provider test/provider/tc_*.rb")
45-
system("rcov --aggregate coverage.data --text-summary -Ilib:test/client test/client/tc_*.rb")
44+
if RUBY_VERSION =~ /^1.8/
45+
Rake::Task['rcov:client'].invoke
46+
Rake::Task['rcov:provider'].invoke
47+
else
48+
ENV['COVERAGE'] = 'true'
49+
Rake::Task['test:client'].invoke
50+
Rake::Task['test:provider'].invoke
51+
end
52+
4653
system("open coverage/index.html") if PLATFORM['darwin']
4754
end
4855

4956
end
5057

58+
if RUBY_VERSION =~ /^1.8/
59+
require 'rcov/rcovtask'
60+
namespace :rcov do
61+
Rcov::RcovTask.new do |t|
62+
t.name = 'client'
63+
t.libs << ['lib', 'test/client']
64+
t.pattern = 'test/client/tc_*.rb'
65+
t.verbose = true
66+
t.rcov_opts = ['--aggregate coverage.data', '--text-summary']
67+
end
68+
69+
Rcov::RcovTask.new('provider') do |t|
70+
t.libs << ['lib', 'test/provider']
71+
t.pattern = 'test/provider/tc_*.rb'
72+
t.verbose = true
73+
t.rcov_opts = ['--aggregate coverage.data', '--text-summary']
74+
end
75+
end
76+
end
77+
5178
task 'test:activerecord_provider' => :create_database
5279

5380
task :environment do

test/client/helpers/test_wrapper.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ def run
99
end
1010

1111
end
12+
13+
unless $provider_server_already_started
14+
$provider_server_already_started = true
15+
ProviderServer.start(3333)
16+
sleep 2
17+
end
18+

test/client/test_helper.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
if ENV['COVERAGE'] and RUBY_VERSION =~ /^1.9/
2+
require 'simplecov'
3+
require 'simplecov-rcov'
4+
5+
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
6+
SimpleCov.start
7+
end
8+
19
require 'oai'
210
require 'test/unit'
311

412
require File.dirname(__FILE__) + '/helpers/provider'
5-
require File.dirname(__FILE__) + '/helpers/test_wrapper'
13+
require File.dirname(__FILE__) + '/helpers/test_wrapper'

0 commit comments

Comments
 (0)