parallel_tests 0.8.4 → 0.8.5

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.8.4)
4
+ parallel_tests (0.8.5)
5
5
  parallel
6
6
 
7
7
  GEM
data/Readme.md CHANGED
@@ -169,6 +169,7 @@ TIPS
169
169
  - `export PARALLEL_TEST_PROCESSORS=X` in your environment and parallel_tests will use this number of processors by default
170
170
  - [ZSH] use quotes to use rake arguments `rake "parallel:prepare[3]"`
171
171
  - [email_spec and/or action_mailer_cache_delivery](https://github.com/grosser/parallel_tests/wiki)
172
+ - [Memcached] use different namespaces e.g. `config.cache_store = ..., :namespace => "test_#{ENV['TEST_ENV_NUMBER']}"`
172
173
 
173
174
  TODO
174
175
  ====
@@ -213,6 +214,8 @@ inspired by [pivotal labs](http://pivotallabs.com/users/miked/blog/articles/849-
213
214
  - [Pablo Manrubia Díez](https://github.com/pmanrubia)
214
215
  - [Slawomir Smiechura](https://github.com/ssmiech)
215
216
  - [Georg Friedrich](https://github.com/georg)
217
+ - [R. Tyler Croy](https://github.com/rtyler)
218
+ - [Ulrich Berkmüller](https://github.com/ulrich-berkmueller)
216
219
 
217
220
  [Michael Grosser](http://grosser.it)<br/>
218
221
  michael@grosser.it<br/>
@@ -39,7 +39,27 @@ module ParallelTests
39
39
  end
40
40
 
41
41
  def self.line_is_result?(line)
42
- line =~ /^\d+ (steps|scenarios)/
42
+ line =~ /^\d+ (steps?|scenarios?)/
43
+ end
44
+
45
+ # cucumber has 2 result lines per test run, that cannot be added
46
+ # 1 scenario (1 failed)
47
+ # 1 step (1 failed)
48
+ def self.summarize_results(results)
49
+ sort_order = %w[scenario step failed undefined skipped pending passed]
50
+
51
+ %w[scenario step].map do |group|
52
+ group_results = results.grep /^\d+ #{group}/
53
+ next if group_results.empty?
54
+
55
+ sums = sum_up_results(group_results)
56
+ sums = sums.sort_by { |word, _| sort_order.index(word) || 999 }
57
+ sums.map! do |word, number|
58
+ plural = "s" if word == group and number != 1
59
+ "#{number} #{word}#{plural}"
60
+ end
61
+ "#{sums[0]} (#{sums[1..-1].join(", ")})"
62
+ end.compact.join("\n")
43
63
  end
44
64
 
45
65
  def self.cucumber_opts(given)
@@ -60,17 +60,22 @@ module ParallelTests
60
60
  end
61
61
 
62
62
  def self.summarize_results(results)
63
+ sums = sum_up_results(results)
64
+ sums.sort.map{|word, number| "#{number} #{word}#{'s' if number != 1}" }.join(', ')
65
+ end
66
+
67
+ protected
68
+
69
+ def self.sum_up_results(results)
63
70
  results = results.join(' ').gsub(/s\b/,'') # combine and singularize results
64
71
  counts = results.scan(/(\d+) (\w+)/)
65
72
  sums = counts.inject(Hash.new(0)) do |sum, (number, word)|
66
73
  sum[word] += number.to_i
67
74
  sum
68
75
  end
69
- sums.sort.map{|word, number| "#{number} #{word}#{'s' if number != 1}" }.join(', ')
76
+ sums
70
77
  end
71
78
 
72
- protected
73
-
74
79
  # read output of the process and print in in chucks
75
80
  def self.fetch_output(process, options)
76
81
  all = ''
@@ -1,3 +1,3 @@
1
1
  module ParallelTests
2
- VERSION = Version = '0.8.4'
2
+ VERSION = Version = '0.8.5'
3
3
  end
@@ -91,6 +91,33 @@ describe ParallelTests::Cucumber do
91
91
  end
92
92
  end
93
93
 
94
+ describe :line_is_result? do
95
+ it "should match lines with only one scenario" do
96
+ line = "1 scenario (1 failed)"
97
+ ParallelTests::Cucumber::Runner.line_is_result?(line).should be_true
98
+ end
99
+
100
+ it "should match lines with multiple scenarios" do
101
+ line = "2 scenarios (1 failed, 1 passed)"
102
+ ParallelTests::Cucumber::Runner.line_is_result?(line).should be_true
103
+ end
104
+
105
+ it "should match lines with only one step" do
106
+ line = "1 step (1 failed)"
107
+ ParallelTests::Cucumber::Runner.line_is_result?(line).should be_true
108
+ end
109
+
110
+ it "should match lines with multiple steps" do
111
+ line = "5 steps (1 failed, 4 passed)"
112
+ ParallelTests::Cucumber::Runner.line_is_result?(line).should be_true
113
+ end
114
+
115
+ it "should not match other lines" do
116
+ line = ' And I should have "2" emails # features/step_definitions/user_steps.rb:25'
117
+ ParallelTests::Cucumber::Runner.line_is_result?(line).should be_false
118
+ end
119
+ end
120
+
94
121
  describe :find_results do
95
122
  it "finds multiple results in test output" do
96
123
  output = <<EOF
@@ -106,8 +133,41 @@ And I should not see "/en/" # features/ste
106
133
  4 scenarios (4 passed)
107
134
  40 steps (40 passed)
108
135
 
136
+ And I should not see "foo" # features/step_definitions/webrat_steps.rb:87
137
+
138
+ 1 scenario (1 passed)
139
+ 1 step (1 passed)
140
+
109
141
  EOF
110
- ParallelTests::Cucumber::Runner.find_results(output).should == ["7 scenarios (3 failed, 4 passed)", "33 steps (3 failed, 2 skipped, 28 passed)", "4 scenarios (4 passed)", "40 steps (40 passed)"]
142
+ ParallelTests::Cucumber::Runner.find_results(output).should == ["7 scenarios (3 failed, 4 passed)", "33 steps (3 failed, 2 skipped, 28 passed)", "4 scenarios (4 passed)", "40 steps (40 passed)", "1 scenario (1 passed)", "1 step (1 passed)"]
143
+ end
144
+ end
145
+
146
+ describe :summarize_results do
147
+ def call(*args)
148
+ ParallelTests::Cucumber::Runner.summarize_results(*args)
149
+ end
150
+
151
+ it "sums up results for scenarios and steps separately from each other" do
152
+ results = ["7 scenarios (3 failed, 4 passed)", "33 steps (3 failed, 2 skipped, 28 passed)", "4 scenarios (4 passed)",
153
+ "40 steps (40 passed)", "1 scenario (1 passed)", "1 step (1 passed)"]
154
+ call(results).should == "12 scenarios (3 failed, 9 passed)\n74 steps (3 failed, 2 skipped, 69 passed)"
155
+ end
156
+
157
+ it "adds same results with plurals" do
158
+ results = ["1 scenario (1 passed)", "2 steps (2 passed)",
159
+ "2 scenarios (2 passed)", "7 steps (7 passed)"]
160
+ call(results).should == "3 scenarios (3 passed)\n9 steps (9 passed)"
161
+ end
162
+
163
+ it "adds non-similar results" do
164
+ results = ["1 scenario (1 passed)", "1 step (1 passed)",
165
+ "2 scenarios (1 failed, 1 pending)", "2 steps (1 failed, 1 pending)"]
166
+ call(results).should == "3 scenarios (1 failed, 1 pending, 1 passed)\n3 steps (1 failed, 1 pending, 1 passed)"
167
+ end
168
+
169
+ it "does not pluralize 1" do
170
+ call(["1 scenario (1 passed)", "1 step (1 passed)"]).should == "1 scenario (1 passed)\n1 step (1 passed)"
111
171
  end
112
172
  end
113
173
  end
@@ -4,6 +4,10 @@ describe ParallelTests::RSpec::SummaryLogger do
4
4
  let(:output){ OutputLogger.new([]) }
5
5
  let(:logger){ ParallelTests::RSpec::SummaryLogger.new(output) }
6
6
 
7
+ def decolorize(string)
8
+ string.gsub(/\e\[\d+m/,'')
9
+ end
10
+
7
11
  # TODO somehow generate a real example with an exception to test this
8
12
  xit "prints failing examples" do
9
13
  logger.example_failed XXX
@@ -20,7 +24,7 @@ describe ParallelTests::RSpec::SummaryLogger do
20
24
  logger.dump_failures
21
25
  output.output.should == []
22
26
  logger.dump_summary(1,2,3,4)
23
- output.output.should == ["\nFinished in 1 seconds\n", "\e[31m2 examples, 3 failures, 4 pending\e[0m"]
27
+ output.output.map{|o| decolorize(o) }.should == ["\nFinished in 1 seconds\n", "2 examples, 3 failures, 4 pending"]
24
28
  end
25
29
 
26
30
  it "does not print anything for pending examples" do
@@ -28,6 +32,6 @@ describe ParallelTests::RSpec::SummaryLogger do
28
32
  logger.dump_failures
29
33
  output.output.should == []
30
34
  logger.dump_summary(1,2,3,4)
31
- output.output.should == ["\nFinished in 1 seconds\n", "\e[31m2 examples, 3 failures, 4 pending\e[0m"]
35
+ output.output.map{|o| decolorize(o) }.should == ["\nFinished in 1 seconds\n", "2 examples, 3 failures, 4 pending"]
32
36
  end
33
37
  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.8.4
4
+ version: 0.8.5
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: 2012-07-09 00:00:00.000000000 Z
12
+ date: 2012-07-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: parallel
@@ -90,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  segments:
92
92
  - 0
93
- hash: -4352567482093763960
93
+ hash: -2098378474977036135
94
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  version: '0'
100
100
  segments:
101
101
  - 0
102
- hash: -4352567482093763960
102
+ hash: -2098378474977036135
103
103
  requirements: []
104
104
  rubyforge_project:
105
105
  rubygems_version: 1.8.24