mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
A saner way of separating the benchmark task.
git-svn-id: svn://hamptoncatlin.com/haml/trunk@219 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
parent
42b2516dea
commit
addce2f8d7
1 changed files with 36 additions and 52 deletions
60
Rakefile
60
Rakefile
|
@ -11,21 +11,33 @@ volatile_requires.each do |file|
|
|||
end
|
||||
end
|
||||
|
||||
# For some crazy reason,
|
||||
# some Rake tasks interfere with others
|
||||
# (specifically, benchmarking).
|
||||
# Thus, it's advantageous to only show
|
||||
# the task currently being used.
|
||||
def is_task?(*tasks)
|
||||
ARGV[0].nil? || tasks.include?(ARGV[0])
|
||||
# ----- Benchmarking -----
|
||||
|
||||
temp_desc = <<END
|
||||
Benchmark HAML against ERb.
|
||||
TIMES=n sets the number of runs. Defaults to 100.
|
||||
END
|
||||
|
||||
desc temp_desc.chomp
|
||||
task :benchmark do
|
||||
require 'test/benchmark'
|
||||
|
||||
puts '-'*51, "Benchmark: Haml vs. ERb", '-'*51
|
||||
puts "Running benchmark #{ENV['TIMES']} times..." if ENV['TIMES']
|
||||
times = ENV['TIMES'].to_i if ENV['TIMES']
|
||||
benchmarker = Haml::Benchmarker.new
|
||||
puts benchmarker.benchmark(times || 100)
|
||||
puts '-'*51
|
||||
end
|
||||
|
||||
#
|
||||
unless ARGV[0] == 'benchmark'
|
||||
|
||||
# ----- Default: Testing ------
|
||||
|
||||
desc 'Default: run unit tests.'
|
||||
task :default => :test
|
||||
|
||||
if is_task?('test', 'default')
|
||||
require 'rake/testtask'
|
||||
|
||||
desc 'Test the Haml plugin'
|
||||
|
@ -34,11 +46,9 @@ if is_task?('test', 'default')
|
|||
t.pattern = 'test/**/*_test.rb'
|
||||
t.verbose = true
|
||||
end
|
||||
end
|
||||
|
||||
# ----- Packaging -----
|
||||
|
||||
if is_task?('package', 'repackage', 'clobber_package')
|
||||
require 'rake/gempackagetask'
|
||||
|
||||
spec = Gem::Specification.new do |spec|
|
||||
|
@ -77,32 +87,9 @@ if is_task?('package', 'repackage', 'clobber_package')
|
|||
end
|
||||
|
||||
Rake::GemPackageTask.new(spec) { |pkg| }
|
||||
end
|
||||
|
||||
# ----- Benchmarking -----
|
||||
|
||||
if is_task?('benchmark')
|
||||
temp_desc = <<END
|
||||
Benchmark HAML against ERb.
|
||||
TIMES=n sets the number of runs. Defaults to 100.
|
||||
END
|
||||
|
||||
desc temp_desc.chomp
|
||||
task :benchmark do
|
||||
require 'test/benchmark'
|
||||
|
||||
puts '-'*51, "Benchmark: Haml vs. ERb", '-'*51
|
||||
puts "Running benchmark #{ENV['TIMES']} times..." if ENV['TIMES']
|
||||
times = ENV['TIMES'].to_i if ENV['TIMES']
|
||||
benchmarker = Haml::Benchmarker.new
|
||||
puts benchmarker.benchmark(times || 100)
|
||||
puts '-'*51
|
||||
end
|
||||
end
|
||||
|
||||
# ----- Documentation -----
|
||||
|
||||
if is_task?('rdoc', 'rerdoc', 'clobber_rdoc', 'rdoc_devel', 'rerdoc_devel', 'clobber_rdoc_devel')
|
||||
require 'rake/rdoctask'
|
||||
|
||||
rdoc_task = Proc.new do |rdoc|
|
||||
|
@ -126,11 +113,9 @@ if is_task?('rdoc', 'rerdoc', 'clobber_rdoc', 'rdoc_devel', 'rerdoc_devel', 'clo
|
|||
rdoc.rdoc_files = Rake::FileList.new(*rdoc.rdoc_files.to_a)
|
||||
rdoc.rdoc_files.include('lib/haml/buffer.rb')
|
||||
end
|
||||
end
|
||||
|
||||
# ----- Coverage -----
|
||||
|
||||
if is_task?('rcov', 'clobber_rcov')
|
||||
unless not_loaded.include? 'rcov/rcovtask'
|
||||
Rcov::RcovTask.new do |t|
|
||||
t.libs << "test"
|
||||
|
@ -141,12 +126,10 @@ if is_task?('rcov', 'clobber_rcov')
|
|||
t.verbose = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# ----- Profiling -----
|
||||
|
||||
if is_task?('profile')
|
||||
temp_desc = <<END
|
||||
temp_desc = <<-END
|
||||
Run a profile of HAML.
|
||||
TIMES=n sets the number of runs. Defaults to 100.
|
||||
FILE=n sets the file to profile. Defaults to 'standard'.
|
||||
|
@ -167,4 +150,5 @@ END
|
|||
|
||||
puts '-'*51
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue