Commit 0adcf264 authored by Fabio Pelosin's avatar Fabio Pelosin

[SpecHelper] Improve support for Bacon.

parent 9dc15fd9
...@@ -75,27 +75,45 @@ module Bacon ...@@ -75,27 +75,45 @@ module Bacon
# Overrides the TestUnitOutput to provide colored result output. # Overrides the TestUnitOutput to provide colored result output.
# #
module TestUnitOutput module TestUnitOutput
# Represents the specifications as `:`.
#
def handle_specification(name) def handle_specification(name)
print Bacon.color(nil, ':') indicator = Bacon.color(nil, ':')
print indicator
@indicators||=''
@indicators << indicator
yield yield
end end
# Represents the requirements as:
#
# - [.] successful
# - [E] error
# - [F] failure
# - [_] skipped
#
# After the first failure or error all the other requirements are skipped.
#
def handle_requirement(description, disabled = false) def handle_requirement(description, disabled = false)
if @first_error if @first_error
print Bacon.color(nil, '_') indicator = Bacon.color(nil, '_')
else else
error = yield error = yield
if !error.empty? if !error.empty?
@first_error = true
m = error[0..0] m = error[0..0]
c = (m == "E" ? :red : :yellow) c = (m == "E" ? :red : :yellow)
print Bacon.color(c, m) indicator = Bacon.color(c, m)
@first_error = true
elsif disabled elsif disabled
print "D" indicator = "D"
else else
print Bacon.color(nil, '.') indicator = Bacon.color(nil, '.')
end end
end end
print indicator
@indicators||=''
@indicators << indicator
end end
def handle_summary def handle_summary
...@@ -105,6 +123,9 @@ module Bacon ...@@ -105,6 +123,9 @@ module Bacon
error_count += 1 if s.include?('Error:') || s.include?('Informative') error_count += 1 if s.include?('Error:') || s.include?('Informative')
first_error << s if error_count <= 1 first_error << s if error_count <= 1
end end
first_error = first_error.gsub(Dir.pwd + '/', '')
first_error = first_error.gsub(/lib\//, Bacon.color(:yellow, 'lib') + '/')
first_error = first_error.gsub(/:([0-9]+):/, ':' + Bacon.color(:yellow, '\1') + ':')
puts "\n#{first_error}" if Backtraces puts "\n#{first_error}" if Backtraces
unless Counter[:disabled].zero? unless Counter[:disabled].zero?
puts Bacon.color(:yellow, "#{Counter[:disabled]} disabled specifications") puts Bacon.color(:yellow, "#{Counter[:disabled]} disabled specifications")
...@@ -117,6 +138,7 @@ module Bacon ...@@ -117,6 +138,7 @@ module Bacon
puts Bacon.color(:red, result) puts Bacon.color(:red, result)
end end
end end
end end
#---------------------------------------------------------------------------# #---------------------------------------------------------------------------#
...@@ -124,7 +146,7 @@ module Bacon ...@@ -124,7 +146,7 @@ module Bacon
module FilterBacktraces module FilterBacktraces
def handle_summary def handle_summary
ErrorLog.replace(ErrorLog.split("\n").reject do |line| ErrorLog.replace(ErrorLog.split("\n").reject do |line|
line =~ %r{(gems/mocha|spec_helper)} line =~ %r{(gems/mocha|spec_helper|ruby_noexec_wrapper)}
end.join("\n").lstrip << "\n\n") end.join("\n").lstrip << "\n\n")
super super
end end
...@@ -141,6 +163,3 @@ module Bacon ...@@ -141,6 +163,3 @@ module Bacon
end end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment