Sha256: ef0d41b085db69747849704b08643b1c92bfadf96e9a506a53914b8f2ce2e0c1

Contents?: true

Size: 765 Bytes

Versions: 2

Compression:

Stored size: 765 Bytes

Contents

require_relative 'message'

module Torkify::Event

  # Event used for test passes or failures.
  #
  # Types:
  #
  #  - pass
  #  - fail
  class PassOrFailEvent < Struct.new(:type, :file, :lines, :log_file, :worker, :exit_code, :exit_info)
    include Message

    # Get the PID from the exit info.
    def pid
      matched = exit_info.scan(/pid ([0-9]+)/).first
      matched.first.to_i if matched
    end

    def errors
      @errors ||= parse_errors_from_log
    end

    def to_s
      s = "#{type.upcase} #{file}"
      s += lines.any? ? " (lines #{lines.join(', ')})" : ''
    end

  protected
    def parse_errors_from_log
      log = File.open log_file
      parser = Torkify::Log::Parser.new log
      parser.parse
      parser.errors
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
torkify-0.0.3 lib/torkify/event/pass_or_fail_event.rb
torkify-0.0.2 lib/torkify/event/pass_or_fail_event.rb