diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 18:09:28 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 18:09:28 +0000 |
commit | ce8a0b90849ac5d1895e741c023432930f24d724 (patch) | |
tree | dbdc97de542cdbe18a2fc8b1a6b64ac0673ed3d3 /lib | |
parent | dc889678d1de8c09310b2f8f9742bb6c78a6f1a4 (diff) | |
download | gitlab-ce-ce8a0b90849ac5d1895e741c023432930f24d724.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/parsers/test/junit.rb | 12 | ||||
-rw-r--r-- | lib/gitlab/ci/reports/test_case.rb | 9 |
2 files changed, 18 insertions, 3 deletions
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\|(?<path>.+?)\]\]/.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 |