parallel_tests 0.11.1 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- parallel_tests (0.11.1)
4
+ parallel_tests (0.11.2)
5
5
  parallel
6
6
 
7
7
  GEM
data/Readme.md CHANGED
@@ -5,7 +5,7 @@ ParallelTests splits tests into even groups(by number of tests or runtime) and r
5
5
 
6
6
  Setup for Rails
7
7
  ===============
8
- [RailsCasts episode #413 Fast Tests](http://railscasts.com/episodes/413-fast-tests)
8
+ [RailsCasts episode #413 Fast Tests](http://railscasts.com/episodes/413-fast-tests)
9
9
  [still using Rails 2?](https://github.com/grosser/parallel_tests/blob/master/ReadmeRails2.md)
10
10
 
11
11
  ### Install
@@ -139,6 +139,24 @@ Add the following to your `.rspec_parallel` (or `.rspec`) :
139
139
  --format progress
140
140
  --format ParallelTests::RSpec::FailuresLogger --out tmp/failing_specs.log
141
141
 
142
+ Cucumber: FailuresLogger
143
+ -----------------------
144
+
145
+ This logger logs failed cucumber scenarios to the specified file. The filename can be passed to cucumber, prefixed with '@' to rerun failures.
146
+
147
+ Usage:
148
+
149
+ cucumber --format ParallelTests::Cucumber::FailuresLogger --out tmp/cucumber_failures.log
150
+
151
+ Or add the formatter to the `parallel:` profile of your `cucumber.yml`:
152
+
153
+ parallel: --format progress --format ParallelTests::Cucumber::FailuresLogger --out tmp/cucumber_failures.log
154
+
155
+
156
+ To rerun failures:
157
+
158
+ cucumber @tmp/cucumber_failures.log
159
+
142
160
  Setup for non-rails
143
161
  ===================
144
162
  gem install parallel_tests
@@ -263,6 +281,7 @@ inspired by [pivotal labs](http://pivotallabs.com/users/miked/blog/articles/849-
263
281
  - [Ari Pollak](https://github.com/aripollak)
264
282
  - [Aaron Jensen](https://github.com/aaronjensen)
265
283
  - [Artur Roszczyk](https://github.com/sevos)
284
+ - [Caleb Tomlinson](https://github.com/calebTomlinson)
266
285
 
267
286
  [Michael Grosser](http://grosser.it)<br/>
268
287
  michael@grosser.it<br/>
@@ -0,0 +1,24 @@
1
+ require 'cucumber/formatter/rerun'
2
+
3
+ module ParallelTests
4
+ module Cucumber
5
+ class FailuresLogger < ::Cucumber::Formatter::Rerun
6
+ include Io
7
+
8
+ def initialize(runtime, path_or_io, options)
9
+ @io = prepare_io(path_or_io)
10
+ end
11
+
12
+ def after_feature(feature)
13
+ unless @lines.empty?
14
+ lock_output do
15
+ @lines.each do |line|
16
+ @io.puts "#{feature.file}:#{line}"
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,39 @@
1
+ module ParallelTests
2
+ module Cucumber
3
+ module Io
4
+
5
+ def prepare_io(path_or_io)
6
+ if path_or_io.respond_to?(:write)
7
+ path_or_io
8
+ else # its a path
9
+ File.open(path_or_io, 'w').close # clean out the file
10
+ file = File.open(path_or_io, 'a')
11
+
12
+ at_exit do
13
+ unless file.closed?
14
+ file.flush
15
+ file.close
16
+ end
17
+ end
18
+
19
+ file
20
+ end
21
+ end
22
+
23
+ # do not let multiple processes get in each others way
24
+ def lock_output
25
+ if File === @io
26
+ begin
27
+ @io.flock File::LOCK_EX
28
+ yield
29
+ ensure
30
+ @io.flock File::LOCK_UN
31
+ end
32
+ else
33
+ yield
34
+ end
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -1,6 +1,10 @@
1
+ require 'parallel_tests/cucumber/io'
2
+
1
3
  module ParallelTests
2
4
  module Cucumber
3
5
  class RuntimeLogger
6
+ include Io
7
+
4
8
  def initialize(step_mother, path_or_io, options=nil)
5
9
  @io = prepare_io(path_or_io)
6
10
  @example_times = Hash.new(0)
@@ -19,40 +23,6 @@ module ParallelTests
19
23
  @io.puts @example_times.map { |file, time| "#{file}:#{time}" }
20
24
  end
21
25
  end
22
-
23
- private
24
-
25
- def prepare_io(path_or_io)
26
- if path_or_io.respond_to?(:write)
27
- path_or_io
28
- else # its a path
29
- File.open(path_or_io, 'w').close # clean out the file
30
- file = File.open(path_or_io, 'a')
31
-
32
- at_exit do
33
- unless file.closed?
34
- file.flush
35
- file.close
36
- end
37
- end
38
-
39
- file
40
- end
41
- end
42
-
43
- # do not let multiple processes get in each others way
44
- def lock_output
45
- if File === @io
46
- begin
47
- @io.flock File::LOCK_EX
48
- yield
49
- ensure
50
- @io.flock File::LOCK_UN
51
- end
52
- else
53
- yield
54
- end
55
- end
56
26
  end
57
27
  end
58
28
  end
@@ -1,3 +1,3 @@
1
1
  module ParallelTests
2
- VERSION = Version = '0.11.1'
2
+ VERSION = Version = '0.11.2'
3
3
  end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+ require 'parallel_tests/cucumber/io'
3
+ require 'parallel_tests/cucumber/failures_logger'
4
+
5
+ describe ParallelTests::Cucumber::FailuresLogger do
6
+
7
+ before do
8
+ @output = OutputLogger.new([])
9
+ @output.stub(:write)
10
+
11
+ @logger1 = ParallelTests::Cucumber::FailuresLogger.new(nil, @output, nil)
12
+ @logger2 = ParallelTests::Cucumber::FailuresLogger.new(nil, @output, nil)
13
+ @logger3 = ParallelTests::Cucumber::FailuresLogger.new(nil, @output, nil)
14
+
15
+ @feature1 = mock('feature', :file => "feature/path/to/feature1.feature")
16
+ @feature2 = mock('feature', :file => "feature/path/to/feature2.feature")
17
+ @feature3 = mock('feature', :file => "feature/path/to/feature3.feature")
18
+
19
+ @logger1.instance_variable_set("@lines", [1, 2, 3])
20
+ @logger2.instance_variable_set("@lines", [2, 4, 6])
21
+ @logger3.instance_variable_set("@lines", [3, 6, 9])
22
+ end
23
+
24
+ it "should produce a list of lines for failing scenarios" do
25
+ @logger1.after_feature(@feature1)
26
+ @logger2.after_feature(@feature2)
27
+ @logger3.after_feature(@feature3)
28
+
29
+ output_file_contents = @output.output.join("\n").concat("\n")
30
+
31
+ output_file_contents.should == <<END
32
+ feature/path/to/feature1.feature:1
33
+ feature/path/to/feature1.feature:2
34
+ feature/path/to/feature1.feature:3
35
+ feature/path/to/feature2.feature:2
36
+ feature/path/to/feature2.feature:4
37
+ feature/path/to/feature2.feature:6
38
+ feature/path/to/feature3.feature:3
39
+ feature/path/to/feature3.feature:6
40
+ feature/path/to/feature3.feature:9
41
+ END
42
+ end
43
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.11.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-24 00:00:00.000000000 Z
12
+ date: 2013-04-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: parallel
@@ -49,7 +49,9 @@ files:
49
49
  - bin/parallel_test
50
50
  - lib/parallel_tests.rb
51
51
  - lib/parallel_tests/cli.rb
52
+ - lib/parallel_tests/cucumber/failures_logger.rb
52
53
  - lib/parallel_tests/cucumber/gherkin_listener.rb
54
+ - lib/parallel_tests/cucumber/io.rb
53
55
  - lib/parallel_tests/cucumber/runner.rb
54
56
  - lib/parallel_tests/cucumber/runtime_logger.rb
55
57
  - lib/parallel_tests/grouper.rb
@@ -66,6 +68,7 @@ files:
66
68
  - parallel_tests.gemspec
67
69
  - spec/integration_spec.rb
68
70
  - spec/parallel_tests/cli_spec.rb
71
+ - spec/parallel_tests/cucumber/failure_logger_spec.rb
69
72
  - spec/parallel_tests/cucumber/gherkin_listener_spec.rb
70
73
  - spec/parallel_tests/cucumber/runner_spec.rb
71
74
  - spec/parallel_tests/grouper_spec.rb
@@ -93,7 +96,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
96
  version: '0'
94
97
  segments:
95
98
  - 0
96
- hash: -2228053499352870205
99
+ hash: 2511710589731106807
97
100
  required_rubygems_version: !ruby/object:Gem::Requirement
98
101
  none: false
99
102
  requirements:
@@ -102,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
105
  version: '0'
103
106
  segments:
104
107
  - 0
105
- hash: -2228053499352870205
108
+ hash: 2511710589731106807
106
109
  requirements: []
107
110
  rubyforge_project:
108
111
  rubygems_version: 1.8.25