From 38044943c37566411bcb73906178154ab025400f Mon Sep 17 00:00:00 2001 From: Nick Gauthier Date: Sun, 4 Apr 2010 14:07:27 -0400 Subject: [PATCH] runs rspec, but slowly because spec_helper keeps getting reloaded --- hydra.gemspec | 2 +- lib/hydra/runner.rb | 15 +++++++++------ lib/hydra/spec/hydra_formatter.rb | 5 +++++ lib/hydra/tasks.rb | 4 +++- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/hydra.gemspec b/hydra.gemspec index 135818c..6f35537 100644 --- a/hydra.gemspec +++ b/hydra.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Nick Gauthier"] - s.date = %q{2010-04-03} + s.date = %q{2010-04-04} s.description = %q{Spread your tests over multiple machines to test your code faster.} s.email = %q{nick@smartlogicsolutions.com} s.extra_rdoc_files = [ diff --git a/lib/hydra/runner.rb b/lib/hydra/runner.rb index 0ec2861..e689a7c 100644 --- a/lib/hydra/runner.rb +++ b/lib/hydra/runner.rb @@ -103,7 +103,6 @@ module Hydra #:nodoc: # run all the Specs in an RSpec file (NOT IMPLEMENTED) def run_rspec_file(file) - puts "RUNNING: #{file}" # pull in rspec begin require 'spec' @@ -118,12 +117,15 @@ module Hydra #:nodoc: pipe = Hydra::Pipe.new pid = SafeFork.fork do pipe.identify_as_child - options = Spec::Runner.options hydra_output = StringIO.new - options.formatters = [Spec::Runner::Formatter::HydraFormatter.new(options.formatter_options, hydra_output)] - require file - options.files = [file] - options.run_examples + Spec::Runner.options.formatters = [ + Spec::Runner::Formatter::HydraFormatter.new( + Spec::Runner.options.formatter_options, + hydra_output + ) + ] + Spec::Runner.options.files = [file] + Spec::Runner.options.run_examples hydra_output.rewind output = hydra_output.read.chomp output = "" if output =~ /^\.*$/ @@ -133,6 +135,7 @@ module Hydra #:nodoc: pipe.identify_as_parent output_message = pipe.gets Process.wait pid + return output_message.output end diff --git a/lib/hydra/spec/hydra_formatter.rb b/lib/hydra/spec/hydra_formatter.rb index f9004fa..753d643 100644 --- a/lib/hydra/spec/hydra_formatter.rb +++ b/lib/hydra/spec/hydra_formatter.rb @@ -2,6 +2,11 @@ require 'spec/autorun' require 'spec/runner/formatter/progress_bar_formatter' module Spec module Runner + class << self + def run + return 0 + end + end class Options attr_accessor :formatters attr_accessor :files diff --git a/lib/hydra/tasks.rb b/lib/hydra/tasks.rb index 276a2b5..e7af1a8 100644 --- a/lib/hydra/tasks.rb +++ b/lib/hydra/tasks.rb @@ -72,6 +72,9 @@ module Hydra #:nodoc: yield self if block_given? + # Ensure we override rspec's at_exit + require 'hydra/spec/hydra_formatter' + @config = find_config_file @opts = { @@ -95,7 +98,6 @@ module Hydra #:nodoc: desc "Hydra Tests" + (@name == :hydra ? "" : " for #{@name}") task @name do Hydra::Master.new(@opts) - puts "OK AND QUIT" exit(0) #bypass test on_exit output end end