mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Remove more unused tasks, fix profile task
This commit is contained in:
parent
544c2e4e50
commit
c10808d6df
1 changed files with 19 additions and 115 deletions
134
Rakefile
134
Rakefile
|
@ -2,6 +2,8 @@ require "rake/clean"
|
||||||
require 'rake/testtask'
|
require 'rake/testtask'
|
||||||
require 'rubygems/package_task'
|
require 'rubygems/package_task'
|
||||||
|
|
||||||
|
task :default => :test
|
||||||
|
|
||||||
CLEAN << %w(pkg doc coverage .yardoc)
|
CLEAN << %w(pkg doc coverage .yardoc)
|
||||||
|
|
||||||
def scope(path)
|
def scope(path)
|
||||||
|
@ -74,76 +76,35 @@ task :pages do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# ----- Coverage -----
|
|
||||||
|
|
||||||
begin
|
|
||||||
require 'rcov/rcovtask'
|
|
||||||
|
|
||||||
Rcov::RcovTask.new do |t|
|
|
||||||
t.test_files = FileList[scope('test/**/*_test.rb')]
|
|
||||||
t.rcov_opts << '-x' << '"^\/"'
|
|
||||||
if ENV['NON_NATIVE']
|
|
||||||
t.rcov_opts << "--no-rcovrt"
|
|
||||||
end
|
|
||||||
t.verbose = true
|
|
||||||
end
|
|
||||||
rescue LoadError; end
|
|
||||||
|
|
||||||
# ----- Profiling -----
|
|
||||||
|
|
||||||
begin
|
|
||||||
require 'ruby-prof'
|
|
||||||
|
|
||||||
desc <<END
|
desc <<END
|
||||||
Run a profile of haml.
|
Profile Haml.
|
||||||
TIMES=n sets the number of runs. Defaults to 1000.
|
TIMES=n sets the number of runs. Defaults to 1000.
|
||||||
FILE=str sets the file to profile. Defaults to 'standard'
|
FILE=str sets the file to profile. Defaults to 'standard'
|
||||||
OUTPUT=str sets the ruby-prof output format.
|
OUTPUT=str sets the ruby-prof output format.
|
||||||
Can be Flat, CallInfo, or Graph. Defaults to Flat. Defaults to Flat.
|
Can be Flat, CallInfo, or Graph. Defaults to Flat. Defaults to Flat.
|
||||||
END
|
END
|
||||||
task :profile do
|
task :profile do
|
||||||
times = (ENV['TIMES'] || '1000').to_i
|
times = (ENV['TIMES'] || '1000').to_i
|
||||||
file = ENV['FILE']
|
file = ENV['FILE']
|
||||||
|
|
||||||
require 'lib/haml'
|
require 'bundler/setup'
|
||||||
|
require 'ruby-prof'
|
||||||
|
require 'haml'
|
||||||
|
|
||||||
file = File.read(scope("test/haml/templates/#{file || 'standard'}.haml"))
|
file = File.read(scope("test/templates/#{file || 'standard'}.haml"))
|
||||||
obj = Object.new
|
obj = Object.new
|
||||||
Haml::Engine.new(file).def_method(obj, :render)
|
Haml::Engine.new(file, :ugly => true).def_method(obj, :render)
|
||||||
result = RubyProf.profile { times.times { obj.render } }
|
result = RubyProf.profile { times.times { obj.render } }
|
||||||
|
|
||||||
RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print
|
RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print
|
||||||
end
|
|
||||||
rescue LoadError; end
|
|
||||||
|
|
||||||
# ----- Testing Multiple Rails Versions -----
|
|
||||||
|
|
||||||
rails_versions = [
|
|
||||||
"v3.1.0",
|
|
||||||
"v3.0.10",
|
|
||||||
"v2.3.14",
|
|
||||||
"v2.2.3",
|
|
||||||
"v2.1.2",
|
|
||||||
]
|
|
||||||
rails_versions << "v2.0.5" if RUBY_VERSION =~ /^1\.8/
|
|
||||||
|
|
||||||
def test_rails_version(version)
|
|
||||||
Dir.chdir "test/rails" do
|
|
||||||
sh %{git checkout #{version}}
|
|
||||||
end
|
|
||||||
puts "Testing Rails #{version}"
|
|
||||||
Rake::Task['test'].reenable
|
|
||||||
Rake::Task['test'].execute
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def gemfiles
|
def gemfiles
|
||||||
@gemfiles ||=
|
@gemfiles ||= begin
|
||||||
begin
|
Dir[File.dirname(__FILE__) + '/test/gemfiles/Gemfile.*'].
|
||||||
raise 'Must install bundler to run Rails compatibility tests' if `which bundle`.empty?
|
reject {|f| f =~ /\.lock$/}.
|
||||||
Dir[File.dirname(__FILE__) + '/test/gemfiles/Gemfile.*'].
|
reject {|f| RUBY_VERSION >= '1.9' && f =~ /2\.[0-2]/}
|
||||||
reject {|f| f =~ /\.lock$/}.
|
end
|
||||||
reject {|f| RUBY_VERSION !~ /^1\.8/ && f =~ /Gemfile\.rails-2\.[0-2]/}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_each_gemfile
|
def with_each_gemfile
|
||||||
|
@ -172,63 +133,6 @@ namespace :test do
|
||||||
|
|
||||||
desc "Test all supported versions of rails. This takes a while."
|
desc "Test all supported versions of rails. This takes a while."
|
||||||
task :rails_compatibility => 'test:bundles:install' do
|
task :rails_compatibility => 'test:bundles:install' do
|
||||||
`rm -rf test/rails`
|
|
||||||
`rm -rf test/plugins`
|
|
||||||
with_each_gemfile {sh "bundle exec rake test"}
|
with_each_gemfile {sh "bundle exec rake test"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# ----- Handling Updates -----
|
|
||||||
|
|
||||||
def email_on_error
|
|
||||||
yield
|
|
||||||
rescue Exception => e
|
|
||||||
IO.popen("sendmail nex342@gmail.com", "w") do |sm|
|
|
||||||
sm << "From: nex3@nex-3.com\n" <<
|
|
||||||
"To: nex342@gmail.com\n" <<
|
|
||||||
"Subject: Exception when running rake #{Rake.application.top_level_tasks.join(', ')}\n" <<
|
|
||||||
e.message << "\n\n" <<
|
|
||||||
e.backtrace.join("\n")
|
|
||||||
end
|
|
||||||
ensure
|
|
||||||
raise e if e
|
|
||||||
end
|
|
||||||
|
|
||||||
def ensure_git_cleanup
|
|
||||||
email_on_error {yield}
|
|
||||||
ensure
|
|
||||||
sh %{git reset --hard HEAD}
|
|
||||||
sh %{git clean -xdf}
|
|
||||||
sh %{git checkout master}
|
|
||||||
end
|
|
||||||
|
|
||||||
task :handle_update do
|
|
||||||
email_on_error do
|
|
||||||
unless ENV["REF"] =~ %r{^refs/heads/(master|stable|haml-pages)$}
|
|
||||||
puts "#{'=' * 20} Ignoring rake handle_update REF=#{ENV["REF"].inspect}"
|
|
||||||
next
|
|
||||||
end
|
|
||||||
branch = $1
|
|
||||||
|
|
||||||
puts
|
|
||||||
puts
|
|
||||||
puts '=' * 150
|
|
||||||
puts "Running rake handle_update REF=#{ENV["REF"].inspect}"
|
|
||||||
|
|
||||||
sh %{git fetch origin}
|
|
||||||
sh %{git checkout stable}
|
|
||||||
sh %{git reset --hard origin/stable}
|
|
||||||
sh %{git checkout master}
|
|
||||||
sh %{git reset --hard origin/master}
|
|
||||||
|
|
||||||
case branch
|
|
||||||
when "master"
|
|
||||||
sh %{rake release_edge --trace}
|
|
||||||
when "stable", "haml-pages"
|
|
||||||
sh %{rake pages --trace}
|
|
||||||
end
|
|
||||||
|
|
||||||
puts 'Done running handle_update'
|
|
||||||
puts '=' * 150
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
Loading…
Reference in a new issue