more work on tests
This commit is contained in:
parent
c88f16b7a2
commit
265cb5021a
1
Gemfile
1
Gemfile
|
@ -2,3 +2,4 @@ source :rubygems
|
|||
|
||||
gemspec
|
||||
gem 'rake', '0.8.7'
|
||||
gem 'test-unit', :require => 'test/unit'
|
||||
|
|
|
@ -2,7 +2,8 @@ PATH
|
|||
remote: .
|
||||
specs:
|
||||
hydra (0.23.3)
|
||||
hydra
|
||||
rake (= 0.8.7)
|
||||
test-unit
|
||||
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
|
@ -30,6 +31,7 @@ GEM
|
|||
rspec-mocks (2.6.0)
|
||||
shoulda (2.10.3)
|
||||
term-ansicolor (1.0.6)
|
||||
test-unit (2.3.2)
|
||||
therubyracer (0.7.4)
|
||||
|
||||
PLATFORMS
|
||||
|
@ -40,6 +42,7 @@ DEPENDENCIES
|
|||
hydra!
|
||||
rake (= 0.8.7)
|
||||
rspec (~> 2.6.0)
|
||||
rspec-core (>= 2.6.4)
|
||||
rspec-core (= 2.6.4)
|
||||
shoulda (= 2.10.3)
|
||||
test-unit
|
||||
therubyracer (= 0.7.4)
|
||||
|
|
|
@ -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 = [%q{Nick Gauthier}]
|
||||
s.date = %q{2011-08-23}
|
||||
s.date = %q{2011-08-31}
|
||||
s.description = %q{Spread your tests over multiple machines to test your code faster.}
|
||||
s.email = %q{nick@smartlogicsolutions.com}
|
||||
s.extra_rdoc_files = [
|
||||
|
@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|||
"hydra.gemspec",
|
||||
"hydra_gray.png",
|
||||
"lib/hydra.rb",
|
||||
"lib/hydra/config.rb",
|
||||
"lib/hydra/cucumber/formatter.rb",
|
||||
"lib/hydra/cucumber/partial_html.rb",
|
||||
"lib/hydra/hash.rb",
|
||||
|
@ -94,50 +95,95 @@ Gem::Specification.new do |s|
|
|||
]
|
||||
s.homepage = %q{http://github.com/ngauthier/hydra}
|
||||
s.require_paths = [%q{lib}]
|
||||
s.rubygems_version = %q{1.8.6}
|
||||
s.rubygems_version = %q{1.8.9}
|
||||
s.summary = %q{Distributed testing toolkit}
|
||||
|
||||
if s.respond_to? :specification_version then
|
||||
s.specification_version = 3
|
||||
|
||||
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
||||
s.add_runtime_dependency(%q<rake>, ["= 0.8.7"])
|
||||
s.add_runtime_dependency(%q<test-unit>, [">= 0"])
|
||||
s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_development_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_development_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_development_dependency(%q<rspec>, ["= 2.6.4"])
|
||||
s.add_development_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_development_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
|
||||
s.add_development_dependency(%q<rspec-core>, [">= 2.6.4"])
|
||||
s.add_development_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_development_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
|
||||
s.add_development_dependency(%q<rspec-core>, ["= 2.6.4"])
|
||||
s.add_development_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_development_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
|
||||
s.add_development_dependency(%q<rspec-core>, ["= 2.6.4"])
|
||||
s.add_development_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_development_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
|
||||
s.add_development_dependency(%q<rspec-core>, ["= 2.6.4"])
|
||||
s.add_development_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_development_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
else
|
||||
s.add_dependency(%q<rake>, ["= 0.8.7"])
|
||||
s.add_dependency(%q<test-unit>, [">= 0"])
|
||||
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_dependency(%q<rspec>, ["= 2.6.4"])
|
||||
s.add_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_dependency(%q<rspec>, ["~> 2.6.0"])
|
||||
s.add_dependency(%q<rspec-core>, [">= 2.6.4"])
|
||||
s.add_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_dependency(%q<rspec>, ["~> 2.6.0"])
|
||||
s.add_dependency(%q<rspec-core>, ["= 2.6.4"])
|
||||
s.add_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_dependency(%q<rspec>, ["~> 2.6.0"])
|
||||
s.add_dependency(%q<rspec-core>, ["= 2.6.4"])
|
||||
s.add_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_dependency(%q<rspec>, ["~> 2.6.0"])
|
||||
s.add_dependency(%q<rspec-core>, ["= 2.6.4"])
|
||||
s.add_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
end
|
||||
else
|
||||
s.add_dependency(%q<rake>, ["= 0.8.7"])
|
||||
s.add_dependency(%q<test-unit>, [">= 0"])
|
||||
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_dependency(%q<rspec>, ["= 2.6.4"])
|
||||
s.add_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_dependency(%q<rspec>, ["~> 2.6.0"])
|
||||
s.add_dependency(%q<rspec-core>, [">= 2.6.4"])
|
||||
s.add_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_dependency(%q<rspec>, ["~> 2.6.0"])
|
||||
s.add_dependency(%q<rspec-core>, ["= 2.6.4"])
|
||||
s.add_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_dependency(%q<rspec>, ["~> 2.6.0"])
|
||||
s.add_dependency(%q<rspec-core>, ["= 2.6.4"])
|
||||
s.add_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
|
||||
s.add_dependency(%q<rspec>, ["~> 2.6.0"])
|
||||
s.add_dependency(%q<rspec-core>, ["= 2.6.4"])
|
||||
s.add_dependency(%q<cucumber>, ["= 0.9.2"])
|
||||
s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
|
||||
end
|
||||
|
|
|
@ -167,7 +167,7 @@ module Hydra #:nodoc:
|
|||
if sync.result == 0
|
||||
runners = worker.fetch('runners') { raise "You must specify the number of runners" }
|
||||
command = worker.fetch('command') {
|
||||
"RAILS_ENV=#{@environment} #{bundler? ? "bundle exec" : ""} ruby -e \"require 'hydra'; Hydra::Worker.new(:io => Hydra::Stdio.new, :runners => #{runners}, :verbose => #{@verbose}, :runner_listeners => \'#{@string_runner_event_listeners}\', :runner_log_file => \'#{@runner_log_file}\', :options => {} );\""
|
||||
%{RAILS_ENV=#{@environment} ruby -rrubygems -e "require \\"bundler/setup\\"; require \\"hydra\\"; Hydra::Worker.new(:io => Hydra::Stdio.new, :runners => #{runners}, :verbose => #{@verbose}, :runner_listeners => \\"#{@string_runner_event_listeners}\\", :runner_log_file => \\"#{@runner_log_file}\\", :options => {} );"}
|
||||
}
|
||||
|
||||
trace "Booting SSH worker"
|
||||
|
@ -179,10 +179,6 @@ module Hydra #:nodoc:
|
|||
end
|
||||
end
|
||||
|
||||
def bundler?
|
||||
File.file?('Gemfile')
|
||||
end
|
||||
|
||||
def shutdown_all_workers
|
||||
trace "Shutting down all workers"
|
||||
@workers.each do |worker|
|
||||
|
|
|
@ -116,6 +116,7 @@ module Hydra #:nodoc:
|
|||
# Run all the Test::Unit Suites in a ruby file
|
||||
def run_test_unit_file(file)
|
||||
begin
|
||||
gem 'test-unit'
|
||||
require 'test/unit'
|
||||
require 'test/unit/testresult'
|
||||
Test::Unit.run = true
|
||||
|
|
|
@ -26,10 +26,7 @@ module Hydra #:nodoc:
|
|||
# To connect to server.com as user on port 3022, then CD to their desktop, then
|
||||
# list all the files.
|
||||
def initialize(connection_options, directory, command)
|
||||
@writer, @reader, @error = popen3("ssh -tt #{connection_options}")
|
||||
@writer.write("mkdir -p #{directory}\n")
|
||||
@writer.write("cd #{directory}\n")
|
||||
@writer.write(command+"\n")
|
||||
@writer, @reader, @error = popen3(%{ssh -tt #{connection_options} 'mkdir -p #{directory} && cd #{directory} && #{command}'})
|
||||
end
|
||||
|
||||
# Close the SSH connection
|
||||
|
|
|
@ -28,6 +28,7 @@ module Hydra #:nodoc:
|
|||
@connect = worker_opts.fetch('connect') { raise "You must specify an SSH connection target" }
|
||||
@ssh_opts = worker_opts.fetch('ssh_opts') { "" }
|
||||
@remote_dir = worker_opts.fetch('directory') { raise "You must specify a remote directory" }
|
||||
@result = 0
|
||||
|
||||
return unless sync_opts
|
||||
sync_opts.stringify_keys!
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<div class="feature"><h2><span class="val">Feature: Write a file</span></h2><p class="narrative"></p><div class='scenario'><h3 id="scenario_1"><span class="keyword">Scenario:</span> <span class="val">Write to hydra_test.txt</span></h3><ol><li id='_Users_john_Projects_hydra_test_fixtures_features_write_alternate_file_feature_4' class='step passed'><div class="step_name"><span class="keyword">Given </span><span class="step val">an alternate target file</span></div><div class="step_file"><span>test/fixtures/features/step_definitions.rb:5</span></div></li><li id='_Users_john_Projects_hydra_test_fixtures_features_write_alternate_file_feature_5' class='step passed'><div class="step_name"><span class="keyword">When </span><span class="step val">I write "<span class="param">HYDRA</span>" to the file</span></div><div class="step_file"><span>test/fixtures/features/step_definitions.rb:9</span></div></li><li id='_Users_john_Projects_hydra_test_fixtures_features_write_alternate_file_feature_6' class='step passed'><div class="step_name"><span class="keyword">Then </span><span class="step val">"<span class="param">HYDRA</span>" should be written in the file</span></div><div class="step_file"><span>test/fixtures/features/step_definitions.rb:16</span></div></li></ol></div></div>
|
|
@ -0,0 +1 @@
|
|||
<div class="feature"><h2><span class="val">Feature: Write a file</span></h2><p class="narrative"></p><div class='scenario'><h3 id="scenario_1"><span class="keyword">Scenario:</span> <span class="val">Write to hydra_test.txt</span></h3><ol><li id='_Users_john_Projects_hydra_test_fixtures_features_write_file_feature_4' class='step passed'><div class="step_name"><span class="keyword">Given </span><span class="step val">a target file</span></div><div class="step_file"><span>test/fixtures/features/step_definitions.rb:1</span></div></li><li id='_Users_john_Projects_hydra_test_fixtures_features_write_file_feature_5' class='step passed'><div class="step_name"><span class="keyword">When </span><span class="step val">I write "<span class="param">HYDRA</span>" to the file</span></div><div class="step_file"><span>test/fixtures/features/step_definitions.rb:9</span></div></li><li id='_Users_john_Projects_hydra_test_fixtures_features_write_file_feature_6' class='step passed'><div class="step_name"><span class="keyword">Then </span><span class="step val">"<span class="param">HYDRA</span>" should be written in the file</span></div><div class="step_file"><span>test/fixtures/features/step_definitions.rb:16</span></div></li></ol></div></div>
|
|
@ -1,3 +1,5 @@
|
|||
require 'rubygems'
|
||||
gem 'test-unit'
|
||||
require 'test/unit'
|
||||
|
||||
class SyncTest < Test::Unit::TestCase
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require 'tmpdir'
|
||||
require 'rspec'
|
||||
context "file writing" do
|
||||
|
||||
describe "file writing" do
|
||||
it "writes to a file" do
|
||||
File.open(File.join(Dir.consistent_tmpdir, 'hydra_test.txt'), 'a') do |f|
|
||||
f.write "HYDRA"
|
||||
|
|
|
@ -165,6 +165,7 @@ class MasterTest < Test::Unit::TestCase
|
|||
:type => :ssh,
|
||||
:connect => 'localhost',
|
||||
:directory => remote,
|
||||
:verbose => true,
|
||||
:runners => 1
|
||||
}],
|
||||
:sync => {
|
||||
|
@ -336,7 +337,7 @@ class MasterTest < Test::Unit::TestCase
|
|||
:runners => 1
|
||||
}],
|
||||
:verbose => false,
|
||||
:runner_log_file => 'invalid-dir/#{runner_log_file}'
|
||||
:runner_log_file => "invalid-dir/#{runner_log_file}"
|
||||
)
|
||||
end
|
||||
Process.waitpid @pid
|
||||
|
|
|
@ -39,19 +39,19 @@ class RunnerTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should "run a js lint file and find errors" do
|
||||
runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
|
||||
runner = Hydra::Runner.new(:options => {}, :io => File.new('/dev/null', 'w'))
|
||||
results = runner.run_file(javascript_file)
|
||||
assert results =~ /Missing semicolon/, results
|
||||
end
|
||||
|
||||
should "run a json data file and find errors" do
|
||||
runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
|
||||
runner = Hydra::Runner.new(:options => {}, :io => File.new('/dev/null', 'w'))
|
||||
results = runner.run_file(json_file)
|
||||
assert results =~ /trailing comma/, results
|
||||
end
|
||||
|
||||
should "run two rspec tests" do
|
||||
runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
|
||||
runner = Hydra::Runner.new(:options => {}, :io => File.new('/dev/null', 'w'))
|
||||
runner.run_file(rspec_file)
|
||||
assert File.exists?(target_file)
|
||||
assert_equal "HYDRA", File.read(target_file)
|
||||
|
@ -65,7 +65,7 @@ class RunnerTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should "run rspec tests with pending examples" do
|
||||
runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
|
||||
runner = Hydra::Runner.new(:options => {}, :io => File.new('/dev/null', 'w'))
|
||||
assert File.exists?(rspec_file_with_pending)
|
||||
|
||||
runner.run_file(rspec_file_with_pending)
|
||||
|
@ -82,7 +82,7 @@ class RunnerTest < Test::Unit::TestCase
|
|||
# the main test environment
|
||||
capture_stderr do # redirect stderr
|
||||
pid = Process.fork do
|
||||
runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
|
||||
runner = Hydra::Runner.new(:options => {}, :io => File.new('/dev/null', 'w'))
|
||||
runner.run_file(cucumber_feature_file)
|
||||
assert File.exists?(target_file)
|
||||
assert_equal "HYDRA", File.read(target_file)
|
||||
|
@ -102,7 +102,7 @@ class RunnerTest < Test::Unit::TestCase
|
|||
ssh = Hydra::SSH.new(
|
||||
'localhost',
|
||||
File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')),
|
||||
"ruby -e \"require 'rubygems'; require 'hydra'; Hydra::Runner.new(:io => Hydra::Stdio.new, :verbose => true);\""
|
||||
%{ruby -rrubygems -e "require \\"bundler/setup\\"; require \\"hydra\\"; Hydra::Runner.new(:options => {}, :io => Hydra::Stdio.new, :verbose => true);"}
|
||||
)
|
||||
assert ssh.gets.is_a?(Hydra::Messages::Runner::RequestFile)
|
||||
ssh.write(Hydra::Messages::Worker::RunFile.new(:file => test_file))
|
||||
|
@ -188,7 +188,7 @@ class RunnerTest < Test::Unit::TestCase
|
|||
|
||||
def run_the_runner(pipe, listeners = [])
|
||||
pipe.identify_as_child
|
||||
Hydra::Runner.new( :io => pipe, :runner_listeners => listeners )
|
||||
Hydra::Runner.new( :io => pipe, :options => {}, :runner_listeners => listeners )
|
||||
end
|
||||
end
|
||||
include RunnerTestHelper
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require 'rubygems'
|
||||
gem 'test-unit'
|
||||
require 'test/unit'
|
||||
require 'shoulda'
|
||||
require 'tmpdir'
|
||||
|
|
Loading…
Reference in New Issue