hydra 0.15.1 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.15.1
1
+ 0.16.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hydra}
8
- s.version = "0.15.1"
8
+ s.version = "0.16.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-03-31}
12
+ s.date = %q{2010-04-04}
13
13
  s.description = %q{Spread your tests over multiple machines to test your code faster.}
14
14
  s.email = %q{nick@smartlogicsolutions.com}
15
15
  s.extra_rdoc_files = [
@@ -46,6 +46,7 @@ Gem::Specification.new do |s|
46
46
  "lib/hydra/pipe.rb",
47
47
  "lib/hydra/runner.rb",
48
48
  "lib/hydra/safe_fork.rb",
49
+ "lib/hydra/spec/hydra_formatter.rb",
49
50
  "lib/hydra/ssh.rb",
50
51
  "lib/hydra/stdio.rb",
51
52
  "lib/hydra/tasks.rb",
@@ -60,6 +61,8 @@ Gem::Specification.new do |s|
60
61
  "test/fixtures/slow.rb",
61
62
  "test/fixtures/sync_test.rb",
62
63
  "test/fixtures/write_file.rb",
64
+ "test/fixtures/write_file_alternate_spec.rb",
65
+ "test/fixtures/write_file_spec.rb",
63
66
  "test/master_test.rb",
64
67
  "test/message_test.rb",
65
68
  "test/pipe_test.rb",
@@ -71,22 +74,24 @@ Gem::Specification.new do |s|
71
74
  s.homepage = %q{http://github.com/ngauthier/hydra}
72
75
  s.rdoc_options = ["--charset=UTF-8"]
73
76
  s.require_paths = ["lib"]
74
- s.rubygems_version = %q{1.3.5}
77
+ s.rubygems_version = %q{1.3.6}
75
78
  s.summary = %q{Distributed testing toolkit}
76
79
  s.test_files = [
77
- "test/message_test.rb",
80
+ "test/pipe_test.rb",
78
81
  "test/test_helper.rb",
79
82
  "test/ssh_test.rb",
83
+ "test/message_test.rb",
84
+ "test/master_test.rb",
80
85
  "test/fixtures/write_file.rb",
81
86
  "test/fixtures/slow.rb",
87
+ "test/fixtures/write_file_spec.rb",
88
+ "test/fixtures/features/step_definitions.rb",
89
+ "test/fixtures/hello_world.rb",
90
+ "test/fixtures/write_file_alternate_spec.rb",
82
91
  "test/fixtures/sync_test.rb",
83
92
  "test/fixtures/assert_true.rb",
84
- "test/fixtures/hello_world.rb",
85
- "test/fixtures/features/step_definitions.rb",
86
- "test/master_test.rb",
87
- "test/worker_test.rb",
88
93
  "test/runner_test.rb",
89
- "test/pipe_test.rb"
94
+ "test/worker_test.rb"
90
95
  ]
91
96
 
92
97
  if s.respond_to? :specification_version then
@@ -1,6 +1,7 @@
1
1
  require 'hydra/hash'
2
2
  require 'open3'
3
3
  require 'tmpdir'
4
+ require 'yaml'
4
5
  module Hydra #:nodoc:
5
6
  # Hydra class responsible for delegate work down to workers.
6
7
  #
@@ -29,6 +29,18 @@ module Hydra #:nodoc:
29
29
  # the connectivity of the IO
30
30
  end
31
31
  end
32
+
33
+ # The runner forks to run rspec messages
34
+ # so that specs don't get rerun. It uses
35
+ # this message to report the results. See
36
+ # Runner::run_rspec_file.
37
+ class RSpecResult < Hydra::Message
38
+ # the output of the spec
39
+ attr_accessor :output
40
+ def serialize #:nodoc:
41
+ super(:output => @output)
42
+ end
43
+ end
32
44
  end
33
45
  end
34
46
  end
@@ -35,10 +35,12 @@ module Hydra #:nodoc:
35
35
  trace "Running file: #{file}"
36
36
 
37
37
  output = ""
38
- if file =~ /.rb$/
39
- output = run_ruby_file(file)
38
+ if file =~ /_spec.rb$/
39
+ output = run_rspec_file(file)
40
40
  elsif file =~ /.feature$/
41
41
  output = run_cucumber_file(file)
42
+ else
43
+ output = run_test_unit_file(file)
42
44
  end
43
45
 
44
46
  output = "." if output == ""
@@ -75,11 +77,6 @@ module Hydra #:nodoc:
75
77
  end
76
78
  end
77
79
 
78
- # Run a ruby file (ending in .rb)
79
- def run_ruby_file(file)
80
- run_test_unit_file(file) + run_rspec_file(file)
81
- end
82
-
83
80
  # Run all the Test::Unit Suites in a ruby file
84
81
  def run_test_unit_file(file)
85
82
  begin
@@ -106,11 +103,35 @@ module Hydra #:nodoc:
106
103
 
107
104
  # run all the Specs in an RSpec file (NOT IMPLEMENTED)
108
105
  def run_rspec_file(file)
109
- #TODO
110
- # Given the file
111
- # return "" if all the tests passed
112
- # or return the error messages for the entire file
113
- return ""
106
+ # pull in rspec
107
+ begin
108
+ require 'spec'
109
+ require 'hydra/spec/hydra_formatter'
110
+ rescue LoadError => ex
111
+ return ex.to_s
112
+ end
113
+ hydra_output = StringIO.new
114
+ Spec::Runner.options.instance_variable_set(:@formatters, [
115
+ Spec::Runner::Formatter::HydraFormatter.new(
116
+ Spec::Runner.options.formatter_options,
117
+ hydra_output
118
+ )
119
+ ])
120
+ Spec::Runner.options.instance_variable_set(
121
+ :@example_groups, []
122
+ )
123
+ Spec::Runner.options.instance_variable_set(
124
+ :@files, [file]
125
+ )
126
+ Spec::Runner.options.instance_variable_set(
127
+ :@files_loaded, false
128
+ )
129
+ Spec::Runner.options.run_examples
130
+ hydra_output.rewind
131
+ output = hydra_output.read.chomp
132
+ output = "" if output =~ /^\.*$/
133
+
134
+ return output
114
135
  end
115
136
 
116
137
  # run all the scenarios in a cucumber feature file
@@ -7,7 +7,11 @@ class SafeFork
7
7
  child = Process.fork do
8
8
  begin
9
9
  # create a new connection and perform the action
10
+ begin
10
11
  ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
12
+ rescue ActiveRecord::AdapterNotSpecified
13
+ # AR was defined but we didn't have a connection
14
+ end
11
15
  yield
12
16
  ensure
13
17
  # make sure we remove the connection before we're done
@@ -16,7 +20,11 @@ class SafeFork
16
20
  end
17
21
  ensure
18
22
  # make sure we re-establish the connection before returning to the main instance
23
+ begin
19
24
  ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
25
+ rescue ActiveRecord::AdapterNotSpecified
26
+ # AR was defined but we didn't have a connection
27
+ end
20
28
  end
21
29
  return child
22
30
  end
@@ -0,0 +1,20 @@
1
+ require 'spec/autorun'
2
+ require 'spec/runner/formatter/progress_bar_formatter'
3
+ module Spec
4
+ module Runner
5
+ class << self
6
+ # stop the auto-run at_exit
7
+ def run
8
+ return 0
9
+ end
10
+ end
11
+ module Formatter
12
+ class HydraFormatter < ProgressBarFormatter
13
+ # Stifle the post-test summary
14
+ def dump_summary(duration, example, failure, pending)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
@@ -72,6 +72,9 @@ module Hydra #:nodoc:
72
72
 
73
73
  yield self if block_given?
74
74
 
75
+ # Ensure we override rspec's at_exit
76
+ require 'hydra/spec/hydra_formatter'
77
+
75
78
  @config = find_config_file
76
79
 
77
80
  @opts = {
@@ -95,7 +98,7 @@ module Hydra #:nodoc:
95
98
  desc "Hydra Tests" + (@name == :hydra ? "" : " for #{@name}")
96
99
  task @name do
97
100
  Hydra::Master.new(@opts)
98
- exit(0) #bypass test on_exit output
101
+ #exit(0) #bypass test on_exit output
99
102
  end
100
103
  end
101
104
  end
@@ -0,0 +1,9 @@
1
+ require 'tmpdir'
2
+ context "file writing" do
3
+ it "writes to a file" do
4
+ File.open(File.join(Dir.tmpdir, 'alternate_hydra_test.txt'), 'a') do |f|
5
+ f.write "HYDRA"
6
+ end
7
+ end
8
+ end
9
+
@@ -0,0 +1,8 @@
1
+ require 'tmpdir'
2
+ context "file writing" do
3
+ it "writes to a file" do
4
+ File.open(File.join(Dir.tmpdir, 'hydra_test.txt'), 'a') do |f|
5
+ f.write "HYDRA"
6
+ end
7
+ end
8
+ end
@@ -37,22 +37,43 @@ class RunnerTest < Test::Unit::TestCase
37
37
  Process.wait(child)
38
38
  end
39
39
 
40
- should "run two cucumber tests" do
41
- puts "THE FOLLOWING WARNINGS CAN BE IGNORED"
42
- puts "It is caused by Cucumber loading all rb files near its features"
43
-
40
+ should "run two rspec tests" do
44
41
  runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
45
- runner.run_file(cucumber_feature_file)
42
+ runner.run_file(rspec_file)
46
43
  assert File.exists?(target_file)
47
44
  assert_equal "HYDRA", File.read(target_file)
48
-
45
+
49
46
  FileUtils.rm_f(target_file)
50
47
 
51
- runner.run_file(alternate_cucumber_feature_file)
48
+ runner.run_file(alternate_rspec_file)
52
49
  assert File.exists?(alternate_target_file)
53
50
  assert_equal "HYDRA", File.read(alternate_target_file)
54
-
55
- puts "END IGNORABLE OUTPUT"
51
+ assert !File.exists?(target_file)
52
+ end
53
+
54
+ should "run two cucumber tests" do
55
+ # because of all the crap cucumber pulls in
56
+ # we run this in a fork to not contaminate
57
+ # the main test environment
58
+ pid = Process.fork do
59
+ puts "THE FOLLOWING WARNINGS CAN BE IGNORED"
60
+ puts "It is caused by Cucumber loading all rb files near its features"
61
+
62
+ runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
63
+ runner.run_file(cucumber_feature_file)
64
+ assert File.exists?(target_file)
65
+ assert_equal "HYDRA", File.read(target_file)
66
+
67
+ FileUtils.rm_f(target_file)
68
+
69
+ runner.run_file(alternate_cucumber_feature_file)
70
+ assert File.exists?(alternate_target_file)
71
+ assert_equal "HYDRA", File.read(alternate_target_file)
72
+ assert !File.exists?(target_file)
73
+
74
+ puts "END IGNORABLE OUTPUT"
75
+ end
76
+ Process.wait pid
56
77
  end
57
78
 
58
79
  should "be able to run a runner over ssh" do
@@ -23,6 +23,14 @@ class Test::Unit::TestCase
23
23
  File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'write_file.rb'))
24
24
  end
25
25
 
26
+ def rspec_file
27
+ File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'write_file_spec.rb'))
28
+ end
29
+
30
+ def alternate_rspec_file
31
+ File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'write_file_alternate_spec.rb'))
32
+ end
33
+
26
34
  def cucumber_feature_file
27
35
  File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'features', 'write_file.feature'))
28
36
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 16
8
+ - 0
9
+ version: 0.16.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Nick Gauthier
@@ -9,19 +14,23 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-03-31 00:00:00 -04:00
17
+ date: 2010-04-04 00:00:00 -04:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: shoulda
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - "="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 10
30
+ - 3
23
31
  version: 2.10.3
24
- version:
32
+ type: :development
33
+ version_requirements: *id001
25
34
  description: Spread your tests over multiple machines to test your code faster.
26
35
  email: nick@smartlogicsolutions.com
27
36
  executables: []
@@ -61,6 +70,7 @@ files:
61
70
  - lib/hydra/pipe.rb
62
71
  - lib/hydra/runner.rb
63
72
  - lib/hydra/safe_fork.rb
73
+ - lib/hydra/spec/hydra_formatter.rb
64
74
  - lib/hydra/ssh.rb
65
75
  - lib/hydra/stdio.rb
66
76
  - lib/hydra/tasks.rb
@@ -75,6 +85,8 @@ files:
75
85
  - test/fixtures/slow.rb
76
86
  - test/fixtures/sync_test.rb
77
87
  - test/fixtures/write_file.rb
88
+ - test/fixtures/write_file_alternate_spec.rb
89
+ - test/fixtures/write_file_spec.rb
78
90
  - test/master_test.rb
79
91
  - test/message_test.rb
80
92
  - test/pipe_test.rb
@@ -95,32 +107,36 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
107
  requirements:
96
108
  - - ">="
97
109
  - !ruby/object:Gem::Version
110
+ segments:
111
+ - 0
98
112
  version: "0"
99
- version:
100
113
  required_rubygems_version: !ruby/object:Gem::Requirement
101
114
  requirements:
102
115
  - - ">="
103
116
  - !ruby/object:Gem::Version
117
+ segments:
118
+ - 0
104
119
  version: "0"
105
- version:
106
120
  requirements: []
107
121
 
108
122
  rubyforge_project:
109
- rubygems_version: 1.3.5
123
+ rubygems_version: 1.3.6
110
124
  signing_key:
111
125
  specification_version: 3
112
126
  summary: Distributed testing toolkit
113
127
  test_files:
114
- - test/message_test.rb
128
+ - test/pipe_test.rb
115
129
  - test/test_helper.rb
116
130
  - test/ssh_test.rb
131
+ - test/message_test.rb
132
+ - test/master_test.rb
117
133
  - test/fixtures/write_file.rb
118
134
  - test/fixtures/slow.rb
135
+ - test/fixtures/write_file_spec.rb
136
+ - test/fixtures/features/step_definitions.rb
137
+ - test/fixtures/hello_world.rb
138
+ - test/fixtures/write_file_alternate_spec.rb
119
139
  - test/fixtures/sync_test.rb
120
140
  - test/fixtures/assert_true.rb
121
- - test/fixtures/hello_world.rb
122
- - test/fixtures/features/step_definitions.rb
123
- - test/master_test.rb
124
- - test/worker_test.rb
125
141
  - test/runner_test.rb
126
- - test/pipe_test.rb
142
+ - test/worker_test.rb