hydra 0.15.0 → 0.15.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +17 -3
- data/VERSION +1 -1
- data/hydra.gemspec +3 -2
- data/lib/hydra/cucumber/formatter.rb +1 -2
- data/lib/hydra/runner.rb +38 -35
- data/test/fixtures/features/step_definitions.rb +4 -0
- data/test/fixtures/features/write_alternate_file.feature +7 -0
- data/test/runner_test.rb +19 -7
- data/test/test_helper.rb +8 -0
- metadata +3 -2
data/README.rdoc
CHANGED
@@ -20,12 +20,9 @@ In your rakefile:
|
|
20
20
|
require 'hydra/tasks'
|
21
21
|
|
22
22
|
Hydra::TestTask.new('hydra') do |t|
|
23
|
-
# test unit
|
24
23
|
t.add_files 'test/unit/**/*_test.rb'
|
25
24
|
t.add_files 'test/functional/**/*_test.rb'
|
26
25
|
t.add_files 'test/integration/**/*_test.rb'
|
27
|
-
# cucumber
|
28
|
-
t.add_files 'features/**/*.feature'
|
29
26
|
end
|
30
27
|
|
31
28
|
Run:
|
@@ -35,6 +32,23 @@ Run:
|
|
35
32
|
Hydra defaults to Single Core mode, so you may want to configure it
|
36
33
|
to use two (or more) of your cores if you have a multi-processing machine.
|
37
34
|
|
35
|
+
== Hydra + Cucumber
|
36
|
+
|
37
|
+
Hydra can run cucumber features, but because of cucumber's specialized
|
38
|
+
environment, cucumber features have to be run after your other tests.
|
39
|
+
|
40
|
+
Hydra::TestTask.new('hydra') do |t|
|
41
|
+
t.add_files 'test/unit/**/*_test.rb'
|
42
|
+
t.add_files 'test/functional/**/*_test.rb'
|
43
|
+
t.add_files 'test/integration/**/*_test.rb'
|
44
|
+
# cucumber
|
45
|
+
t.autosort = false
|
46
|
+
t.add_files 'features/**/*.feature'
|
47
|
+
end
|
48
|
+
|
49
|
+
Hydra's autosort feature sorts files by their runtime, so we
|
50
|
+
have to disable it in order to run cucumber features at the end
|
51
|
+
|
38
52
|
== Supported frameworks
|
39
53
|
|
40
54
|
Right now hydra only supports a few frameworks:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.15.
|
1
|
+
0.15.1
|
data/hydra.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{hydra}
|
8
|
-
s.version = "0.15.
|
8
|
+
s.version = "0.15.1"
|
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-
|
12
|
+
s.date = %q{2010-03-31}
|
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 = [
|
@@ -54,6 +54,7 @@ Gem::Specification.new do |s|
|
|
54
54
|
"test/fixtures/assert_true.rb",
|
55
55
|
"test/fixtures/config.yml",
|
56
56
|
"test/fixtures/features/step_definitions.rb",
|
57
|
+
"test/fixtures/features/write_alternate_file.feature",
|
57
58
|
"test/fixtures/features/write_file.feature",
|
58
59
|
"test/fixtures/hello_world.rb",
|
59
60
|
"test/fixtures/slow.rb",
|
data/lib/hydra/runner.rb
CHANGED
@@ -44,6 +44,7 @@ module Hydra #:nodoc:
|
|
44
44
|
output = "." if output == ""
|
45
45
|
|
46
46
|
@io.write Results.new(:output => output, :file => file)
|
47
|
+
return output
|
47
48
|
end
|
48
49
|
|
49
50
|
# Stop running
|
@@ -114,48 +115,38 @@ module Hydra #:nodoc:
|
|
114
115
|
|
115
116
|
# run all the scenarios in a cucumber feature file
|
116
117
|
def run_cucumber_file(file)
|
117
|
-
require 'cucumber'
|
118
|
-
require 'cucumber/formatter/progress'
|
119
|
-
require 'hydra/cucumber/formatter'
|
120
|
-
def tag_excess(features, limits)
|
121
|
-
limits.map do |tag_name, tag_limit|
|
122
|
-
tag_locations = features.tag_locations(tag_name)
|
123
|
-
if tag_limit && (tag_locations.length > tag_limit)
|
124
|
-
[tag_name, tag_limit, tag_locations]
|
125
|
-
else
|
126
|
-
nil
|
127
|
-
end
|
128
|
-
end.compact
|
129
|
-
end
|
130
118
|
|
131
119
|
files = [file]
|
132
120
|
dev_null = StringIO.new
|
133
|
-
|
134
|
-
options = Cucumber::Cli::Options.new
|
135
|
-
configuration = Cucumber::Cli::Configuration.new(dev_null, dev_null)
|
136
|
-
configuration.parse!([]+files)
|
137
|
-
step_mother = Cucumber::StepMother.new
|
138
|
-
|
139
|
-
step_mother.options = configuration.options
|
140
|
-
step_mother.log = configuration.log
|
141
|
-
step_mother.load_code_files(configuration.support_to_load)
|
142
|
-
step_mother.after_configuration(configuration)
|
143
|
-
features = step_mother.load_plain_text_features(files)
|
144
|
-
step_mother.load_code_files(configuration.step_defs_to_load)
|
145
|
-
|
146
|
-
tag_excess = tag_excess(features, configuration.options[:tag_expression].limits)
|
147
|
-
configuration.options[:tag_excess] = tag_excess
|
148
|
-
|
149
121
|
hydra_response = StringIO.new
|
150
|
-
|
151
|
-
|
122
|
+
|
123
|
+
unless @step_mother
|
124
|
+
require 'cucumber'
|
125
|
+
require 'hydra/cucumber/formatter'
|
126
|
+
@step_mother = Cucumber::StepMother.new
|
127
|
+
@cuke_configuration = Cucumber::Cli::Configuration.new(dev_null, dev_null)
|
128
|
+
@cuke_configuration.parse!(['features']+files)
|
129
|
+
|
130
|
+
@step_mother.options = @cuke_configuration.options
|
131
|
+
@step_mother.log = @cuke_configuration.log
|
132
|
+
@step_mother.load_code_files(@cuke_configuration.support_to_load)
|
133
|
+
@step_mother.after_configuration(@cuke_configuration)
|
134
|
+
@step_mother.load_code_files(@cuke_configuration.step_defs_to_load)
|
135
|
+
end
|
136
|
+
cuke_formatter = Cucumber::Formatter::Hydra.new(
|
137
|
+
@step_mother, hydra_response, @cuke_configuration.options
|
152
138
|
)
|
153
139
|
|
154
|
-
|
155
|
-
step_mother, [
|
140
|
+
cuke_runner ||= Cucumber::Ast::TreeWalker.new(
|
141
|
+
@step_mother, [cuke_formatter], @cuke_configuration.options, dev_null
|
156
142
|
)
|
157
|
-
step_mother.visitor =
|
158
|
-
|
143
|
+
@step_mother.visitor = cuke_runner
|
144
|
+
|
145
|
+
features = @step_mother.load_plain_text_features(files)
|
146
|
+
tag_excess = tag_excess(features, @cuke_configuration.options[:tag_expression].limits)
|
147
|
+
@cuke_configuration.options[:tag_excess] = tag_excess
|
148
|
+
|
149
|
+
cuke_runner.visit_features(features)
|
159
150
|
|
160
151
|
hydra_response.rewind
|
161
152
|
return hydra_response.read
|
@@ -184,5 +175,17 @@ module Hydra #:nodoc:
|
|
184
175
|
end
|
185
176
|
return klasses.select{|k| k.respond_to? 'suite'}
|
186
177
|
end
|
178
|
+
|
179
|
+
# Yanked a method from Cucumber
|
180
|
+
def tag_excess(features, limits)
|
181
|
+
limits.map do |tag_name, tag_limit|
|
182
|
+
tag_locations = features.tag_locations(tag_name)
|
183
|
+
if tag_limit && (tag_locations.length > tag_limit)
|
184
|
+
[tag_name, tag_limit, tag_locations]
|
185
|
+
else
|
186
|
+
nil
|
187
|
+
end
|
188
|
+
end.compact
|
189
|
+
end
|
187
190
|
end
|
188
191
|
end
|
@@ -2,6 +2,10 @@ Given /^a target file$/ do
|
|
2
2
|
@target_file = File.expand_path(File.join(Dir.tmpdir, 'hydra_test.txt'))
|
3
3
|
end
|
4
4
|
|
5
|
+
Given /^an alternate target file$/ do
|
6
|
+
@target_file = File.expand_path(File.join(Dir.tmpdir, 'alternate_hydra_test.txt'))
|
7
|
+
end
|
8
|
+
|
5
9
|
When /^I write "([^\"]*)" to the file$/ do |text|
|
6
10
|
f = File.new(@target_file, 'w')
|
7
11
|
f.write text
|
data/test/runner_test.rb
CHANGED
@@ -5,10 +5,12 @@ class RunnerTest < Test::Unit::TestCase
|
|
5
5
|
setup do
|
6
6
|
sleep(0.2)
|
7
7
|
FileUtils.rm_f(target_file)
|
8
|
+
FileUtils.rm_f(alternate_target_file)
|
8
9
|
end
|
9
10
|
|
10
11
|
teardown do
|
11
12
|
FileUtils.rm_f(target_file)
|
13
|
+
FileUtils.rm_f(alternate_target_file)
|
12
14
|
end
|
13
15
|
|
14
16
|
|
@@ -35,13 +37,22 @@ class RunnerTest < Test::Unit::TestCase
|
|
35
37
|
Process.wait(child)
|
36
38
|
end
|
37
39
|
|
38
|
-
should "run
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
+
|
44
|
+
runner = Hydra::Runner.new(:io => File.new('/dev/null', 'w'))
|
45
|
+
runner.run_file(cucumber_feature_file)
|
46
|
+
assert File.exists?(target_file)
|
47
|
+
assert_equal "HYDRA", File.read(target_file)
|
48
|
+
|
49
|
+
FileUtils.rm_f(target_file)
|
50
|
+
|
51
|
+
runner.run_file(alternate_cucumber_feature_file)
|
52
|
+
assert File.exists?(alternate_target_file)
|
53
|
+
assert_equal "HYDRA", File.read(alternate_target_file)
|
54
|
+
|
55
|
+
puts "END IGNORABLE OUTPUT"
|
45
56
|
end
|
46
57
|
|
47
58
|
should "be able to run a runner over ssh" do
|
@@ -80,6 +91,7 @@ class RunnerTest < Test::Unit::TestCase
|
|
80
91
|
|
81
92
|
# grab its response. This makes us wait for it to finish
|
82
93
|
response = pipe.gets
|
94
|
+
puts response.output
|
83
95
|
|
84
96
|
# tell it to shut down
|
85
97
|
pipe.write(Hydra::Messages::Worker::Shutdown.new)
|
data/test/test_helper.rb
CHANGED
@@ -14,6 +14,10 @@ class Test::Unit::TestCase
|
|
14
14
|
def target_file
|
15
15
|
File.expand_path(File.join(Dir.tmpdir, 'hydra_test.txt'))
|
16
16
|
end
|
17
|
+
|
18
|
+
def alternate_target_file
|
19
|
+
File.expand_path(File.join(Dir.tmpdir, 'alternate_hydra_test.txt'))
|
20
|
+
end
|
17
21
|
|
18
22
|
def test_file
|
19
23
|
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'write_file.rb'))
|
@@ -22,6 +26,10 @@ class Test::Unit::TestCase
|
|
22
26
|
def cucumber_feature_file
|
23
27
|
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'features', 'write_file.feature'))
|
24
28
|
end
|
29
|
+
|
30
|
+
def alternate_cucumber_feature_file
|
31
|
+
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'features', 'write_alternate_file.feature'))
|
32
|
+
end
|
25
33
|
end
|
26
34
|
|
27
35
|
module Hydra #:nodoc:
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Gauthier
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-03-
|
12
|
+
date: 2010-03-31 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- test/fixtures/assert_true.rb
|
70
70
|
- test/fixtures/config.yml
|
71
71
|
- test/fixtures/features/step_definitions.rb
|
72
|
+
- test/fixtures/features/write_alternate_file.feature
|
72
73
|
- test/fixtures/features/write_file.feature
|
73
74
|
- test/fixtures/hello_world.rb
|
74
75
|
- test/fixtures/slow.rb
|