diff options
-rwxr-xr-x | bin/bacon | 4 | ||||
-rw-r--r-- | lib/bacon.rb | 28 |
2 files changed, 31 insertions, 1 deletions
diff --git a/bin/bacon b/bin/bacon index 8e78bca..60997d8 100755 --- a/bin/bacon +++ b/bin/bacon @@ -45,6 +45,10 @@ opts = OptionParser.new("", 24, ' ') { |opts| output = 'TestUnitOutput' } + opts.on("-p", "--tap", "do TAP (Test Anything Protocol) output") { + output = 'TapOutput' + } + opts.on("-a", "--automatic", "gather tests from ./test/, include ./lib/") { $LOAD_PATH.unshift "lib" if File.directory? "lib" automatic = true diff --git a/lib/bacon.rb b/lib/bacon.rb index 4b0cf58..eab0716 100644 --- a/lib/bacon.rb +++ b/lib/bacon.rb @@ -57,6 +57,32 @@ module Bacon end end + module TapOutput + def handle_specification(name) + yield + end + + def handle_requirement(description) + Bacon::ErrorLog.replace "" + error = yield + if error.empty? + printf "ok %-8d # %s\n" % [Counter[:specifications], description] + else + printf "not ok %-4d # %s: %s\n" % + [Counter[:specifications], description, error] + puts Bacon::ErrorLog.strip.gsub(/^/, '# ') + end + end + + def handle_summary + puts "1..#{Counter[:specifications]}" + puts "# %d tests, %d assertions, %d failures, %d errors" % + [Counter[:specifications], Counter[:requirements], + Counter[:failed], Counter[:errors]] + p Bacon::Counter + end + end + extend SpecDoxOutput # default class Error < RuntimeError @@ -95,7 +121,7 @@ module Bacon @after.each { |block| instance_eval(&block) } rescue Object => e ErrorLog << "#{e.class}: #{e.message}\n" - e.backtrace.find_all { |line| line !~ /\/bacon.rb:\d+/ }. + e.backtrace.find_all { |line| line !~ /bin\/bacon|\/bacon\.rb:\d+/ }. each_with_index { |line, i| ErrorLog << "\t#{line}#{i==0?": "+@name + " - "+description:""}\n" } |