Sha256: d157e7b481d0dbb54df700298e8674954a7e6145a71bf7c85bcc477be2a18a91

Contents?: true

Size: 990 Bytes

Versions: 8

Compression:

Stored size: 990 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 = 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

8 entries across 8 versions & 1 rubygems

Version Path
tork-18.2.4 lib/tork/config/notify.rb
tork-18.2.3 lib/tork/config/notify.rb
tork-18.2.2 lib/tork/config/notify.rb
tork-18.2.1 lib/tork/config/notify.rb
tork-18.2.0 lib/tork/config/notify.rb
tork-18.1.0 lib/tork/config/notify.rb
tork-18.0.1 lib/tork/config/notify.rb
tork-18.0.0 lib/tork/config/notify.rb