Skip to content

Commit

Permalink
add ci for memcached as a service
Browse files Browse the repository at this point in the history
Change-Id: I650c53d5f269529b225ed742e4a69934ac528792
  • Loading branch information
SlimYang committed Jun 6, 2012
1 parent 83f4526 commit ec38957
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions memcached/spec/Rakefile
Expand Up @@ -5,38 +5,45 @@ require 'rubygems'
require 'bundler/setup'
Bundler.require(:default, :test)

require 'rspec'
require 'rspec/core/rake_task'
require 'ci/reporter/rake/rspec'

require "simplecov"
require "simplecov-rcov"

coverage_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_coverage"))
reports_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_reports"))
dump_file = File.join(Dir.tmpdir, "redis.rcov")

ENV['CI_REPORTS'] = reports_dir

desc "Run specs using RCov"
task "spec:rcov" => ["ci:setup:rspec", "spec:rcov_internal", "convert_rcov_to_clover"]
desc "Run specs using SimpleCov"
task "spec:ci" => ["ci:setup:rspec", "simcov"]

RSpec::Core::RakeTask.new do |t|
t.pattern = "**/*_spec.rb"
t.rspec_opts = ["--format", "documentation", "--colour"]
end

ignore_pattern = 'spec,[.]bundle,[/]gems[/]'

desc "Run specs using RCov (internal, use spec:rcov instead)"
RSpec::Core::RakeTask.new("spec:rcov_internal") do |t|
FileUtils.rm_rf(dump_file)
t.pattern = "**/*_spec.rb"
t.rspec_opts = ["--format", "progress", "--colour"]
t.rcov = true
t.rcov_opts = ['--aggregate', dump_file, '--exclude', ignore_pattern, '--output', coverage_dir]
# t.rcov_opts = %W{--exclude osx\/objc,gems\/,spec\/,features\/ -o "#{coverage_dir}"}
desc "Run spec with coverage"
task "simcov" => "cleanup_coverage" do
class SimpleCov::Formatter::CombinedFormatter
def format(result)
SimpleCov::Formatter::RcovFormatter.new.format(result)
end
end

SimpleCov.formatter = SimpleCov::Formatter::CombinedFormatter
SimpleCov.root('..')
SimpleCov.coverage_dir('spec_coverage')
SimpleCov.start do
add_filter "/spec/"
spec_dir = File.expand_path("..", __FILE__)
Rspec::Core::Runner.disable_autorun!
Rspec::Core::Runner.run([spec_dir], STDERR, STDOUT)
end
end

task "convert_rcov_to_clover" do |t|
clover_output = File.join(coverage_dir, "clover.xml")
analyzer = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "tests", "common", "rcov_analyzer.rb"))
sh("ruby #{analyzer} #{dump_file} #{ignore_pattern} > #{clover_output}")
FileUtils.rm_rf(dump_file)
task "cleanup_coverage" do
rm_rf coverage_dir
end

0 comments on commit ec38957

Please sign in to comment.