carlosbrando-autotest-notification 1.0.0 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,4 +1,13 @@
1
- == 0.3.0
1
+ == 1.1.2
2
+ * Refactoring code.
3
+
4
+ * 1.1.1
5
+ * Changed to speak when passing the tests after a series of failures. Only in Mac.
6
+
7
+ * 1.1.0
8
+ * Now speaking in Linux too.
9
+
10
+ * 0.3.0
2
11
  * If a test failed, the computer will speak. Only for Mac.
3
12
 
4
13
  * 0.2.2 2008-05-13
data/Manifest.txt CHANGED
@@ -9,9 +9,9 @@ config/requirements.rb
9
9
  lib/autotest_notification.rb
10
10
  lib/autotest_notification/version.rb
11
11
  lib/autotest_notification/linux.rb
12
- lib/autotest_notification/mac.rb
13
12
  lib/autotest_notification/windows.rb
14
13
  lib/autotest_notification/cygwin.rb
14
+ lib/autotest_notification/mac.rb
15
15
  script/console
16
16
  script/destroy
17
17
  script/generate
@@ -24,8 +24,8 @@ test/test_autotest_notification.rb
24
24
  test/test_helper.rb
25
25
  test/autotest_notification/test_cygwin.rb
26
26
  test/autotest_notification/test_linux.rb
27
- test/autotest_notification/test_mac.rb
28
27
  test/autotest_notification/test_windows.rb
28
+ test/autotest_notification/test_mac.rb
29
29
  website/index.html
30
30
  website/index.txt
31
31
  website/javascripts/rounded_corners_lite.inc.js
data/README.txt CHANGED
@@ -25,6 +25,8 @@ Independent of operating system you are using, you must install the ZenTest:
25
25
  In your shell, cd to the directory on the Growl disk image containing growlnotify, and type ./install.sh.
26
26
  That script will install growlnotify to /usr/local/bin and the manpage to /usr/local/man.
27
27
 
28
+ If you want to be notified with voice of the test results, when running an-install, pass a "-s" switch, when you do not want voices notifications anymore, just run it again without the "-s" switch.
29
+
28
30
 
29
31
  * If you're using Windows (with cygwin):
30
32
  You need to have Snarl and sncmd installed on your machine.
@@ -60,6 +62,9 @@ Independent of operating system you are using, you must install the ZenTest:
60
62
  If you use KDE and do not have libnotify-bin installed, it will try to use kdialog wich is part of KDE.
61
63
  It also works if you have zenity installed.
62
64
 
65
+ If you want to be notified with voice of the test results, instal espeak [http://espeak.sourceforge.net/] too, it is not needed.
66
+ And when running an-install, pass a "-s" switch, when you do not want voices notifications anymore, just run it again without the "-s" switch.
67
+
63
68
 
64
69
  == INSTALL:
65
70
 
@@ -67,7 +72,7 @@ Independent of operating system you are using, you must install the ZenTest:
67
72
 
68
73
  Run it to let the notifier in automatic mode:
69
74
 
70
- $ an-install [--speaking]
75
+ $ an-install
71
76
 
72
77
  In Windows without cygwin, it's necessary to install in the directory of the project:
73
78
 
@@ -1,17 +1,17 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{autotest-notification}
3
- s.version = "1.0.0"
3
+ s.version = "1.1.2"
4
4
 
5
5
  s.specification_version = 2 if s.respond_to? :specification_version=
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Carlos Brando", "Rodrigo Urubatan", "Alexandre da Silva", "Carlos J\303\272nior", "Davis Zanetti Cabral", "Marcos Tapaj\303\263s"]
9
- s.date = %q{2008-05-16}
9
+ s.date = %q{2008-05-28}
10
10
  s.description = %q{This gem set the autotest (ZenTest) to send messages to software as Growl, LibNotify, and Snarl, displaying a window with the results.}
11
11
  s.email = ["eduardobrando@gmail.com"]
12
12
  s.executables = ["an-install", "an-uninstall"]
13
13
  s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.txt", "website/index.txt"]
14
- s.files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.txt", "Rakefile", "config/hoe.rb", "config/requirements.rb", "lib/autotest_notification.rb", "lib/autotest_notification/version.rb", "lib/autotest_notification/linux.rb", "lib/autotest_notification/mac.rb", "lib/autotest_notification/windows.rb", "lib/autotest_notification/cygwin.rb", "script/console", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/website.rake", "test/test_autotest_notification.rb", "test/test_helper.rb", "test/autotest_notification/test_cygwin.rb", "test/autotest_notification/test_linux.rb", "test/autotest_notification/test_mac.rb", "test/autotest_notification/test_windows.rb", "website/index.html", "website/index.txt", "website/javascripts/rounded_corners_lite.inc.js", "website/stylesheets/screen.css", "website/template.html.erb", "bin/an-install", "bin/an-uninstall", "images/pass.png", "images/fail.png", "autotest-notification.gemspec"]
14
+ s.files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.txt", "Rakefile", "config/hoe.rb", "config/requirements.rb", "lib/autotest_notification.rb", "lib/autotest_notification/version.rb", "lib/autotest_notification/linux.rb", "lib/autotest_notification/windows.rb", "lib/autotest_notification/cygwin.rb", "lib/autotest_notification/mac.rb", "script/console", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/website.rake", "test/test_autotest_notification.rb", "test/test_helper.rb", "test/autotest_notification/test_cygwin.rb", "test/autotest_notification/test_linux.rb", "test/autotest_notification/test_windows.rb", "test/autotest_notification/test_mac.rb", "website/index.html", "website/index.txt", "website/javascripts/rounded_corners_lite.inc.js", "website/stylesheets/screen.css", "website/template.html.erb", "bin/an-install", "bin/an-uninstall", "images/pass.png", "images/fail.png", "autotest-notification.gemspec"]
15
15
  s.has_rdoc = true
16
16
  s.homepage = %q{http://github.com/carlosbrando/autotest-notification/}
17
17
  s.post_install_message = %q{
@@ -32,4 +32,4 @@ To turn off:
32
32
  s.test_files = ["test/autotest_notification/test_cygwin.rb", "test/autotest_notification/test_linux.rb", "test/autotest_notification/test_mac.rb", "test/autotest_notification/test_windows.rb", "test/test_autotest_notification.rb", "test/test_helper.rb"]
33
33
 
34
34
  s.add_dependency(%q<ZenTest>, [">= 3.9.2"])
35
- end
35
+ end
@@ -2,7 +2,7 @@ require 'fileutils'
2
2
  include FileUtils
3
3
 
4
4
  require 'rubygems'
5
- %w[rake hoe newgem rubigen].each do |req_gem|
5
+ %w[rake hoe newgem rubigen ZenTest].each do |req_gem|
6
6
  begin
7
7
  require req_gem
8
8
  rescue LoadError
@@ -2,9 +2,7 @@ module AutotestNotification
2
2
  class Cygwin
3
3
  class << self
4
4
  def notify(title, msg, img)
5
- img = get_image_path(img)
6
- img.strip!
7
-
5
+ img = get_image_path(img).strip
8
6
  system "sncmd /m '#{title}' '#{msg}' '#{img}' /t #{EXPIRATION_IN_SECONDS}"
9
7
  end
10
8
 
@@ -1,7 +1,8 @@
1
1
  module AutotestNotification
2
2
  class Linux
3
3
  class << self
4
- def notify(title, msg, img)
4
+
5
+ def notify(title, msg, img, failures=0)
5
6
  if has_notify?
6
7
  notify_send(title, msg, img)
7
8
  elsif has_zenity?
@@ -9,7 +10,8 @@ module AutotestNotification
9
10
  elsif has_kdialog?
10
11
  kdialog(title, msg, img)
11
12
  end
12
- true # true, cause we did everything we could
13
+
14
+ talk(msg, failures)
13
15
  end
14
16
 
15
17
  protected
@@ -25,6 +27,14 @@ module AutotestNotification
25
27
  system "zenity --info --text='#{msg}' --title='#{title}'"
26
28
  end
27
29
 
30
+ def talk(msg, failures)
31
+ # TODO: check if user has espeak installed
32
+ begin
33
+ system("/usr/bin/espeak '#{failures} test#{'s' unless failures == 1} failed'") if SPEAKING && failures > 0
34
+ rescue
35
+ end
36
+ end
37
+
28
38
  def has_zenity?
29
39
  system "which zenity 2> /dev/null"
30
40
  end
@@ -1,9 +1,18 @@
1
1
  module AutotestNotification
2
2
  class Mac
3
+ @last_test_failed = false
4
+
3
5
  class << self
4
6
  def notify(title, msg, img, failures = 0, pri = 0)
5
7
  system "growlnotify -n autotest --image #{img} -p #{pri} -m '#{msg}' #{title}"
6
- system("say #{failures} test#{'s' unless failures == 1} failed.") if SPEAKING && failures > 0
8
+
9
+ if SPEAKING && failures > 0
10
+ system("say #{failures} test#{'s' unless failures == 1} failed.")
11
+ @last_test_failed = true
12
+ elsif @last_test_failed
13
+ system("say All tests passed successfully.")
14
+ @last_test_failed = false
15
+ end
7
16
  end
8
17
  end
9
18
  end
@@ -1,8 +1,8 @@
1
1
  module AutotestNotification #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
- MINOR = 0
5
- TINY = 0
4
+ MINOR = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,51 +1,36 @@
1
1
  $:.unshift(File.dirname(__FILE__))
2
- require 'autotest_notification/linux'
3
- require 'autotest_notification/mac'
4
- require 'autotest_notification/windows'
5
- require 'autotest_notification/cygwin'
2
+ %w{ linux mac windows cygwin }.each { |x| require "autotest_notification/#{x}" }
6
3
 
7
4
  module AutotestNotification
8
- FAIL = -1
9
- PENDING = 0
10
- SUCCESS = 1
11
-
12
- EXPIRATION_IN_SECONDS = 3
13
-
14
5
  IMAGES_DIRECTORY = File.expand_path(File.dirname(__FILE__) + "/../images/")
15
6
  SUCCESS_IMAGE = "#{IMAGES_DIRECTORY}/pass.png"
16
7
  FAIL_IMAGE = "#{IMAGES_DIRECTORY}/fail.png"
17
8
 
18
- Autotest.add_hook :ran_command do |at|
9
+ EXPIRATION_IN_SECONDS = 3
19
10
 
11
+ Autotest.add_hook :ran_command do |at|
20
12
  result = at.results.is_a?(Array) ? at.results.last : at.results.split("\n").last
21
13
 
22
14
  if result
15
+ %w{ test assertion error example pending failure }.each { |x| instance_variable_set "@#{x}s", result[/(\d+) #{x}/, 1].to_i }
23
16
 
24
- # Test::Unit
25
- tests = result =~ /(\d+) test/ ? $1.to_i : 0
26
- assertions = result =~ /(\d+) assertion/ ? $1.to_i : 0
27
- errors = result =~ /(\d+) error/ ? $1.to_i : 0
28
-
29
- # RSpec
30
- examples = result =~ /(\d+) example/ ? $1.to_i : 0
31
- pendings = result =~ /(\d+) pending/ ? $1.to_i : 0
32
-
33
- # Shared
34
- failures = result =~ /(\d+) failure/ ? $1.to_i : 0
35
-
36
- code = 32
37
- msg = if result =~ /test/
38
- code = 31 if failures > 0 || errors > 0
39
- "#{pluralize('test', tests)}, #{pluralize('assertion', assertions)}, #{pluralize('failure', failures)}, #{pluralize('error', errors)}"
17
+ case result
18
+ when /test/
19
+ code = 31 if @failures > 0 || @errors > 0
20
+ msg = unit_test_message(@tests, @assertions, @failures, @errors)
21
+ when /example/
22
+ code = (@failures > 0) ? 31 : (@pendings > 0) ? 33 : 32
23
+ msg = rspec_message(@examples, @failures, @pendings)
40
24
  else
41
- code = (failures > 0) ? 31 : (pendings > 0) ? 33 : 32
42
- "#{pluralize('example', examples)}, #{pluralize('failure', failures)}, #{pendings} pending"
25
+ code = 31
26
+ msg = "1 exception occurred"
27
+ @failures = 1
43
28
  end
44
29
 
45
- if failures > 0 || errors > 0
46
- notify "FAIL", msg, FAIL_IMAGE, failures, 2
30
+ if @failures > 0 || @errors > 0
31
+ notify "FAIL", msg, FAIL_IMAGE, @failures + @errors, 2
47
32
  else
48
- notify "Pass", msg, SUCCESS_IMAGE, failures
33
+ notify "Pass", msg, SUCCESS_IMAGE
49
34
  end
50
35
 
51
36
  puts "\e[#{code}m#{'=' * 80}\e[0m\n\n"
@@ -56,7 +41,7 @@ module AutotestNotification
56
41
  def notify(title, msg, img = SUCCESS_IMAGE, failures = 0, pri = 0)
57
42
  case RUBY_PLATFORM
58
43
  when /linux/
59
- Linux.notify(title, msg, img)
44
+ Linux.notify(title, msg, img, failures)
60
45
  when /darwin/
61
46
  Mac.notify(title, msg, img, failures, pri)
62
47
  when /cygwin/
@@ -69,5 +54,13 @@ module AutotestNotification
69
54
  def pluralize(text, number)
70
55
  "#{number} #{text}#{'s' if number != 1}"
71
56
  end
57
+
58
+ def unit_test_message(tests, assertions, failures, errors)
59
+ "#{pluralize('test', tests)}, #{pluralize('assertion', assertions)}, #{pluralize('failure', failures)}, #{pluralize('error', errors)}"
60
+ end
61
+
62
+ def rspec_message(examples, failures, pendings)
63
+ "#{pluralize('example', examples)}, #{pluralize('failure', failures)}, #{pendings} pending"
64
+ end
72
65
  end
73
66
  end
@@ -1,49 +1,76 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper.rb'
2
2
 
3
3
  class TestLinux < Test::Unit::TestCase
4
-
4
+
5
5
  def setup
6
6
  turn_methods_public AutotestNotification::Linux
7
7
  end
8
-
9
- def test_notify_when_use_notify
8
+
9
+ def test_notify_when_use_notify_without_speak
10
+ Object.const_set :SPEAKING, false
11
+ AutotestNotification::Linux.expects(:has_notify?).returns(true)
12
+ verify_notify(:notify_send)
13
+ end
14
+
15
+ def test_notify_when_use_zenity_without_speak
16
+ Object.const_set :SPEAKING, false
17
+ AutotestNotification::Linux.expects(:has_notify?).returns(false)
18
+ AutotestNotification::Linux.expects(:has_zenity?).returns(true)
19
+ verify_notify(:zenity)
20
+ end
21
+
22
+ def test_notify_when_use_kdialog_without_speak
23
+ Object.const_set :SPEAKING, false
24
+ AutotestNotification::Linux.expects(:has_notify?).returns(false)
25
+ AutotestNotification::Linux.expects(:has_zenity?).returns(false)
26
+ AutotestNotification::Linux.expects(:has_kdialog?).returns(true)
27
+ verify_notify(:kdialog)
28
+ end
29
+
30
+ def test_notify_when_use_notify_with_speak
31
+ Object.const_set :SPEAKING, true
10
32
  AutotestNotification::Linux.expects(:has_notify?).returns(true)
33
+ AutotestNotification::Linux.expects(:system).with("/usr/bin/espeak '1 test failed'")
11
34
  verify_notify(:notify_send)
12
35
  end
13
-
14
- def test_notify_when_use_zenity
36
+
37
+ def test_notify_when_use_zenity_with_speak
38
+ Object.const_set :SPEAKING, true
15
39
  AutotestNotification::Linux.expects(:has_notify?).returns(false)
16
40
  AutotestNotification::Linux.expects(:has_zenity?).returns(true)
41
+ AutotestNotification::Linux.expects(:system).with("/usr/bin/espeak '1 test failed'")
17
42
  verify_notify(:zenity)
18
43
  end
19
-
20
- def test_notify_when_use_kdialog
44
+
45
+ def test_notify_when_use_kdialog_with_speak
46
+ Object.const_set :SPEAKING, true
21
47
  AutotestNotification::Linux.expects(:has_notify?).returns(false)
22
48
  AutotestNotification::Linux.expects(:has_zenity?).returns(false)
23
49
  AutotestNotification::Linux.expects(:has_kdialog?).returns(true)
50
+ AutotestNotification::Linux.expects(:system).with("/usr/bin/espeak '1 test failed'")
24
51
  verify_notify(:kdialog)
25
52
  end
26
-
53
+
27
54
  def test_notify_send
28
55
  AutotestNotification::Linux.expects(:system).with('notify-send -t 3000 -i image \'title\' \'msg\'')
29
56
  AutotestNotification::Linux.notify_send("title", "msg", "image")
30
57
  end
31
-
58
+
32
59
  def test_notify_kdialog
33
60
  AutotestNotification::Linux.expects(:system).with('kdialog --title \'title\' --passivepopup \'msg\' 3')
34
61
  AutotestNotification::Linux.kdialog("title", "msg", "image")
35
62
  end
36
-
63
+
37
64
  def test_notify_zenity
38
65
  AutotestNotification::Linux.expects(:system).with('zenity --info --text=\'msg\' --title=\'title\'')
39
66
  AutotestNotification::Linux.zenity("title", "msg", "image")
40
67
  end
41
-
68
+
42
69
  def test_has_zenity?
43
70
  AutotestNotification::Linux.expects(:system).with('which zenity 2> /dev/null')
44
71
  AutotestNotification::Linux.has_zenity?
45
72
  end
46
-
73
+
47
74
  def test_has_notify?
48
75
  AutotestNotification::Linux.expects(:system).with('which notify-send 2> /dev/null')
49
76
  AutotestNotification::Linux.has_notify?
@@ -53,12 +80,13 @@ class TestLinux < Test::Unit::TestCase
53
80
  AutotestNotification::Linux.expects(:system).with('which kdialog 2> /dev/null')
54
81
  AutotestNotification::Linux.has_kdialog?
55
82
  end
56
-
83
+
57
84
  private
58
-
85
+
59
86
  def verify_notify(method)
60
- AutotestNotification::Linux.expects(method).returns("title", "msg", "image")
61
- AutotestNotification::Linux.notify("title", "msg", "image")
87
+ AutotestNotification::Linux.expects(method).returns("title", "msg", "image", 1)
88
+ AutotestNotification::Linux.notify("title", "msg", "image",1)
62
89
  end
63
-
90
+
64
91
  end
92
+
@@ -1,10 +1,19 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper.rb'
2
2
 
3
3
  class TestMac < Test::Unit::TestCase
4
-
5
- def test_notify
4
+
5
+ def test_notify_without_voice
6
+ Object.const_set :SPEAKING, false
7
+ AutotestNotification::Mac.expects(:system).with("growlnotify -n autotest --image image -p 0 -m 'msg' title")
8
+ AutotestNotification::Mac.notify("title", "msg", "image", 1)
9
+ end
10
+
11
+ def test_notify_with_voice
12
+ Object.const_set :SPEAKING, true
6
13
  AutotestNotification::Mac.expects(:system).with("growlnotify -n autotest --image image -p 0 -m 'msg' title")
7
- AutotestNotification::Mac.notify("title", "msg", "image")
14
+ AutotestNotification::Mac.expects(:system).with("say 1 test failed.")
15
+ AutotestNotification::Mac.notify("title", "msg", "image", 1)
8
16
  end
9
-
17
+
10
18
  end
19
+
@@ -20,12 +20,12 @@ class TestAutotestNotification < Test::Unit::TestCase
20
20
  end
21
21
 
22
22
  def test_notify_when_os_is_linux
23
- AutotestNotification::Linux.expects(:notify).with(@title, @msg, @image)
23
+ AutotestNotification::Linux.expects(:notify).with(@title, @msg, @image,@pri)
24
24
  verify_to("linux")
25
25
  end
26
26
 
27
27
  def test_notify_when_os_is_mac
28
- AutotestNotification::Mac.expects(:notify).with(@title, @msg, @image, @pri)
28
+ AutotestNotification::Mac.expects(:notify).with(@title, @msg, @image, @pri, 0)
29
29
  verify_to("darwin")
30
30
  end
31
31
 
data/website/index.html CHANGED
@@ -33,7 +33,7 @@
33
33
  <h1>autotest_notification</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/autotest_notification"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/autotest_notification" class="numbers">0.3.0</a>
36
+ <a href="http://rubyforge.org/projects/autotest_notification" class="numbers">1.1.2</a>
37
37
  </div>
38
38
  <h1>&#x2192; &#8216;autotest_notification&#8217;</h1>
39
39
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carlosbrando-autotest-notification
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Brando
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2008-05-16 00:00:00 -07:00
17
+ date: 2008-05-28 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -53,9 +53,9 @@ files:
53
53
  - lib/autotest_notification.rb
54
54
  - lib/autotest_notification/version.rb
55
55
  - lib/autotest_notification/linux.rb
56
- - lib/autotest_notification/mac.rb
57
56
  - lib/autotest_notification/windows.rb
58
57
  - lib/autotest_notification/cygwin.rb
58
+ - lib/autotest_notification/mac.rb
59
59
  - script/console
60
60
  - script/destroy
61
61
  - script/generate
@@ -68,8 +68,8 @@ files:
68
68
  - test/test_helper.rb
69
69
  - test/autotest_notification/test_cygwin.rb
70
70
  - test/autotest_notification/test_linux.rb
71
- - test/autotest_notification/test_mac.rb
72
71
  - test/autotest_notification/test_windows.rb
72
+ - test/autotest_notification/test_mac.rb
73
73
  - website/index.html
74
74
  - website/index.txt
75
75
  - website/javascripts/rounded_corners_lite.inc.js