File: runner.rb

package info (click to toggle)
ruby-parallel-tests 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,280 kB
  • sloc: ruby: 5,381; javascript: 30; makefile: 4
file content (44 lines) | stat: -rw-r--r-- 1,189 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true
require "parallel_tests/gherkin/runner"

module ParallelTests
  module Cucumber
    class Runner < ParallelTests::Gherkin::Runner
      SCENARIOS_RESULTS_BOUNDARY_REGEX = /^(Failing|Flaky) Scenarios:$/.freeze
      SCENARIO_REGEX = %r{^cucumber features/.+:\d+}.freeze

      class << self
        def name
          'cucumber'
        end

        def default_test_folder
          'features'
        end

        def line_is_result?(line)
          super || line =~ SCENARIO_REGEX || line =~ SCENARIOS_RESULTS_BOUNDARY_REGEX
        end

        def summarize_results(results)
          output = []

          scenario_groups = results.slice_before(SCENARIOS_RESULTS_BOUNDARY_REGEX).group_by(&:first)
          scenario_groups.each do |header, group|
            scenarios = group.flatten.grep(SCENARIO_REGEX)
            output << ([header] + scenarios).join("\n") if scenarios.any?
          end

          output << super

          output.join("\n\n")
        end

        def command_with_seed(cmd, seed)
          clean = remove_command_arguments(cmd, '--order')
          [*clean, '--order', "random:#{seed}"]
        end
      end
    end
  end
end