Class: Gitlab::Ci::Parsers::Test::Junit

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/parsers/test/junit.rb

Constant Summary collapse

JunitParserError =
Class.new(Gitlab::Ci::Parsers::ParserError)
ATTACHMENT_TAG_REGEX =
/\[\[ATTACHMENT\|(?<path>.+?)\]\]/.freeze

Instance Method Summary collapse

Instance Method Details

#parse!(xml_data, test_suite, job:) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gitlab/ci/parsers/test/junit.rb', line 11

def parse!(xml_data, test_suite, job:)
  root = Hash.from_xml(xml_data)
  total_parsed = 0
  max_test_cases = job.max_test_cases_per_report

  all_cases(root) do |test_case|
    test_case = create_test_case(test_case, test_suite, job)
    test_suite.add_test_case(test_case)
    total_parsed += 1

    ensure_test_cases_limited!(total_parsed, max_test_cases)
  end
rescue Nokogiri::XML::SyntaxError => e
  test_suite.set_suite_error("JUnit XML parsing failed: #{e}")
rescue StandardError => e
  test_suite.set_suite_error("JUnit data parsing failed: #{e}")
end