Sha256: 04887e11f329fbef46665a2bf313c5a4e9d8410af3704f2c1c76dcc3985a7b9d

Contents?: true

Size: 1018 Bytes

Versions: 1

Compression:

Stored size: 1018 Bytes

Contents

require 'tork/config'
require 'set'

failed_test_files = Set.new

Tork::Config.test_event_hooks.push lambda {|message|
  event, test_file, line_numbers, log_file, worker_number, exit_status = message

  # make notifications edge-triggered: pass => fail or vice versa.
  # we do not care about pass => pass or fail => fail transitions.
  case event.to_sym
  when :fail
    if failed_test_files.add? test_file
      icon = 'dialog-error'
    end
  when :pass
    if line_numbers.empty? and failed_test_files.delete? test_file
      icon = 'dialog-information'
    end
  end

  if icon
    title = [event.upcase, test_file].join(' ')

    statistics = File.readlines(log_file).grep(/^\d+ \w+,/).join.
      gsub(/\e\[\d+(;\d+)?m/, '') # strip ANSI SGR escape codes

    Thread.new do # run in background
      system 'notify-send', '-i', icon, title, statistics or
      system 'growlnotify', '-a', 'Xcode', '-m', statistics, title or
      system 'xmessage', '-timeout', '5', '-title', title, statistics
    end
  end
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tork-17.1.0 lib/tork/config/notify.rb