# This Rakefile serves as an example of how to use Rcov::RcovTask. # Take a look at the RDoc documentation (or README.rake) for further # information. $:.unshift "lib" if File.directory? "lib" require 'rcov/rcovtask' require 'rake/testtask' require 'rake/rdoctask' # Use the specified rcov executable instead of the one in $PATH # (this way we get a sort of informal functional test). # This could also be specified from the command like, e.g. # rake rcov RCOVPATH=/path/to/myrcov ENV["RCOVPATH"] = "bin/rcov" # The following task is largely equivalent to: # Rcov::RcovTask.new # (really!) desc "Create a cross-referenced code coverage report." Rcov::RcovTask.new do |t| t.test_files = FileList['test/test*.rb'] t.ruby_opts << "-Ilib:ext/rcovrt" # in order to use this rcov t.rcov_opts << "--xrefs" # comment to disable cross-references t.verbose = true end desc "Analyze code coverage for the FileStatistics class." Rcov::RcovTask.new(:rcov_sourcefile) do |t| t.test_files = FileList['test/test_FileStatistics.rb'] t.verbose = true t.rcov_opts << "--test-unit-only" t.ruby_opts << "-Ilib:ext/rcovrt" # in order to use this rcov t.output_dir = "coverage.sourcefile" end Rcov::RcovTask.new(:rcov_ccanalyzer) do |t| t.test_files = FileList['test/test_CodeCoverageAnalyzer.rb'] t.verbose = true t.rcov_opts << "--test-unit-only" t.ruby_opts << "-Ilib:ext/rcovrt" # in order to use this rcov t.output_dir = "coverage.ccanalyzer" end desc "Run the unit tests with rcovrt." Rake::TestTask.new(:test_rcovrt => ["ext/rcovrt/rcovrt.so"]) do |t| t.libs << "ext/rcovrt" t.test_files = FileList['test/test*.rb'] t.verbose = true end file "ext/rcovrt/rcovrt.so" => FileList["ext/rcovrt/*.c"] do ruby "setup.rb config" ruby "setup.rb setup" end desc "Run the unit tests in pure-Ruby mode." Rake::TestTask.new(:test_pure_ruby) do |t| t.libs << "ext/rcovrt" t.test_files = FileList['test/turn_off_rcovrt.rb', 'test/test*.rb'] t.verbose = true end desc "Run the unit tests, both rcovrt and pure-Ruby modes" task :test => [:test_rcovrt, :test_pure_ruby] task :default => :test desc "Generate rdoc documentation for the rcov library" Rake::RDocTask.new("rdoc") { |rdoc| rdoc.rdoc_dir = 'doc' rdoc.title = "rcov" rdoc.options << "--line-numbers" << "--inline-source" rdoc.rdoc_files.include('README.API') rdoc.rdoc_files.include('README.rake') rdoc.rdoc_files.include('README.rant') rdoc.rdoc_files.include('README.vim') rdoc.rdoc_files.include('lib/**/*.rb') } # {{{ Package tasks require 'rcov/version' PKG_REVISION = ".1" PKG_FILES = FileList[ "bin/rcov", "lib/**/*.rb", "ext/rcovrt/extconf.rb", "ext/rcovrt/*.c", "ext/rcovrt/*.h", "LEGAL", "LICENSE", "Rakefile", "Rantfile", "README.*", "THANKS", "test/*.rb", "mingw-rbconfig.rb", "rcov.vim", "setup.rb", "BLURB", "CHANGES" ] require 'rake/gempackagetask' Spec = Gem::Specification.new do |s| s.name = "rcov" s.version = Rcov::VERSION + PKG_REVISION s.summary = "Code coverage analysis tool for Ruby" s.description = < [:test] Rake::GemPackageTask.new(Spec) do |p| p.need_tar = true end # {{{ Cross-compilation and building of a binary RubyGems package for mswin32 require 'rake/clean' WIN32_PKG_DIR = "rcov-" + Rcov::VERSION + PKG_REVISION file "#{WIN32_PKG_DIR}" => [:package] do sh "tar zxf pkg/#{WIN32_PKG_DIR}.tgz" end desc "Cross-compile the rcovrt.so extension for win32" file "rcovrt_win32" => ["#{WIN32_PKG_DIR}"] do cp "mingw-rbconfig.rb", "#{WIN32_PKG_DIR}/ext/rcovrt/rbconfig.rb" sh "cd #{WIN32_PKG_DIR}/ext/rcovrt/ && ruby -I. extconf.rb && make" mv "#{WIN32_PKG_DIR}/ext/rcovrt/rcovrt.so", "#{WIN32_PKG_DIR}/lib" end Win32Spec = Spec.clone Win32Spec.platform = Gem::Platform::WIN32 Win32Spec.extensions = [] Win32Spec.files += ["lib/rcovrt.so"] desc "Build the binary RubyGems package for win32" task :rubygems_win32 => ["rcovrt_win32"] do Dir.chdir("#{WIN32_PKG_DIR}") do Gem::Builder.new(Win32Spec).build verbose(true) { mv Dir["*.gem"].first, "../pkg/rcov-#{Rcov::VERSION + PKG_REVISION}-mswin32.gem" } end end CLEAN.include "#{WIN32_PKG_DIR}" # vim: set sw=2 ft=ruby: