Jack Nagel 8cc3479fb7 tests: add profiling support
`rake profile` will run ruby-prof on the test suite if the ruby-prof gem
is installed.
2012-11-17 22:59:06 -06:00

56 lines
1.1 KiB
Ruby

require 'rake'
require 'rake/testtask'
require 'pathname'
TEST_DIRECTORY = Pathname.new(File.expand_path(__FILE__)).parent.realpath
TEST_FILES = FileList["#{TEST_DIRECTORY}/test_*.rb"]
Dir.chdir(TEST_DIRECTORY)
task :default => :test
Rake::TestTask.new(:test) do |t|
t.libs << Dir.pwd
t.test_files = TEST_FILES
end
namespace :test do
TEST_FILES.each do |file|
task = /test_(.+)\.rb/.match(file)
Rake::TestTask.new(task[1]) do |t|
t.libs << Dir.pwd
t.pattern = task[0]
end
end
end
begin
require 'rubygems'
require 'rcov/rcovtask'
Rcov::RcovTask.new do |t|
t.libs << Dir.pwd
t.test_files = TEST_FILES
t.rcov_opts = %w{--exclude=Gems
--exclude=test_
--exclude=testball
--exclude=testing}
t.output_dir = TEST_DIRECTORY+'coverage'
end
rescue LoadError
end
begin
require 'rubygems'
require 'ruby-prof/task'
RubyProf::ProfileTask.new do |t|
t.libs << Dir.pwd
t.test_files = TEST_FILES
t.output_dir = TEST_DIRECTORY+'prof'
t.printer = :graph_html
t.min_percent = 2
end
rescue LoadError
end