Sha256: 2b08c3ee5b9ccc5fdd74e27f4aa51ce941031536276bfb9bb9187ee12ad5afbf

Contents?: true

Size: 778 Bytes

Versions: 3

Compression:

Stored size: 778 Bytes

Contents

require_relative 'module'

module Scan
  class TestResultParser
    def parse_result(output)
      unless output
        return {
            tests: 0,
            failures: 0
        }
      end

      # e.g. ...<testsuites tests='2' failures='1'>...
      matched = output.scan(/<testsuites\b(?=[^<>]*\s+tests='(\d+)')(?=[^<>]*\s+failures='(\d+)')[^<>]+>/)

      if matched && matched.length == 1 && matched[0].length == 2
        tests = matched[0][0].to_i
        failures = matched[0][1].to_i

        {
          tests: tests,
          failures: failures
        }
      else
        UI.error("Couldn't parse the number of tests from the output")
        {
          tests: 0,
          failures: 0
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fastlane_hotfix-2.165.1 scan/lib/scan/test_result_parser.rb
fastlane_hotfix-2.165.0 scan/lib/scan/test_result_parser.rb
fastlane_hotfix-2.187.0 scan/lib/scan/test_result_parser.rb