fast rspec running

This commit is contained in:
Nick Gauthier 2010-04-04 21:22:20 -04:00
parent 38044943c3
commit c36ec7a0a0
3 changed files with 24 additions and 31 deletions

View File

@ -110,33 +110,28 @@ module Hydra #:nodoc:
rescue LoadError => ex rescue LoadError => ex
return ex.to_s return ex.to_s
end end
# we have to run the rspec test in a sub-process hydra_output = StringIO.new
# this is because rspec runs all the tests that Spec::Runner.options.instance_variable_set(:@formatters, [
# have been required, so if we kept requiring the Spec::Runner::Formatter::HydraFormatter.new(
# files they'd get run over and over Spec::Runner.options.formatter_options,
pipe = Hydra::Pipe.new hydra_output
pid = SafeFork.fork do )
pipe.identify_as_child ])
hydra_output = StringIO.new Spec::Runner.options.instance_variable_set(
Spec::Runner.options.formatters = [ :@example_groups, []
Spec::Runner::Formatter::HydraFormatter.new( )
Spec::Runner.options.formatter_options, Spec::Runner.options.instance_variable_set(
hydra_output :@files, [file]
) )
] Spec::Runner.options.instance_variable_set(
Spec::Runner.options.files = [file] :@files_loaded, false
Spec::Runner.options.run_examples )
hydra_output.rewind Spec::Runner.options.run_examples
output = hydra_output.read.chomp hydra_output.rewind
output = "" if output =~ /^\.*$/ output = hydra_output.read.chomp
pipe.write RSpecResult.new(:output => output) output = "" if output =~ /^\.*$/
pipe.close
end
pipe.identify_as_parent
output_message = pipe.gets
Process.wait pid
return output_message.output return output
end end
# run all the scenarios in a cucumber feature file # run all the scenarios in a cucumber feature file

View File

@ -3,16 +3,14 @@ require 'spec/runner/formatter/progress_bar_formatter'
module Spec module Spec
module Runner module Runner
class << self class << self
# stop the auto-run at_exit
def run def run
return 0 return 0
end end
end end
class Options
attr_accessor :formatters
attr_accessor :files
end
module Formatter module Formatter
class HydraFormatter < ProgressBarFormatter class HydraFormatter < ProgressBarFormatter
# Stifle the post-test summary
def dump_summary(duration, example, failure, pending) def dump_summary(duration, example, failure, pending)
end end
end end

View File

@ -98,7 +98,7 @@ 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 #exit(0) #bypass test on_exit output
end end
end end
end end