hydra 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.21.0
1
+ 0.22.0
@@ -1,64 +1,76 @@
1
1
  #!/usr/bin/env ruby
2
- if File.expand_path($0) == File.expand_path(__FILE__)
3
- require 'rubygems'
4
- require 'hydra'
5
-
6
- @files = ARGV.inject([]){|memo,f| memo += Dir.glob f}
7
-
8
- if @files.empty?
9
- puts "You must specify a list of files to run"
10
- puts "If you specify a pattern, it must be in quotes"
11
- puts %{USAGE: #{$0} test/unit/my_test.rb "test/functional/**/*_test.rb"}
12
- exit(1)
13
- end
14
-
15
- Signal.trap("TERM", "KILL") do
16
- puts "Warm Snake says bye bye"
17
- exit(0)
18
- end
19
-
20
- bold_yellow = "\033[1;33m"
21
- reset = "\033[0m"
22
-
23
-
24
- loop do
25
- env_proc = Process.fork do
26
- puts "#{bold_yellow}Booting Environment#{reset}"
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}]"
27
49
  start = Time.now
28
- ENV['RAILS_ENV']='test'
29
- require 'config/environment'
30
- require 'test/test_helper'
50
+ Hydra::Master.new(
51
+ :files => @files.dup,
52
+ :listeners => Hydra::Listener::ProgressBar.new(STDOUT),
53
+ :workers => [{:type => :local, :runners => 4}]
54
+ )
31
55
  finish = Time.now
32
- puts "#{bold_yellow}Environment Booted (#{finish-start})#{reset}"
33
-
34
- loop do
35
- puts "#{bold_yellow}Running#{reset} [#{@files.inspect}]"
36
- start = Time.now
37
- Hydra::Master.new(
38
- :files => @files.dup,
39
- :listeners => Hydra::Listener::ProgressBar.new(STDOUT),
40
- :workers => [{:type => :local, :runners => 4}]
41
- )
42
- finish = Time.now
43
- puts "#{bold_yellow}Tests finished#{reset} (#{finish-start})"
44
-
45
- puts ""
46
-
47
- $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> "
48
- begin
49
- command = $stdin.gets
50
- rescue Interrupt
51
- exit(0)
52
- end
53
- break if !command.nil? and command.chomp == "r"
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)
54
65
  end
66
+ break if !command.nil? and command.chomp == "r"
55
67
  end
56
- begin
57
- Process.wait env_proc
58
- rescue Interrupt
59
- puts "\n#{bold_yellow}SSsssSsssSSssSs#{reset}"
60
- break
61
- end
68
+ end
69
+ begin
70
+ Process.wait env_proc
71
+ rescue Interrupt
72
+ puts "\n#{bold_yellow}SSsssSsssSSssSs#{reset}"
73
+ break
62
74
  end
63
75
  end
64
76
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hydra}
8
- s.version = "0.21.0"
8
+ s.version = "0.22.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nick Gauthier"]
12
- s.date = %q{2010-08-23}
12
+ s.date = %q{2010-09-02}
13
13
  s.default_executable = %q{warmsnake.rb}
14
14
  s.description = %q{Spread your tests over multiple machines to test your code faster.}
15
15
  s.email = %q{nick@smartlogicsolutions.com}
@@ -56,6 +56,7 @@ Gem::Specification.new do |s|
56
56
  "lib/hydra/stdio.rb",
57
57
  "lib/hydra/sync.rb",
58
58
  "lib/hydra/tasks.rb",
59
+ "lib/hydra/tmpdir.rb",
59
60
  "lib/hydra/trace.rb",
60
61
  "lib/hydra/worker.rb",
61
62
  "test/fixtures/assert_true.rb",
@@ -88,21 +89,21 @@ Gem::Specification.new do |s|
88
89
  s.summary = %q{Distributed testing toolkit}
89
90
  s.test_files = [
90
91
  "test/pipe_test.rb",
91
- "test/sync_test.rb",
92
+ "test/test_helper.rb",
92
93
  "test/ssh_test.rb",
94
+ "test/message_test.rb",
95
+ "test/master_test.rb",
96
+ "test/fixtures/write_file.rb",
97
+ "test/fixtures/slow.rb",
98
+ "test/fixtures/write_file_with_pending_spec.rb",
99
+ "test/fixtures/write_file_spec.rb",
100
+ "test/fixtures/features/step_definitions.rb",
101
+ "test/fixtures/hello_world.rb",
93
102
  "test/fixtures/write_file_alternate_spec.rb",
94
103
  "test/fixtures/sync_test.rb",
95
- "test/fixtures/hello_world.rb",
96
- "test/fixtures/features/step_definitions.rb",
97
104
  "test/fixtures/assert_true.rb",
98
- "test/fixtures/slow.rb",
99
- "test/fixtures/write_file_spec.rb",
100
- "test/fixtures/write_file_with_pending_spec.rb",
101
- "test/fixtures/write_file.rb",
102
- "test/message_test.rb",
103
- "test/test_helper.rb",
104
- "test/master_test.rb",
105
105
  "test/runner_test.rb",
106
+ "test/sync_test.rb",
106
107
  "test/worker_test.rb"
107
108
  ]
108
109
 
@@ -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
 
@@ -232,7 +232,7 @@ module Hydra #:nodoc:
232
232
  end
233
233
 
234
234
  def heuristic_file
235
- @heuristic_file ||= File.join(Dir.tmpdir, 'hydra_heuristics.yml')
235
+ @heuristic_file ||= File.join(Dir.consistent_tmpdir, 'hydra_heuristics.yml')
236
236
  end
237
237
  end
238
238
  end
@@ -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
@@ -20,6 +20,7 @@ module Hydra #:nodoc:
20
20
  @runners = []
21
21
  @listeners = []
22
22
 
23
+ load_worker_initializer
23
24
  boot_runners(opts.fetch(:runners) { 1 })
24
25
  @io.write(Hydra::Messages::Worker::WorkerBegin.new)
25
26
 
@@ -28,7 +29,15 @@ module Hydra #:nodoc:
28
29
  @runners.each{|r| Process.wait r[:pid] }
29
30
  end
30
31
 
31
-
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
+
32
41
  # message handling methods
33
42
 
34
43
  # When a runner wants a file, it hits this method with a message.
@@ -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|
@@ -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
@@ -35,7 +35,7 @@ class MasterTest < Test::Unit::TestCase
35
35
  Hydra::Master.new(:files => [test_file])
36
36
  assert File.exists?(target_file)
37
37
  assert_equal "HYDRA", File.read(target_file)
38
- report_file = File.join(Dir.tmpdir, 'hydra_heuristics.yml')
38
+ report_file = File.join(Dir.consistent_tmpdir, 'hydra_heuristics.yml')
39
39
  assert File.exists?(report_file)
40
40
  assert report = YAML.load_file(report_file)
41
41
  assert_not_nil report[test_file]
@@ -104,8 +104,8 @@ class MasterTest < Test::Unit::TestCase
104
104
  end
105
105
 
106
106
  should "synchronize a test file over ssh with rsync" do
107
- local = File.join(Dir.tmpdir, 'hydra', 'local')
108
- remote = File.join(Dir.tmpdir, 'hydra', 'remote')
107
+ local = File.join(Dir.consistent_tmpdir, 'hydra', 'local')
108
+ remote = File.join(Dir.consistent_tmpdir, 'hydra', 'remote')
109
109
  sync_test = File.join(File.dirname(__FILE__), 'fixtures', 'sync_test.rb')
110
110
  [local, remote].each{|f| FileUtils.rm_rf f; FileUtils.mkdir_p f}
111
111
 
@@ -50,7 +50,6 @@ class RunnerTest < Test::Unit::TestCase
50
50
  end
51
51
 
52
52
  should "run two rspec tests" do
53
- puts "First test"
54
53
  runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
55
54
  runner.run_file(rspec_file)
56
55
  assert File.exists?(target_file)
@@ -81,8 +80,8 @@ class RunnerTest < Test::Unit::TestCase
81
80
  # we run this in a fork to not contaminate
82
81
  # the main test environment
83
82
  pid = Process.fork do
84
- puts "THE FOLLOWING WARNINGS CAN BE IGNORED"
85
- puts "It is caused by Cucumber loading all rb files near its features"
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'))
86
85
 
87
86
  runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
88
87
  runner.run_file(cucumber_feature_file)
@@ -95,8 +94,6 @@ class RunnerTest < Test::Unit::TestCase
95
94
  assert File.exists?(alternate_target_file)
96
95
  assert_equal "HYDRA", File.read(alternate_target_file)
97
96
  assert !File.exists?(target_file)
98
-
99
- puts "END IGNORABLE OUTPUT"
100
97
  end
101
98
  Process.wait pid
102
99
  end
@@ -137,7 +134,6 @@ class RunnerTest < Test::Unit::TestCase
137
134
 
138
135
  # grab its response. This makes us wait for it to finish
139
136
  response = pipe.gets
140
- puts response.output
141
137
 
142
138
  # tell it to shut down
143
139
  pipe.write(Hydra::Messages::Worker::Shutdown.new)
@@ -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
 
@@ -12,11 +12,11 @@ Test::Unit.run = false
12
12
 
13
13
  class Test::Unit::TestCase
14
14
  def target_file
15
- File.expand_path(File.join(Dir.tmpdir, 'hydra_test.txt'))
15
+ File.expand_path(File.join(Dir.consistent_tmpdir, 'hydra_test.txt'))
16
16
  end
17
17
 
18
18
  def alternate_target_file
19
- File.expand_path(File.join(Dir.tmpdir, 'alternate_hydra_test.txt'))
19
+ File.expand_path(File.join(Dir.consistent_tmpdir, 'alternate_hydra_test.txt'))
20
20
  end
21
21
 
22
22
  def test_file
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 21
7
+ - 22
8
8
  - 0
9
- version: 0.21.0
9
+ version: 0.22.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Nick Gauthier
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-23 00:00:00 -04:00
17
+ date: 2010-09-02 00:00:00 -05:00
18
18
  default_executable: warmsnake.rb
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -122,6 +122,7 @@ files:
122
122
  - lib/hydra/stdio.rb
123
123
  - lib/hydra/sync.rb
124
124
  - lib/hydra/tasks.rb
125
+ - lib/hydra/tmpdir.rb
125
126
  - lib/hydra/trace.rb
126
127
  - lib/hydra/worker.rb
127
128
  - test/fixtures/assert_true.rb
@@ -178,19 +179,19 @@ specification_version: 3
178
179
  summary: Distributed testing toolkit
179
180
  test_files:
180
181
  - test/pipe_test.rb
181
- - test/sync_test.rb
182
+ - test/test_helper.rb
182
183
  - test/ssh_test.rb
184
+ - test/message_test.rb
185
+ - test/master_test.rb
186
+ - test/fixtures/write_file.rb
187
+ - test/fixtures/slow.rb
188
+ - test/fixtures/write_file_with_pending_spec.rb
189
+ - test/fixtures/write_file_spec.rb
190
+ - test/fixtures/features/step_definitions.rb
191
+ - test/fixtures/hello_world.rb
183
192
  - test/fixtures/write_file_alternate_spec.rb
184
193
  - test/fixtures/sync_test.rb
185
- - test/fixtures/hello_world.rb
186
- - test/fixtures/features/step_definitions.rb
187
194
  - test/fixtures/assert_true.rb
188
- - test/fixtures/slow.rb
189
- - test/fixtures/write_file_spec.rb
190
- - test/fixtures/write_file_with_pending_spec.rb
191
- - test/fixtures/write_file.rb
192
- - test/message_test.rb
193
- - test/test_helper.rb
194
- - test/master_test.rb
195
195
  - test/runner_test.rb
196
+ - test/sync_test.rb
196
197
  - test/worker_test.rb