Sha256: 039fc9285837350a9d099bae2ea14fed25233a09bca9909b685450262831b6ee

Contents?: true

Size: 1.48 KB

Versions: 5

Compression:

Stored size: 1.48 KB

Contents

require 'second_curtain/xcode_test_case'
require 'second_curtain/test_suite'
require 'second_curtain/kaleidoscope_command'

# Lifted from https://github.com/orta/Snapshots/blob/master/SnapshotDiffs/ORLogReader.m

class Parser
  def initialize
    @test_suites = []
  end

  def parse_line(line)
    if line.include?("Test Suite")
      test_suite = TestSuite.suite_from_line(line)
      @test_suites.push test_suite unless test_suite == nil
    end

    if line.include?("Test Case") && latest_test_suite
      if line.include?("started.")
        test_case = XcodeTestCase.test_case_from_line(line)
        latest_test_suite.test_cases.push test_case unless test_case == nil
      elsif line.include?("' failed (")
        command = latest_test_suite.latest_test_case.latest_command
        if command != nil
          command.fails = true
        end
      end
    end

    if line.include?("ksdiff") && latest_test_suite
      command_string = extract_command_string_from_line(line)
      command = KaleidoscopeCommand.command_from_line(command_string)
      if command != nil
        latest_test_suite.latest_test_case.add_command command
      end
    end
  end

  def latest_test_suite
    @test_suites.last
  end

  def extract_command_string_from_line(line)
    return line.split("diff:\n").last
  end

  def failing_commands
    @test_suites.map { |e| e.test_cases }.flatten.map { |e| e.commands }.flatten.select { |e| e.fails }
  end

  def has_failing_commands
    failing_commands.count > 0
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
second_curtain-0.4.0 lib/second_curtain/parser.rb
second_curtain-0.3.0 lib/second_curtain/parser.rb
second_curtain-0.2.4 lib/second_curtain/parser.rb
second_curtain-0.2.3 lib/second_curtain/parser.rb
second_curtain-0.2.2 lib/second_curtain/parser.rb