From ce8a0b90849ac5d1895e741c023432930f24d724 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 12 Mar 2020 18:09:28 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- lib/gitlab/ci/parsers/test/junit.rb | 12 +++++++++++- lib/gitlab/ci/reports/test_case.rb | 9 +++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/gitlab/ci/parsers/test/junit.rb b/lib/gitlab/ci/parsers/test/junit.rb index 133eb16a83e..0ce901fa5aa 100644 --- a/lib/gitlab/ci/parsers/test/junit.rb +++ b/lib/gitlab/ci/parsers/test/junit.rb @@ -6,6 +6,7 @@ module Gitlab module Test class Junit JunitParserError = Class.new(Gitlab::Ci::Parsers::ParserError) + ATTACHMENT_TAG_REGEX = /\[\[ATTACHMENT\|(?.+?)\]\]/.freeze def parse!(xml_data, test_suite) root = Hash.from_xml(xml_data) @@ -49,6 +50,7 @@ module Gitlab if data['failure'] status = ::Gitlab::Ci::Reports::TestCase::STATUS_FAILED system_output = data['failure'] + attachment = attachment_path(data['system_out']) elsif data['error'] status = ::Gitlab::Ci::Reports::TestCase::STATUS_ERROR system_output = data['error'] @@ -63,9 +65,17 @@ module Gitlab file: data['file'], execution_time: data['time'], status: status, - system_output: system_output + system_output: system_output, + attachment: attachment ) end + + def attachment_path(data) + return unless data + + matches = data.match(ATTACHMENT_TAG_REGEX) + matches[:path] if matches + end end end end diff --git a/lib/gitlab/ci/reports/test_case.rb b/lib/gitlab/ci/reports/test_case.rb index fdeaad698b9..55856f64533 100644 --- a/lib/gitlab/ci/reports/test_case.rb +++ b/lib/gitlab/ci/reports/test_case.rb @@ -10,9 +10,9 @@ module Gitlab STATUS_ERROR = 'error' STATUS_TYPES = [STATUS_SUCCESS, STATUS_FAILED, STATUS_SKIPPED, STATUS_ERROR].freeze - attr_reader :name, :classname, :execution_time, :status, :file, :system_output, :stack_trace, :key + attr_reader :name, :classname, :execution_time, :status, :file, :system_output, :stack_trace, :key, :attachment - def initialize(name:, classname:, execution_time:, status:, file: nil, system_output: nil, stack_trace: nil) + def initialize(name:, classname:, execution_time:, status:, file: nil, system_output: nil, stack_trace: nil, attachment: nil) @name = name @classname = classname @file = file @@ -21,6 +21,11 @@ module Gitlab @system_output = system_output @stack_trace = stack_trace @key = sanitize_key_name("#{classname}_#{name}") + @attachment = attachment + end + + def has_attachment? + attachment.present? end private -- cgit v1.2.1