-
Notifications
You must be signed in to change notification settings - Fork 3
/
tmc-check-convert-results
executable file
·55 lines (45 loc) · 1.3 KB
/
tmc-check-convert-results
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
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'json'
if ARGV.length > 1
puts "Usage: #{$0} [path-to-test-result-directory]"
exit 1
elsif ARGV.length == 1
Dir.chdir(ARGV[0])
end
suite_points = {}
test_points = {}
IO.readlines('tmc_available_points.txt').map(&:strip).each do |line|
if line =~ /\[(suite|test)\] \[(.*)\] (.*)/
type = $1
name = $2
points = $3.split(' ')
result = if type == 'suite' then suite_points else test_points end
result[name] ||= []
result[name] += points
else
puts "Warning: weird line in available points file:"
puts line
end
end
result = []
document = Nokogiri::XML::Document.parse(File.read('tmc_test_results.xml')) { |config| config.nonet }
document.css('suite').each do |suite|
suite_name = suite.css('title').text
suite.css('test').each do |test|
test_name = test.css('id').text
status = if test['result'] == 'success' then 'PASSED' else test['result'].upcase end
status = 'FAILED' if status.empty?
result << {
className: suite_name,
methodName: test_name,
message: test.css('message').text,
status: status,
pointNames: (suite_points[suite_name] || []) + (test_points[test_name] || [])
#TODO: valgrind info
}
end
end
puts JSON.generate(result)
#TODO: unit test this