almost done with rspec integration. rspec is still running its at_exit

This commit is contained in:
Nick Gauthier 2010-04-03 21:43:35 -04:00
parent 55fb81f5de
commit b831522a47
6 changed files with 32 additions and 12 deletions

View File

@ -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-03-31}
s.date = %q{2010-04-03}
s.description = %q{Spread your tests over multiple machines to test your code faster.}
s.email = %q{nick@smartlogicsolutions.com}
s.extra_rdoc_files = [
@ -46,6 +46,7 @@ Gem::Specification.new do |s|
"lib/hydra/pipe.rb",
"lib/hydra/runner.rb",
"lib/hydra/safe_fork.rb",
"lib/hydra/spec/hydra_formatter.rb",
"lib/hydra/ssh.rb",
"lib/hydra/stdio.rb",
"lib/hydra/tasks.rb",
@ -60,6 +61,8 @@ Gem::Specification.new do |s|
"test/fixtures/slow.rb",
"test/fixtures/sync_test.rb",
"test/fixtures/write_file.rb",
"test/fixtures/write_file_alternate_spec.rb",
"test/fixtures/write_file_spec.rb",
"test/master_test.rb",
"test/message_test.rb",
"test/pipe_test.rb",
@ -71,22 +74,24 @@ Gem::Specification.new do |s|
s.homepage = %q{http://github.com/ngauthier/hydra}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.5}
s.rubygems_version = %q{1.3.6}
s.summary = %q{Distributed testing toolkit}
s.test_files = [
"test/message_test.rb",
"test/pipe_test.rb",
"test/test_helper.rb",
"test/ssh_test.rb",
"test/message_test.rb",
"test/master_test.rb",
"test/fixtures/write_file.rb",
"test/fixtures/slow.rb",
"test/fixtures/write_file_spec.rb",
"test/fixtures/features/step_definitions.rb",
"test/fixtures/hello_world.rb",
"test/fixtures/write_file_alternate_spec.rb",
"test/fixtures/sync_test.rb",
"test/fixtures/assert_true.rb",
"test/fixtures/hello_world.rb",
"test/fixtures/features/step_definitions.rb",
"test/master_test.rb",
"test/worker_test.rb",
"test/runner_test.rb",
"test/pipe_test.rb"
"test/worker_test.rb"
]
if s.respond_to? :specification_version then

View File

@ -37,6 +37,9 @@ module Hydra #:nodoc:
class RSpecResult < Hydra::Message
# the output of the spec
attr_accessor :output
def serialize #:nodoc:
super(:output => @output)
end
end
end
end

View File

@ -103,9 +103,10 @@ 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/autorun'
require 'spec'
require 'hydra/spec/hydra_formatter'
rescue LoadError => ex
return ex.to_s
@ -121,17 +122,18 @@ module Hydra #:nodoc:
hydra_output = StringIO.new
options.formatters = [Spec::Runner::Formatter::HydraFormatter.new(options.formatter_options, hydra_output)]
require file
options.files = [file]
options.run_examples
hydra_output.rewind
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 = pipe.gets
output_message = pipe.gets
Process.wait pid
return output
return output_message.output
end
# run all the scenarios in a cucumber feature file

View File

@ -7,7 +7,11 @@ class SafeFork
child = Process.fork do
begin
# create a new connection and perform the action
begin
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
rescue ActiveRecord::AdapterNotSpecified
# AR was defined but we didn't have a connection
end
yield
ensure
# make sure we remove the connection before we're done
@ -16,7 +20,11 @@ class SafeFork
end
ensure
# make sure we re-establish the connection before returning to the main instance
begin
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
rescue ActiveRecord::AdapterNotSpecified
# AR was defined but we didn't have a connection
end
end
return child
end

View File

@ -4,6 +4,7 @@ module Spec
module Runner
class Options
attr_accessor :formatters
attr_accessor :files
end
module Formatter
class HydraFormatter < ProgressBarFormatter

View File

@ -95,6 +95,7 @@ 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