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
# this is because rspec runs all the tests that
# have been required, so if we kept requiring the
# files they'd get run over and over
pipe = Hydra::Pipe.new
pid = SafeFork.fork do
pipe.identify_as_child
hydra_output = StringIO.new hydra_output = StringIO.new
Spec::Runner.options.formatters = [ Spec::Runner.options.instance_variable_set(:@formatters, [
Spec::Runner::Formatter::HydraFormatter.new( Spec::Runner::Formatter::HydraFormatter.new(
Spec::Runner.options.formatter_options, Spec::Runner.options.formatter_options,
hydra_output hydra_output
) )
] ])
Spec::Runner.options.files = [file] Spec::Runner.options.instance_variable_set(
:@example_groups, []
)
Spec::Runner.options.instance_variable_set(
:@files, [file]
)
Spec::Runner.options.instance_variable_set(
:@files_loaded, false
)
Spec::Runner.options.run_examples Spec::Runner.options.run_examples
hydra_output.rewind hydra_output.rewind
output = hydra_output.read.chomp output = hydra_output.read.chomp
output = "" if output =~ /^\.*$/ output = "" if output =~ /^\.*$/
pipe.write RSpecResult.new(:output => 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