From 02cd1ee66229043160a382f8068786503084e78e Mon Sep 17 00:00:00 2001 From: Nick Gauthier Date: Thu, 25 Mar 2010 13:52:40 -0400 Subject: [PATCH] added notifier listener and documentation on listener customization --- README.rdoc | 30 ++++++++++++++++++++++++++++++ hydra-icon-64x64.png | Bin 0 -> 6865 bytes hydra.gemspec | 2 ++ lib/hydra.rb | 1 + lib/hydra/listener/notifier.rb | 17 +++++++++++++++++ lib/hydra/master.rb | 5 +++++ lib/hydra/tasks.rb | 10 ++++++---- 7 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 hydra-icon-64x64.png create mode 100644 lib/hydra/listener/notifier.rb diff --git a/README.rdoc b/README.rdoc index 3c651fc..fe6d733 100644 --- a/README.rdoc +++ b/README.rdoc @@ -132,6 +132,36 @@ Use ssh_opts to set the port or compression options. The *directory* option is the path for the project directory where the tests should be run. +=== Using Hydra::Listeners + +Hydra comes with a couple of listeners for the events it fires. By +default, Hydra::Listener::MinimalOutput is used to display the +files being tests and the ./F/E for each file and F/E output. + +It also uses Hydra::Listener::ReportGenerator to generate reports +of the test files to that it can order them by their run times. + +To use another listener, just add a listeners node to the config file. +For example, if you are on Ubuntu Linux (or have access to the +notify-send command) you can add a notifier listener like this: + + listeners: + - Hydra::Listener::Notifier.new + +Note that if you make a listener node, the default listeners will be +overridden, so you will no longer have the standard minimal output +unless you do: + + listeners: + - Hydra::Listener::Notifier.new + - Hydra::Listener::MinimalOutput.new + +Listeners take one argument to their contstructor: an IO object. So, +you can easily output Hydra to a variety of log files. For example: + + listeners: + - Hydra::Listener::ReportGenerator.new(File.new('/home/ngauthier/Desktop/hydra_log.yml', 'w')) + == More Information For more information on Hydra, check out the rdocs: diff --git a/hydra-icon-64x64.png b/hydra-icon-64x64.png new file mode 100644 index 0000000000000000000000000000000000000000..2a2bb3e702c7175cea411e3e6660ee46ef84d150 GIT binary patch literal 6865 zcmV;?8ZPCDP)Oz@Z0f2-7z;ux~O9+4z06=<WDR*FRcSTFz- zW=q650N5=6F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WaRiP{cD} zNJvm*T`Ht}=%R3e%$Le733Uf=^Cl+yna*f96ER-!+*90qHu?KsgTu_SW0{Cf00000 LNkvXXu0mjfIH%k& literal 0 HcmV?d00001 diff --git a/hydra.gemspec b/hydra.gemspec index 7be199c..98c9f5f 100644 --- a/hydra.gemspec +++ b/hydra.gemspec @@ -26,12 +26,14 @@ Gem::Specification.new do |s| "TODO", "VERSION", "caliper.yml", + "hydra-icon-64x64.png", "hydra.gemspec", "hydra_gray.png", "lib/hydra.rb", "lib/hydra/hash.rb", "lib/hydra/listener/abstract.rb", "lib/hydra/listener/minimal_output.rb", + "lib/hydra/listener/notifier.rb", "lib/hydra/listener/report_generator.rb", "lib/hydra/master.rb", "lib/hydra/message.rb", diff --git a/lib/hydra.rb b/lib/hydra.rb index f7179de..1d81077 100644 --- a/lib/hydra.rb +++ b/lib/hydra.rb @@ -10,5 +10,6 @@ require 'hydra/master' require 'hydra/listener/abstract' require 'hydra/listener/minimal_output' require 'hydra/listener/report_generator' +require 'hydra/listener/notifier' diff --git a/lib/hydra/listener/notifier.rb b/lib/hydra/listener/notifier.rb new file mode 100644 index 0000000..9e29b0a --- /dev/null +++ b/lib/hydra/listener/notifier.rb @@ -0,0 +1,17 @@ +module Hydra #:nodoc: + module Listener #:nodoc: + # Sends a command to Notifier when the testing has finished + # http://manpages.ubuntu.com/manpages/gutsy/man1/notify-send.1.html + class Notifier < Hydra::Listener::Abstract + # output a finished notification + def testing_end + icon_path = File.join( + File.dirname(__FILE__), '..', '..', '..', + 'hydra-icon-64x64.png' + ) + `notify-send -i #{icon_path} "Hydra" "Testing Completed"` + end + end + end +end + diff --git a/lib/hydra/master.rb b/lib/hydra/master.rb index 96da462..1bd1efd 100644 --- a/lib/hydra/master.rb +++ b/lib/hydra/master.rb @@ -38,6 +38,11 @@ module Hydra #:nodoc: @workers = [] @listeners = [] @event_listeners = Array(opts.fetch('listeners') { nil } ) + @event_listeners.select{|l| l.is_a? String}.each do |l| + @event_listeners.delete_at(@event_listeners.index(l)) + listener = eval(l) + @event_listeners << listener if listener.is_a?(Hydra::Listener::Abstract) + end @verbose = opts.fetch('verbose') { false } @autosort = opts.fetch('autosort') { true } @sync = opts.fetch('sync') { nil } diff --git a/lib/hydra/tasks.rb b/lib/hydra/tasks.rb index 5fe904c..666c421 100644 --- a/lib/hydra/tasks.rb +++ b/lib/hydra/tasks.rb @@ -19,16 +19,18 @@ module Hydra #:nodoc: # If not set, it will check 'hydra.yml' and 'config/hydra.yml' attr_accessor :config - # Set to true if you want hydra to generate a report. - # Defaults to false - attr_accessor :report - # Automatically sort files using their historical runtimes. # Defaults to true # To disable: # t.autosort = false attr_accessor :autosort + # Event listeners. Defaults to the MinimalOutput listener. + # You can add additional listeners if you'd like. For example, + # on linux (with notify-send) you can add the notifier listener: + # t.listeners << Hydra::Listener::Notifier.new + attr_accessor :listeners + # # Search for the hydra config file def find_config_file