rubytest 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,211 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module Test::Reporters
4
-
5
- #
6
- class Outline < Abstract
7
-
8
- #
9
- def begin_suite(suite)
10
- @tab = 0
11
- @start_time = Time.now
12
- @start_test_cache = {}
13
-
14
- timer_reset
15
- end
16
-
17
- #
18
- def begin_case(tc)
19
- lines = tc.to_s.split("\n")
20
- label = lines.shift
21
- if tc.respond_to?(:type)
22
- tabs "#{tc.type}: #{label}".ansi(:bold)
23
- tabs lines.join("\n"), 2 unless lines.empty?
24
- else
25
- tabs "#{label}".ansi(:bold)
26
- tabs lines.join("\n"), 2 unless lines.empty?
27
- end
28
- @tab += 2
29
- end
30
-
31
- #
32
- def begin_test(test)
33
- if test.respond_to?(:topic) && test.topic
34
- topic = test.topic.to_s
35
- @start_test_cache[topic] ||= (
36
- tabs "#{topic}"
37
- true
38
- )
39
- end
40
- timer_reset
41
- end
42
-
43
- #
44
- #
45
- def pass(test)
46
- tabs "#{test}".ansi(:green)
47
- end
48
-
49
- #
50
- def fail(test, exception)
51
- tabs "#{test}".ansi(:red)
52
-
53
- s = []
54
- s << "#{exception}"
55
- s << "#{file_and_line(exception)}"
56
- s << code(exception)
57
- #puts " #{exception.backtrace[0]}"
58
- tabs s.join("\n"), 4
59
- end
60
-
61
- #
62
- def error(test, exception)
63
- tabs "#{test}".ansi(:red, :bold)
64
-
65
- s = []
66
- s << "#{exception.class}"
67
- s << "#{exception}"
68
- s << "#{file_and_line(exception)}"
69
- s << code(exception)
70
- #s << trace.join("\n") unless trace.empty?
71
- tabs s.join("\n"), 4
72
- end
73
-
74
- #
75
- def todo(test, exception)
76
- tabs "#{test}".ansi(:yellow)
77
- tabs "#{file_and_line(exception)}", 4
78
- end
79
-
80
- #
81
- def omit(test, exception)
82
- tabs "#{test}".ansi(:cyan)
83
- end
84
-
85
- #
86
- def end_case(tcase)
87
- @tab -= 2
88
- end
89
-
90
- #
91
- def end_suite(suite)
92
- puts
93
-
94
- #unless record[:omit].empty?
95
- # puts "\nOMITTED:\n\n"
96
- # puts record[:omit].map{ |u| u.to_s }.sort.join(' ')
97
- # puts
98
- #end
99
-
100
- #unless record[:todo].empty?
101
- # puts "\nPENDING:\n\n"
102
- # record[:pending].each do |test, exception|
103
- # puts "#{test}".tabto(4)
104
- # puts "#{file_and_line(exception)}".tabto(4)
105
- # puts
106
- # end
107
- #end
108
-
109
- #unless record[:fail].empty?
110
- # puts "\nFAILURES:\n\n"
111
- # record[:fail].reverse_each do |test, exception|
112
- #
113
- # s = []
114
- # s << "#{test}".ansi(:red)
115
- # s << "#{file_and_line(exception)}".ansi(:bold)
116
- # s << "#{exception}"
117
- # s << code_snippet(exception)
118
- # #puts " #{exception.backtrace[0]}"
119
- # puts s.join("\n").tabto(4)
120
- # end
121
- #end
122
-
123
- #unless record[:error].empty?
124
- # puts "\nERRORS:\n\n"
125
- # record[:error].reverse_each do |test, exception|
126
- # trace = clean_backtrace(exception)[1..-1]
127
- #
128
- # s = []
129
- # s << "#{test}".ansi(:red, :bold)
130
- # s << "#{exception.class} @ #{file_and_line(exception)}".ansi(:bold)
131
- # s << "#{exception}"
132
- # s << code_snippet(exception)
133
- # #s << trace.join("\n") unless trace.empty?
134
- # puts s.join("\n").tabto(4)
135
- # end
136
- #end
137
-
138
- puts
139
- puts timestamp
140
- puts
141
- puts tally
142
- end
143
-
144
- #
145
- def clock
146
- secs = Time.now - @start_time
147
- return "%0.5fs" % [secs.to_s]
148
- end
149
-
150
- #
151
- def timer
152
- secs = Time.now - @time
153
- @time = Time.now
154
- return "%0.5fs" % [secs.to_s]
155
- end
156
-
157
- #
158
- def timer_reset
159
- @time = Time.now
160
- end
161
-
162
- #
163
- def tabs(str, indent=0)
164
- if str
165
- puts(str.tabto(@tab + indent))
166
- else
167
- puts
168
- end
169
- end
170
-
171
- end
172
-
173
- end
174
-
175
-
176
-
177
-
178
- =begin
179
- if cover?
180
-
181
- unless uncovered_cases.empty?
182
- unc = uncovered_cases.map do |mod|
183
- yellow(mod.name)
184
- end.join(", ")
185
- puts "\nUncovered Cases: " + unc
186
- end
187
-
188
- unless uncovered_units.empty?
189
- unc = uncovered_units.map do |unit|
190
- yellow(unit)
191
- end.join(", ")
192
- puts "\nUncovered Units: " + unc
193
- end
194
-
195
- #unless uncovered.empty?
196
- # unc = uncovered.map do |unit|
197
- # yellow(unit)
198
- # end.join(", ")
199
- # puts "\nUncovered: " + unc
200
- #end
201
-
202
- unless undefined_units.empty?
203
- unc = undefined_units.map do |unit|
204
- yellow(unit)
205
- end.join(", ")
206
- puts "\nUndefined Units: " + unc
207
- end
208
-
209
- end
210
- =end
211
-
@@ -1,195 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module Test::Reporters
4
-
5
- # Progess reporter gives test counter, precentage and times.
6
- #
7
- class Progress < Abstract
8
-
9
- #
10
- def begin_suite(suite)
11
- @tab = 0
12
- @total_count = total_count(suite)
13
- @start_time = Time.now
14
- @test_cache = {}
15
- @count = 0
16
-
17
- max = @total_count.to_s.size
18
-
19
- @layout_head = " %3u%% %#{max}s %#{max}s %8s %11s %1s %s"
20
- @layout = " %3u%% %#{max}u/%#{max}u %8s %11s %1s %s"
21
-
22
- timer_reset
23
- end
24
-
25
- #
26
- def begin_case(tc)
27
- #tabs tc.to_s.ansi(:bold)
28
- show_header(' ', tc.to_s)
29
- @tab += 2
30
- end
31
-
32
- #
33
- def begin_test(test)
34
- if test.respond_to?(:topic) && test.topic
35
- topic = test.topic.to_s.rstrip
36
- @test_cache[topic] ||= (
37
- show_header(' ', topic) unless topic.empty?
38
- true
39
- )
40
- end
41
- timer_reset
42
- end
43
-
44
- #
45
- def pass(test)
46
- show_line(".", test, :green)
47
- end
48
-
49
- #
50
- def fail(test, exception)
51
- show_line("F", test, :red)
52
- end
53
-
54
- #
55
- def error(test, exception)
56
- show_line("E", test, :red)
57
- end
58
-
59
- #
60
- def todo(test, exception)
61
- show_line("P", test, :yellow)
62
- end
63
-
64
- #
65
- def omit(test, exception)
66
- show_line("O", test, :cyan)
67
- end
68
-
69
- #
70
- def end_case(tcase)
71
- @tab -= 2
72
- end
73
-
74
- #
75
- def end_suite(suite)
76
- puts
77
-
78
- if runner.verbose?
79
- unless record[:omit].empty?
80
- puts "OMISSIONS:\n\n"
81
- record[:omit].reverse_each do |test, exception|
82
- s = []
83
- s << "#{test}".ansi(:bold)
84
- s << "#{file_and_line(exception)}"
85
- puts s.join("\n").tabto(4)
86
- puts code(exception).to_s.tabto(7)
87
- puts
88
- end
89
- end
90
- end
91
-
92
- unless record[:todo].empty?
93
- puts "PENDING:\n\n"
94
- record[:todo].reverse_each do |test, exception|
95
- s = []
96
- s << "#{test}".ansi(:bold)
97
- s << "#{file_and_line(exception)}"
98
- puts s.join("\n").tabto(4)
99
- puts code(exception).to_s.tabto(7)
100
- puts
101
- end
102
- end
103
-
104
- unless record[:fail].empty?
105
- puts "FAILURES:\n\n"
106
- record[:fail].reverse_each do |test, exception|
107
- s = []
108
- s << "#{test}".ansi(:bold)
109
- s << "#{exception}".ansi(:red)
110
- s << "#{file_and_line(exception)}"
111
- puts s.join("\n").tabto(4)
112
- puts code(exception).to_s.tabto(7)
113
- #puts " #{exception.backtrace[0]}"
114
- puts
115
- end
116
- end
117
-
118
- unless record[:error].empty?
119
- puts "ERRORS:\n\n"
120
- record[:error].reverse_each do |test, exception|
121
- trace = clean_backtrace(exception)[1..-1].map{ |bt| bt.sub(Dir.pwd+'/', '') }
122
- s = []
123
- s << "#{test}".ansi(:bold)
124
- s << "#{exception.class}".ansi(:red)
125
- s << "#{exception}".ansi(:red)
126
- s << "#{file_and_line(exception)}"
127
- puts s.join("\n").tabto(4)
128
- puts code(exception).to_s.tabto(7)
129
- puts trace.join("\n").tabto(4) unless trace.empty?
130
- puts
131
- end
132
- end
133
-
134
- puts
135
- puts timestamp
136
- puts
137
- puts tally
138
- end
139
-
140
- private
141
-
142
- #
143
- def show_header(status, text)
144
- text = text[0..text.index("\n")||-1]
145
- data = [prcnt, ' ', ' ', clock, timer, status, (' ' * @tab) + text.to_s]
146
- #puts (" " * @tab) + (@layout_head % data)
147
- puts (@layout_head % data).ansi(:bold)
148
- end
149
-
150
- #
151
- def show_line(status, test, color)
152
- @count += 1
153
- data = [prcnt, @count, @total_count, clock, timer, status, (' ' * @tab) + test.to_s]
154
- #puts (" " * @tab) + (@layout % data)
155
- puts (@layout % data).ansi(color)
156
- end
157
-
158
- #
159
- def prcnt
160
- ((@count.to_f / @total_count) * 100).round.to_s
161
- end
162
-
163
- #
164
- def clock
165
- secs = Time.now - @start_time
166
- m, s = secs.divmod(60)
167
- #s, ms = s.divmod(1)
168
- #ms = ms * 1000
169
- return "%u:%02u" % [m, s]
170
- end
171
-
172
- #
173
- def timer
174
- secs = Time.now - @time
175
- @time = Time.now
176
- return "%0.5fs" % secs
177
- end
178
-
179
- #
180
- def timer_reset
181
- @time = Time.now
182
- end
183
-
184
- #
185
- def tabs(str=nil)
186
- if str
187
- puts(str.tabto(@tab))
188
- else
189
- puts
190
- end
191
- end
192
-
193
- end
194
-
195
- end
@@ -1,145 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module Test::Reporters
4
-
5
- # Summary Reporter
6
- class Summary < Abstract
7
-
8
- #
9
- SEP = ' '
10
-
11
- #
12
- def begin_suite(suite)
13
- timer_reset
14
- @tc = []
15
- end
16
-
17
- #
18
- def begin_case(tc)
19
- @tc << tc.to_s.split("\n").first
20
- end
21
-
22
- #
23
- #def report_instance(instance)
24
- # puts
25
- # puts instance #"== #{concern.description}\n\n" unless concern.description.empty?
26
- # #timer_reset
27
- #end
28
-
29
- #
30
- #def begin_test(test)
31
- # context = test.context
32
- # if @instance != context
33
- # @context = context
34
- # puts
35
- # puts " #{context}"
36
- # puts
37
- # end
38
- #end
39
-
40
- #
41
- def pass(test)
42
- print "PASS ".ansi(:green, :bold)
43
- e = @tc + [test.to_s]
44
- puts e.join(SEP).ansi(:green)
45
- end
46
-
47
- #
48
- def fail(test, exception)
49
- print "FAIL ".ansi(:red, :bold)
50
- e = @tc + [test.to_s]
51
- puts e.join(SEP).ansi(:red)
52
- end
53
-
54
- #
55
- def error(test, exception)
56
- print "ERROR ".ansi(:red, :bold)
57
- e = @tc + [test.to_s]
58
- puts e.join(SEP).ansi(:red)
59
- end
60
-
61
- #
62
- def todo(test, exception)
63
- print "TODO ".ansi(:yellow, :bold)
64
- e = @tc + [test.to_s]
65
- puts e.join(SEP).ansi(:yellow)
66
- end
67
-
68
- #
69
- def omit(test)
70
- print "OMIT ".ansi(:cyan, :bold)
71
- e = @tc + [test.to_s]
72
- puts e.join(SEP).ansi(:cyan)
73
- end
74
-
75
- #
76
- def skip_test(test)
77
- print "SKIP ".ansi(:blue, :bold)
78
- e = @tc + [test.to_s]
79
- puts e.join(SEP).ansi(:blue)
80
- end
81
-
82
- #
83
- def end_case(test_case)
84
- @tc.pop
85
- end
86
-
87
- #
88
- def end_suite(suite)
89
- puts
90
-
91
- unless record[:pending].empty?
92
- puts "PENDING:\n\n"
93
- record[:pending].each do |test, exception|
94
- puts " #{test}"
95
- puts " #{file_and_line(exception)}"
96
- puts
97
- end
98
- end
99
-
100
- unless record[:fail].empty?
101
- puts "FAILURES:\n\n"
102
- record[:fail].each do |test, exception|
103
- puts " #{test}"
104
- puts " #{file_and_line(exception)}"
105
- puts " #{exception}"
106
- puts code(exception).to_s
107
- #puts " #{exception.backtrace[0]}"
108
- puts
109
- end
110
- end
111
-
112
- unless record[:error].empty?
113
- puts "ERRORS:\n\n"
114
- record[:error].each do |test, exception|
115
- puts " #{test}"
116
- puts " #{file_and_line(exception)}"
117
- puts " #{exception}"
118
- puts code(exception).to_s
119
- #puts " #{exception.backtrace[0]}"
120
- puts
121
- end
122
- end
123
-
124
- puts timestamp
125
- puts
126
- puts tally
127
- end
128
-
129
- private
130
-
131
- #
132
- def timer
133
- secs = Time.now - @time
134
- @time = Time.now
135
- return "%0.5fs" % [secs.to_s]
136
- end
137
-
138
- #
139
- def timer_reset
140
- @time = Time.now
141
- end
142
-
143
- end
144
-
145
- end