summaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-05-13 16:09:28 -0500
committerLuke Kanies <luke@madstop.com>2008-05-13 16:09:28 -0500
commitc61fc0217fe8880216fe059ce54c4d0d61a78811 (patch)
tree1ccf25b5c48972f53428301764cf8b3e85c277d2 /ext
parent59b9958712d033bbd294ff6469ea3a242c45c82c (diff)
downloadpuppet-c61fc0217fe8880216fe059ce54c4d0d61a78811.tar.gz
puppet-c61fc0217fe8880216fe059ce54c4d0d61a78811.tar.xz
puppet-c61fc0217fe8880216fe059ce54c4d0d61a78811.zip
Adding autotest info to the ext/ directory.
Adding the autotest config, instructions, and a Rakefile that can install it.
Diffstat (limited to 'ext')
-rw-r--r--ext/autotest/Rakefile8
-rw-r--r--ext/autotest/config43
-rw-r--r--ext/autotest/readme.rst9
3 files changed, 60 insertions, 0 deletions
diff --git a/ext/autotest/Rakefile b/ext/autotest/Rakefile
new file mode 100644
index 000000000..86327c04b
--- /dev/null
+++ b/ext/autotest/Rakefile
@@ -0,0 +1,8 @@
+dest = File.expand_path("~/.autotest")
+file dest => ["config", "Rakefile"] do
+ sh "cp config #{dest}"
+end
+
+task :install => dest
+
+task :default => :install
diff --git a/ext/autotest/config b/ext/autotest/config
new file mode 100644
index 000000000..d37c1b2c6
--- /dev/null
+++ b/ext/autotest/config
@@ -0,0 +1,43 @@
+# vim: syntax=ruby
+# From http://pastie.caboo.se/115692, linked from rickbradley
+
+require 'autotest/redgreen'
+require 'autotest/timestamp'
+
+Autotest.send(:alias_method, :real_find_files, :find_files)
+Autotest.send(:define_method, :find_files) do |*args|
+ real_find_files.reject do |k, v|
+ if (ENV['AUTOTEST'] and !ENV['AUTOTEST'].empty?)
+ !Regexp.new(ENV['AUTOTEST']).match(k)
+ end
+ end
+end
+
+module Autotest::Growl
+
+ def self.growl title, msg, img, pri=0, sticky=""
+ system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}"
+ end
+
+ Autotest.add_hook :ran_command do |at|
+ image_root = "~/.autotest_images"
+ results = [at.results].flatten.join("\n")
+ output = results.slice(/(\d+)\stests,\s(\d+)\sassertions,\s(\d+)\sfailures,\s(\d+)\serrors/)
+ if output
+ if $~[3].to_i > 0 || $~[4].to_i > 0
+ growl "FAIL", "#{output}", "#{image_root}/fail.png", 2
+ else
+ growl "Pass", "#{output}", "#{image_root}/pass.png"
+ end
+ end
+
+ output = results.slice(/(\d+)\sexamples,\s(\d+)\sfailures?(,\s+\d+\s+pending)?/)
+ if output
+ if $~[2].to_i > 0 || $~[4].to_i > 0
+ growl "FAIL", "#{output}", "#{image_root}/fail.png", 2
+ else
+ growl "Pass", "#{output}", "#{image_root}/pass.png"
+ end
+ end
+ end
+end
diff --git a/ext/autotest/readme.rst b/ext/autotest/readme.rst
new file mode 100644
index 000000000..338d4b0d3
--- /dev/null
+++ b/ext/autotest/readme.rst
@@ -0,0 +1,9 @@
+Autotest is a simple tool that automatically links tests with the files being
+tested, and runs tests automatically when either the test or code has changed.
+
+If you are running on a Mac and have growlnotify_ installed, install the
+ZenTest_ gem, then copy the ``config`` file to ``~/.autotest`` (or just
+run ``rake`` in this directory).
+
+.. _zentest: http://www.zenspider.com/ZSS/Products/ZenTest/
+.. _growlnotify: http://growl.info/extras.php