-
-
Save janxious/294107 to your computer and use it in GitHub Desktop.
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
# -*- coding: utf-8 -*- | |
module Color | |
COLORS = { :clear => 0, :red => 31, :green => 32, :yellow => 33, :magenta => 35 } | |
end | |
class Test::Unit::Slow | |
alias :old_long_display :long_display | |
def long_display | |
time_index = /\d+\.\d+s$/ =~ old_long_display | |
time = old_long_display[time_index..-1] if index | |
new_display = old_long_display.sub(time, Color.magenta(time)) if time | |
new_display.sub('Too Slow', Color.magenta('Too Slow')) | |
end | |
end | |
class Test::Unit::UI::Console::RedGreenTestRunner < Test::Unit::UI::Console::TestRunner | |
def output_single(something, level=NORMAL) | |
return unless (output?(level)) | |
something = case something | |
when '.' then Color.green('.') | |
when '☻' then Color.magenta("☻") | |
when 'F' then Color.red("F") | |
when 'E' then Color.yellow("E") | |
else something | |
end | |
@io.write(something) | |
@io.flush | |
end | |
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
# -*- coding: utf-8 -*- | |
module Test | |
module Unit | |
class Slow | |
attr_reader :test_name, :message | |
def initialize(test_name, time_taken) | |
@test_name = test_name | |
@time_taken = time_taken | |
@message = "Too Slow" | |
end | |
def single_character_display | |
"☻" | |
end | |
def short_display | |
"#{@message}:\n#@test_name: #{"%.3f" % @time_taken}s" | |
end | |
def long_display | |
short_display | |
end | |
def to_s | |
long_display | |
end | |
end | |
end | |
end | |
module Test | |
module Unit | |
module UI | |
module Console | |
class TestRunner | |
def test_started(name) | |
@individual_test_start_time = Time.now | |
output_single(name + ": ", VERBOSE) | |
end | |
def test_finished(name) | |
elapsed_test_time = Time.now - @individual_test_start_time | |
if elapsed_test_time > 1 | |
add_fault(Test::Unit::Slow.new(name, elapsed_test_time)) | |
else | |
output_single(".", PROGRESS_ONLY) unless (@already_outputted) | |
nl(VERBOSE) | |
end | |
@already_outputted = false | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment