parallel_tests 2.10.0 → 2.11.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f34b66a3c93d2d993a2dc48704ad2bea7efe9e9a
4
- data.tar.gz: c7e7d4c3086a9d5e22f6c6aedd88af52206f1e8d
3
+ metadata.gz: c698774063cf365ab657b0fda5f8ff791d08a5e3
4
+ data.tar.gz: 6f09e57121be15de5172a2503b458e4c045d4a21
5
5
  SHA512:
6
- metadata.gz: 3412a03740acb6cdbce200e985c945c49d5a686c9099639ca28811f8c49b902ff4295c1428d0cb33d500bfe75d274d74567f8dd19281a0f79c0998e420a62a68
7
- data.tar.gz: d03d689a49d61238f022bc1c55179aeed768e2ad52ad341f926ae837c42dd240198db9116da54222d92faf03878e751a40c22785901ee1e12364c60e631425a6
6
+ metadata.gz: 4e3af2ade6a79b80babbe78426450e2b8ca5ca8ad6da942939b71b0e87f5ee6976aca3634f692b8b0b9af5c99afaea7685b539184df6e1ca70c303441b6c0a39
7
+ data.tar.gz: a47ed561002b35cb792ab850b14b10a4581e435fac46481bb4f3cde0ac85d5e7ef6cfb6cdcb5c89159987f955913e16287cbc40e7652aa29d3bdf25893e6249a
data/Readme.md CHANGED
@@ -85,7 +85,7 @@ Running things once
85
85
  # either sleep a bit or use a lock for example File.lock
86
86
  ParallelTests.first_process? ? do_something : sleep(1)
87
87
 
88
- # cleanup:
88
+ # cleanup:
89
89
  # last_process? does NOT mean last finished process, just last started
90
90
  ParallelTests.last_process? ? do_something : sleep(1)
91
91
 
@@ -359,6 +359,7 @@ inspired by [pivotal labs](https://blog.pivotal.io/labs/labs/parallelize-your-rs
359
359
  - [Ryan Zhang](https://github.com/ryanus)
360
360
  - [Rhett Sutphin](https://github.com/rsutphin)
361
361
  - [Doc Ritezel](https://github.com/ohrite)
362
+ - [Alexandre Wilhelm](https://github.com/dogild)
362
363
 
363
364
 
364
365
  [Michael Grosser](http://grosser.it)<br/>
@@ -29,8 +29,8 @@ module ParallelTests
29
29
  end
30
30
 
31
31
  def command_with_seed(cmd, seed)
32
- cmd = cmd.sub(/\s--order random(:\d*)?/, '')
33
- "#{cmd} --order random:#{seed}"
32
+ clean = cmd.sub(/\s--order\s+random(:\d+)?\b/, '')
33
+ "#{clean} --order random:#{seed}"
34
34
  end
35
35
  end
36
36
  end
@@ -6,42 +6,38 @@ module ParallelTests
6
6
  class ScenarioLineLogger
7
7
  attr_reader :scenarios
8
8
 
9
- def initialize(tag_expression = ::Gherkin::TagExpression.new([]))
10
- raise "ScenarioLineLogger not supported anymore after upgrading to Cucumber 2.0, please fix!"
9
+ def initialize(tag_expression = ::Cucumber::Core::Gherkin::TagExpression.new([]))
11
10
  @scenarios = []
12
11
  @tag_expression = tag_expression
13
12
  end
14
13
 
15
- def visit_feature_element(feature_element)
16
- return unless @tag_expression.evaluate(feature_element.source_tags)
14
+ def visit_feature_element(uri, feature_element)
15
+ tags = feature_element[:tags].map {|tag| ::Cucumber::Core::Ast::Tag.new(tag[:location], tag[:name])}
17
16
 
18
- case feature_element
19
- when ::Cucumber::Ast::Scenario
20
- line = if feature_element.respond_to?(:line)
21
- feature_element.line
22
- else
23
- feature_element.instance_variable_get(:@line)
24
- end
25
- @scenarios << [feature_element.feature.file, line].join(":")
26
- when ::Cucumber::Ast::ScenarioOutline
27
- sections = feature_element.instance_variable_get(:@example_sections)
28
- sections.each { |section|
29
- rows = if section[1].respond_to?(:rows)
30
- section[1].rows
31
- else
32
- section[1].instance_variable_get(:@rows)
33
- end
34
- rows.each_with_index { |row, index|
35
- next if index == 0 # slices didn't work with jruby data structure
36
- line = if row.respond_to?(:line)
37
- row.line
38
- else
39
- row.instance_variable_get(:@line)
40
- end
41
- @scenarios << [feature_element.feature.file, line].join(":")
42
- }
43
- }
44
- end
17
+ # We don't accept the feature_element if the current tags are not valid
18
+ return unless @tag_expression.evaluate(tags)
19
+ @scenarios << [uri, feature_element[:location][:line]].join(":")
20
+
21
+ # TODO handle scenario outlines
22
+ # Previous code
23
+ # when ::Cucumber::Ast::ScenarioOutline
24
+ # sections = feature_element.instance_variable_get(:@example_sections)
25
+ # sections.each { |section|
26
+ # rows = if section[1].respond_to?(:rows)
27
+ # section[1].rows
28
+ # else
29
+ # section[1].instance_variable_get(:@rows)
30
+ # end
31
+ # rows.each_with_index { |row, index|
32
+ # next if index == 0 # slices didn't work with jruby data structure
33
+ # line = if row.respond_to?(:line)
34
+ # row.line
35
+ # else
36
+ # row.instance_variable_get(:@line)
37
+ # end
38
+ # @scenarios << [feature_element.feature.file, line].join(":")
39
+ # }
40
+ # }
45
41
  end
46
42
 
47
43
  def method_missing(*args)
@@ -3,6 +3,7 @@ require 'cucumber/runtime'
3
3
  require 'cucumber'
4
4
  require 'parallel_tests/cucumber/scenario_line_logger'
5
5
  require 'parallel_tests/gherkin/listener'
6
+ require 'gherkin/errors'
6
7
 
7
8
  module ParallelTests
8
9
  module Cucumber
@@ -12,18 +13,51 @@ module ParallelTests
12
13
  tags = []
13
14
  tags.concat options[:ignore_tag_pattern].to_s.split(/\s*,\s*/).map {|tag| "~#{tag}" }
14
15
  tags.concat options[:test_options].to_s.scan(/(?:-t|--tags) (~?@[\w,~@]+)/).flatten
16
+
15
17
  split_into_scenarios files, tags.uniq
16
18
  end
17
19
 
18
20
  private
19
21
 
20
22
  def split_into_scenarios(files, tags=[])
21
- tag_expression = ::Gherkin::TagExpression.new(tags)
23
+
24
+ # Create the tag expression instance from gherkin, this is needed to know if the scenario matches with the tags invoked by the request
25
+ tag_expression = ::Cucumber::Core::Gherkin::TagExpression.new(tags)
26
+
27
+ # Create the ScenarioLineLogger which will filter the scenario we want
22
28
  scenario_line_logger = ParallelTests::Cucumber::Formatters::ScenarioLineLogger.new(tag_expression)
23
- loader = ::Cucumber::Runtime::FeaturesLoader.new(files, [], tag_expression)
24
29
 
25
- loader.features.each do |feature|
26
- feature.accept(scenario_line_logger)
30
+ # here we loop on the files map, each file will containe one or more scenario
31
+ features ||= files.map do |path|
32
+
33
+ # We encode the file and get the content of it
34
+ source = ::Cucumber::Runtime::NormalisedEncodingFile.read(path)
35
+ # We create a Gherkin document, this will be used to decode the details of each scenario
36
+ document = ::Cucumber::Core::Gherkin::Document.new(path, source)
37
+
38
+ # We create a parser for the gherkin document
39
+ parser = ::Gherkin::Parser.new()
40
+ scanner = ::Gherkin::TokenScanner.new(document.body)
41
+
42
+ begin
43
+ # We make an attempt to parse the gherkin document, this could be failed if the document is not well formated
44
+ result = parser.parse(scanner)
45
+
46
+ # We loop on each children of the feature
47
+ result[:feature][:children].each do |feature_element|
48
+ # If the type of the child is not a scenario, we continue, we are only interested by the name of the scenario here
49
+ if feature_element[:type].to_s != 'Scenario'
50
+ next
51
+ end
52
+
53
+ # It's a scenario, we add it to the scenario_line_logger
54
+ scenario_line_logger.visit_feature_element(document.uri, feature_element)
55
+ end
56
+
57
+ rescue StandardError => e
58
+ # Exception if the document is no well formated or error in the tags
59
+ raise ::Cucumber::Core::Gherkin::ParseError.new("#{document.uri}: #{e.message}")
60
+ end
27
61
  end
28
62
 
29
63
  scenario_line_logger.scenarios
@@ -47,6 +47,17 @@ module ParallelTests
47
47
  line =~ /\d+ examples?, \d+ failures?/
48
48
  end
49
49
 
50
+ # remove old seed and add new seed
51
+ # --seed 1234
52
+ # --order rand
53
+ # --order rand:1234
54
+ # --order random:1234
55
+ def command_with_seed(cmd, seed)
56
+ clean = cmd.sub(/\s--(seed\s+\d+|order\s+rand(om)?(:\d+)?)\b/, '')
57
+ "#{clean} --seed #{seed}"
58
+ end
59
+
60
+
50
61
  private
51
62
 
52
63
  # so it can be stubbed....
@@ -121,10 +121,10 @@ module ParallelTests
121
121
  sums.sort.map{|word, number| "#{number} #{word}#{'s' if number != 1}" }.join(', ')
122
122
  end
123
123
 
124
+ # remove old seed and add new seed
124
125
  def command_with_seed(cmd, seed)
125
- cmd = cmd.sub(/\s--seed(\s\d*){0,1}/, '')
126
- cmd = cmd.sub(/\s--order rand(:\d*){0,1}/, '')
127
- "#{cmd} --seed #{seed}"
126
+ clean = cmd.sub(/\s--seed\s+\d+\b/, '')
127
+ "#{clean} --seed #{seed}"
128
128
  end
129
129
 
130
130
  protected
@@ -1,3 +1,3 @@
1
1
  module ParallelTests
2
- VERSION = Version = '2.10.0'
2
+ VERSION = Version = '2.11.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.0
4
+ version: 2.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-17 00:00:00.000000000 Z
11
+ date: 2016-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel