diff --git a/Gemfile b/Gemfile index 0def5d5..5ae609d 100644 --- a/Gemfile +++ b/Gemfile @@ -2,3 +2,4 @@ source :rubygems gemspec gem 'rake', '0.8.7' +gem 'test-unit', :require => 'test/unit' diff --git a/Gemfile.lock b/Gemfile.lock index 6e23e14..c4fc4a5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/hydra.gemspec b/hydra.gemspec index 2c3b2b7..7e30aaf 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 = [%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, ["= 0.8.7"]) + s.add_runtime_dependency(%q, [">= 0"]) s.add_development_dependency(%q, ["= 2.10.3"]) s.add_development_dependency(%q, ["= 0.9.2"]) s.add_development_dependency(%q, ["= 0.7.4"]) s.add_development_dependency(%q, ["= 2.10.3"]) - s.add_development_dependency(%q, ["= 2.6.4"]) s.add_development_dependency(%q, ["= 0.9.2"]) s.add_development_dependency(%q, ["= 0.7.4"]) s.add_development_dependency(%q, ["= 2.10.3"]) s.add_development_dependency(%q, ["~> 2.6.0"]) - s.add_development_dependency(%q, [">= 2.6.4"]) + s.add_development_dependency(%q, ["= 0.9.2"]) + s.add_development_dependency(%q, ["= 0.7.4"]) + s.add_development_dependency(%q, ["= 2.10.3"]) + s.add_development_dependency(%q, ["~> 2.6.0"]) + s.add_development_dependency(%q, ["= 2.6.4"]) + s.add_development_dependency(%q, ["= 0.9.2"]) + s.add_development_dependency(%q, ["= 0.7.4"]) + s.add_development_dependency(%q, ["= 2.10.3"]) + s.add_development_dependency(%q, ["~> 2.6.0"]) + s.add_development_dependency(%q, ["= 2.6.4"]) + s.add_development_dependency(%q, ["= 0.9.2"]) + s.add_development_dependency(%q, ["= 0.7.4"]) + s.add_development_dependency(%q, ["= 2.10.3"]) + s.add_development_dependency(%q, ["~> 2.6.0"]) + s.add_development_dependency(%q, ["= 2.6.4"]) s.add_development_dependency(%q, ["= 0.9.2"]) s.add_development_dependency(%q, ["= 0.7.4"]) else + s.add_dependency(%q, ["= 0.8.7"]) + s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, ["= 2.10.3"]) s.add_dependency(%q, ["= 0.9.2"]) s.add_dependency(%q, ["= 0.7.4"]) s.add_dependency(%q, ["= 2.10.3"]) - s.add_dependency(%q, ["= 2.6.4"]) s.add_dependency(%q, ["= 0.9.2"]) s.add_dependency(%q, ["= 0.7.4"]) s.add_dependency(%q, ["= 2.10.3"]) s.add_dependency(%q, ["~> 2.6.0"]) - s.add_dependency(%q, [">= 2.6.4"]) + s.add_dependency(%q, ["= 0.9.2"]) + s.add_dependency(%q, ["= 0.7.4"]) + s.add_dependency(%q, ["= 2.10.3"]) + s.add_dependency(%q, ["~> 2.6.0"]) + s.add_dependency(%q, ["= 2.6.4"]) + s.add_dependency(%q, ["= 0.9.2"]) + s.add_dependency(%q, ["= 0.7.4"]) + s.add_dependency(%q, ["= 2.10.3"]) + s.add_dependency(%q, ["~> 2.6.0"]) + s.add_dependency(%q, ["= 2.6.4"]) + s.add_dependency(%q, ["= 0.9.2"]) + s.add_dependency(%q, ["= 0.7.4"]) + s.add_dependency(%q, ["= 2.10.3"]) + s.add_dependency(%q, ["~> 2.6.0"]) + s.add_dependency(%q, ["= 2.6.4"]) s.add_dependency(%q, ["= 0.9.2"]) s.add_dependency(%q, ["= 0.7.4"]) end else + s.add_dependency(%q, ["= 0.8.7"]) + s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, ["= 2.10.3"]) s.add_dependency(%q, ["= 0.9.2"]) s.add_dependency(%q, ["= 0.7.4"]) s.add_dependency(%q, ["= 2.10.3"]) - s.add_dependency(%q, ["= 2.6.4"]) s.add_dependency(%q, ["= 0.9.2"]) s.add_dependency(%q, ["= 0.7.4"]) s.add_dependency(%q, ["= 2.10.3"]) s.add_dependency(%q, ["~> 2.6.0"]) - s.add_dependency(%q, [">= 2.6.4"]) + s.add_dependency(%q, ["= 0.9.2"]) + s.add_dependency(%q, ["= 0.7.4"]) + s.add_dependency(%q, ["= 2.10.3"]) + s.add_dependency(%q, ["~> 2.6.0"]) + s.add_dependency(%q, ["= 2.6.4"]) + s.add_dependency(%q, ["= 0.9.2"]) + s.add_dependency(%q, ["= 0.7.4"]) + s.add_dependency(%q, ["= 2.10.3"]) + s.add_dependency(%q, ["~> 2.6.0"]) + s.add_dependency(%q, ["= 2.6.4"]) + s.add_dependency(%q, ["= 0.9.2"]) + s.add_dependency(%q, ["= 0.7.4"]) + s.add_dependency(%q, ["= 2.10.3"]) + s.add_dependency(%q, ["~> 2.6.0"]) + s.add_dependency(%q, ["= 2.6.4"]) s.add_dependency(%q, ["= 0.9.2"]) s.add_dependency(%q, ["= 0.7.4"]) end diff --git a/lib/hydra/master.rb b/lib/hydra/master.rb index ddb844a..b1525b8 100644 --- a/lib/hydra/master.rb +++ b/lib/hydra/master.rb @@ -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| diff --git a/lib/hydra/runner.rb b/lib/hydra/runner.rb index 5b19db6..d3dc282 100644 --- a/lib/hydra/runner.rb +++ b/lib/hydra/runner.rb @@ -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 diff --git a/lib/hydra/ssh.rb b/lib/hydra/ssh.rb index 01f3b91..6c93574 100644 --- a/lib/hydra/ssh.rb +++ b/lib/hydra/ssh.rb @@ -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 diff --git a/lib/hydra/sync.rb b/lib/hydra/sync.rb index 4f5f8d7..c7bace4 100644 --- a/lib/hydra/sync.rb +++ b/lib/hydra/sync.rb @@ -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! diff --git a/results/features/write_alternate_file.feature.html b/results/features/write_alternate_file.feature.html new file mode 100644 index 0000000..985dad7 --- /dev/null +++ b/results/features/write_alternate_file.feature.html @@ -0,0 +1 @@ +

Feature: Write a file

Scenario: Write to hydra_test.txt

  1. Given an alternate target file
    test/fixtures/features/step_definitions.rb:5
  2. When I write "HYDRA" to the file
    test/fixtures/features/step_definitions.rb:9
  3. Then "HYDRA" should be written in the file
    test/fixtures/features/step_definitions.rb:16
\ No newline at end of file diff --git a/results/features/write_file.feature.html b/results/features/write_file.feature.html new file mode 100644 index 0000000..ef9a638 --- /dev/null +++ b/results/features/write_file.feature.html @@ -0,0 +1 @@ +

Feature: Write a file

Scenario: Write to hydra_test.txt

  1. Given a target file
    test/fixtures/features/step_definitions.rb:1
  2. When I write "HYDRA" to the file
    test/fixtures/features/step_definitions.rb:9
  3. Then "HYDRA" should be written in the file
    test/fixtures/features/step_definitions.rb:16
\ No newline at end of file diff --git a/test/fixtures/sync_test.rb b/test/fixtures/sync_test.rb index 13e00a5..6201a34 100644 --- a/test/fixtures/sync_test.rb +++ b/test/fixtures/sync_test.rb @@ -1,3 +1,5 @@ +require 'rubygems' +gem 'test-unit' require 'test/unit' class SyncTest < Test::Unit::TestCase diff --git a/test/fixtures/write_file_with_pending_spec.rb b/test/fixtures/write_file_with_pending_spec.rb index 10f30af..a46504e 100644 --- a/test/fixtures/write_file_with_pending_spec.rb +++ b/test/fixtures/write_file_with_pending_spec.rb @@ -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" diff --git a/test/master_test.rb b/test/master_test.rb index bfc3ac8..236fbac 100644 --- a/test/master_test.rb +++ b/test/master_test.rb @@ -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 diff --git a/test/runner_test.rb b/test/runner_test.rb index f4e8157..6301be2 100644 --- a/test/runner_test.rb +++ b/test/runner_test.rb @@ -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 diff --git a/test/test_helper.rb b/test/test_helper.rb index ca08375..e7d1103 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,4 +1,5 @@ require 'rubygems' +gem 'test-unit' require 'test/unit' require 'shoulda' require 'tmpdir'