parallel_tests 0.9.0 → 0.9.1
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/Gemfile.lock +1 -1
- data/Readme.md +2 -0
- data/lib/parallel_tests/cli.rb +1 -0
- data/lib/parallel_tests/cucumber/gherkin_listener.rb +25 -3
- data/lib/parallel_tests/cucumber/runner.rb +1 -1
- data/lib/parallel_tests/grouper.rb +6 -3
- data/lib/parallel_tests/version.rb +1 -1
- data/spec/parallel_tests/cucumber/gherkin_listener_spec.rb +49 -0
- data/spec/parallel_tests/grouper_spec.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/Readme.md
CHANGED
@@ -139,6 +139,7 @@ Options are:
|
|
139
139
|
-t, --type [TYPE] test(default) / rspec / cucumber
|
140
140
|
--non-parallel execute same commands but do not in parallel, needs --exec
|
141
141
|
--no-symlinks Do not traverse symbolic links to find test files
|
142
|
+
--ignore-tags [PATTERN] When counting steps ignore scenarios with tags that match this pattern
|
142
143
|
-v, --version Show Version
|
143
144
|
-h, --help Show this.
|
144
145
|
|
@@ -226,6 +227,7 @@ inspired by [pivotal labs](http://pivotallabs.com/users/miked/blog/articles/849-
|
|
226
227
|
- [Florian Motlik](https://github.com/flomotlik)
|
227
228
|
- [Artem Kuzko](https://github.com/akuzko)
|
228
229
|
- [Zeke Fast](https://github.com/zekefast)
|
230
|
+
- [Joseph Shraibman](https://github.com/jshraibman-mdsol)
|
229
231
|
|
230
232
|
[Michael Grosser](http://grosser.it)<br/>
|
231
233
|
michael@grosser.it<br/>
|
data/lib/parallel_tests/cli.rb
CHANGED
@@ -108,6 +108,7 @@ TEXT
|
|
108
108
|
opts.on("-t", "--type [TYPE]", "test(default) / rspec / cucumber") { |type| options[:type] = type }
|
109
109
|
opts.on("--non-parallel", "execute same commands but do not in parallel, needs --exec") { options[:non_parallel] = true }
|
110
110
|
opts.on("--no-symlinks", "Do not traverse symbolic links to find test files") { options[:symlinks] = false }
|
111
|
+
opts.on('--ignore-tags [PATTERN]', 'When counting steps ignore scenarios with tags that match this pattern') { |arg| options[:ignore_tag_pattern] = arg }
|
111
112
|
opts.on("-v", "--version", "Show Version") { puts ParallelTests::VERSION; exit }
|
112
113
|
opts.on("-h", "--help", "Show this.") { puts opts; exit }
|
113
114
|
end.parse!(argv)
|
@@ -5,26 +5,35 @@ module ParallelTests
|
|
5
5
|
class GherkinListener
|
6
6
|
attr_reader :collect
|
7
7
|
|
8
|
+
attr_writer :ignore_tag_pattern
|
9
|
+
|
8
10
|
def initialize
|
9
11
|
@steps, @uris = [], []
|
10
12
|
@collect = {}
|
11
13
|
reset_counters!
|
12
14
|
end
|
13
15
|
|
16
|
+
def feature(feature)
|
17
|
+
@feature = feature
|
18
|
+
end
|
19
|
+
|
14
20
|
def background(*args)
|
15
21
|
@background = 1
|
16
22
|
end
|
17
23
|
|
18
|
-
def scenario(
|
19
|
-
@scenarios += 1
|
24
|
+
def scenario(scenario)
|
20
25
|
@outline = @background = 0
|
26
|
+
return if should_ignore(scenario)
|
27
|
+
@scenarios += 1
|
21
28
|
end
|
22
29
|
|
23
|
-
def scenario_outline(
|
30
|
+
def scenario_outline(outline)
|
31
|
+
return if should_ignore(outline)
|
24
32
|
@outline = 1
|
25
33
|
end
|
26
34
|
|
27
35
|
def step(*args)
|
36
|
+
return if @ignoring
|
28
37
|
if @background == 1
|
29
38
|
@background_steps += 1
|
30
39
|
elsif @outline > 0
|
@@ -50,11 +59,24 @@ module ParallelTests
|
|
50
59
|
|
51
60
|
def reset_counters!
|
52
61
|
@examples = @outline = @outline_steps = @background = @background_steps = @scenarios = 0
|
62
|
+
@ignoring = nil
|
53
63
|
end
|
54
64
|
|
55
65
|
# ignore lots of other possible callbacks ...
|
56
66
|
def method_missing(*args)
|
57
67
|
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
# Return a combination of tags declared on this scenario/outline and the feature it belongs to
|
72
|
+
def all_tags(scenario)
|
73
|
+
(scenario.tags || []) + ((@feature && @feature.tags) || [])
|
74
|
+
end
|
75
|
+
|
76
|
+
# Set @ignoring if we should ignore this scenario/outline based on its tags
|
77
|
+
def should_ignore(scenario)
|
78
|
+
@ignoring = @ignore_tag_pattern && all_tags(scenario).find{ |tag| @ignore_tag_pattern === tag.name }
|
79
|
+
end
|
58
80
|
end
|
59
81
|
end
|
60
82
|
end
|
@@ -80,7 +80,7 @@ module ParallelTests
|
|
80
80
|
|
81
81
|
def self.tests_in_groups(tests, num_groups, options={})
|
82
82
|
if options[:group_by] == :steps
|
83
|
-
Grouper.by_steps(find_tests(tests, options), num_groups)
|
83
|
+
Grouper.by_steps(find_tests(tests, options), num_groups, options)
|
84
84
|
else
|
85
85
|
super
|
86
86
|
end
|
@@ -35,14 +35,17 @@ module ParallelTests
|
|
35
35
|
group[:size] += size
|
36
36
|
end
|
37
37
|
|
38
|
-
def self.by_steps(tests, num_groups)
|
39
|
-
features_with_steps = build_features_with_steps(tests)
|
38
|
+
def self.by_steps(tests, num_groups, options)
|
39
|
+
features_with_steps = build_features_with_steps(tests, options)
|
40
40
|
in_even_groups_by_size(features_with_steps, num_groups)
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
private
|
44
|
+
|
45
|
+
def self.build_features_with_steps(tests, options)
|
44
46
|
require 'parallel_tests/cucumber/gherkin_listener'
|
45
47
|
listener = Cucumber::GherkinListener.new
|
48
|
+
listener.ignore_tag_pattern = Regexp.compile(options[:ignore_tag_pattern]) if options[:ignore_tag_pattern]
|
46
49
|
parser = Gherkin::Parser::Parser.new(listener, true, 'root')
|
47
50
|
tests.each{|file|
|
48
51
|
parser.parse(File.read(file), file, 0)
|
@@ -44,5 +44,54 @@ describe ParallelTests::Cucumber::GherkinListener do
|
|
44
44
|
@listener.eof
|
45
45
|
@listener.collect.should == {"feature_file" => 17}
|
46
46
|
end
|
47
|
+
|
48
|
+
it 'counts scenarios that should not be ignored' do
|
49
|
+
@listener.ignore_tag_pattern = nil
|
50
|
+
@listener.scenario( stub('scenario', :tags =>[ stub('tag', :name => '@WIP' )]) )
|
51
|
+
@listener.step(nil)
|
52
|
+
@listener.eof
|
53
|
+
@listener.collect.should == {"feature_file" => 1}
|
54
|
+
|
55
|
+
@listener.ignore_tag_pattern = /@something_other_than_WIP/
|
56
|
+
@listener.scenario( stub('scenario', :tags =>[ stub('tag', :name => '@WIP' )]) )
|
57
|
+
@listener.step(nil)
|
58
|
+
@listener.eof
|
59
|
+
@listener.collect.should == {"feature_file" => 2}
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'does not count scenarios that should be ignored' do
|
63
|
+
@listener.ignore_tag_pattern = /@WIP/
|
64
|
+
@listener.scenario( stub('scenario', :tags =>[ stub('tag', :name => '@WIP' )]))
|
65
|
+
@listener.step(nil)
|
66
|
+
@listener.eof
|
67
|
+
@listener.collect.should == {"feature_file" => 0}
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'counts outlines that should not be ignored' do
|
71
|
+
@listener.ignore_tag_pattern = nil
|
72
|
+
@listener.scenario_outline( stub('scenario', :tags =>[ stub('tag', :name => '@WIP' )]) )
|
73
|
+
@listener.step(nil)
|
74
|
+
3.times {@listener.examples}
|
75
|
+
@listener.eof
|
76
|
+
@listener.collect.should == {"feature_file" => 3}
|
77
|
+
|
78
|
+
|
79
|
+
@listener.ignore_tag_pattern = /@something_other_than_WIP/
|
80
|
+
@listener.scenario_outline( stub('scenario', :tags =>[ stub('tag', :name => '@WIP' )]) )
|
81
|
+
@listener.step(nil)
|
82
|
+
3.times {@listener.examples}
|
83
|
+
@listener.eof
|
84
|
+
@listener.collect.should == {"feature_file" => 6}
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'does not count outlines that should be ignored' do
|
88
|
+
@listener.ignore_tag_pattern = /@WIP/
|
89
|
+
@listener.scenario_outline( stub('scenario', :tags =>[ stub('tag', :name => '@WIP' )]) )
|
90
|
+
@listener.step(nil)
|
91
|
+
3.times {@listener.examples}
|
92
|
+
@listener.eof
|
93
|
+
@listener.collect.should == {"feature_file" => 0}
|
94
|
+
end
|
95
|
+
|
47
96
|
end
|
48
97
|
end
|
@@ -15,7 +15,7 @@ describe ParallelTests::Grouper do
|
|
15
15
|
write("#{dir}/a.feature", "Feature: xxx\n Scenario: xxx\n Given something")
|
16
16
|
write("#{dir}/b.feature", "Feature: xxx\n Scenario: xxx\n Given something\n Scenario: yyy\n Given something")
|
17
17
|
write("#{dir}/c.feature", "Feature: xxx\n Scenario: xxx\n Given something")
|
18
|
-
ParallelTests::Grouper.by_steps(["#{dir}/a.feature", "#{dir}/b.feature", "#{dir}/c.feature"],2)
|
18
|
+
ParallelTests::Grouper.by_steps(["#{dir}/a.feature", "#{dir}/b.feature", "#{dir}/c.feature"], 2, {})
|
19
19
|
end
|
20
20
|
|
21
21
|
# testing inside mktmpdir is always green
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: parallel_tests
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.9.
|
5
|
+
version: 0.9.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Michael Grosser
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -90,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
90
|
version: '0'
|
91
91
|
segments:
|
92
92
|
- 0
|
93
|
-
hash:
|
93
|
+
hash: 3154313804102056863
|
94
94
|
none: false
|
95
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
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:
|
102
|
+
hash: 3154313804102056863
|
103
103
|
none: false
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project:
|