Commit bcbd1910 authored by Erick Bajao's avatar Erick Bajao

Ignore sources node from cobertura XML

parent 5e8394b0
---
title: Ignore the sources node from the cobertura XML
merge_request: 39385
author:
type: fixed
......@@ -28,6 +28,8 @@ module Gitlab
end
def parse_node(key, value, coverage_report)
return if key == 'sources'
if key == 'class'
Array.wrap(value).each do |item|
parse_class(item, coverage_report)
......
......@@ -19,6 +19,41 @@ RSpec.describe Gitlab::Ci::Parsers::Coverage::Cobertura do
end
end
context 'when there is a <sources>' do
shared_examples_for 'ignoring sources' do
it 'parses XML without errors' do
expect { subject }.not_to raise_error
expect(coverage_report.files).to eq({})
end
end
context 'and has a single source' do
let(:cobertura) do
<<-EOF.strip_heredoc
<sources>
<source>project/src</source>
</sources>
EOF
end
it_behaves_like 'ignoring sources'
end
context 'and has multiple sources' do
let(:cobertura) do
<<-EOF.strip_heredoc
<sources>
<source>project/src/foo</source>
<source>project/src/bar</source>
</sources>
EOF
end
it_behaves_like 'ignoring sources'
end
end
context 'when there is a single <class>' do
context 'with no lines' do
let(:cobertura) do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment