From 5f55baba19cad7814871a25efdaddf5ca49ac37e Mon Sep 17 00:00:00 2001 From: Nick Gauthier Date: Thu, 8 Jul 2010 10:45:25 -0400 Subject: [PATCH] added t.serial task option. moved rails env check to task run instead of definition --- hydra.gemspec | 2 +- lib/hydra/tasks.rb | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/hydra.gemspec b/hydra.gemspec index f65fa20..5137de0 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-06-18} + s.date = %q{2010-07-08} 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/tasks.rb b/lib/hydra/tasks.rb index 953e10f..5105ec0 100644 --- a/lib/hydra/tasks.rb +++ b/lib/hydra/tasks.rb @@ -31,6 +31,11 @@ module Hydra #:nodoc: # t.listeners << Hydra::Listener::Notifier.new attr_accessor :listeners + # Set to true if you want to run this task only on the local + # machine with one runner. A "Safe Mode" for some test + # files that may not play nice with others. + attr_accessor :serial + # # Search for the hydra config file def find_config_file @@ -68,20 +73,17 @@ module Hydra #:nodoc: @files = [] @verbose = false @autosort = true + @serial = false @listeners = [Hydra::Listener::ProgressBar.new] yield self if block_given? - if Object.const_defined?('RAILS_ENV') && RAILS_ENV == 'development' - $stderr.puts <<-MSG -WARNING: RAILS_ENV is "development". Make sure to set it properly (ex: "RAILS_ENV=test rake hydra") - MSG - end - # Ensure we override rspec's at_exit require 'hydra/spec/autorun_override' - @config = find_config_file + unless @serial + @config = find_config_file + end @opts = { :verbose => @verbose, @@ -103,6 +105,10 @@ WARNING: RAILS_ENV is "development". Make sure to set it properly (ex: "RAILS_EN def define desc "Hydra Tests" + (@name == :hydra ? "" : " for #{@name}") task @name do + if Object.const_defined?('RAILS_ENV') && RAILS_ENV == 'development' + $stderr.puts %{WARNING: RAILS_ENV is "development". Make sure to set it properly (ex: "RAILS_ENV=test rake hydra")} + end + Hydra::Master.new(@opts) end end