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:
nex3 2006-12-16 04:21:34 +00:00
parent 42b2516dea
commit addce2f8d7
1 changed files with 36 additions and 52 deletions

View File

@ -11,21 +11,33 @@ volatile_requires.each do |file|
end end
end end
# For some crazy reason, # ----- Benchmarking -----
# some Rake tasks interfere with others
# (specifically, benchmarking). temp_desc = <<END
# Thus, it's advantageous to only show Benchmark HAML against ERb.
# the task currently being used. TIMES=n sets the number of runs. Defaults to 100.
def is_task?(*tasks) END
ARGV[0].nil? || tasks.include?(ARGV[0])
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
# ----- Default: Testing ------ #
unless ARGV[0] == 'benchmark'
desc 'Default: run unit tests.' # ----- Default: Testing ------
task :default => :test
desc 'Default: run unit tests.'
task :default => :test
if is_task?('test', 'default')
require 'rake/testtask' require 'rake/testtask'
desc 'Test the Haml plugin' desc 'Test the Haml plugin'
@ -34,13 +46,11 @@ if is_task?('test', 'default')
t.pattern = 'test/**/*_test.rb' t.pattern = 'test/**/*_test.rb'
t.verbose = true t.verbose = true
end end
end
# ----- Packaging ----- # ----- Packaging -----
if is_task?('package', 'repackage', 'clobber_package')
require 'rake/gempackagetask' require 'rake/gempackagetask'
spec = Gem::Specification.new do |spec| spec = Gem::Specification.new do |spec|
spec.name = 'haml' spec.name = 'haml'
spec.summary = 'An elegant, structured XHTML/XML templating engine.' spec.summary = 'An elegant, structured XHTML/XML templating engine.'
@ -75,36 +85,13 @@ if is_task?('package', 'repackage', 'clobber_package')
] ]
spec.test_files = FileList['test/**/*_test.rb'].to_a spec.test_files = FileList['test/**/*_test.rb'].to_a
end end
Rake::GemPackageTask.new(spec) { |pkg| } Rake::GemPackageTask.new(spec) { |pkg| }
end
# ----- Benchmarking ----- # ----- Documentation -----
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' require 'rake/rdoctask'
rdoc_task = Proc.new do |rdoc| rdoc_task = Proc.new do |rdoc|
rdoc.title = 'Haml' rdoc.title = 'Haml'
rdoc.options << '--line-numbers' << '--inline-source' rdoc.options << '--line-numbers' << '--inline-source'
@ -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 = Rake::FileList.new(*rdoc.rdoc_files.to_a)
rdoc.rdoc_files.include('lib/haml/buffer.rb') rdoc.rdoc_files.include('lib/haml/buffer.rb')
end end
end
# ----- Coverage ----- # ----- Coverage -----
if is_task?('rcov', 'clobber_rcov')
unless not_loaded.include? 'rcov/rcovtask' unless not_loaded.include? 'rcov/rcovtask'
Rcov::RcovTask.new do |t| Rcov::RcovTask.new do |t|
t.libs << "test" t.libs << "test"
@ -141,16 +126,14 @@ if is_task?('rcov', 'clobber_rcov')
t.verbose = true t.verbose = true
end end
end end
end
# ----- Profiling ----- # ----- Profiling -----
if is_task?('profile') temp_desc = <<-END
temp_desc = <<END Run a profile of HAML.
Run a profile of HAML. TIMES=n sets the number of runs. Defaults to 100.
TIMES=n sets the number of runs. Defaults to 100. FILE=n sets the file to profile. Defaults to 'standard'.
FILE=n sets the file to profile. Defaults to 'standard'. END
END
desc temp_desc.chomp desc temp_desc.chomp
task :profile do task :profile do
require 'test/profile' require 'test/profile'
@ -167,4 +150,5 @@ END
puts '-'*51 puts '-'*51
end end
end end