turn 0.8.3 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +1 -8
- data/History.txt +16 -0
- data/{license/GPLv2.txt → LICENSE-GPL2.txt} +0 -0
- data/{license/MIT-LICENSE.txt → LICENSE-MIT.txt} +0 -0
- data/{license/RUBY-LICENSE.txt → LICENSE-RUBY.txt} +0 -0
- data/{NOTICE.txt → LICENSE.txt} +1 -1
- data/README.md +26 -0
- data/Rakefile +1 -0
- data/Version.txt +1 -1
- data/bin/turn +7 -1
- data/lib/turn.rb +20 -11
- data/lib/turn/autoload.rb +1 -1
- data/lib/turn/autorun.rb +8 -0
- data/lib/turn/bin.rb +7 -1
- data/lib/turn/colorize.rb +26 -10
- data/lib/turn/command.rb +32 -13
- data/lib/turn/components.rb +4 -0
- data/lib/turn/components/case.rb +1 -1
- data/lib/turn/components/suite.rb +9 -3
- data/lib/turn/configuration.rb +197 -0
- data/lib/turn/controller.rb +15 -206
- data/lib/turn/{autorun/minitest.rb → minitest.rb} +7 -3
- data/lib/turn/reporter.rb +65 -10
- data/lib/turn/reporters/cue_reporter.rb +13 -2
- data/lib/turn/reporters/dot_reporter.rb +12 -11
- data/lib/turn/reporters/outline_reporter.rb +57 -36
- data/lib/turn/reporters/pretty_reporter.rb +37 -24
- data/lib/turn/reporters/progress_reporter.rb +64 -26
- data/lib/turn/runners/minirunner.rb +7 -32
- data/lib/turn/testunit.rb +5 -0
- data/test/helper.rb +11 -2
- data/test/test_framework.rb +39 -30
- data/test/test_runners.rb +9 -7
- data/{demo → try}/test_autorun_minitest.rb +0 -0
- data/{demo → try}/test_autorun_testunit.rb +0 -0
- data/{demo → try}/test_counts.rb +0 -0
- data/{demo → try}/test_sample.rb +0 -0
- data/{demo → try}/test_sample2.rb +0 -0
- data/turn.gemspec +2 -2
- metadata +42 -29
- data/lib/turn/autorun/minitest0.rb +0 -163
- data/lib/turn/autorun/testunit.rb +0 -9
- data/lib/turn/autorun/testunit0.rb +0 -116
@@ -1,116 +0,0 @@
|
|
1
|
-
require 'test/unit/ui/console/testrunner'
|
2
|
-
require 'turn/colorize'
|
3
|
-
|
4
|
-
module ::Test::Unit
|
5
|
-
module UI
|
6
|
-
module Console
|
7
|
-
class TestRunner
|
8
|
-
include Turn::Colorize
|
9
|
-
|
10
|
-
# 1.x of test/unut used @io, where as 2.x uses @output.
|
11
|
-
def turn_out
|
12
|
-
@turn_out ||= (@io || @output)
|
13
|
-
end
|
14
|
-
|
15
|
-
alias :t_attach_to_mediator :attach_to_mediator
|
16
|
-
def attach_to_mediator
|
17
|
-
@mediator.add_listener(TestRunnerMediator::STARTED, &method(:t_started))
|
18
|
-
@mediator.add_listener(TestRunnerMediator::FINISHED, &method(:t_finished))
|
19
|
-
@mediator.add_listener(TestCase::STARTED, &method(:t_test_started))
|
20
|
-
@mediator.add_listener(TestCase::FINISHED, &method(:t_test_finished))
|
21
|
-
@mediator.add_listener(TestResult::FAULT, &method(:t_fault))
|
22
|
-
turn_out.sync = true
|
23
|
-
@t_cur_file, @t_fault = nil
|
24
|
-
end
|
25
|
-
|
26
|
-
def t_started( result )
|
27
|
-
@t_result = result
|
28
|
-
end
|
29
|
-
|
30
|
-
def t_finished( elapsed_time )
|
31
|
-
failure = @t_result.failure_count
|
32
|
-
error = @t_result.error_count
|
33
|
-
total = @t_result.run_count
|
34
|
-
pass = total - failure - error
|
35
|
-
|
36
|
-
bar = '=' * 78
|
37
|
-
if colorize?
|
38
|
-
bar = if pass == total then ::ANSI::Code.green{bar}
|
39
|
-
else ::ANSI::Code.red{bar} end
|
40
|
-
end
|
41
|
-
|
42
|
-
turn_out.puts bar
|
43
|
-
turn_out.puts " pass: %d, fail: %d, error: %d" % [pass, failure, error]
|
44
|
-
turn_out.puts " total: %d tests with %d assertions in #{elapsed_time} seconds" % [total, @t_result.assertion_count]
|
45
|
-
turn_out.puts bar
|
46
|
-
end
|
47
|
-
|
48
|
-
def t_test_started( name )
|
49
|
-
method, file = name.scan(%r/^([^\(]+)\(([^\)]+)\)/o).flatten!
|
50
|
-
if @t_cur_file != file
|
51
|
-
@t_cur_file = file
|
52
|
-
file = colorize? ? ::ANSI::Code.yellow{file} : file
|
53
|
-
turn_out.puts file
|
54
|
-
end
|
55
|
-
turn_out.print " %-69s" % method
|
56
|
-
end
|
57
|
-
|
58
|
-
def t_test_finished( name )
|
59
|
-
turn_out.puts " #{PASS}" unless @t_fault
|
60
|
-
@t_fault = false
|
61
|
-
end
|
62
|
-
|
63
|
-
def t_fault( fault )
|
64
|
-
@t_fault = true
|
65
|
-
msg = "\t"
|
66
|
-
|
67
|
-
case fault
|
68
|
-
when ::Test::Unit::Error
|
69
|
-
turn_out.puts ERROR
|
70
|
-
msg << fault.to_s.split("\n")[2..-1].join("\n\t")
|
71
|
-
when ::Test::Unit::Failure
|
72
|
-
test_name = underscore(fault.test_name.match(/\((.*)\)/)[1])
|
73
|
-
better_location = fault.location.detect{|line|line.include?(test_name)} || fault.location[0]
|
74
|
-
turn_out.puts " #{FAIL}"
|
75
|
-
msg << better_location.to_s << "\n\t"
|
76
|
-
msg << fault.message.gsub("\n","\n\t")
|
77
|
-
end
|
78
|
-
|
79
|
-
msg = ::ANSI::Code.magenta{msg} if colorize?
|
80
|
-
turn_out.puts msg
|
81
|
-
end
|
82
|
-
|
83
|
-
private
|
84
|
-
|
85
|
-
# Taken from ActiveSupport::Inflector
|
86
|
-
def underscore(camel_cased_word)
|
87
|
-
word = camel_cased_word.to_s.dup
|
88
|
-
word.gsub!(/::/, '/')
|
89
|
-
word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
90
|
-
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
91
|
-
word.tr!("-", "_")
|
92
|
-
word.downcase!
|
93
|
-
word
|
94
|
-
end
|
95
|
-
|
96
|
-
def setup_mediator
|
97
|
-
@mediator = create_mediator(@suite)
|
98
|
-
suite_name = @suite.to_s
|
99
|
-
if ( @suite.kind_of?(Module) )
|
100
|
-
suite_name = @suite.name
|
101
|
-
end
|
102
|
-
msg = rails? ? "\n" : "Loaded suite #{suite_name}" #always same in rails so scrap it
|
103
|
-
output(msg)
|
104
|
-
end
|
105
|
-
|
106
|
-
def rails?
|
107
|
-
$:.to_s.include? "rails"
|
108
|
-
end
|
109
|
-
|
110
|
-
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
# EOF
|