summaryrefslogtreecommitdiffstats
path: root/lib/tasks/testing.rake
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2008-08-13 04:20:16 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2008-08-13 04:20:16 +0000
commitfab5c1fdef5dbe4a64e3975855620d6bea7024b9 (patch)
tree885e898a9153a342cbde459a2284266cfbf83681 /lib/tasks/testing.rake
parentca2449d9cfab4ce9f0712b867d82e593b31b0f4c (diff)
downloadredmine-fab5c1fdef5dbe4a64e3975855620d6bea7024b9.tar.gz
redmine-fab5c1fdef5dbe4a64e3975855620d6bea7024b9.zip
Added rake tasks to generate rcov code coverage reports. rake -T test:coverage to see them all
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1744 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/tasks/testing.rake')
-rw-r--r--lib/tasks/testing.rake44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/tasks/testing.rake b/lib/tasks/testing.rake
new file mode 100644
index 000000000..3821ca5df
--- /dev/null
+++ b/lib/tasks/testing.rake
@@ -0,0 +1,44 @@
+### From http://svn.geekdaily.org/public/rails/plugins/generally_useful/tasks/coverage_via_rcov.rake
+
+### Inspired by http://blog.labratz.net/articles/2006/12/2/a-rake-task-for-rcov
+begin
+ require 'rcov/rcovtask'
+
+ namespace :test do
+ desc "Aggregate code coverage for all tests"
+ Rcov::RcovTask.new('coverage') do |t|
+ t.libs << 'test'
+ t.test_files = FileList['test/{unit,integration,functional}/*_test.rb']
+ t.verbose = true
+ t.rcov_opts << '--rails --aggregate test/coverage.data'
+ end
+
+ namespace :coverage do
+ desc "Delete coverage test data"
+ task :clean do
+ rm_f "test/coverage.data"
+ rm_rf "test/coverage"
+ end
+
+ desc "Aggregate code coverage for all tests with HTML output"
+ Rcov::RcovTask.new('html') do |t|
+ t.libs << 'test'
+ t.test_files = FileList['test/{unit,integration,functional}/*_test.rb']
+ t.output_dir = "test/coverage"
+ t.verbose = true
+ t.rcov_opts << '--rails --aggregate test/coverage.data'
+ end
+
+ desc "Open the HTML coverage report"
+ task :show_results do
+ system "open test/coverage/index.html"
+ end
+
+ task :full => "test:coverage:clean"
+ task :full => "test:coverage:html"
+ task :full => "test:coverage:show_results"
+ end
+ end
+rescue LoadError
+ puts 'Rcov is not available. Proceeding without...'
+end