test 0.2.1 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- metadata +36 -112
- data/.gemspec +0 -152
- data/.gitignore +0 -7
- data/.ruby +0 -46
- data/.test +0 -11
- data/.yardopts +0 -7
- data/Assembly +0 -46
- data/COPYING.rdoc +0 -31
- data/HISTORY.md +0 -29
- data/LICENSE.txt +0 -25
- data/MANIFEST +0 -37
- data/PROFILE +0 -31
- data/README.md +0 -110
- data/VERSION +0 -1
- data/bin/ruby-test +0 -4
- data/lib/test.rb +0 -3
- data/lib/test/autorun.rb +0 -18
- data/lib/test/cli.rb +0 -110
- data/lib/test/code_snippet.rb +0 -93
- data/lib/test/config.rb +0 -72
- data/lib/test/core_ext.rb +0 -9
- data/lib/test/core_ext/assertion.rb +0 -30
- data/lib/test/core_ext/exception.rb +0 -8
- data/lib/test/core_ext/string.rb +0 -30
- data/lib/test/rake.rb +0 -124
- data/lib/test/recorder.rb +0 -53
- data/lib/test/reporters/abstract.rb +0 -268
- data/lib/test/reporters/abstract_hash.rb +0 -224
- data/lib/test/reporters/dotprogress.rb +0 -89
- data/lib/test/reporters/html.rb +0 -155
- data/lib/test/reporters/outline.rb +0 -211
- data/lib/test/reporters/progress.rb +0 -197
- data/lib/test/reporters/summary.rb +0 -145
- data/lib/test/reporters/tap.rb +0 -61
- data/lib/test/reporters/tapj.rb +0 -53
- data/lib/test/reporters/tapy.rb +0 -53
- data/lib/test/reporters/test.rb +0 -51
- data/lib/test/runner.rb +0 -342
- data/site/assets/images/test_pattern.jpg +0 -0
- data/site/index.html +0 -77
- data/spec/01_test.md +0 -29
- data/spec/02_case.md +0 -34
- data/spec/applique/ruby-test.rb +0 -2
- data/test/basic_case.rb +0 -11
- data/try/raw_example.rb +0 -41
- data/work/NOTES.md +0 -17
@@ -1,211 +0,0 @@
|
|
1
|
-
require 'test/reporters/abstract'
|
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,197 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'test/reporters/abstract'
|
4
|
-
|
5
|
-
module Test::Reporters
|
6
|
-
|
7
|
-
# Progess reporter gives test counter, precentage and times.
|
8
|
-
#
|
9
|
-
class Progress < Abstract
|
10
|
-
|
11
|
-
#
|
12
|
-
def begin_suite(suite)
|
13
|
-
@tab = 0
|
14
|
-
@total_count = total_count(suite)
|
15
|
-
@start_time = Time.now
|
16
|
-
@test_cache = {}
|
17
|
-
@count = 0
|
18
|
-
|
19
|
-
max = @total_count.to_s.size
|
20
|
-
|
21
|
-
@layout_head = " %3u%% %#{max}s %#{max}s %8s %11s %1s %s"
|
22
|
-
@layout = " %3u%% %#{max}u/%#{max}u %8s %11s %1s %s"
|
23
|
-
|
24
|
-
timer_reset
|
25
|
-
end
|
26
|
-
|
27
|
-
#
|
28
|
-
def begin_case(tc)
|
29
|
-
#tabs tc.to_s.ansi(:bold)
|
30
|
-
show_header(' ', tc.to_s)
|
31
|
-
@tab += 2
|
32
|
-
end
|
33
|
-
|
34
|
-
#
|
35
|
-
def begin_test(test)
|
36
|
-
if test.respond_to?(:topic) && test.topic
|
37
|
-
topic = test.topic.to_s.rstrip
|
38
|
-
@test_cache[topic] ||= (
|
39
|
-
show_header(' ', topic) unless topic.empty?
|
40
|
-
true
|
41
|
-
)
|
42
|
-
end
|
43
|
-
timer_reset
|
44
|
-
end
|
45
|
-
|
46
|
-
#
|
47
|
-
def pass(test)
|
48
|
-
show_line(".", test, :green)
|
49
|
-
end
|
50
|
-
|
51
|
-
#
|
52
|
-
def fail(test, exception)
|
53
|
-
show_line("F", test, :red)
|
54
|
-
end
|
55
|
-
|
56
|
-
#
|
57
|
-
def error(test, exception)
|
58
|
-
show_line("E", test, :red)
|
59
|
-
end
|
60
|
-
|
61
|
-
#
|
62
|
-
def todo(test, exception)
|
63
|
-
show_line("P", test, :yellow)
|
64
|
-
end
|
65
|
-
|
66
|
-
#
|
67
|
-
def omit(test, exception)
|
68
|
-
show_line("O", test, :cyan)
|
69
|
-
end
|
70
|
-
|
71
|
-
#
|
72
|
-
def end_case(tcase)
|
73
|
-
@tab -= 2
|
74
|
-
end
|
75
|
-
|
76
|
-
#
|
77
|
-
def end_suite(suite)
|
78
|
-
puts
|
79
|
-
|
80
|
-
if runner.verbose?
|
81
|
-
unless record[:omit].empty?
|
82
|
-
puts "OMISSIONS:\n\n"
|
83
|
-
record[:omit].reverse_each do |test, exception|
|
84
|
-
s = []
|
85
|
-
s << "#{test}".ansi(:bold)
|
86
|
-
s << "#{file_and_line(exception)}"
|
87
|
-
puts s.join("\n").tabto(4)
|
88
|
-
puts code(exception).to_s.tabto(7)
|
89
|
-
puts
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
unless record[:todo].empty?
|
95
|
-
puts "PENDING:\n\n"
|
96
|
-
record[:todo].reverse_each do |test, exception|
|
97
|
-
s = []
|
98
|
-
s << "#{test}".ansi(:bold)
|
99
|
-
s << "#{file_and_line(exception)}"
|
100
|
-
puts s.join("\n").tabto(4)
|
101
|
-
puts code(exception).to_s.tabto(7)
|
102
|
-
puts
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
unless record[:fail].empty?
|
107
|
-
puts "FAILURES:\n\n"
|
108
|
-
record[:fail].reverse_each do |test, exception|
|
109
|
-
s = []
|
110
|
-
s << "#{test}".ansi(:bold)
|
111
|
-
s << "#{exception}".ansi(:red)
|
112
|
-
s << "#{file_and_line(exception)}"
|
113
|
-
puts s.join("\n").tabto(4)
|
114
|
-
puts code(exception).to_s.tabto(7)
|
115
|
-
#puts " #{exception.backtrace[0]}"
|
116
|
-
puts
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
unless record[:error].empty?
|
121
|
-
puts "ERRORS:\n\n"
|
122
|
-
record[:error].reverse_each do |test, exception|
|
123
|
-
trace = clean_backtrace(exception)[1..-1].map{ |bt| bt.sub(Dir.pwd+'/', '') }
|
124
|
-
s = []
|
125
|
-
s << "#{test}".ansi(:bold)
|
126
|
-
s << "#{exception.class}".ansi(:red)
|
127
|
-
s << "#{exception}".ansi(:red)
|
128
|
-
s << "#{file_and_line(exception)}"
|
129
|
-
puts s.join("\n").tabto(4)
|
130
|
-
puts code(exception).to_s.tabto(7)
|
131
|
-
puts trace.join("\n").tabto(4) unless trace.empty?
|
132
|
-
puts
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
puts
|
137
|
-
puts timestamp
|
138
|
-
puts
|
139
|
-
puts tally
|
140
|
-
end
|
141
|
-
|
142
|
-
private
|
143
|
-
|
144
|
-
#
|
145
|
-
def show_header(status, text)
|
146
|
-
text = text[0..text.index("\n")||-1]
|
147
|
-
data = [prcnt, ' ', ' ', clock, timer, status, (' ' * @tab) + text.to_s]
|
148
|
-
#puts (" " * @tab) + (@layout_head % data)
|
149
|
-
puts (@layout_head % data).ansi(:bold)
|
150
|
-
end
|
151
|
-
|
152
|
-
#
|
153
|
-
def show_line(status, test, color)
|
154
|
-
@count += 1
|
155
|
-
data = [prcnt, @count, @total_count, clock, timer, status, (' ' * @tab) + test.to_s]
|
156
|
-
#puts (" " * @tab) + (@layout % data)
|
157
|
-
puts (@layout % data).ansi(color)
|
158
|
-
end
|
159
|
-
|
160
|
-
#
|
161
|
-
def prcnt
|
162
|
-
((@count.to_f / @total_count) * 100).round.to_s
|
163
|
-
end
|
164
|
-
|
165
|
-
#
|
166
|
-
def clock
|
167
|
-
secs = Time.now - @start_time
|
168
|
-
m, s = secs.divmod(60)
|
169
|
-
#s, ms = s.divmod(1)
|
170
|
-
#ms = ms * 1000
|
171
|
-
return "%u:%02u" % [m, s]
|
172
|
-
end
|
173
|
-
|
174
|
-
#
|
175
|
-
def timer
|
176
|
-
secs = Time.now - @time
|
177
|
-
@time = Time.now
|
178
|
-
return "%0.5fs" % secs
|
179
|
-
end
|
180
|
-
|
181
|
-
#
|
182
|
-
def timer_reset
|
183
|
-
@time = Time.now
|
184
|
-
end
|
185
|
-
|
186
|
-
#
|
187
|
-
def tabs(str=nil)
|
188
|
-
if str
|
189
|
-
puts(str.tabto(@tab))
|
190
|
-
else
|
191
|
-
puts
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
end
|
196
|
-
|
197
|
-
end
|
@@ -1,145 +0,0 @@
|
|
1
|
-
require 'test/reporters/abstract'
|
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
|