Created
September 16, 2014 05:08
-
-
Save bhenderson/19ca15a86809eb8efc07 to your computer and use it in GitHub Desktop.
zentest issue #44
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/.autotest b/.autotest | |
index be4dedd..5ce4720 100644 | |
--- a/.autotest | |
+++ b/.autotest | |
@@ -21,6 +21,17 @@ Autotest.add_hook :initialize do |at| | |
# end | |
end | |
+Autotest.add_hook :initialize do |at| | |
+ raise ENV['ERR'] | |
+end | |
+ | |
+Autotest.add_hook :died do |at, err| | |
+ if err.message == 'an error' | |
+ puts "it's ok... don't cry" | |
+ true | |
+ end | |
+end | |
+ | |
# Autotest.add_hook :run_command do |at| | |
# system "rake build" | |
# end | |
diff --git a/lib/autotest.rb b/lib/autotest.rb | |
index 479b3e9..7d2863f 100755 | |
--- a/lib/autotest.rb | |
+++ b/lib/autotest.rb | |
@@ -266,7 +266,7 @@ def run | |
rescue Exception => err | |
hook(:died, err) or raise err | |
ensure | |
- Minitest::Server.stop | |
+ # Minitest::Server.stop | |
end | |
## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ERR='an error' ruby -Ilib bin/autotest | |
Unhandled exception: an error | |
/home/bhenderson/prog/github/minitest-autotest/.autotest:25:in `block in <top (required)>' | |
/home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:700:in `[]' | |
/home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:700:in `block in hook' | |
/home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:700:in `each' | |
/home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:700:in `any?' | |
/home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:700:in `hook' | |
/home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:237:in `run' | |
/home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:141:in `run' | |
bin/autotest:6:in `<main>' | |
Quitting | |
it's ok... don't cry | |
$ ERR='a different error' ruby -Ilib bin/autotest | |
Unhandled exception: a different error | |
/home/bhenderson/prog/github/minitest-autotest/.autotest:25:in `block in <top (required)>' | |
/home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:700:in `[]' | |
/home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:700:in `block in hook' | |
/home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:700:in `each' | |
/home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:700:in `any?' | |
/home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:700:in `hook' | |
/home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:237:in `run' | |
/home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:141:in `run' | |
bin/autotest:6:in `<main>' | |
Quitting | |
/home/bhenderson/prog/github/minitest-autotest/.autotest:25:in `block in <top (required)>': a different error (RuntimeError) | |
from /home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:700:in `[]' | |
from /home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:700:in `block in hook' | |
from /home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:700:in `each' | |
from /home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:700:in `any?' | |
from /home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:700:in `hook' | |
from /home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:237:in `run' | |
from /home/bhenderson/prog/github/minitest-autotest/lib/autotest.rb:141:in `run' | |
from bin/autotest:6:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had to comment out Minitest::Server as I was getting a nameerror for some reason.
when I want to handle the error, the default :died hook says it's unhandled, but I'm really trying to handle it.
When I don't "handle" it, it outputs the error twice.