From c0a39160801124f5fa30baf9da14a7c7a57fcabc Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sun, 25 Oct 2009 20:14:09 -0700 Subject: [PATCH] Use rcov to generate a coverage report for tests. --- .gitignore | 1 + Rakefile | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/.gitignore b/.gitignore index b6cd7a3b..d85e13a5 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ test/fixtures/stylesheets/*/saved test/fixtures/stylesheets/empty test/fixtures/stylesheets/*/sass/.sass-cache pkg/* +coverage* diff --git a/Rakefile b/Rakefile index ee6c3cb0..09ca56b0 100644 --- a/Rakefile +++ b/Rakefile @@ -14,6 +14,7 @@ require 'rubygems' require 'rake' $:.unshift File.join(File.dirname(__FILE__), 'lib') require 'compass' +require 'rcov/rcovtask' # ----- Default: Testing ------ @@ -129,3 +130,34 @@ namespace :git do sh "git", "clean", "-fdx" end end + +require 'cucumber/rake/task' + +namespace :rcov do + Cucumber::Rake::Task.new(:cucumber) do |t| + t.rcov = true + t.rcov_opts = %w{--exclude osx\/objc,gems\/,spec\/,features\/ --aggregate coverage.data} + t.rcov_opts << %[-o "coverage"] + end + + Rcov::RcovTask.new(:units) do |rcov| + rcov.libs << 'lib' + rcov.libs << 'haml/lib' if ENV["RUN_CODE_RUN"] + test_files = FileList['test/**/*_test.rb'] + test_files.exclude('test/rails/*', 'test/haml/*') + rcov.pattern = test_files + rcov.output_dir = 'coverage' + rcov.verbose = true + rcov.rcov_opts = %w{--exclude osx\/objc,gems\/,spec\/,features\/ --aggregate coverage.data} + rcov.rcov_opts << %[-o "coverage" --sort coverage] + end + + + desc "Run both specs and features to generate aggregated coverage" + task :all do |t| + rm "coverage.data" if File.exist?("coverage.data") + Rake::Task["rcov:units"].invoke + Rake::Task["rcov:cucumber"].invoke + end +end +