早速Growlとautotestを連携させてみようと思ったのですが、
growlnotif
1 % growlnotify -m "test" 2 2008-09-15 09:13:20.9 29 growlnotif y[901:10b] could not find local GrowlAppli cationBrid gePathway, falling back to NSDNC
こんな感じのWARNINGが出てきます。 メッセージ自体はきちんと表示されるので、実用上問題ないのですが、 毎回警告が出てくるのはちょっと気になるので、 警告が出ない方法が無いかいくつか試してみた所、 以下のようにホストを指定すると大丈夫なようでした。
1 % growlnotify -m "test" -H localhost
ということで、autotestと連携させるために、
以下のような.autotest
ファイルを作成しました。
1 class Autotest 2 module Growl 3 IMG_OK = '/Developer/Examples/ Carbon/Dia l/English. lproj/' + 4 'rotate_kno b_select.t iff' 5 IMG_NG = "/Applicati ons/Mail.a pp/Content s/Resource s/Caution. tiff" 6 class << self 7 def growl(title, msg, img = nil, pri = 0, sticky = "") 8 img ||= IMG_NG 9 msg += " at #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}" 10 system "growlnotif y -n autotest #{title} -m #{msg.inspect}" + 11 " -H localhost --image #{img} -p #{pri} #{sticky}" 12 end 13 end 14 15 Autotest.add_hook :run_comman d do |at| 16 growl "autotest running", "Started", IMG_OK 17 end 18 19 Autotest.add_hook :ran_comman d do |at| 20 result = [at.results].flatten.join("\n") 21 examples = result.slice(/(\d+)\s+examples?/).to_i 22 tests = result.slice(/(\d+)\s+tests?/).to_i 23 failures = result.slice(/(\d+)\s+failures?/).to_i 24 errors = result.slice(/(\d+)\s+failures?/).to_i 25 if failures + errors > 0 26 growl "Tests Failed", 27 "#{failures} failures #{errors} errors", IMG_NG, 2#, "-s" 28 else 29 growl "Tests Passed", "#{tests + examples} tests", IMG_OK 30 end 31 end 32 end 33 end
最初はrequire 'autotest/g
をしてモンキーパッチを当てていたのですが、
結局ほとんど書きかえてしまったのでこうなりました。
エラーが発生した場所や、エラーメッセージなんかも表示できるようになるともっと便利になるかもしれないですね。
posted by
genki
on Mon 15 Sep 2008
at 09:24
with
2 comments
補足
-H で接続するようにする場合は、以下のように、Growlの設定画面で
「受信される通知を聞く」をチェックしておく必要があるようです。
それでもセグブる → osx再起動 → 治った♪
ありがとう!!