Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lib/test/unit.rb: colorize
* lib/test/unit.rb (Test::Unit::Runner#_run_testcase): colorize.
  • Loading branch information
nobu committed May 7, 2012
commit 0c979e773c324f1803f402bd689bd2c58bb2da3e
9 changes: 8 additions & 1 deletion lib/test/unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,8 @@ def _run_testcase(inst)
@report_count ||= 0
report.each do |msg|
next if @options[:hide_skip] and msg.start_with? "Skipped:"
puts "%3d) %s\n" % [@report_count += 1, msg]
msg = msg.split(/$/, 2)
puts "#{@failed_color}%3d) %s#{@reset_color}%s\n" % [@report_count += 1, *msg]
end
report.clear
end
Expand Down Expand Up @@ -729,6 +730,12 @@ def puke klass, meth, e
def initialize # :nodoc:
super
@tty = $stdout.tty?
if @tty and /mswin|mingw/ !~ RUBY_PLATFORM and /dumb/ !~ ENV["TERM"]
@failed_color = "\e[31m"
@reset_color = "\e[m"
else
@failed_color = @reset_color = ""
end
end

def status(*args)
Expand Down