Skip to content

Commit

Permalink
Add new Boost Test results XML parser
Browse files Browse the repository at this point in the history
  • Loading branch information
GreyCat committed Jun 1, 2018
1 parent 5c4e3b4 commit 5d2125c
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions aggregate/boost_test_parser.rb
Expand Up @@ -10,6 +10,14 @@ def initialize(fn)
end

def each_test
# Boost actually uses two slightly different formats: old and
# new. Instead of trying to detect which one we have, we actually
# just try both.
each_from_old_boost_format { |tr| yield tr }
each_from_new_boost_format { |tr| yield tr }
end

def each_from_old_boost_format
@doc.root.elements.each('TestSuite') { |ts|
ts.elements.each('TestCase') { |tc|
name = tc.attribute('name').value
Expand Down Expand Up @@ -48,4 +56,43 @@ def each_test
}
}
end

def each_from_new_boost_format
@doc.root.elements.each('testcase') { |tc|
name = tc.attribute('name').value

raise "Unable to parse name: \"#{name}\"" unless name =~ /^test_(.*?)$/
name = underscore_to_ucamelcase($1)

failures = []
tc.elements.each('failure') { |err|
failures << TestResult::Failure.new(
nil, # filename
nil, # line
err.text,
nil
)
}

tc.elements.each('error') { |err|
failures << TestResult::Failure.new(
nil, # filename
nil, # line
err.text,
nil
)
}

if failures.empty?
status = :passed
failure = nil
else
status = :failed
failure = failures[0]
end

tr = TestResult.new(name, status, tc.attribute('time').value.to_f, failure)
yield tr
}
end
end

0 comments on commit 5d2125c

Please sign in to comment.