Commit 851161ad authored by Shinya Maeda's avatar Shinya Maeda

Merge branch 'eb-fix-cobertura-empty-sources' into 'master'

Fix parsing of empty sources in cobertura

See merge request gitlab-org/gitlab!50971
parents 94a9154e 0b2a23af
---
title: Fix cobertura parser when there is an empty sources node
merge_request: 50971
author:
type: fixed
......@@ -36,7 +36,7 @@ module Gitlab
end
def parse_node(key, value, coverage_report, context)
if key == 'sources' && value['source'].present?
if key == 'sources' && value && value['source'].present?
parse_sources(value['source'], context)
elsif key == 'package'
Array.wrap(value).each do |item|
......
......@@ -224,6 +224,12 @@ RSpec.describe Gitlab::Ci::Parsers::Coverage::Cobertura do
it_behaves_like 'ignoring sources, project_path, and worktree_paths'
end
context 'when there is an empty <sources>' do
let(:sources_xml) { '<sources />' }
it_behaves_like 'ignoring sources, project_path, and worktree_paths'
end
context 'when there is a <sources>' do
context 'and has a single source with a pattern for Go projects' do
let(:project_path) { 'local/go' } # Make sure we're not making false positives
......
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