ppovb5fc7/gazebo/tools/junit_to_csv.rb

22 lines
429 B
Ruby
Raw Permalink Normal View History

2019-03-25 11:01:43 +08:00
#!/usr/bin/env ruby
require 'rexml/document'
xml = File.read(ARGV[0])
doc, arrayOfHashes = REXML::Document.new(xml), []
doc.elements.each('testsuites/testsuite/testcase') do |t|
arrayOfHashes << t.attributes
end
sortedKeys = arrayOfHashes.first.keys.sort
sortedKeys.delete("value_param")
puts sortedKeys.join(',')
arrayOfHashes.each do |h|
row = []
sortedKeys.each do |k|
row << h[k]
end
puts row.join(',')
end