Skip to content

Instantly share code, notes, and snippets.

@wagenet
Created May 15, 2009 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wagenet/112225 to your computer and use it in GitHub Desktop.
Save wagenet/112225 to your computer and use it in GitHub Desktop.
# Tasks to use with test_benchmark when it is installed as a gem
# Does not require you to install as a plugin or frozen gem or otherwise modify your project
# Author: Peter Wagenet (http://in.finitu.de)
# URL: http://gist.github.com/112225
begin
require 'rubygems'
gem 'timocratic-test_benchmark'
def find_file(fn)
$LOAD_PATH.each do |path|
file_path = File.join(path, "#{fn}.rb")
return file_path if File.exist? file_path
end
nil
end
if (test_benchmark_file = find_file('test_benchmark'))
namespace :test do
desc "Run and benchmark all tests"
task :benchmark do
errors = %w(test:benchmark:units test:benchmark:functionals test:benchmark:integration).collect do |task|
begin
Rake::Task[task].invoke
nil
rescue => e
task
end
end.compact
abort "Errors running #{errors.to_sentence}!" if errors.any?
end
namespace :benchmark do
Rake::TestTask.new(:units => "db:test:prepare") do |t|
t.libs << "test"
t.test_files = test_benchmark_file
t.pattern = 'test/unit/**/*_test.rb'
t.verbose = true
end
Rake::Task['test:benchmark:units'].comment = "Run and benchmark the unit tests in test/unit"
Rake::TestTask.new(:functionals => "db:test:prepare") do |t|
t.libs << "test"
t.test_files = test_benchmark_file
t.pattern = 'test/functional/**/*_test.rb'
t.verbose = true
end
Rake::Task['test:benchmark:functionals'].comment = "Run and benchmark the functional tests in test/functional"
Rake::TestTask.new(:integration => "db:test:prepare") do |t|
t.libs << "test"
t.test_files = test_benchmark_file
t.pattern = 'test/integration/**/*_test.rb'
t.verbose = true
end
Rake::Task['test:benchmark:integration'].comment = "Run and benchmark the integration tests in test/integration"
end
end
end
rescue LoadError
# test_benchmark gem not installed
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment