Skip to content

Commit

Permalink
Add --single-process-tag option to run specific Cucumber/Gherkin scen…
Browse files Browse the repository at this point in the history
…arios sequentially
  • Loading branch information
andrii-rymar committed Apr 14, 2021
1 parent a5a01bd commit d4bc8e7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/parallel_tests/grouper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def by_steps(tests, num_groups, options)

def by_scenarios(tests, num_groups, options = {})
scenarios = group_by_scenarios(tests, options)
in_even_groups_by_size(scenarios, num_groups, options.slice(BY_SCENARIOS_SUPPORTED_OPTIONS))
in_even_groups_by_size(scenarios, num_groups, options.slice(*BY_SCENARIOS_SUPPORTED_OPTIONS))
end

def in_even_groups_by_size(items, num_groups, options = {})
Expand Down Expand Up @@ -128,14 +128,15 @@ def group_by_scenarios(tests, options = {})
end

def separate_single_items(items, options)
items.partition { |item, _size| to_single_items?(item, options) }
items.partition { |item| to_single_items?(item, options) }
end

def to_single_items?(item, options)
if options[:single_process]
item = item_with_tags?(item) || item_with_size?(item) ? item[0] : item
options[:single_process].any? { |pattern| item =~ pattern }
elsif options[:single_process_tag]
raise "--single-tag option can be used only with '--group-by scenarios'" unless item_with_tags?(item)
raise "--single-tag option can only be used with '--group-by scenarios'" unless item_with_tags?(item)
item_tags = item[1]
item_tags.any? { |tag| tag.match?(options[:single_process_tag]) }
else
Expand Down

0 comments on commit d4bc8e7

Please sign in to comment.