test 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemspec +152 -0
- data/.gitignore +7 -0
- data/.ruby +43 -0
- data/.test +11 -0
- data/.yardopts +7 -0
- data/Assembly +46 -0
- data/COPYING.rdoc +31 -0
- data/HISTORY.md +29 -0
- data/LICENSE.txt +25 -0
- data/MANIFEST +38 -0
- data/PROFILE +31 -0
- data/README.md +110 -0
- data/VERSION +1 -0
- data/bin/ruby-test +4 -0
- data/lib/test.rb +3 -0
- data/lib/test/autorun.rb +18 -0
- data/lib/test/cli.rb +110 -0
- data/lib/test/code_snippet.rb +93 -0
- data/lib/test/config.rb +72 -0
- data/lib/test/core_ext.rb +9 -0
- data/lib/test/core_ext/assertion.rb +30 -0
- data/lib/test/core_ext/exception.rb +8 -0
- data/lib/test/core_ext/string.rb +30 -0
- data/lib/test/rake.rb +120 -0
- data/lib/test/recorder.rb +53 -0
- data/lib/test/reporters/abstract.rb +238 -0
- data/lib/test/reporters/abstract_hash.rb +224 -0
- data/lib/test/reporters/dotprogress.rb +89 -0
- data/lib/test/reporters/html.rb +155 -0
- data/lib/test/reporters/outline.rb +211 -0
- data/lib/test/reporters/progress.rb +197 -0
- data/lib/test/reporters/summary.rb +145 -0
- data/lib/test/reporters/tap.rb +61 -0
- data/lib/test/reporters/tapj.rb +53 -0
- data/lib/test/reporters/tapy.rb +53 -0
- data/lib/test/reporters/test.rb +51 -0
- data/lib/test/runner.rb +342 -0
- data/site/assets/images/test_pattern.jpg +0 -0
- data/site/index.html +31 -0
- data/spec/01_test.md +29 -0
- data/spec/02_case.md +34 -0
- data/spec/applique/ruby-test.rb +2 -0
- data/test/basic_case.rb +11 -0
- data/try/raw_example.rb +41 -0
- data/work/NOTES.md +17 -0
- metadata +129 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'test/reporters/abstract'
|
2
|
+
|
3
|
+
module Test::Reporters
|
4
|
+
|
5
|
+
# Simple Dot-Progress Reporter
|
6
|
+
class Dotprogress < Abstract
|
7
|
+
|
8
|
+
def pass(unit)
|
9
|
+
print "."
|
10
|
+
$stdout.flush
|
11
|
+
end
|
12
|
+
|
13
|
+
def fail(unit, exception)
|
14
|
+
print "F".ansi(:red)
|
15
|
+
$stdout.flush
|
16
|
+
end
|
17
|
+
|
18
|
+
def error(unit, exception)
|
19
|
+
print "E".ansi(:red, :bold)
|
20
|
+
$stdout.flush
|
21
|
+
end
|
22
|
+
|
23
|
+
def todo(unit, exception)
|
24
|
+
print "P".ansi(:yellow)
|
25
|
+
$stdout.flush
|
26
|
+
end
|
27
|
+
|
28
|
+
def omit(unit, exception)
|
29
|
+
print "O".ansi(:cyan)
|
30
|
+
$stdout.flush
|
31
|
+
end
|
32
|
+
|
33
|
+
def end_suite(suite)
|
34
|
+
puts; puts
|
35
|
+
puts timestamp
|
36
|
+
puts
|
37
|
+
|
38
|
+
if runner.verbose?
|
39
|
+
unless record[:omit].empty?
|
40
|
+
puts "OMISSIONS:\n\n"
|
41
|
+
record[:omit].each do |test, exception|
|
42
|
+
puts " #{test}".ansi(:bold)
|
43
|
+
puts " #{exception}"
|
44
|
+
puts " #{file_and_line(exception)}"
|
45
|
+
#puts code(exception)
|
46
|
+
puts
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
unless record[:todo].empty?
|
52
|
+
puts "PENDING:\n\n"
|
53
|
+
record[:todo].each do |test, exception|
|
54
|
+
puts " #{test}".ansi(:bold) unless test.to_s.empty?
|
55
|
+
puts " #{exception}"
|
56
|
+
puts " #{file_and_line(exception)}"
|
57
|
+
puts code(exception)
|
58
|
+
puts
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
unless record[:fail].empty?
|
63
|
+
puts "FAILURES:\n\n"
|
64
|
+
record[:fail].each do |test_unit, exception|
|
65
|
+
puts " #{test_unit}".ansi(:bold)
|
66
|
+
puts " #{exception}"
|
67
|
+
puts " #{file_and_line(exception)}"
|
68
|
+
puts code(exception)
|
69
|
+
puts
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
unless record[:error].empty?
|
74
|
+
puts "ERRORS:\n\n"
|
75
|
+
record[:error].each do |test_unit, exception|
|
76
|
+
puts " #{test_unit}".ansi(:bold)
|
77
|
+
puts " #{exception}"
|
78
|
+
puts " #{file_and_line(exception)}"
|
79
|
+
puts code(exception)
|
80
|
+
puts
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
puts tally
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
require 'test/reporters/abstract'
|
2
|
+
|
3
|
+
module Test::Reporters
|
4
|
+
|
5
|
+
# HTML Test Reporter
|
6
|
+
#
|
7
|
+
# This reporter is rather simplistic and rough at this point --in need
|
8
|
+
# of some TLC. Also, it may move to the TAPOUT project rather than be
|
9
|
+
# a built-in Ruby-Test reporter.
|
10
|
+
#--
|
11
|
+
# TODO: Make this more like a microformat and add timer info.
|
12
|
+
#++
|
13
|
+
class Html < Abstract
|
14
|
+
|
15
|
+
#
|
16
|
+
def begin_suite(suite)
|
17
|
+
timer_reset
|
18
|
+
|
19
|
+
@html = []
|
20
|
+
@html << %[<html>]
|
21
|
+
@html << %[<head>]
|
22
|
+
@html << %[<title>Test Report</title>]
|
23
|
+
@html << %[ <style>]
|
24
|
+
@html << %[ html{ background: #fff; margin: 0; padding: 0; font-family: helvetica; }]
|
25
|
+
@html << %[ body{ margin: 0; padding: 0;}]
|
26
|
+
@html << %[ h3{color:#555;}]
|
27
|
+
@html << %[ #main{ margin: 0 auto; color: #110; width: 600px; ]
|
28
|
+
@html << %[ border-right: 1px solid #ddd; border-left: 1px solid #ddd; ]
|
29
|
+
@html << %[ padding: 10px 30px; width: 500px; } ]
|
30
|
+
@html << %[ .lemon{ color: gold; font-size: 22px; font-weight: bold; ]
|
31
|
+
@html << %[ font-family: courier; margin-bottom: -15px;}]
|
32
|
+
@html << %[ .tally{ font-weight: bold; margin-bottom: 10px; }]
|
33
|
+
@html << %[ .omit{ color: cyan; }]
|
34
|
+
@html << %[ .pass{ color: green; }]
|
35
|
+
@html << %[ .fail{ color: red; }]
|
36
|
+
@html << %[ .footer{ font-size: 0.7em; color: #666; margin: 20px 0; }]
|
37
|
+
@html << %[ </style>]
|
38
|
+
@html << %[</head>]
|
39
|
+
@html << %[<body>]
|
40
|
+
@html << %[<div id="main">]
|
41
|
+
@html << %[<div class="lemon">R U B Y - T E S T</div>]
|
42
|
+
@html << %[<h1>Test Report</h1>]
|
43
|
+
@body = []
|
44
|
+
end
|
45
|
+
|
46
|
+
#
|
47
|
+
def begin_case(tc)
|
48
|
+
lines = tc.to_s.split("\n")
|
49
|
+
title = lines.shift
|
50
|
+
@body << "<h2>"
|
51
|
+
@body << title
|
52
|
+
@body << "</h2>"
|
53
|
+
@body << "<div>"
|
54
|
+
@body << lines.join("<br/>")
|
55
|
+
@body << "</div>"
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
def begin_test(test)
|
60
|
+
if test.respond_to?(:topic)
|
61
|
+
topic = test.topic
|
62
|
+
if @topic != topic
|
63
|
+
@topic = topic
|
64
|
+
@body << "<h3>"
|
65
|
+
@body << "#{topic}"
|
66
|
+
@body << "</h3>"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
#
|
72
|
+
def pass(test)
|
73
|
+
@body << %[<li class="pass">]
|
74
|
+
@body << "%s %s" % ["PASS", test.to_s]
|
75
|
+
@body << %[</li>]
|
76
|
+
end
|
77
|
+
|
78
|
+
#
|
79
|
+
def fail(test, exception)
|
80
|
+
@body << %[<li class="fail">]
|
81
|
+
@body << "%s %s" % ["FAIL", test.to_s]
|
82
|
+
@body << "<pre>"
|
83
|
+
@body << " FAIL #{clean_backtrace(exception)[0]}"
|
84
|
+
@body << " #{exception}"
|
85
|
+
@body << "</pre>"
|
86
|
+
@body << %[</li>]
|
87
|
+
end
|
88
|
+
|
89
|
+
#
|
90
|
+
def error(test, exception)
|
91
|
+
@body << %[<li class="error">]
|
92
|
+
@body << "%s %s" % ["ERROR", test.to_s]
|
93
|
+
@body << "<pre>"
|
94
|
+
@body << " ERROR #{exception.class}"
|
95
|
+
@body << " #{exception}"
|
96
|
+
@body << " " + clean_backtrace(exception).join("\n ")
|
97
|
+
@body << "</pre>"
|
98
|
+
@body << %[</li>]
|
99
|
+
end
|
100
|
+
|
101
|
+
#
|
102
|
+
def todo(test, exception)
|
103
|
+
@body << %[<li class="pending">]
|
104
|
+
@body << "%s %s" % ["PENDING", test.to_s]
|
105
|
+
@body << %[</li>]
|
106
|
+
end
|
107
|
+
|
108
|
+
#
|
109
|
+
def omit(test, exception)
|
110
|
+
@body << %[<li class="omit">]
|
111
|
+
@body << "%s %s" % ["OMIT", test.to_s]
|
112
|
+
@body << %[</li>]
|
113
|
+
end
|
114
|
+
|
115
|
+
#
|
116
|
+
def end_suite(suite)
|
117
|
+
@html << ""
|
118
|
+
@html << %[<div class="tally">]
|
119
|
+
@html << tally
|
120
|
+
@html << %[</div>]
|
121
|
+
@html << ""
|
122
|
+
|
123
|
+
@body << ""
|
124
|
+
@body << %[<div class="footer">]
|
125
|
+
@body << %[Generated by <a href="http://rubyworks.github.com/test">Lemon</a>]
|
126
|
+
@body << %[on #{Time.now}.]
|
127
|
+
@body << %[</div>]
|
128
|
+
@body << ""
|
129
|
+
@body << %[</div>]
|
130
|
+
@body << %[</div>]
|
131
|
+
@body << ""
|
132
|
+
@body << %[</body>]
|
133
|
+
@body << %[</html>]
|
134
|
+
|
135
|
+
puts @html.join("\n")
|
136
|
+
puts @body.join("\n")
|
137
|
+
end
|
138
|
+
|
139
|
+
private
|
140
|
+
|
141
|
+
#
|
142
|
+
def timer
|
143
|
+
secs = Time.now - @time
|
144
|
+
@time = Time.now
|
145
|
+
return "%0.5fs" % [secs.to_s]
|
146
|
+
end
|
147
|
+
|
148
|
+
#
|
149
|
+
def timer_reset
|
150
|
+
@time = Time.now
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
@@ -0,0 +1,211 @@
|
|
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
|
+
|