merged with ngauthier master
This commit is contained in:
commit
3500388765
2
Rakefile
2
Rakefile
|
@ -12,7 +12,7 @@ begin
|
||||||
gem.authors = ["Nick Gauthier"]
|
gem.authors = ["Nick Gauthier"]
|
||||||
gem.add_development_dependency "shoulda", "= 2.10.3"
|
gem.add_development_dependency "shoulda", "= 2.10.3"
|
||||||
gem.add_development_dependency "rspec", "= 1.3.0"
|
gem.add_development_dependency "rspec", "= 1.3.0"
|
||||||
gem.add_development_dependency "cucumber", "= 0.6.4"
|
gem.add_development_dependency "cucumber", "= 0.7.2"
|
||||||
end
|
end
|
||||||
Jeweler::GemcutterTasks.new
|
Jeweler::GemcutterTasks.new
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
|
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = %q{hydra}
|
s.name = %q{hydra}
|
||||||
s.version = "0.16.7"
|
s.version = "0.17.0"
|
||||||
|
|
||||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||||
s.authors = ["Nick Gauthier"]
|
s.authors = ["Nick Gauthier"]
|
||||||
s.date = %q{2010-04-28}
|
s.date = %q{2010-05-10}
|
||||||
s.description = %q{Spread your tests over multiple machines to test your code faster.}
|
s.description = %q{Spread your tests over multiple machines to test your code faster.}
|
||||||
s.email = %q{nick@smartlogicsolutions.com}
|
s.email = %q{nick@smartlogicsolutions.com}
|
||||||
s.extra_rdoc_files = [
|
s.extra_rdoc_files = [
|
||||||
|
@ -107,16 +107,16 @@ Gem::Specification.new do |s|
|
||||||
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
||||||
s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
|
s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||||
s.add_development_dependency(%q<rspec>, ["= 1.3.0"])
|
s.add_development_dependency(%q<rspec>, ["= 1.3.0"])
|
||||||
s.add_development_dependency(%q<cucumber>, ["= 0.6.4"])
|
s.add_development_dependency(%q<cucumber>, ["= 0.7.2"])
|
||||||
else
|
else
|
||||||
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||||
s.add_dependency(%q<rspec>, ["= 1.3.0"])
|
s.add_dependency(%q<rspec>, ["= 1.3.0"])
|
||||||
s.add_dependency(%q<cucumber>, ["= 0.6.4"])
|
s.add_dependency(%q<cucumber>, ["= 0.7.2"])
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||||
s.add_dependency(%q<rspec>, ["= 1.3.0"])
|
s.add_dependency(%q<rspec>, ["= 1.3.0"])
|
||||||
s.add_dependency(%q<cucumber>, ["= 0.6.4"])
|
s.add_dependency(%q<cucumber>, ["= 0.7.2"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,81 @@ module Hydra #:nodoc:
|
||||||
desc "Hydra Tests" + (@name == :hydra ? "" : " for #{@name}")
|
desc "Hydra Tests" + (@name == :hydra ? "" : " for #{@name}")
|
||||||
task @name do
|
task @name do
|
||||||
Hydra::Master.new(@opts)
|
Hydra::Master.new(@opts)
|
||||||
#exit(0) #bypass test on_exit output
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Define a test task that uses hydra to profile your test files
|
||||||
|
#
|
||||||
|
# Hydra::ProfileTask.new('hydra:prof') do |t|
|
||||||
|
# t.add_files 'test/unit/**/*_test.rb'
|
||||||
|
# t.add_files 'test/functional/**/*_test.rb'
|
||||||
|
# t.add_files 'test/integration/**/*_test.rb'
|
||||||
|
# t.generate_html = true # defaults to false
|
||||||
|
# t.generate_text = true # defaults to true
|
||||||
|
# end
|
||||||
|
class ProfileTask < Hydra::Task
|
||||||
|
# boolean: generate html output from ruby-prof
|
||||||
|
attr_accessor :generate_html
|
||||||
|
# boolean: generate text output from ruby-prof
|
||||||
|
attr_accessor :generate_text
|
||||||
|
|
||||||
|
# Create a new Hydra ProfileTask
|
||||||
|
def initialize(name = 'hydra:profile')
|
||||||
|
@name = name
|
||||||
|
@files = []
|
||||||
|
@verbose = false
|
||||||
|
@generate_html = false
|
||||||
|
@generate_text = true
|
||||||
|
|
||||||
|
yield self if block_given?
|
||||||
|
|
||||||
|
# Ensure we override rspec's at_exit
|
||||||
|
require 'hydra/spec/autorun_override'
|
||||||
|
|
||||||
|
@config = find_config_file
|
||||||
|
|
||||||
|
@opts = {
|
||||||
|
:verbose => @verbose,
|
||||||
|
:files => @files
|
||||||
|
}
|
||||||
|
define
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
# Create the rake task defined by this HydraTestTask
|
||||||
|
def define
|
||||||
|
desc "Hydra Test Profile" + (@name == :hydra ? "" : " for #{@name}")
|
||||||
|
task @name do
|
||||||
|
require 'ruby-prof'
|
||||||
|
RubyProf.start
|
||||||
|
|
||||||
|
runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
|
||||||
|
@files.each do |file|
|
||||||
|
$stdout.write runner.run_file(file)
|
||||||
|
$stdout.flush
|
||||||
|
end
|
||||||
|
|
||||||
|
$stdout.write "\nTests complete. Generating profiling output\n"
|
||||||
|
$stdout.flush
|
||||||
|
|
||||||
|
result = RubyProf.stop
|
||||||
|
|
||||||
|
if @generate_html
|
||||||
|
printer = RubyProf::GraphHtmlPrinter.new(result)
|
||||||
|
out = File.new("ruby-prof.html", 'w')
|
||||||
|
printer.print(out, :min_self => 0.05)
|
||||||
|
out.close
|
||||||
|
$stdout.write "Profiling data written to [ruby-prof.html]\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
if @generate_text
|
||||||
|
printer = RubyProf::FlatPrinter.new(result)
|
||||||
|
out = File.new("ruby-prof.txt", 'w')
|
||||||
|
printer.print(out, :min_self => 0.05)
|
||||||
|
out.close
|
||||||
|
$stdout.write "Profiling data written to [ruby-prof.txt]\n"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue