cleaned up test suite. allowed warmsnake to be run

This commit is contained in:
Nick Gauthier 2010-08-24 09:50:25 -04:00
parent 4fa7cc2b69
commit a9b9b09853
2 changed files with 56 additions and 62 deletions

View File

@ -1,64 +1,62 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
if File.expand_path($0) == File.expand_path(__FILE__) require 'rubygems'
require 'rubygems' require 'hydra'
require 'hydra'
@files = ARGV.inject([]){|memo,f| memo += Dir.glob f}
@files = ARGV.inject([]){|memo,f| memo += Dir.glob f}
if @files.empty?
if @files.empty? puts "You must specify a list of files to run"
puts "You must specify a list of files to run" puts "If you specify a pattern, it must be in quotes"
puts "If you specify a pattern, it must be in quotes" puts %{USAGE: #{$0} test/unit/my_test.rb "test/functional/**/*_test.rb"}
puts %{USAGE: #{$0} test/unit/my_test.rb "test/functional/**/*_test.rb"} exit(1)
exit(1) end
end
Signal.trap("TERM", "KILL") do
Signal.trap("TERM", "KILL") do puts "Warm Snake says bye bye"
puts "Warm Snake says bye bye" exit(0)
exit(0) end
end
bold_yellow = "\033[1;33m"
bold_yellow = "\033[1;33m" reset = "\033[0m"
reset = "\033[0m"
loop do
loop do env_proc = Process.fork do
env_proc = Process.fork do puts "#{bold_yellow}Booting Environment#{reset}"
puts "#{bold_yellow}Booting Environment#{reset}" start = Time.now
ENV['RAILS_ENV']='test'
require 'config/environment'
require 'test/test_helper'
finish = Time.now
puts "#{bold_yellow}Environment Booted (#{finish-start})#{reset}"
loop do
puts "#{bold_yellow}Running#{reset} [#{@files.inspect}]"
start = Time.now start = Time.now
ENV['RAILS_ENV']='test' Hydra::Master.new(
require 'config/environment' :files => @files.dup,
require 'test/test_helper' :listeners => Hydra::Listener::ProgressBar.new(STDOUT),
:workers => [{:type => :local, :runners => 4}]
)
finish = Time.now finish = Time.now
puts "#{bold_yellow}Environment Booted (#{finish-start})#{reset}" puts "#{bold_yellow}Tests finished#{reset} (#{finish-start})"
loop do puts ""
puts "#{bold_yellow}Running#{reset} [#{@files.inspect}]"
start = Time.now $stdout.write "Press #{bold_yellow}ENTER#{reset} to retest. Type #{bold_yellow}r#{reset} then hit enter to reboot environment. #{bold_yellow}CTRL-C#{reset} to quit\n> "
Hydra::Master.new( begin
:files => @files.dup, command = $stdin.gets
:listeners => Hydra::Listener::ProgressBar.new(STDOUT), rescue Interrupt
:workers => [{:type => :local, :runners => 4}] exit(0)
)
finish = Time.now
puts "#{bold_yellow}Tests finished#{reset} (#{finish-start})"
puts ""
$stdout.write "Press #{bold_yellow}ENTER#{reset} to retest. Type #{bold_yellow}r#{reset} then hit enter to reboot environment. #{bold_yellow}CTRL-C#{reset} to quit\n> "
begin
command = $stdin.gets
rescue Interrupt
exit(0)
end
break if !command.nil? and command.chomp == "r"
end end
break if !command.nil? and command.chomp == "r"
end end
begin end
Process.wait env_proc begin
rescue Interrupt Process.wait env_proc
puts "\n#{bold_yellow}SSsssSsssSSssSs#{reset}" rescue Interrupt
break puts "\n#{bold_yellow}SSsssSsssSSssSs#{reset}"
end break
end end
end end

View File

@ -50,7 +50,6 @@ class RunnerTest < Test::Unit::TestCase
end end
should "run two rspec tests" do should "run two rspec tests" do
puts "First test"
runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w')) runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
runner.run_file(rspec_file) runner.run_file(rspec_file)
assert File.exists?(target_file) assert File.exists?(target_file)
@ -81,8 +80,8 @@ class RunnerTest < Test::Unit::TestCase
# we run this in a fork to not contaminate # we run this in a fork to not contaminate
# the main test environment # the main test environment
pid = Process.fork do pid = Process.fork do
puts "THE FOLLOWING WARNINGS CAN BE IGNORED" # need to get into the fixtures directory so cucumber doesn't load up the whole project
puts "It is caused by Cucumber loading all rb files near its features" Dir.chdir(File.join(File.dirname(__FILE__), 'fixtures'))
runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w')) runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
runner.run_file(cucumber_feature_file) runner.run_file(cucumber_feature_file)
@ -95,8 +94,6 @@ class RunnerTest < Test::Unit::TestCase
assert File.exists?(alternate_target_file) assert File.exists?(alternate_target_file)
assert_equal "HYDRA", File.read(alternate_target_file) assert_equal "HYDRA", File.read(alternate_target_file)
assert !File.exists?(target_file) assert !File.exists?(target_file)
puts "END IGNORABLE OUTPUT"
end end
Process.wait pid Process.wait pid
end end
@ -137,7 +134,6 @@ class RunnerTest < Test::Unit::TestCase
# grab its response. This makes us wait for it to finish # grab its response. This makes us wait for it to finish
response = pipe.gets response = pipe.gets
puts response.output
# tell it to shut down # tell it to shut down
pipe.write(Hydra::Messages::Worker::Shutdown.new) pipe.write(Hydra::Messages::Worker::Shutdown.new)