lib/turn.rb in turn-0.1.2 vs lib/turn.rb in turn-0.2.0
- old
+ new
@@ -1,6 +1,6 @@
-# $Id: turn.rb 46 2006-11-10 22:40:08Z tpease $
+# $Id: turn.rb 55 2006-11-19 20:37:40Z tpease $
require 'test/unit/ui/console/testrunner'
begin
require 'facets/more/ansicode'
rescue LoadError
@@ -15,56 +15,58 @@
module ::Test::Unit
module UI
module Console
class TestRunner
+ alias :t_attach_to_mediator :attach_to_mediator
def attach_to_mediator
- @mediator.add_listener(TestRunnerMediator::STARTED, &method(:p_started))
- @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:p_finished))
- @mediator.add_listener(TestCase::STARTED, &method(:p_test_started))
- @mediator.add_listener(TestCase::FINISHED, &method(:p_test_finished))
- @mediator.add_listener(TestResult::FAULT, &method(:p_fault))
+ @mediator.add_listener(TestRunnerMediator::STARTED, &method(:t_started))
+ @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:t_finished))
+ @mediator.add_listener(TestCase::STARTED, &method(:t_test_started))
+ @mediator.add_listener(TestCase::FINISHED, &method(:t_test_finished))
+ @mediator.add_listener(TestResult::FAULT, &method(:t_fault))
@io.sync = true
+ @t_cur_file, @t_fault = nil
end
- def p_started( result )
- @p_result = result
+ def t_started( result )
+ @t_result = result
end
- def p_finished( elapsed_time )
- failure = @p_result.failure_count
- error = @p_result.error_count
- total = @p_result.run_count
+ def t_finished( elapsed_time )
+ failure = @t_result.failure_count
+ error = @t_result.error_count
+ total = @t_result.run_count
pass = total - failure - error
bar = '=' * 78
if COLORIZE
bar = if pass == total then ::Console::ANSICode.green bar
else ::Console::ANSICode.red bar end
end
@io.puts bar
@io.puts " pass: %d, fail: %d, error: %d" % [pass, failure, error]
- @io.puts " total: %d tests with %d assertions in #{elapsed_time} seconds" % [total, @p_result.assertion_count]
+ @io.puts " total: %d tests with %d assertions in #{elapsed_time} seconds" % [total, @t_result.assertion_count]
@io.puts bar
end
- def p_test_started( name )
+ def t_test_started( name )
method, file = name.scan(%r/^([^\(]+)\(([^\)]+)\)/o).flatten!
- if @p_cur_file != file
- @p_cur_file = file
+ if @t_cur_file != file
+ @t_cur_file = file
@io.puts file
end
@io.print " %-69s" % method
end
- def p_test_finished( name )
- @io.puts PASS unless @p_fault
- @p_fault = false
+ def t_test_finished( name )
+ @io.puts PASS unless @t_fault
+ @t_fault = false
end
- def p_fault( fault )
- @p_fault = true
+ def t_fault( fault )
+ @t_fault = true
msg = "\t"
case fault
when ::Test::Unit::Error
@io.puts ERROR