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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/test-parser/parsers/rspec.rb', line 3
def self.parse test_results
test_info = Hash.new(0)
test_info[:failures] = []
test_results.scan(/(\d+) (specification|example)s?, (\d+) failures?/) do |(examples,_,failures)|
test_info[:failure_count] += failures.to_i
test_info[:success_count] += examples.to_i - failures.to_i
test_info[:test_count] += examples.to_i
end
error_regex1 = /\s*(.*?)\:(\d+)\:(in `(.*?)':)? (.*?) \((.*?)\)/
test_results.scan(error_regex1) do |(file,line,_,method,message,type)|
error_info = {:file => file,
:line => line.to_i,
:message => message,
:error_type => type,}
error_info[:method] = method if method
test_info[:failures] << error_info
end
error_regex2 = /\s+(.*?) in '(.*?)'\s+(.*?)\s+(.*?):(\d+):(in `(.*?)')?/
test_results.scan(error_regex2) do |(type,test,message,file,line,_,method)|
error_info = {:error_type => type,
:test => test,
:message => message,
:file => file,
:line => line.to_i,
}
error_info[:method] = method if method
test_info[:failures] << error_info
end
failure_regex = /\d+\)\s+'(.*?)' FAILED\s+(.*?)\n\s*(.*?):(\d+):/
test_results.scan(failure_regex) do |(test,message,file,line)|
test_info[:failures] << {:test => test,
:message => message,
:file => file,
:line => line.to_i,}
end
test_info.default = nil
test_info
end
|