Class: ParallelTests::Test::Runner
- Inherits:
-
Object
- Object
- ParallelTests::Test::Runner
show all
- Defined in:
- lib/parallel_tests/test/runner.rb
Class Method Summary
collapse
Class Method Details
.execute_command(cmd, process_number, options) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/parallel_tests/test/runner.rb', line 42
def self.execute_command(cmd, process_number, options)
cmd = "TEST_ENV_NUMBER=#{test_env_number(process_number, options)} ; export TEST_ENV_NUMBER; #{cmd}"
f = open("|#{cmd}", 'r')
output = fetch_output(f)
f.close
{:stdout => output, :exit_status => $?.exitstatus}
end
|
.find_results(test_output) ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/parallel_tests/test/runner.rb', line 50
def self.find_results(test_output)
test_output.split("\n").map {|line|
line = line.gsub(/\.|F|\*/,'').gsub(/\e\[\d+m/,'')
next unless line_is_result?(line)
line
}.compact
end
|
.line_is_result?(line) ⇒ Boolean
24
25
26
|
# File 'lib/parallel_tests/test/runner.rb', line 24
def self.line_is_result?(line)
line =~ /\d+ failure/
end
|
.run_tests(test_files, process_number, options) ⇒ Object
18
19
20
21
22
|
# File 'lib/parallel_tests/test/runner.rb', line 18
def self.run_tests(test_files, process_number, options)
require_list = test_files.map { |filename| %{"#{File.expand_path filename}"} }.join(",")
cmd = "ruby -Itest -e '[#{require_list}].each {|f| require f }' -- #{options[:test_options]}"
execute_command(cmd, process_number, options)
end
|
.runtime_log ⇒ Object
— usually overwritten by other runners
6
7
8
|
# File 'lib/parallel_tests/test/runner.rb', line 6
def self.runtime_log
'tmp/parallel_runtime_test.log'
end
|
.summarize_results(results) ⇒ Object
63
64
65
66
|
# File 'lib/parallel_tests/test/runner.rb', line 63
def self.summarize_results(results)
sums = sum_up_results(results)
sums.sort.map{|word, number| "#{number} #{word}#{'s' if number != 1}" }.join(', ')
end
|
.test_env_number(process_number, options) ⇒ Object
58
59
60
61
|
# File 'lib/parallel_tests/test/runner.rb', line 58
def self.test_env_number(process_number, options)
n = options[:advance_number].to_i + process_number + 1
n == 0 ? '' : n
end
|
.test_file_name ⇒ Object
14
15
16
|
# File 'lib/parallel_tests/test/runner.rb', line 14
def self.test_file_name
"test"
end
|
.test_suffix ⇒ Object
10
11
12
|
# File 'lib/parallel_tests/test/runner.rb', line 10
def self.test_suffix
"_test.rb"
end
|
.tests_in_groups(tests, num_groups, options = {}) ⇒ Object
finds all tests and partitions them into groups
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/parallel_tests/test/runner.rb', line 31
def self.tests_in_groups(tests, num_groups, options={})
tests = find_tests(tests, options)
tests = if options[:group_by] == :found
tests.map { |t| [t, 1] }
else
with_runtime_info(tests)
end
Grouper.in_even_groups_by_size(tests, num_groups, options)
end
|