sskirby-hydra 0.21.0 → 0.23.3

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Nick Gauthier
1
+ Copyright (c) 2009-2010 Nick Gauthier
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -9,10 +9,10 @@ begin
9
9
  gem.description = %Q{Spread your tests over multiple machines to test your code faster.}
10
10
  gem.email = "nick@smartlogicsolutions.com"
11
11
  gem.homepage = "http://github.com/ngauthier/hydra"
12
- gem.authors = ["Nick Gauthier"]
12
+ gem.authors = ["Nick Gauthier", "Sean Kirby", "Arturo Pie"]
13
13
  gem.add_development_dependency "shoulda", "= 2.10.3"
14
14
  gem.add_development_dependency "rspec", "= 2.0.0.beta.19"
15
- gem.add_development_dependency "cucumber", "= 0.8.5"
15
+ gem.add_development_dependency "cucumber", "= 0.9.2"
16
16
  gem.add_development_dependency "therubyracer", "= 0.7.4"
17
17
  end
18
18
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.21.0
1
+ 0.23.3
data/lib/hydra/master.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'hydra/hash'
2
2
  require 'open3'
3
- require 'tmpdir'
3
+ require 'hydra/tmpdir'
4
4
  require 'erb'
5
5
  require 'yaml'
6
6
 
@@ -14,6 +14,7 @@ module Hydra #:nodoc:
14
14
  include Hydra::Messages::Master
15
15
  include Open3
16
16
  traceable('MASTER')
17
+ attr_reader :failed_files
17
18
 
18
19
  # Create a new Master
19
20
  #
@@ -54,6 +55,7 @@ module Hydra #:nodoc:
54
55
  @files = Array(opts.fetch('files') { nil })
55
56
  raise "No files, nothing to do" if @files.empty?
56
57
  @incomplete_files = @files.dup
58
+ @failed_files = []
57
59
  @workers = []
58
60
  @listeners = []
59
61
  @event_listeners = Array(opts.fetch('listeners') { nil } )
@@ -66,7 +68,6 @@ module Hydra #:nodoc:
66
68
  @autosort = opts.fetch('autosort') { true }
67
69
  @sync = opts.fetch('sync') { nil }
68
70
  @environment = opts.fetch('environment') { 'test' }
69
- @remote_require = opts.fetch('remote_require') {[]}
70
71
 
71
72
  if @autosort
72
73
  sort_files_from_report
@@ -117,6 +118,9 @@ module Hydra #:nodoc:
117
118
  @incomplete_files.delete_at(@incomplete_files.index(message.file))
118
119
  trace "#{@incomplete_files.size} Files Remaining"
119
120
  @event_listeners.each{|l| l.file_end(message.file, message.output) }
121
+ unless message.output == '.'
122
+ @failed_files << message.file
123
+ end
120
124
  if @incomplete_files.empty?
121
125
  @workers.each do |worker|
122
126
  @event_listeners.each{|l| l.worker_end(worker) }
@@ -166,11 +170,9 @@ module Hydra #:nodoc:
166
170
  def boot_ssh_worker(worker)
167
171
  sync = Sync.new(worker, @sync, @verbose)
168
172
 
169
- custom_require = @remote_require.map {|r| " require '#{r}';"}.join(' ')
170
-
171
173
  runners = worker.fetch('runners') { raise "You must specify the number of runners" }
172
174
  command = worker.fetch('command') {
173
- "RAILS_ENV=#{@environment} ruby -e \"require 'rubygems'; require 'hydra';#{custom_require} Hydra::Worker.new(:io => Hydra::Stdio.new, :runners => #{runners}, :verbose => #{@verbose}, :remote => '#{sync.connect}');\""
175
+ "RAILS_ENV=#{@environment} ruby -e \"require 'rubygems'; require 'hydra'; Hydra::Worker.new(:io => Hydra::Stdio.new, :runners => #{runners}, :verbose => #{@verbose});\""
174
176
  }
175
177
 
176
178
  trace "Booting SSH worker"
@@ -235,7 +237,7 @@ module Hydra #:nodoc:
235
237
  end
236
238
 
237
239
  def heuristic_file
238
- @heuristic_file ||= File.join(Dir.tmpdir, 'hydra_heuristics.yml')
240
+ @heuristic_file ||= File.join(Dir.consistent_tmpdir, 'hydra_heuristics.yml')
239
241
  end
240
242
  end
241
243
  end
@@ -8,15 +8,17 @@ module Hydra #:nodoc:
8
8
  # IO.gets
9
9
  # => Hydra::Message # or subclass
10
10
  def gets
11
- raise IOError unless @reader
12
- message = @reader.gets
13
- return nil unless message
14
- puts message if message.include?(Hydra::Trace::REMOTE_IDENTIFIER)
15
- return Message.build(eval(message.chomp))
16
- rescue SyntaxError, NameError
17
- # uncomment to help catch remote errors by seeing all traffic
18
- #$stderr.write "Not a message: [#{message.inspect}]\n"
19
- return gets
11
+ while true
12
+ begin
13
+ raise IOError unless @reader
14
+ message = @reader.gets
15
+ return nil unless message
16
+ return Message.build(eval(message.chomp))
17
+ rescue SyntaxError, NameError
18
+ # uncomment to help catch remote errors by seeing all traffic
19
+ #$stderr.write "Not a message: [#{message.inspect}]\n"
20
+ end
21
+ end
20
22
  end
21
23
 
22
24
  # Write a Message to the output IO object. It will automatically
data/lib/hydra/runner.rb CHANGED
@@ -18,7 +18,6 @@ module Hydra #:nodoc:
18
18
  def initialize(opts = {})
19
19
  @io = opts.fetch(:io) { raise "No IO Object" }
20
20
  @verbose = opts.fetch(:verbose) { false }
21
- @remote = opts.fetch(:remote) { false }
22
21
  $stdout.sync = true
23
22
  trace 'Booted. Sending Request for file'
24
23
 
@@ -57,14 +56,6 @@ module Hydra #:nodoc:
57
56
  @running = false
58
57
  end
59
58
 
60
- def format_ex_in_file(file, ex)
61
- "Error in #{file}:\n #{format_exception(ex)}"
62
- end
63
-
64
- def format_exception(ex)
65
- "#{ex.class.name}: #{ex.message}\n #{ex.backtrace.join("\n ")}"
66
- end
67
-
68
59
  private
69
60
 
70
61
  # The runner will continually read messages and handle them.
@@ -88,6 +79,14 @@ module Hydra #:nodoc:
88
79
  end
89
80
  end
90
81
 
82
+ def format_ex_in_file(file, ex)
83
+ "Error in #{file}:\n #{format_exception(ex)}"
84
+ end
85
+
86
+ def format_exception(ex)
87
+ "#{ex.class.name}: #{ex.message}\n #{ex.backtrace.join("\n ")}"
88
+ end
89
+
91
90
  # Run all the Test::Unit Suites in a ruby file
92
91
  def run_test_unit_file(file)
93
92
  begin
@@ -122,7 +121,7 @@ module Hydra #:nodoc:
122
121
  require 'rspec'
123
122
  require 'hydra/spec/hydra_formatter'
124
123
  # Ensure we override rspec's at_exit
125
- require 'hydra/spec/autorun_override'
124
+ RSpec::Core::Runner.disable_autorun!
126
125
  rescue LoadError => ex
127
126
  return ex.to_s
128
127
  end
@@ -150,29 +149,35 @@ module Hydra #:nodoc:
150
149
  dev_null = StringIO.new
151
150
  hydra_response = StringIO.new
152
151
 
153
- unless @step_mother
152
+ unless @cuke_runtime
154
153
  require 'cucumber'
155
154
  require 'hydra/cucumber/formatter'
156
- @step_mother = Cucumber::StepMother.new
155
+ Cucumber.logger.level = Logger::INFO
156
+ @cuke_runtime = Cucumber::Runtime.new
157
157
  @cuke_configuration = Cucumber::Cli::Configuration.new(dev_null, dev_null)
158
158
  @cuke_configuration.parse!(['features']+files)
159
159
 
160
- @step_mother.options = @cuke_configuration.options
161
- @step_mother.log = @cuke_configuration.log
162
- @step_mother.load_code_files(@cuke_configuration.support_to_load)
163
- @step_mother.after_configuration(@cuke_configuration)
164
- @step_mother.load_code_files(@cuke_configuration.step_defs_to_load)
160
+ support_code = Cucumber::Runtime::SupportCode.new(@cuke_runtime, @cuke_configuration.guess?)
161
+ support_code.load_files!(@cuke_configuration.support_to_load + @cuke_configuration.step_defs_to_load)
162
+ support_code.fire_hook(:after_configuration, @cuke_configuration)
163
+ # i don't like this, but there no access to set the instance of SupportCode in Runtime
164
+ @cuke_runtime.instance_variable_set('@support_code',support_code)
165
165
  end
166
166
  cuke_formatter = Cucumber::Formatter::Hydra.new(
167
- @step_mother, hydra_response, @cuke_configuration.options
167
+ @cuke_runtime, hydra_response, @cuke_configuration.options
168
168
  )
169
169
 
170
170
  cuke_runner ||= Cucumber::Ast::TreeWalker.new(
171
- @step_mother, [cuke_formatter], @cuke_configuration.options, dev_null
171
+ @cuke_runtime, [cuke_formatter], @cuke_configuration
172
172
  )
173
- @step_mother.visitor = cuke_runner
173
+ @cuke_runtime.visitor = cuke_runner
174
174
 
175
- features = @step_mother.load_plain_text_features(files)
175
+ loader = Cucumber::Runtime::FeaturesLoader.new(
176
+ files,
177
+ @cuke_configuration.filters,
178
+ @cuke_configuration.tag_expression
179
+ )
180
+ features = loader.features
176
181
  tag_excess = tag_excess(features, @cuke_configuration.options[:tag_expression].limits)
177
182
  @cuke_configuration.options[:tag_excess] = tag_excess
178
183
 
data/lib/hydra/tasks.rb CHANGED
@@ -36,10 +36,7 @@ module Hydra #:nodoc:
36
36
  # files that may not play nice with others.
37
37
  attr_accessor :serial
38
38
 
39
- # When running remote workers with extensions to hydra (such as
40
- # custom messages), you will need to make those extensions
41
- # available to the remote workers by specifying them here.
42
- attr_accessor :remote_require
39
+ attr_accessor :environment
43
40
 
44
41
  #
45
42
  # Search for the hydra config file
@@ -69,7 +66,6 @@ module Hydra #:nodoc:
69
66
  # t.add_files 'test/integration/**/*_test.rb'
70
67
  # t.verbose = false # optionally set to true for lots of debug messages
71
68
  # t.autosort = false # disable automatic sorting based on runtime of tests
72
- # t.remote_require << 'hydra_extensions'
73
69
  # end
74
70
  class TestTask < Hydra::Task
75
71
 
@@ -81,12 +77,13 @@ module Hydra #:nodoc:
81
77
  @autosort = true
82
78
  @serial = false
83
79
  @listeners = [Hydra::Listener::ProgressBar.new]
84
- @remote_require = []
85
80
 
86
81
  yield self if block_given?
87
82
 
88
83
  # Ensure we override rspec's at_exit
89
- require 'hydra/spec/autorun_override'
84
+ if defined?(RSpec)
85
+ RSpec::Core::Runner.disable_autorun!
86
+ end
90
87
 
91
88
  unless @serial
92
89
  @config = find_config_file
@@ -97,7 +94,7 @@ module Hydra #:nodoc:
97
94
  :autosort => @autosort,
98
95
  :files => @files,
99
96
  :listeners => @listeners,
100
- :remote_require => @remote_require
97
+ :environment => @environment
101
98
  }
102
99
  if @config
103
100
  @opts.merge!(:config => @config)
@@ -113,11 +110,14 @@ module Hydra #:nodoc:
113
110
  def define
114
111
  desc "Hydra Tests" + (@name == :hydra ? "" : " for #{@name}")
115
112
  task @name do
116
- if Object.const_defined?('RAILS_ENV') && RAILS_ENV == 'development'
117
- $stderr.puts %{WARNING: RAILS_ENV is "development". Make sure to set it properly (ex: "RAILS_ENV=test rake hydra")}
113
+ if Object.const_defined?('Rails') && Rails.env == 'development'
114
+ $stderr.puts %{WARNING: Rails Environment is "development". Make sure to set it properly (ex: "RAILS_ENV=test rake hydra")}
118
115
  end
119
116
 
120
- Hydra::Master.new(@opts)
117
+ master = Hydra::Master.new(@opts)
118
+ unless master.failed_files.empty?
119
+ raise "Hydra: Not all tests passes"
120
+ end
121
121
  end
122
122
  end
123
123
  end
@@ -243,8 +243,9 @@ module Hydra #:nodoc:
243
243
  include Open3
244
244
  # Create a new hydra remote task with the given name.
245
245
  # The task will be named hydra:remote:<name>
246
- def initialize(name)
246
+ def initialize(name, command=nil)
247
247
  @name = name
248
+ @command = command
248
249
  yield self if block_given?
249
250
  @config = find_config_file
250
251
  if @config
@@ -262,6 +263,7 @@ module Hydra #:nodoc:
262
263
  environment = config.fetch('environment') { 'test' }
263
264
  workers = config.fetch('workers') { [] }
264
265
  workers = workers.select{|w| w['type'] == 'ssh'}
266
+ @command = "RAILS_ENV=#{environment} rake #{@name}" unless @command
265
267
 
266
268
  $stdout.write "==== Hydra Running #{@name} ====\n"
267
269
  Thread.abort_on_exception = true
@@ -270,7 +272,7 @@ module Hydra #:nodoc:
270
272
  workers.each do |worker|
271
273
  @listeners << Thread.new do
272
274
  begin
273
- @results[worker] = if run_task(worker, environment)
275
+ @results[worker] = if run_command(worker, @command)
274
276
  "==== #{@name} passed on #{worker['connect']} ====\n"
275
277
  else
276
278
  "==== #{@name} failed on #{worker['connect']} ====\nPlease see above for more details.\n"
@@ -286,13 +288,13 @@ module Hydra #:nodoc:
286
288
  end
287
289
  end
288
290
 
289
- def run_task worker, environment
291
+ def run_command worker, command
290
292
  $stdout.write "==== Hydra Running #{@name} on #{worker['connect']} ====\n"
291
293
  ssh_opts = worker.fetch('ssh_opts') { '' }
292
294
  writer, reader, error = popen3("ssh -tt #{ssh_opts} #{worker['connect']} ")
293
295
  writer.write("cd #{worker['directory']}\n")
294
296
  writer.write "echo BEGIN HYDRA\n"
295
- writer.write("RAILS_ENV=#{environment} rake #{@name}\n")
297
+ writer.write(command + "\r")
296
298
  writer.write "echo END HYDRA\n"
297
299
  writer.write("exit\n")
298
300
  writer.close
@@ -0,0 +1,11 @@
1
+ require 'tmpdir'
2
+
3
+ class Dir
4
+ def self.consistent_tmpdir
5
+ if RUBY_PLATFORM =~ /darwin/i
6
+ '/tmp' # OS X normally returns a crazy tmpdir, BUT when logged in via SSH, it is '/tmp'. This unifies it.
7
+ else
8
+ Dir.tmpdir
9
+ end
10
+ end
11
+ end
data/lib/hydra/trace.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  module Hydra #:nodoc:
2
2
  # Trace output when in verbose mode.
3
3
  module Trace
4
- REMOTE_IDENTIFIER = 'REMOTE'
5
-
6
4
  module ClassMethods
7
5
  # Make a class traceable. Takes one parameter,
8
6
  # which is the prefix for the trace to identify this class
@@ -18,10 +16,7 @@ module Hydra #:nodoc:
18
16
  # Trace some output with the class's prefix and a newline.
19
17
  # Checks to ensure we're running verbosely.
20
18
  def trace(str)
21
- return unless @verbose
22
- remote_info = @remote ? "#{REMOTE_IDENTIFIER} #{@remote} " : ''
23
- str = str.gsub /\n/, "\n#{remote_info}"
24
- $stdout.write "#{Time.now.to_f} #{remote_info}#{self.class._traceable_prefix}| #{str}\n"
19
+ $stdout.write "#{Time.now.to_f} #{self.class._traceable_prefix}| #{str}\n" if @verbose
25
20
  end
26
21
  end
27
22
  end
data/lib/hydra/worker.rb CHANGED
@@ -16,11 +16,11 @@ module Hydra #:nodoc:
16
16
  # * num_runners: The number of runners to launch
17
17
  def initialize(opts = {})
18
18
  @verbose = opts.fetch(:verbose) { false }
19
- @remote = opts.fetch(:remote) { false }
20
19
  @io = opts.fetch(:io) { raise "No IO Object" }
21
20
  @runners = []
22
21
  @listeners = []
23
22
 
23
+ load_worker_initializer
24
24
  boot_runners(opts.fetch(:runners) { 1 })
25
25
  @io.write(Hydra::Messages::Worker::WorkerBegin.new)
26
26
 
@@ -29,7 +29,15 @@ module Hydra #:nodoc:
29
29
  @runners.each{|r| Process.wait r[:pid] }
30
30
  end
31
31
 
32
-
32
+ def load_worker_initializer
33
+ if File.exist?('./hydra_worker_init.rb')
34
+ trace('Requiring hydra_worker_init.rb')
35
+ require 'hydra_worker_init'
36
+ else
37
+ trace('hydra_worker_init.rb not present')
38
+ end
39
+ end
40
+
33
41
  # message handling methods
34
42
 
35
43
  # When a runner wants a file, it hits this method with a message.
@@ -75,7 +83,7 @@ module Hydra #:nodoc:
75
83
  pipe = Hydra::Pipe.new
76
84
  child = SafeFork.fork do
77
85
  pipe.identify_as_child
78
- Hydra::Runner.new(:io => pipe, :verbose => @verbose, :remote => @remote)
86
+ Hydra::Runner.new(:io => pipe, :verbose => @verbose)
79
87
  end
80
88
  pipe.identify_as_parent
81
89
  @runners << { :pid => child, :io => pipe, :idle => false }
@@ -0,0 +1,136 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{sskirby-hydra}
8
+ s.version = "0.23.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Nick Gauthier", "Sean Kirby", "Arturo Pie"]
12
+ s.date = %q{2011-04-26}
13
+ s.description = %q{Spread your tests over multiple machines to test your code faster.}
14
+ s.email = %q{nick@smartlogicsolutions.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc",
18
+ "TODO"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".gitignore",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "TODO",
27
+ "VERSION",
28
+ "caliper.yml",
29
+ "hydra-icon-64x64.png",
30
+ "hydra_gray.png",
31
+ "lib/hydra.rb",
32
+ "lib/hydra/cucumber/formatter.rb",
33
+ "lib/hydra/hash.rb",
34
+ "lib/hydra/js/lint.js",
35
+ "lib/hydra/listener/abstract.rb",
36
+ "lib/hydra/listener/minimal_output.rb",
37
+ "lib/hydra/listener/notifier.rb",
38
+ "lib/hydra/listener/progress_bar.rb",
39
+ "lib/hydra/listener/report_generator.rb",
40
+ "lib/hydra/master.rb",
41
+ "lib/hydra/message.rb",
42
+ "lib/hydra/message/master_messages.rb",
43
+ "lib/hydra/message/runner_messages.rb",
44
+ "lib/hydra/message/worker_messages.rb",
45
+ "lib/hydra/messaging_io.rb",
46
+ "lib/hydra/pipe.rb",
47
+ "lib/hydra/runner.rb",
48
+ "lib/hydra/safe_fork.rb",
49
+ "lib/hydra/spec/autorun_override.rb",
50
+ "lib/hydra/spec/hydra_formatter.rb",
51
+ "lib/hydra/ssh.rb",
52
+ "lib/hydra/stdio.rb",
53
+ "lib/hydra/sync.rb",
54
+ "lib/hydra/tasks.rb",
55
+ "lib/hydra/tmpdir.rb",
56
+ "lib/hydra/trace.rb",
57
+ "lib/hydra/worker.rb",
58
+ "sskirby-hydra.gemspec",
59
+ "test/fixtures/assert_true.rb",
60
+ "test/fixtures/config.yml",
61
+ "test/fixtures/conflicting.rb",
62
+ "test/fixtures/features/step_definitions.rb",
63
+ "test/fixtures/features/write_alternate_file.feature",
64
+ "test/fixtures/features/write_file.feature",
65
+ "test/fixtures/hello_world.rb",
66
+ "test/fixtures/js_file.js",
67
+ "test/fixtures/json_data.json",
68
+ "test/fixtures/many_outputs_to_console.rb",
69
+ "test/fixtures/slow.rb",
70
+ "test/fixtures/sync_test.rb",
71
+ "test/fixtures/task_test_config.yml",
72
+ "test/fixtures/write_file.rb",
73
+ "test/fixtures/write_file_alternate_spec.rb",
74
+ "test/fixtures/write_file_spec.rb",
75
+ "test/fixtures/write_file_with_pending_spec.rb",
76
+ "test/master_test.rb",
77
+ "test/message_test.rb",
78
+ "test/pipe_test.rb",
79
+ "test/runner_test.rb",
80
+ "test/ssh_test.rb",
81
+ "test/sync_test.rb",
82
+ "test/task_test.rb",
83
+ "test/test_helper.rb",
84
+ "test/worker_test.rb"
85
+ ]
86
+ s.homepage = %q{http://github.com/ngauthier/hydra}
87
+ s.rdoc_options = ["--charset=UTF-8"]
88
+ s.require_paths = ["lib"]
89
+ s.rubygems_version = %q{1.3.6}
90
+ s.summary = %q{Distributed testing toolkit}
91
+ s.test_files = [
92
+ "test/sync_test.rb",
93
+ "test/test_helper.rb",
94
+ "test/message_test.rb",
95
+ "test/runner_test.rb",
96
+ "test/fixtures/write_file.rb",
97
+ "test/fixtures/sync_test.rb",
98
+ "test/fixtures/hello_world.rb",
99
+ "test/fixtures/write_file_alternate_spec.rb",
100
+ "test/fixtures/write_file_with_pending_spec.rb",
101
+ "test/fixtures/slow.rb",
102
+ "test/fixtures/assert_true.rb",
103
+ "test/fixtures/write_file_spec.rb",
104
+ "test/fixtures/many_outputs_to_console.rb",
105
+ "test/fixtures/features/step_definitions.rb",
106
+ "test/fixtures/conflicting.rb",
107
+ "test/ssh_test.rb",
108
+ "test/pipe_test.rb",
109
+ "test/task_test.rb",
110
+ "test/master_test.rb",
111
+ "test/worker_test.rb"
112
+ ]
113
+
114
+ if s.respond_to? :specification_version then
115
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
116
+ s.specification_version = 3
117
+
118
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
119
+ s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
120
+ s.add_development_dependency(%q<rspec>, ["= 2.0.0.beta.19"])
121
+ s.add_development_dependency(%q<cucumber>, ["= 0.9.2"])
122
+ s.add_development_dependency(%q<therubyracer>, ["= 0.7.4"])
123
+ else
124
+ s.add_dependency(%q<shoulda>, ["= 2.10.3"])
125
+ s.add_dependency(%q<rspec>, ["= 2.0.0.beta.19"])
126
+ s.add_dependency(%q<cucumber>, ["= 0.9.2"])
127
+ s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
128
+ end
129
+ else
130
+ s.add_dependency(%q<shoulda>, ["= 2.10.3"])
131
+ s.add_dependency(%q<rspec>, ["= 2.0.0.beta.19"])
132
+ s.add_dependency(%q<cucumber>, ["= 0.9.2"])
133
+ s.add_dependency(%q<therubyracer>, ["= 0.7.4"])
134
+ end
135
+ end
136
+
@@ -1,9 +1,9 @@
1
1
  Given /^a target file$/ do
2
- @target_file = File.expand_path(File.join(Dir.tmpdir, 'hydra_test.txt'))
2
+ @target_file = File.expand_path(File.join(Dir.consistent_tmpdir, 'hydra_test.txt'))
3
3
  end
4
4
 
5
5
  Given /^an alternate target file$/ do
6
- @target_file = File.expand_path(File.join(Dir.tmpdir, 'alternate_hydra_test.txt'))
6
+ @target_file = File.expand_path(File.join(Dir.consistent_tmpdir, 'alternate_hydra_test.txt'))
7
7
  end
8
8
 
9
9
  When /^I write "([^\"]*)" to the file$/ do |text|
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ 10000.times do
4
+ $stdout.write "A non-hydra message...\n"
5
+ $stdout.flush
6
+ end
7
+
8
+ $stdout.write "{:class=>Hydra::Messages::TestMessage, :text=>\"My message\"}\n"
9
+ $stdout.flush
@@ -0,0 +1,6 @@
1
+ ---
2
+ workers:
3
+ - type: ssh
4
+ connect: localhost
5
+ directory: /tmp
6
+ runners: 1
@@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), '..', 'test_helper')
2
2
 
3
3
  class WriteFileTest < Test::Unit::TestCase
4
4
  def test_write_a_file
5
- File.open(File.join(Dir.tmpdir, 'hydra_test.txt'), 'a') do |f|
5
+ File.open(File.join(Dir.consistent_tmpdir, 'hydra_test.txt'), 'a') do |f|
6
6
  f.write "HYDRA"
7
7
  end
8
8
  end
@@ -1,8 +1,8 @@
1
- require 'tmpdir'
2
1
  require 'rspec'
2
+ require 'hydra/tmpdir'
3
3
  context "file writing" do
4
4
  it "writes to a file" do
5
- File.open(File.join(Dir.tmpdir, 'alternate_hydra_test.txt'), 'a') do |f|
5
+ File.open(File.join(Dir.consistent_tmpdir, 'alternate_hydra_test.txt'), 'a') do |f|
6
6
  f.write "HYDRA"
7
7
  end
8
8
  end
@@ -1,8 +1,8 @@
1
- require 'tmpdir'
2
1
  require 'rspec'
2
+ require 'hydra/tmpdir'
3
3
  context "file writing" do
4
4
  it "writes to a file" do
5
- File.open(File.join(Dir.tmpdir, 'hydra_test.txt'), 'a') do |f|
5
+ File.open(File.join(Dir.consistent_tmpdir, 'hydra_test.txt'), 'a') do |f|
6
6
  f.write "HYDRA"
7
7
  end
8
8
  end
@@ -2,7 +2,7 @@ require 'tmpdir'
2
2
  require 'rspec'
3
3
  context "file writing" do
4
4
  it "writes to a file" do
5
- File.open(File.join(Dir.tmpdir, 'hydra_test.txt'), 'a') do |f|
5
+ File.open(File.join(Dir.consistent_tmpdir, 'hydra_test.txt'), 'a') do |f|
6
6
  f.write "HYDRA"
7
7
  end
8
8
  end
data/test/master_test.rb CHANGED
@@ -64,7 +64,7 @@ class MasterTest < Test::Unit::TestCase
64
64
  Hydra::Master.new(:files => [test_file])
65
65
  assert File.exists?(target_file)
66
66
  assert_equal "HYDRA", File.read(target_file)
67
- report_file = File.join(Dir.tmpdir, 'hydra_heuristics.yml')
67
+ report_file = File.join(Dir.consistent_tmpdir, 'hydra_heuristics.yml')
68
68
  assert File.exists?(report_file)
69
69
  assert report = YAML.load_file(report_file)
70
70
  assert_not_nil report[test_file]
@@ -133,8 +133,8 @@ class MasterTest < Test::Unit::TestCase
133
133
  end
134
134
 
135
135
  should "synchronize a test file over ssh with rsync" do
136
- local = File.join(Dir.tmpdir, 'hydra', 'local')
137
- remote = File.join(Dir.tmpdir, 'hydra', 'remote')
136
+ local = File.join(Dir.consistent_tmpdir, 'hydra', 'local')
137
+ remote = File.join(Dir.consistent_tmpdir, 'hydra', 'remote')
138
138
  sync_test = File.join(File.dirname(__FILE__), 'fixtures', 'sync_test.rb')
139
139
  [local, remote].each{|f| FileUtils.rm_rf f; FileUtils.mkdir_p f}
140
140
 
data/test/runner_test.rb CHANGED
@@ -80,9 +80,6 @@ class RunnerTest < Test::Unit::TestCase
80
80
  # we run this in a fork to not contaminate
81
81
  # the main test environment
82
82
  pid = Process.fork do
83
- # need to get into the fixtures directory so cucumber doesn't load up the whole project
84
- Dir.chdir(File.join(File.dirname(__FILE__), 'fixtures'))
85
-
86
83
  runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
87
84
  runner.run_file(cucumber_feature_file)
88
85
  assert File.exists?(target_file)
data/test/ssh_test.rb CHANGED
@@ -11,4 +11,15 @@ class SSHTest < Test::Unit::TestCase
11
11
  assert_equal "Hello World", response.text
12
12
  ssh.close
13
13
  end
14
+
15
+ should "be able to handle a large number of non-Hydra console output" do
16
+ ssh = Hydra::SSH.new(
17
+ 'localhost', # connect to this machine
18
+ File.expand_path(File.join(File.dirname(__FILE__))), # move to the test directory
19
+ "ruby fixtures/many_outputs_to_console.rb"
20
+ )
21
+ response = ssh.gets
22
+ assert_equal "My message", response.text
23
+ ssh.close
24
+ end
14
25
  end
data/test/sync_test.rb CHANGED
@@ -13,8 +13,8 @@ class SyncTest < Test::Unit::TestCase
13
13
  end
14
14
 
15
15
  should "synchronize a test file over ssh with rsync" do
16
- local = File.join(Dir.tmpdir, 'hydra', 'local')
17
- remote = File.join(Dir.tmpdir, 'hydra', 'remote')
16
+ local = File.join(Dir.consistent_tmpdir, 'hydra', 'local')
17
+ remote = File.join(Dir.consistent_tmpdir, 'hydra', 'remote')
18
18
  sync_test = File.join(File.dirname(__FILE__), 'fixtures', 'sync_test.rb')
19
19
  [local, remote].each{|f| FileUtils.rm_rf f; FileUtils.mkdir_p f}
20
20
 
@@ -58,9 +58,9 @@ class SyncTest < Test::Unit::TestCase
58
58
  end
59
59
 
60
60
  should "synchronize a test file over ssh with rsync to multiple workers" do
61
- local = File.join(Dir.tmpdir, 'hydra', 'local')
62
- remote_a = File.join(Dir.tmpdir, 'hydra', 'remote_a')
63
- remote_b = File.join(Dir.tmpdir, 'hydra', 'remote_b')
61
+ local = File.join(Dir.consistent_tmpdir, 'hydra', 'local')
62
+ remote_a = File.join(Dir.consistent_tmpdir, 'hydra', 'remote_a')
63
+ remote_b = File.join(Dir.consistent_tmpdir, 'hydra', 'remote_b')
64
64
  sync_test = File.join(File.dirname(__FILE__), 'fixtures', 'sync_test.rb')
65
65
  [local, remote_a, remote_b].each{|f| FileUtils.rm_rf f; FileUtils.mkdir_p f}
66
66
 
data/test/task_test.rb ADDED
@@ -0,0 +1,21 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+ require 'hydra/tasks'
3
+ require 'rake'
4
+
5
+ class TaskTest < Test::Unit::TestCase
6
+ context "a task" do
7
+ should "execute the command in a remote machine" do
8
+
9
+ File.delete( "/tmp/new_file" ) if File.exists? "/tmp/new_file"
10
+
11
+ Hydra::RemoteTask.new('cat:text_file', 'touch new_file') do |t|
12
+ t.config = "test/fixtures/task_test_config.yml"
13
+ end
14
+
15
+ Rake.application['hydra:remote:cat:text_file'].invoke
16
+
17
+ assert( File.exists? "/tmp/new_file" )
18
+
19
+ end
20
+ end
21
+ end
data/test/test_helper.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
+ gem 'shoulda', '2.10.3'
4
+ gem 'rspec', '2.0.0.beta.19'
3
5
  require 'shoulda'
4
6
  require 'tmpdir'
5
7
 
@@ -12,11 +14,11 @@ Test::Unit.run = false
12
14
 
13
15
  class Test::Unit::TestCase
14
16
  def target_file
15
- File.expand_path(File.join(Dir.tmpdir, 'hydra_test.txt'))
17
+ File.expand_path(File.join(Dir.consistent_tmpdir, 'hydra_test.txt'))
16
18
  end
17
19
 
18
20
  def alternate_target_file
19
- File.expand_path(File.join(Dir.tmpdir, 'alternate_hydra_test.txt'))
21
+ File.expand_path(File.join(Dir.consistent_tmpdir, 'alternate_hydra_test.txt'))
20
22
  end
21
23
 
22
24
  def test_file
metadata CHANGED
@@ -1,32 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sskirby-hydra
3
3
  version: !ruby/object:Gem::Version
4
- hash: 75
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
- - 21
9
- - 0
10
- version: 0.21.0
7
+ - 23
8
+ - 3
9
+ version: 0.23.3
11
10
  platform: ruby
12
11
  authors:
13
12
  - Nick Gauthier
13
+ - Sean Kirby
14
+ - Arturo Pie
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-08-29 00:00:00 -04:00
19
- default_executable: warmsnake.rb
19
+ date: 2011-04-26 00:00:00 -04:00
20
+ default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  name: shoulda
23
24
  prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
26
  requirements:
27
27
  - - "="
28
28
  - !ruby/object:Gem::Version
29
- hash: 33
30
29
  segments:
31
30
  - 2
32
31
  - 10
@@ -38,11 +37,9 @@ dependencies:
38
37
  name: rspec
39
38
  prerelease: false
40
39
  requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
40
  requirements:
43
41
  - - "="
44
42
  - !ruby/object:Gem::Version
45
- hash: 62196421
46
43
  segments:
47
44
  - 2
48
45
  - 0
@@ -56,27 +53,23 @@ dependencies:
56
53
  name: cucumber
57
54
  prerelease: false
58
55
  requirement: &id003 !ruby/object:Gem::Requirement
59
- none: false
60
56
  requirements:
61
57
  - - "="
62
58
  - !ruby/object:Gem::Version
63
- hash: 53
64
59
  segments:
65
60
  - 0
66
- - 8
67
- - 5
68
- version: 0.8.5
61
+ - 9
62
+ - 2
63
+ version: 0.9.2
69
64
  type: :development
70
65
  version_requirements: *id003
71
66
  - !ruby/object:Gem::Dependency
72
67
  name: therubyracer
73
68
  prerelease: false
74
69
  requirement: &id004 !ruby/object:Gem::Requirement
75
- none: false
76
70
  requirements:
77
71
  - - "="
78
72
  - !ruby/object:Gem::Version
79
- hash: 11
80
73
  segments:
81
74
  - 0
82
75
  - 7
@@ -86,8 +79,8 @@ dependencies:
86
79
  version_requirements: *id004
87
80
  description: Spread your tests over multiple machines to test your code faster.
88
81
  email: nick@smartlogicsolutions.com
89
- executables:
90
- - warmsnake.rb
82
+ executables: []
83
+
91
84
  extensions: []
92
85
 
93
86
  extra_rdoc_files:
@@ -102,7 +95,6 @@ files:
102
95
  - Rakefile
103
96
  - TODO
104
97
  - VERSION
105
- - bin/warmsnake.rb
106
98
  - caliper.yml
107
99
  - hydra-icon-64x64.png
108
100
  - hydra_gray.png
@@ -130,8 +122,10 @@ files:
130
122
  - lib/hydra/stdio.rb
131
123
  - lib/hydra/sync.rb
132
124
  - lib/hydra/tasks.rb
125
+ - lib/hydra/tmpdir.rb
133
126
  - lib/hydra/trace.rb
134
127
  - lib/hydra/worker.rb
128
+ - sskirby-hydra.gemspec
135
129
  - test/fixtures/assert_true.rb
136
130
  - test/fixtures/config.yml
137
131
  - test/fixtures/conflicting.rb
@@ -141,8 +135,10 @@ files:
141
135
  - test/fixtures/hello_world.rb
142
136
  - test/fixtures/js_file.js
143
137
  - test/fixtures/json_data.json
138
+ - test/fixtures/many_outputs_to_console.rb
144
139
  - test/fixtures/slow.rb
145
140
  - test/fixtures/sync_test.rb
141
+ - test/fixtures/task_test_config.yml
146
142
  - test/fixtures/write_file.rb
147
143
  - test/fixtures/write_file_alternate_spec.rb
148
144
  - test/fixtures/write_file_spec.rb
@@ -153,8 +149,8 @@ files:
153
149
  - test/runner_test.rb
154
150
  - test/ssh_test.rb
155
151
  - test/sync_test.rb
152
+ - test/task_test.rb
156
153
  - test/test_helper.rb
157
- - test/trace_test.rb
158
154
  - test/worker_test.rb
159
155
  has_rdoc: true
160
156
  homepage: http://github.com/ngauthier/hydra
@@ -166,47 +162,44 @@ rdoc_options:
166
162
  require_paths:
167
163
  - lib
168
164
  required_ruby_version: !ruby/object:Gem::Requirement
169
- none: false
170
165
  requirements:
171
166
  - - ">="
172
167
  - !ruby/object:Gem::Version
173
- hash: 3
174
168
  segments:
175
169
  - 0
176
170
  version: "0"
177
171
  required_rubygems_version: !ruby/object:Gem::Requirement
178
- none: false
179
172
  requirements:
180
173
  - - ">="
181
174
  - !ruby/object:Gem::Version
182
- hash: 3
183
175
  segments:
184
176
  - 0
185
177
  version: "0"
186
178
  requirements: []
187
179
 
188
180
  rubyforge_project:
189
- rubygems_version: 1.3.7
181
+ rubygems_version: 1.3.6
190
182
  signing_key:
191
183
  specification_version: 3
192
184
  summary: Distributed testing toolkit
193
185
  test_files:
186
+ - test/sync_test.rb
187
+ - test/test_helper.rb
194
188
  - test/message_test.rb
195
- - test/master_test.rb
196
- - test/ssh_test.rb
197
- - test/fixtures/assert_true.rb
198
- - test/fixtures/slow.rb
199
- - test/fixtures/write_file_alternate_spec.rb
189
+ - test/runner_test.rb
190
+ - test/fixtures/write_file.rb
191
+ - test/fixtures/sync_test.rb
200
192
  - test/fixtures/hello_world.rb
193
+ - test/fixtures/write_file_alternate_spec.rb
201
194
  - test/fixtures/write_file_with_pending_spec.rb
202
- - test/fixtures/write_file.rb
203
- - test/fixtures/conflicting.rb
195
+ - test/fixtures/slow.rb
196
+ - test/fixtures/assert_true.rb
204
197
  - test/fixtures/write_file_spec.rb
198
+ - test/fixtures/many_outputs_to_console.rb
205
199
  - test/fixtures/features/step_definitions.rb
206
- - test/fixtures/sync_test.rb
207
- - test/test_helper.rb
208
- - test/runner_test.rb
209
- - test/trace_test.rb
210
- - test/sync_test.rb
200
+ - test/fixtures/conflicting.rb
201
+ - test/ssh_test.rb
211
202
  - test/pipe_test.rb
203
+ - test/task_test.rb
204
+ - test/master_test.rb
212
205
  - test/worker_test.rb
data/bin/warmsnake.rb DELETED
@@ -1,76 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # warmsnake.rb
4
- #
5
- # This is a first attempt at making a hydra binary.
6
- #
7
- # Currently, all it does is run the files you pass into it. When you
8
- # press Enter it will run them again, maintaining your rails environment.
9
- # When you type 'r' and hit Enter it will reboot the rails environment.
10
- #
11
- # It is extremely specific about its behavior and only works in rails.
12
- #
13
- # It is not really ready for any kind of release, but it is useful, so
14
- # it's included.
15
- #
16
- require 'rubygems'
17
- require 'hydra'
18
-
19
- @files = ARGV.inject([]){|memo,f| memo += Dir.glob f}
20
-
21
- if @files.empty?
22
- puts "You must specify a list of files to run"
23
- puts "If you specify a pattern, it must be in quotes"
24
- puts %{USAGE: #{$0} test/unit/my_test.rb "test/functional/**/*_test.rb"}
25
- exit(1)
26
- end
27
-
28
- Signal.trap("TERM", "KILL") do
29
- puts "Warm Snake says bye bye"
30
- exit(0)
31
- end
32
-
33
- bold_yellow = "\033[1;33m"
34
- reset = "\033[0m"
35
-
36
-
37
- loop do
38
- env_proc = Process.fork do
39
- puts "#{bold_yellow}Booting Environment#{reset}"
40
- start = Time.now
41
- ENV['RAILS_ENV']='test'
42
- require 'config/environment'
43
- require 'test/test_helper'
44
- finish = Time.now
45
- puts "#{bold_yellow}Environment Booted (#{finish-start})#{reset}"
46
-
47
- loop do
48
- puts "#{bold_yellow}Running#{reset} [#{@files.inspect}]"
49
- start = Time.now
50
- Hydra::Master.new(
51
- :files => @files.dup,
52
- :listeners => Hydra::Listener::ProgressBar.new(STDOUT),
53
- :workers => [{:type => :local, :runners => 4}]
54
- )
55
- finish = Time.now
56
- puts "#{bold_yellow}Tests finished#{reset} (#{finish-start})"
57
-
58
- puts ""
59
-
60
- $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> "
61
- begin
62
- command = $stdin.gets
63
- rescue Interrupt
64
- exit(0)
65
- end
66
- break if !command.nil? and command.chomp == "r"
67
- end
68
- end
69
- begin
70
- Process.wait env_proc
71
- rescue Interrupt
72
- puts "\n#{bold_yellow}SSsssSsssSSssSs#{reset}"
73
- break
74
- end
75
- end
76
-
data/test/trace_test.rb DELETED
@@ -1,72 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
2
-
3
- class TraceTester
4
- traceable("TEST")
5
- attr_accessor :verbose, :remote
6
- def initialize verbose, remote
7
- self.verbose, self.remote = verbose, remote
8
- end
9
- end
10
-
11
- class TraceTest < Test::Unit::TestCase
12
- def setup
13
- @result = StringIO.new("")
14
- end
15
-
16
- def run_trace object, str
17
- old_stdout = $stdout
18
- $stdout = @result
19
- object.trace str
20
- return @result.string
21
- ensure
22
- $stdout = old_stdout
23
- end
24
-
25
- context "with no tracing enabled" do
26
- setup do
27
- @tracer = TraceTester.new false, false
28
- end
29
-
30
- should "not output" do
31
- result = run_trace @tracer, "testing"
32
- assert_equal '', result
33
- end
34
- end
35
-
36
- context "with a local object" do
37
- setup do
38
- @tracer = TraceTester.new true, false
39
- end
40
-
41
- should "output" do
42
- result = run_trace @tracer, 'testing'
43
- assert_match /TEST/, result
44
- assert_match /testing/, result
45
- assert_no_match /#{Hydra::Trace::REMOTE_IDENTIFIER}/, result
46
- end
47
- end
48
-
49
- context "with a remote object" do
50
- setup do
51
- @tracer = TraceTester.new true, 'localhost'
52
- end
53
-
54
- should "output" do
55
- result = run_trace @tracer, 'testing'
56
- assert_match /TEST/, result
57
- assert_match /testing/, result
58
- assert_equal "\n"[0], result[-1]
59
- assert_match /#{Hydra::Trace::REMOTE_IDENTIFIER} localhost/, result
60
- end
61
-
62
- should "output a multiline message" do
63
- result = run_trace @tracer, "testing\ntrace line #1\ntrace line #2"
64
- assert_match /TEST/, result
65
- assert_match /testing/, result
66
- assert_match /#{Hydra::Trace::REMOTE_IDENTIFIER} localhost TEST/, result
67
- assert_match /\n#{Hydra::Trace::REMOTE_IDENTIFIER} localhost trace line #1/, result
68
- assert_match /\n#{Hydra::Trace::REMOTE_IDENTIFIER} localhost trace line #2/, result
69
- end
70
- end
71
- end
72
-