Navigation Menu

Skip to content

Commit

Permalink
Truncate long test name
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Aug 11, 2012
1 parent 778774d commit 047b99a
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions lib/groonga/tester.rb
Expand Up @@ -1316,11 +1316,24 @@ def report_diff(expected, actual)
end

def report_test_result(result, label)
message = " %10.4fs [%s]" % [result.elapsed_time, label]
message = test_result_message(result, label)
message = message.rjust(@term_width - @current_column) if @term_width > 0
puts(message)
end

def test_result_message(result, label)
" %7.4fs [%s]" % [result.elapsed_time, label]
end

def max_test_result_width
@max_test_result_width ||= guess_max_test_result_width
end

def guess_max_test_result_width
result = Result.new
test_result_message(result, "not checked").bytesize
end

def justify(message, width)
return " " * width if message.nil?
return message.ljust(width) if message.bytesize <= width
Expand Down Expand Up @@ -1382,6 +1395,10 @@ def start_suite(worker)

def start_test(worker)
label = " #{worker.test_name}"
if @term_width > 0
width = @term_width - @current_column - max_test_result_width
label = justify(label, width)
end
print(label)
@output.flush
end
Expand Down Expand Up @@ -1494,10 +1511,11 @@ def draw_status_line(worker)
def draw_test_line(worker)
clear_line
if worker.test_name
puts(" #{worker.test_name}")
label = " #{worker.test_name}"
else
puts(" #{worker.statistics}")
label = " #{worker.statistics}"
end
puts(justify(label, @term_width))
end

def redraw
Expand Down

0 comments on commit 047b99a

Please sign in to comment.