spicycode-rcov 0.8.1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/BLURB +149 -0
- data/CHANGES +177 -0
- data/LEGAL +36 -0
- data/LICENSE +56 -0
- data/Rakefile +193 -0
- data/Rantfile +76 -0
- data/THANKS +96 -0
- data/bin/rcov +552 -0
- data/ext/rcovrt/callsite.c +242 -0
- data/ext/rcovrt/extconf.rb +13 -0
- data/ext/rcovrt/rcovrt.c +331 -0
- data/lib/rcov/lowlevel.rb +147 -0
- data/lib/rcov/rant.rb +87 -0
- data/lib/rcov/rcovtask.rb +156 -0
- data/lib/rcov/report.rb +1249 -0
- data/lib/rcov/version.rb +13 -0
- data/lib/rcov/xx.rb +761 -0
- data/lib/rcov.rb +990 -0
- data/rcov.el +131 -0
- data/rcov.vim +38 -0
- data/readme_for_api +42 -0
- data/readme_for_rake +62 -0
- data/readme_for_rant +68 -0
- data/readme_for_vim +47 -0
- data/setup.rb +1588 -0
- data/test/assets/sample_01.rb +7 -0
- data/test/assets/sample_02.rb +5 -0
- data/test/assets/sample_03.rb +20 -0
- data/test/assets/sample_04.rb +10 -0
- data/test/assets/sample_05-new.rb +17 -0
- data/test/assets/sample_05-old.rb +13 -0
- data/test/assets/sample_05.rb +17 -0
- data/test/call_site_analyzer_test.rb +207 -0
- data/test/code_coverage_analyzer_test.rb +186 -0
- data/test/file_statistics_test.rb +471 -0
- data/test/functional_test.rb +94 -0
- data/test/turn_off_rcovrt.rb +4 -0
- metadata +98 -0
@@ -0,0 +1,471 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class TestFileStatistics < Test::Unit::TestCase
|
4
|
+
def test_trailing_end_is_inferred
|
5
|
+
verify_everything_marked "trailing end", <<-EOF
|
6
|
+
1 class X
|
7
|
+
1 def foo
|
8
|
+
2 "foo"
|
9
|
+
0 end
|
10
|
+
0 end
|
11
|
+
EOF
|
12
|
+
verify_everything_marked "trailing end with comments", <<-EOF
|
13
|
+
1 class X
|
14
|
+
1 def foo
|
15
|
+
2 "foo"
|
16
|
+
0 end
|
17
|
+
0 # foo bar
|
18
|
+
0 =begin
|
19
|
+
0 ....
|
20
|
+
0 =end
|
21
|
+
0 end
|
22
|
+
EOF
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_begin_ensure_else_case_are_inferred
|
26
|
+
verify_everything_marked "begin ensure else case", <<-EOF
|
27
|
+
0 begin
|
28
|
+
# bleh
|
29
|
+
2 puts a
|
30
|
+
0 begin
|
31
|
+
2 raise "foo"
|
32
|
+
0 rescue Exception => e
|
33
|
+
2 puts b
|
34
|
+
0 ensure
|
35
|
+
2 puts c
|
36
|
+
0 end
|
37
|
+
2 if a()
|
38
|
+
1 b
|
39
|
+
0 else
|
40
|
+
1 c
|
41
|
+
0 end
|
42
|
+
0 case
|
43
|
+
2 when bar =~ /foo/
|
44
|
+
1 puts "bar"
|
45
|
+
0 else
|
46
|
+
1 puts "baz"
|
47
|
+
0 end
|
48
|
+
0 end
|
49
|
+
EOF
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_rescue_is_inferred
|
53
|
+
verify_everything_marked "rescue", <<-EOF
|
54
|
+
0 begin
|
55
|
+
1 foo
|
56
|
+
0 rescue
|
57
|
+
1 puts "bar"
|
58
|
+
0 end
|
59
|
+
EOF
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_code_metrics_are_computed_correctly
|
63
|
+
lines, coverage, counts = code_info_from_string <<-EOF
|
64
|
+
1 a = 1
|
65
|
+
0 # this is a comment
|
66
|
+
1 if bar
|
67
|
+
0 b = 2
|
68
|
+
0 end
|
69
|
+
0 =begin
|
70
|
+
0 this too
|
71
|
+
0 bleh
|
72
|
+
0 =end
|
73
|
+
0 puts <<EOF
|
74
|
+
0 bleh
|
75
|
+
0 EOF
|
76
|
+
3 c.times{ i += 1}
|
77
|
+
EOF
|
78
|
+
sf = Rcov::FileStatistics.new("metrics", lines, counts)
|
79
|
+
assert_in_delta(0.307, sf.total_coverage, 0.01)
|
80
|
+
assert_in_delta(0.375, sf.code_coverage, 0.01)
|
81
|
+
assert_equal(8, sf.num_code_lines)
|
82
|
+
assert_equal(13, sf.num_lines)
|
83
|
+
assert_equal([true, :inferred, true, false, false, false, false, false,
|
84
|
+
false, false, false, false, true], sf.coverage.to_a)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_merge
|
88
|
+
lines, coverage, counts = code_info_from_string <<-EOF
|
89
|
+
1 a = 1
|
90
|
+
1 if bar
|
91
|
+
0 b = 2
|
92
|
+
0 end
|
93
|
+
1 puts <<EOF
|
94
|
+
0 bleh
|
95
|
+
0 EOF
|
96
|
+
3 c.times{ i += 1}
|
97
|
+
EOF
|
98
|
+
sf = Rcov::FileStatistics.new("merge", lines, counts)
|
99
|
+
lines, coverage, counts = code_info_from_string <<-EOF
|
100
|
+
1 a = 1
|
101
|
+
1 if bar
|
102
|
+
1 b = 2
|
103
|
+
0 end
|
104
|
+
1 puts <<EOF
|
105
|
+
0 bleh
|
106
|
+
0 EOF
|
107
|
+
10 c.times{ i += 1}
|
108
|
+
EOF
|
109
|
+
sf2 = Rcov::FileStatistics.new("merge", lines, counts)
|
110
|
+
expected = [true, true, true, :inferred, true, :inferred, :inferred, true]
|
111
|
+
assert_equal(expected, sf2.coverage.to_a)
|
112
|
+
sf.merge(sf2.lines, sf2.coverage, sf2.counts)
|
113
|
+
assert_equal(expected, sf.coverage.to_a)
|
114
|
+
assert_equal([2, 2, 1, 0, 2, 0, 0, 13], sf.counts)
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_last_comment_block_is_marked
|
118
|
+
verify_everything_marked "last comment block", <<-EOF
|
119
|
+
1 a = 1
|
120
|
+
1 b = 1
|
121
|
+
0 # foo
|
122
|
+
0 # bar baz
|
123
|
+
EOF
|
124
|
+
verify_everything_marked "last comment block, =begin/=end", <<-EOF
|
125
|
+
1 a = 1
|
126
|
+
2 b = 1
|
127
|
+
0 # fooo
|
128
|
+
0 =begin
|
129
|
+
0 bar baz
|
130
|
+
0 =end
|
131
|
+
EOF
|
132
|
+
verify_everything_marked "last comment block, __END__", <<-EOF
|
133
|
+
1 a = 1
|
134
|
+
2 b = 1
|
135
|
+
0 # fooo
|
136
|
+
0 =begin
|
137
|
+
0 bar baz
|
138
|
+
0 =end
|
139
|
+
__END__
|
140
|
+
EOF
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_heredocs_basic
|
144
|
+
verify_everything_marked "heredocs-basic.rb", <<-EOF
|
145
|
+
1 puts 1 + 1
|
146
|
+
1 puts <<HEREDOC
|
147
|
+
0 first line of the heredoc
|
148
|
+
0 not marked
|
149
|
+
0 but should be
|
150
|
+
0 HEREDOC
|
151
|
+
1 puts 1
|
152
|
+
EOF
|
153
|
+
verify_everything_marked "squote", <<-EOF
|
154
|
+
1 puts <<'HEREDOC'
|
155
|
+
0 first line of the heredoc
|
156
|
+
0 HEREDOC
|
157
|
+
EOF
|
158
|
+
verify_everything_marked "dquote", <<-EOF
|
159
|
+
1 puts <<"HEREDOC"
|
160
|
+
0 first line of the heredoc
|
161
|
+
0 HEREDOC
|
162
|
+
EOF
|
163
|
+
verify_everything_marked "xquote", <<-EOF
|
164
|
+
1 puts <<`HEREDOC`
|
165
|
+
0 first line of the heredoc
|
166
|
+
0 HEREDOC
|
167
|
+
EOF
|
168
|
+
verify_everything_marked "stuff-after-heredoc", <<-EOF
|
169
|
+
1 full_message = build_message(msg, <<EOT, object1, object2)
|
170
|
+
0 <?> and <?> do not contain the same elements
|
171
|
+
0 EOT
|
172
|
+
EOF
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_heredocs_multiple
|
176
|
+
verify_everything_marked "multiple-unquoted", <<-EOF
|
177
|
+
1 puts <<HEREDOC, <<HERE2
|
178
|
+
0 first line of the heredoc
|
179
|
+
0 HEREDOC
|
180
|
+
0 second heredoc
|
181
|
+
0 HERE2
|
182
|
+
EOF
|
183
|
+
verify_everything_marked "multiple-quoted", <<-EOF
|
184
|
+
1 puts <<'HEREDOC', <<`HERE2`, <<"HERE3"
|
185
|
+
0 first line of the heredoc
|
186
|
+
0 HEREDOC
|
187
|
+
0 second heredoc
|
188
|
+
0 HERE2
|
189
|
+
0 dsfdsfffd
|
190
|
+
0 HERE3
|
191
|
+
EOF
|
192
|
+
verify_everything_marked "same-identifier", <<-EOF
|
193
|
+
1 puts <<H, <<H
|
194
|
+
0 foo
|
195
|
+
0 H
|
196
|
+
0 bar
|
197
|
+
0 H
|
198
|
+
EOF
|
199
|
+
verify_everything_marked "stuff-after-heredoc", <<-EOF
|
200
|
+
1 full_message = build_message(msg, <<EOT, object1, object2, <<EOT)
|
201
|
+
0 <?> and <?> do not contain the same elements
|
202
|
+
0 EOT
|
203
|
+
0 <?> and <?> are foo bar baz
|
204
|
+
0 EOT
|
205
|
+
EOF
|
206
|
+
end
|
207
|
+
def test_ignore_non_heredocs
|
208
|
+
verify_marked_exactly "bitshift-numeric", [0], <<-EOF
|
209
|
+
1 puts 1<<2
|
210
|
+
0 return if foo
|
211
|
+
0 do_stuff()
|
212
|
+
0 2
|
213
|
+
EOF
|
214
|
+
verify_marked_exactly "bitshift-symbolic", [0], <<-EOF
|
215
|
+
1 puts 1<<LSHIFT
|
216
|
+
0 return if bar
|
217
|
+
0 do_stuff()
|
218
|
+
0 LSHIFT
|
219
|
+
EOF
|
220
|
+
verify_marked_exactly "bitshift-symbolic-multi", 0..3, <<-EOF
|
221
|
+
1 puts <<EOF, 1<<LSHIFT
|
222
|
+
0 random text
|
223
|
+
0 EOF
|
224
|
+
1 return if bar
|
225
|
+
0 puts "foo"
|
226
|
+
0 LSHIFT
|
227
|
+
EOF
|
228
|
+
verify_marked_exactly "bitshift-symshift-evil", 0..2, <<-EOF
|
229
|
+
1 foo = 1
|
230
|
+
1 puts foo<<CONS
|
231
|
+
1 return if bar
|
232
|
+
0 foo + baz
|
233
|
+
EOF
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_heredocs_with_interpolation_alone_in_method
|
237
|
+
verify_everything_marked "lonely heredocs with interpolation", <<-'EOS'
|
238
|
+
1 def to_s
|
239
|
+
0 <<-EOF
|
240
|
+
1 #{name}
|
241
|
+
0 #{street}
|
242
|
+
0 #{city}, #{state}
|
243
|
+
0 #{zip}
|
244
|
+
0 EOF
|
245
|
+
0 end
|
246
|
+
EOS
|
247
|
+
end
|
248
|
+
|
249
|
+
def test_handle_multiline_expressions
|
250
|
+
verify_everything_marked "expression", <<-EOF
|
251
|
+
1 puts 1, 2.
|
252
|
+
0 abs +
|
253
|
+
0 1 -
|
254
|
+
0 1 *
|
255
|
+
0 1 /
|
256
|
+
0 1, 1 <
|
257
|
+
0 2, 3 >
|
258
|
+
0 4 %
|
259
|
+
0 3 &&
|
260
|
+
0 true ||
|
261
|
+
0 foo <<
|
262
|
+
0 bar(
|
263
|
+
0 baz[
|
264
|
+
0 {
|
265
|
+
0 1,2}] =
|
266
|
+
0 1 )
|
267
|
+
EOF
|
268
|
+
verify_everything_marked "boolean expression", <<-EOF
|
269
|
+
1 x = (foo and
|
270
|
+
0 bar) or
|
271
|
+
0 baz
|
272
|
+
EOF
|
273
|
+
verify_marked_exactly "code blocks", [0, 3, 6], <<-EOF
|
274
|
+
1 x = foo do # stuff
|
275
|
+
0 baz
|
276
|
+
0 end
|
277
|
+
1 bar do |x|
|
278
|
+
0 baz
|
279
|
+
0 end
|
280
|
+
1 bar {|a, b| # bleh | +1
|
281
|
+
0 baz
|
282
|
+
0 }
|
283
|
+
EOF
|
284
|
+
verify_everything_marked "escaped linebreaks", <<-EOF
|
285
|
+
1 def t2
|
286
|
+
0 puts \\
|
287
|
+
1 "foo"
|
288
|
+
0 end
|
289
|
+
0 end
|
290
|
+
EOF
|
291
|
+
end
|
292
|
+
|
293
|
+
def test_handle_multiline_blocks_first_not_marked
|
294
|
+
verify_everything_marked "multiline block first not marked", <<-'EOF'
|
295
|
+
1 blah = Array.new
|
296
|
+
1 10.times do
|
297
|
+
0 blah << lambda do |f|
|
298
|
+
1 puts "I should say #{f}!"
|
299
|
+
0 end
|
300
|
+
0 end
|
301
|
+
EOF
|
302
|
+
end
|
303
|
+
|
304
|
+
def test_handle_multiline_blocks_last_line_not_marked
|
305
|
+
verify_everything_marked "multiline block last not marked", <<-'EOF'
|
306
|
+
1 blee = [1, 2, 3]
|
307
|
+
0 blee.map! do |e|
|
308
|
+
1 [e, e]
|
309
|
+
0 end.flatten!
|
310
|
+
1 p blee
|
311
|
+
EOF
|
312
|
+
end
|
313
|
+
|
314
|
+
def test_handle_multiline_data_with_trailing_stuff_on_last_line
|
315
|
+
verify_everything_marked "multiline data hash", <<-'EOF'
|
316
|
+
1 @review = Review.new({
|
317
|
+
0 :product_id => params[:id],
|
318
|
+
0 :user => current_user
|
319
|
+
0 }.merge(params[:review])) #red
|
320
|
+
1 @review.save
|
321
|
+
EOF
|
322
|
+
end
|
323
|
+
|
324
|
+
def test_handle_multiline_expression_1st_line_ends_in_block_header
|
325
|
+
# excerpt taken from mongrel/handlers.rb
|
326
|
+
verify_everything_marked "multiline with block starting on 1st", <<-EOF
|
327
|
+
1 uris = listener.classifier.handler_map
|
328
|
+
0 results << table("handlers", uris.map {|uri,handlers|
|
329
|
+
1 [uri,
|
330
|
+
0 "<pre>" +
|
331
|
+
1 handlers.map {|h| h.class.to_s }.join("\n") +
|
332
|
+
0 "</pre>"
|
333
|
+
0 ]
|
334
|
+
1 })
|
335
|
+
EOF
|
336
|
+
end
|
337
|
+
|
338
|
+
def test_handle_multiple_block_end_delimiters_in_empty_line
|
339
|
+
verify_everything_marked "multiline with }) delimiter, forward", <<-EOF
|
340
|
+
1 assert(@c.config == {
|
341
|
+
0 'host' => 'myhost.tld',
|
342
|
+
0 'port' => 1234
|
343
|
+
0 })
|
344
|
+
EOF
|
345
|
+
verify_everything_marked "multiline with }) delimiter, backwards", <<-EOF
|
346
|
+
0 assert(@c.config == {
|
347
|
+
0 'host' => 'myhost.tld',
|
348
|
+
0 'port' => 1234
|
349
|
+
1 })
|
350
|
+
EOF
|
351
|
+
end
|
352
|
+
|
353
|
+
STRING_DELIMITER_PAIRS = [
|
354
|
+
%w-%{ }-, %w-%q{ }-, %w-%Q{ }-, %w{%[ ]}, %w{%q[ ]},
|
355
|
+
%w{%( )}, %w{%Q( )}, %w{%Q[ ]}, %w{%q! !}, %w{%! !},
|
356
|
+
]
|
357
|
+
|
358
|
+
def test_multiline_strings_basic
|
359
|
+
STRING_DELIMITER_PAIRS.each do |s_delim, e_delim|
|
360
|
+
verify_everything_marked "multiline strings, basic #{s_delim}", <<-EOF
|
361
|
+
1 PATTERN_TEXT = #{s_delim}
|
362
|
+
0 NUMBERS = 'one|two|three|four|five'
|
363
|
+
0 ON_OFF = 'on|off'
|
364
|
+
0 #{e_delim}
|
365
|
+
EOF
|
366
|
+
end
|
367
|
+
STRING_DELIMITER_PAIRS.each do |s_delim, e_delim|
|
368
|
+
verify_marked_exactly "multiline strings, escaped #{s_delim}", [0], <<-EOF
|
369
|
+
1 PATTERN_TEXT = #{s_delim} foooo bar baz \\#{e_delim} baz #{e_delim}
|
370
|
+
0 NUMBERS = 'one|two|three|four|five'
|
371
|
+
0 ON_OFF = 'on|off'
|
372
|
+
EOF
|
373
|
+
|
374
|
+
verify_marked_exactly "multiline strings, #{s_delim}, interpolation",
|
375
|
+
[0], <<-EOF
|
376
|
+
1 PATTERN_TEXT = #{s_delim} \#{#{s_delim} foo #{e_delim}} \\#{e_delim} baz #{e_delim}
|
377
|
+
0 NUMBERS = 'one|two|three|four|five'
|
378
|
+
0 ON_OFF = 'on|off'
|
379
|
+
EOF
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
def test_multiline_strings_escaped_delimiter
|
384
|
+
STRING_DELIMITER_PAIRS.each do |s_delim, e_delim|
|
385
|
+
verify_everything_marked "multiline, escaped #{s_delim}", <<-EOF
|
386
|
+
1 PATTERN_TEXT = #{s_delim} foo \\#{e_delim}
|
387
|
+
0 NUMBERS = 'one|two|three|four|five'
|
388
|
+
0 ON_OFF = 'on|off'
|
389
|
+
0 #{e_delim}
|
390
|
+
EOF
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
def test_handle_multiline_expressions_with_heredocs
|
395
|
+
verify_everything_marked "multiline and heredocs", <<-EOF
|
396
|
+
1 puts <<EOF +
|
397
|
+
0 testing
|
398
|
+
0 one two three
|
399
|
+
0 EOF
|
400
|
+
0 somevar
|
401
|
+
EOF
|
402
|
+
end
|
403
|
+
|
404
|
+
def test_begin_end_comment_blocks
|
405
|
+
verify_everything_marked "=begin/=end", <<-EOF
|
406
|
+
1 x = foo
|
407
|
+
0 =begin
|
408
|
+
0 return if bar(x)
|
409
|
+
0 =end
|
410
|
+
1 y = 1
|
411
|
+
EOF
|
412
|
+
end
|
413
|
+
|
414
|
+
def test_is_code_p
|
415
|
+
verify_is_code "basic", [true] + [false] * 5 + [true], <<-EOF
|
416
|
+
1 x = foo
|
417
|
+
0 =begin
|
418
|
+
0 return if bar
|
419
|
+
0 =end
|
420
|
+
0 # foo
|
421
|
+
0 # bar
|
422
|
+
1 y = 1
|
423
|
+
EOF
|
424
|
+
end
|
425
|
+
|
426
|
+
def test_is_code_p_tricky_heredocs
|
427
|
+
verify_is_code "tricky heredocs", [true] * 4, <<-EOF
|
428
|
+
2 x = foo <<EOF and return
|
429
|
+
0 =begin
|
430
|
+
0 EOF
|
431
|
+
0 z = x + 1
|
432
|
+
EOF
|
433
|
+
end
|
434
|
+
|
435
|
+
def verify_is_code(testname, is_code_arr, str)
|
436
|
+
lines, coverage, counts = code_info_from_string str
|
437
|
+
|
438
|
+
sf = Rcov::FileStatistics.new(testname, lines, counts)
|
439
|
+
is_code_arr.each_with_index do |val,i|
|
440
|
+
assert_equal(val, sf.is_code?(i),
|
441
|
+
"Unable to detect =begin comments properly: #{lines[i].inspect}")
|
442
|
+
end
|
443
|
+
end
|
444
|
+
|
445
|
+
def verify_marked_exactly(testname, marked_indices, str)
|
446
|
+
lines, coverage, counts = code_info_from_string(str)
|
447
|
+
|
448
|
+
sf = Rcov::FileStatistics.new(testname, lines, counts)
|
449
|
+
lines.size.times do |i|
|
450
|
+
if marked_indices.include? i
|
451
|
+
assert(sf.coverage[i], "Test #{testname}; " +
|
452
|
+
"line should have been marked: #{lines[i].inspect}.")
|
453
|
+
else
|
454
|
+
assert(!sf.coverage[i], "Test #{testname}; " +
|
455
|
+
"line should not have been marked: #{lines[i].inspect}.")
|
456
|
+
end
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
460
|
+
def verify_everything_marked(testname, str)
|
461
|
+
verify_marked_exactly(testname, (0...str.size).to_a, str)
|
462
|
+
end
|
463
|
+
|
464
|
+
|
465
|
+
def code_info_from_string(str)
|
466
|
+
str = str.gsub(/^\s*/,"")
|
467
|
+
[ str.map{|line| line.sub(/^\d+ /, "") },
|
468
|
+
str.map{|line| line[/^\d+/].to_i > 0},
|
469
|
+
str.map{|line| line[/^\d+/].to_i } ]
|
470
|
+
end
|
471
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
=begin
|
4
|
+
Updating functional testdata automatically is DANGEROUS, so I do manually.
|
5
|
+
|
6
|
+
== update functional test
|
7
|
+
cd ~/src/rcov/test
|
8
|
+
rcov="ruby ../bin/rcov -I../lib:../ext/rcovrt -o expected_coverage"
|
9
|
+
|
10
|
+
$rcov -a sample_04.rb
|
11
|
+
$rcov sample_04.rb
|
12
|
+
$rcov --gcc --include-file=sample --exclude=rcov sample_04.rb > expected_coverage/gcc-text.out
|
13
|
+
|
14
|
+
cp sample_05-old.rb sample_05.rb
|
15
|
+
$rcov --no-html --gcc --include-file=sample --exclude=rcov --save=coverage.info sample_05.rb > expected_coverage/diff-gcc-original.out
|
16
|
+
cp sample_05-new.rb sample_05.rb
|
17
|
+
$rcov --no-html --gcc -D --include-file=sample --exclude=rcov sample_05.rb > expected_coverage/diff-gcc-diff.out
|
18
|
+
$rcov --no-html -D --include-file=sample --exclude=rcov sample_05.rb > expected_coverage/diff.out
|
19
|
+
$rcov --no-html --no-color -D --include-file=sample --exclude=rcov sample_05.rb > expected_coverage/diff-no-color.out
|
20
|
+
$rcov --no-html --gcc --include-file=sample --exclude=rcov sample_05.rb > expected_coverage/diff-gcc-all.out
|
21
|
+
|
22
|
+
=end
|
23
|
+
|
24
|
+
class TestFunctional < Test::Unit::TestCase
|
25
|
+
@@dir = Pathname(__FILE__).expand_path.dirname
|
26
|
+
|
27
|
+
def strip_variable_sections(str)
|
28
|
+
str.sub(/Generated on.+$/, '').sub(/Generated using the.+$/, '')
|
29
|
+
end
|
30
|
+
|
31
|
+
def cmp(file)
|
32
|
+
content = lambda{|dir| strip_variable_sections(File.read(@@dir+dir+file))}
|
33
|
+
|
34
|
+
assert_equal(content["expected_coverage"], content["actual_coverage"])
|
35
|
+
end
|
36
|
+
|
37
|
+
def with_testdir(&block)
|
38
|
+
Dir.chdir(@@dir, &block)
|
39
|
+
end
|
40
|
+
|
41
|
+
def run_rcov(opts, script="assets/sample_04.rb", opts_tail="")
|
42
|
+
rcov = @@dir+"../bin/rcov"
|
43
|
+
ruby_opts = "-I../lib:../ext/rcovrt"
|
44
|
+
with_testdir do
|
45
|
+
`cd #{@@dir}; ruby #{ruby_opts} #{rcov} #{opts} -o actual_coverage #{script} #{opts_tail}`
|
46
|
+
yield if block_given?
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_annotation
|
51
|
+
run_rcov("-a") do
|
52
|
+
cmp "../assets/sample_04.rb"
|
53
|
+
cmp "../assets/sample_03.rb"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
@@selection = "--include-file=sample --exclude=rcov"
|
58
|
+
def test_text_gcc
|
59
|
+
run_rcov("--gcc #{@@selection}",
|
60
|
+
"assets/sample_04.rb",
|
61
|
+
"> actual_coverage/gcc-text.out") do
|
62
|
+
cmp "gcc-text.out"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_diff
|
67
|
+
with_testdir { FileUtils.cp "assets/sample_05-old.rb", "assets/sample_05.rb" }
|
68
|
+
run_rcov("--no-html --gcc #{@@selection} --save=coverage.info", "assets/sample_05.rb",
|
69
|
+
"> actual_coverage/diff-gcc-original.out") do
|
70
|
+
cmp "diff-gcc-original.out"
|
71
|
+
end
|
72
|
+
|
73
|
+
with_testdir { FileUtils.cp "assets/sample_05-new.rb", "assets/sample_05.rb" }
|
74
|
+
run_rcov("--no-html -D --gcc #{@@selection}", "assets/sample_05.rb",
|
75
|
+
"> actual_coverage/diff-gcc-diff.out") do
|
76
|
+
cmp "diff-gcc-diff.out"
|
77
|
+
end
|
78
|
+
|
79
|
+
run_rcov("--no-html -D #{@@selection}", "assets/sample_05.rb",
|
80
|
+
"> actual_coverage/diff.out") do
|
81
|
+
cmp "diff.out"
|
82
|
+
end
|
83
|
+
|
84
|
+
run_rcov("--no-html --no-color -D #{@@selection}", "assets/sample_05.rb",
|
85
|
+
"> actual_coverage/diff-no-color.out") do
|
86
|
+
cmp "diff-no-color.out"
|
87
|
+
end
|
88
|
+
|
89
|
+
run_rcov("--no-html --gcc #{@@selection}", "assets/sample_05.rb",
|
90
|
+
"> actual_coverage/diff-gcc-all.out") do
|
91
|
+
cmp "diff-gcc-all.out"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spicycode-rcov
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.8.1.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mauricio Fernandez
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
date: 2008-08-29 00:00:00 -07:00
|
12
|
+
default_executable: rcov
|
13
|
+
dependencies: []
|
14
|
+
|
15
|
+
description: rcov is a code coverage tool for Ruby. It is commonly used for viewing overall test unit coverage of target code. It features fast execution (20-300 times faster than previous tools), multiple analysis modes, XHTML and several kinds of text reports, easy automation with Rake via a RcovTask, fairly accurate coverage information through code linkage inference using simple heuristics, colorblind-friendliness...
|
16
|
+
email: mfp@acm.org
|
17
|
+
executables:
|
18
|
+
- rcov
|
19
|
+
extensions:
|
20
|
+
- ext/rcovrt/extconf.rb
|
21
|
+
extra_rdoc_files:
|
22
|
+
- readme_for_api
|
23
|
+
- readme_for_rake
|
24
|
+
- readme_for_rant
|
25
|
+
- readme_for_vim
|
26
|
+
files:
|
27
|
+
- bin/rcov
|
28
|
+
- lib/rcov.rb
|
29
|
+
- lib/rcov/lowlevel.rb
|
30
|
+
- lib/rcov/xx.rb
|
31
|
+
- lib/rcov/version.rb
|
32
|
+
- lib/rcov/rant.rb
|
33
|
+
- lib/rcov/report.rb
|
34
|
+
- lib/rcov/rcovtask.rb
|
35
|
+
- ext/rcovrt/extconf.rb
|
36
|
+
- ext/rcovrt/rcovrt.c
|
37
|
+
- ext/rcovrt/callsite.c
|
38
|
+
- LEGAL
|
39
|
+
- LICENSE
|
40
|
+
- Rakefile
|
41
|
+
- Rantfile
|
42
|
+
- readme_for_rake
|
43
|
+
- readme_for_rant
|
44
|
+
- readme_for_vim
|
45
|
+
- readme_for_apien
|
46
|
+
- readme_for_api
|
47
|
+
- THANKS
|
48
|
+
- test/functional_test.rb
|
49
|
+
- test/file_statistics_test.rb
|
50
|
+
- test/assets/sample_03.rb
|
51
|
+
- test/assets/sample_05-new.rb
|
52
|
+
- test/code_coverage_analyzer_test.rb
|
53
|
+
- test/assets/sample_04.rb
|
54
|
+
- test/assets/sample_02.rb
|
55
|
+
- test/assets/sample_05-old.rb
|
56
|
+
- test/assets/sample_01.rb
|
57
|
+
- test/turn_off_rcovrt.rb
|
58
|
+
- test/call_site_analyzer_test.rb
|
59
|
+
- test/assets/sample_05.rb
|
60
|
+
- rcov.vim
|
61
|
+
- rcov.el
|
62
|
+
- setup.rb
|
63
|
+
- BLURB
|
64
|
+
- CHANGES
|
65
|
+
has_rdoc: true
|
66
|
+
homepage: http://eigenclass.org/hiki.rb?rcov
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options:
|
69
|
+
- --main
|
70
|
+
- readme_for_api
|
71
|
+
- --title
|
72
|
+
- rcov code coverage tool
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 0.0.0
|
80
|
+
version:
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
version:
|
87
|
+
requirements: []
|
88
|
+
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 1.2.0
|
91
|
+
signing_key:
|
92
|
+
specification_version: 1
|
93
|
+
summary: Code coverage analysis tool for Ruby
|
94
|
+
test_files:
|
95
|
+
- test/functional_test.rb
|
96
|
+
- test/file_statistics_test.rb
|
97
|
+
- test/code_coverage_analyzer_test.rb
|
98
|
+
- test/call_site_analyzer_test.rb
|