Class: ParallelTests::Gherkin::Runner
Constant Summary
Constants inherited
from Test::Runner
Test::Runner::NAME
Class Method Summary
collapse
execute_command, execute_command_and_capture_output, find_results, name, test_env_number, tests_with_size
Class Method Details
.cucumber_opts(given) ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/parallel_tests/gherkin/runner.rb', line 63
def cucumber_opts(given)
if given =~ /--profile/ or given =~ /(^|\s)-p /
given
else
[given, profile_from_config].compact.join(" ")
end
end
|
.determine_executable ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/parallel_tests/gherkin/runner.rb', line 100
def determine_executable
case
when File.exist?("bin/#{name}")
"bin/#{name}"
when ParallelTests.bundler_enabled?
"bundle exec #{name}"
when File.file?("script/#{name}")
"script/#{name}"
else
"#{name}"
end
end
|
.line_is_result?(line) ⇒ Boolean
39
40
41
|
# File 'lib/parallel_tests/gherkin/runner.rb', line 39
def line_is_result?(line)
line =~ /^\d+ (steps?|scenarios?)/
end
|
.profile_from_config ⇒ Object
71
72
73
74
75
76
77
|
# File 'lib/parallel_tests/gherkin/runner.rb', line 71
def profile_from_config
config = Dir.glob("{,.config/,config/}#{name}{.yml,.yaml}").first
if config && File.read(config) =~ /^parallel:/
"--profile parallel"
end
end
|
.run_tests(test_files, process_number, num_processes, options) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/parallel_tests/gherkin/runner.rb', line 9
def run_tests(test_files, process_number, num_processes, options)
combined_scenarios = test_files
if options[:group_by] == :scenarios
grouped = test_files.map { |t| t.split(':') }.group_by(&:first)
combined_scenarios = grouped.map {|file,files_and_lines| "#{file}:#{files_and_lines.map(&:last).join(':')}" }
end
sanitized_test_files = combined_scenarios.map { |val| WINDOWS ? "\"#{val}\"" : Shellwords.escape(val) }
options[:env] ||= {}
options[:env] = options[:env].merge({'AUTOTEST' => '1'}) if $stdout.tty?
cmd = [
executable,
(runtime_logging if File.directory?(File.dirname(runtime_log))),
cucumber_opts(options[:test_options]),
*sanitized_test_files
].compact.reject(&:empty?).join(' ')
execute_command(cmd, process_number, num_processes, options)
end
|
.runtime_log ⇒ Object
96
97
98
|
# File 'lib/parallel_tests/gherkin/runner.rb', line 96
def runtime_log
"tmp/parallel_runtime_#{name}.log"
end
|
.runtime_logging ⇒ Object
92
93
94
|
# File 'lib/parallel_tests/gherkin/runner.rb', line 92
def runtime_logging
"--format ParallelTests::Gherkin::RuntimeLogger --out #{runtime_log}"
end
|
.summarize_results(results) ⇒ Object
cucumber has 2 result lines per test run, that cannot be added 1 scenario (1 failed) 1 step (1 failed)
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/parallel_tests/gherkin/runner.rb', line 46
def summarize_results(results)
sort_order = %w[scenario step failed undefined skipped pending passed]
%w[scenario step].map do |group|
group_results = results.grep(/^\d+ #{group}/)
next if group_results.empty?
sums = sum_up_results(group_results)
sums = sums.sort_by { |word, _| sort_order.index(word) || 999 }
sums.map! do |word, number|
plural = "s" if word == group and number != 1
"#{number} #{word}#{plural}"
end
"#{sums[0]} (#{sums[1..-1].join(", ")})"
end.compact.join("\n")
end
|
.test_file_name ⇒ Object
31
32
33
|
# File 'lib/parallel_tests/gherkin/runner.rb', line 31
def test_file_name
@test_file_name || 'feature'
end
|
.test_suffix ⇒ Object
35
36
37
|
# File 'lib/parallel_tests/gherkin/runner.rb', line 35
def test_suffix
/\.feature$/
end
|
.tests_in_groups(tests, num_groups, options = {}) ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/parallel_tests/gherkin/runner.rb', line 79
def tests_in_groups(tests, num_groups, options={})
if options[:group_by] == :scenarios
@test_file_name = "scenario"
end
method = "by_#{options[:group_by]}"
if Grouper.respond_to?(method)
Grouper.send(method, find_tests(tests, options), num_groups, options)
else
super
end
end
|