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/THANKS ADDED
@@ -0,0 +1,96 @@
1
+
2
+ Tom Dolbilin:
3
+ * identified and fixed backslash problem on win32 for generated filenames
4
+
5
+ Andrew Kreiling:
6
+ * made the index XHTML compliant
7
+ * consolidate multiple references to the same underlying .rb file
8
+
9
+ Robert Feldt:
10
+ * pointed me to dynamic uses of the tracing hooks, provided the inspiration
11
+ for RCOV__.run_hooked
12
+ * helped to refine the color scheme
13
+
14
+ Andre Nathan:
15
+ * identified a bug in the heuristics: missing propagation for lines
16
+ with only }, ), ]
17
+
18
+ David Roberts:
19
+ * reported confusing behavior when all files are ignored because they match
20
+ a regexp in the reject list
21
+ * tested the RubyGems package for win32
22
+
23
+ John-Mason Shackelford:
24
+ * reported an important bug in the pure-Ruby tracer module, which broke it
25
+ altogether in 0.4.0
26
+ * suggested a change in the CSS to make XHTML reports more readable under IE
27
+
28
+ Dave Burt:
29
+ * reported an issue with text reports under cmd.exe (should use < 80 cols)
30
+
31
+ Alex Wayne:
32
+ * reported problem with heredocs: they were not being marked as a whole if
33
+ the "header" wasn't reported by Ruby.
34
+ * reported problem with the last line of literal data structs not being
35
+ covered if there was stuff after the end delimiter
36
+
37
+ Coda Hale:
38
+ * reported problem with blocks were the first line is not being marked
39
+ and ditto for the last line when end/} is followed by more stuff
40
+
41
+ Tim Shadel:
42
+ * reported that the last comment block was not being marked even when
43
+ it was the last thing in the file
44
+
45
+ Thomas Leitner:
46
+ * reported that the SCRIPT_LINES__ workaround did not always work
47
+ * fixed the bug which broke differential reports for filenames with
48
+ special characters
49
+
50
+ Assaph Mehr:
51
+ * beta-tested 0.7.0 and found a bug in --aggregate (missing files)
52
+
53
+ Ryan Kinderman:
54
+ * suggested that -Ipath be passed to ruby instead of rcov in RcovTasks
55
+
56
+ Jan Svitok:
57
+ * reported typo in rcovtask.rb's RDoc
58
+
59
+ rubikitch:
60
+ * implemented --annotate mode
61
+ * implemented --gcc option
62
+ * superior emacs support
63
+ * testing, refactoring...
64
+ * many other things, see darcs changes
65
+
66
+ Zed A. Shaw:
67
+ * reported and fixed segfault triggered by rspec
68
+
69
+ Lee Marlow:
70
+ * patch allowing to run rcov against a data file with no input code
71
+
72
+ Kurt Stephens:
73
+ * patch to rethrow any exceptions generated by the traced scripts after
74
+ report generation; notably SystemExit, allowing to use the exit code from
75
+ test runners under rake.
76
+
77
+ Brian Candler:
78
+ * found compatibility issues with the REXML lib included in ruby-1.8.6-p110
79
+ and provided a workaround
80
+
81
+ Mat Schaffer:
82
+ * reported missing line colorization on Safari and probably other browsers,
83
+ owing to self-closing <a> not being handled properly despite being valid
84
+ XHTML 1.0.
85
+
86
+ Sam Granieri:
87
+ * tested workaround for REXML bug
88
+
89
+ Kosmas Schütz, Daniel Berger, François Beausoleil, Bil Kleb:
90
+ * provided information about the ruby-1.8.6-p11[01] REXML problems
91
+
92
+ Chad Humphries:
93
+ * indicated that Spec::DSL::Example has changed in RSpec trunk
94
+
95
+ Jeremy Hinegardner:
96
+ * more info about REXML's bugs in 1.8.6-p11[01]
data/bin/rcov ADDED
@@ -0,0 +1,552 @@
1
+ #!/usr/bin/env ruby
2
+ # rcov Copyright (c) 2004-2006 Mauricio Fernandez <mfp@acm.org>
3
+ #
4
+ # rcov originally based on
5
+ # module COVERAGE__ originally (c) NAKAMURA Hiroshi
6
+ # module PrettyCoverage originally (c) Simon Strandgaard
7
+ #
8
+ # rewritten & extended by Mauricio Fern�ndez <mfp@acm.org>
9
+ #
10
+ # See LEGAL and LICENSE for additional licensing information.
11
+ #
12
+
13
+ require 'cgi'
14
+ require 'rbconfig'
15
+ require 'optparse'
16
+ require 'ostruct'
17
+
18
+ SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
19
+ require 'rcov/version'
20
+ require 'rcov/report'
21
+
22
+ #{{{ "main" code
23
+ options = OpenStruct.new
24
+ options.color = true
25
+ options.range = 30.0
26
+ options.profiling = false
27
+ options.destdir = nil
28
+ options.loadpaths = []
29
+ options.textmode = false
30
+ options.skip = Rcov::Formatter::DEFAULT_OPTS[:ignore]
31
+ options.include = []
32
+ options.html = true
33
+ options.comments_run_by_default = false
34
+ options.test_unit_only = false
35
+ options.spec_only = false
36
+ options.sort = :name
37
+ options.sort_reverse = false
38
+ options.output_threshold = 101
39
+ options.replace_prog_name = false
40
+ options.callsites = false
41
+ options.crossrefs = false
42
+ options.coverage_diff_file = "coverage.info"
43
+ options.coverage_diff_mode = :compare
44
+ options.coverage_diff_save = false
45
+ options.diff_cmd = "diff"
46
+ options.report_cov_bug_for = nil
47
+ options.aggregate_file = nil
48
+ options.gcc_output = false
49
+ options.show_validator_links = true
50
+ options.charset = nil
51
+
52
+ EXTRA_HELP = <<-EOF
53
+
54
+ You can run several programs at once:
55
+ rcov something.rb somethingelse.rb
56
+
57
+ The parameters to be passed to the program under inspection can be specified
58
+ after --:
59
+
60
+ rcov -Ilib -t something.rb -- --theseopts --are --given --to --something.rb
61
+
62
+ ARGV will be set to the specified parameters after --.
63
+ Keep in mind that all the programs are run under the same process
64
+ (i.e. they just get Kernel#load()'ed in sequence).
65
+
66
+ $PROGRAM_NAME (aka. $0) will be set before each file is load()ed if
67
+ --replace-progname is used.
68
+ EOF
69
+
70
+ #{{{ OptionParser
71
+ opts = OptionParser.new do |opts|
72
+ opts.banner = <<-EOF
73
+ rcov #{Rcov::VERSION} #{Rcov::RELEASE_DATE}
74
+ Usage: rcov [options] <script1.rb> [script2.rb] [-- --extra-options]
75
+ EOF
76
+ opts.separator ""
77
+ opts.separator "Options:"
78
+ opts.on("-o", "--output PATH", "Destination directory.") do |dir|
79
+ options.destdir = dir
80
+ end
81
+ opts.on("-I", "--include PATHS",
82
+ "Prepend PATHS to $: (colon separated list)") do |paths|
83
+ options.loadpaths = paths.split(/:/)
84
+ end
85
+ opts.on("--[no-]comments",
86
+ "Mark all comments by default.",
87
+ "(default: --no-comments)") do |comments_run_p|
88
+ options.comments_run_by_default = comments_run_p
89
+ end
90
+ opts.on("--test-unit-only",
91
+ "Only trace code executed inside TestCases.") do
92
+ options.test_unit_only = true
93
+ end
94
+ opts.on("--spec-only",
95
+ "Only trace code executed inside RSpec specs.") do
96
+ options.spec_only = true
97
+ end
98
+ opts.on("-n", "--no-color", "Create colorblind-safe output.") do
99
+ options.color = false
100
+ end
101
+ opts.on("-i", "--include-file PATTERNS",
102
+ "Generate info for files matching a",
103
+ "pattern (comma-separated regexp list)") do |list|
104
+ begin
105
+ regexps = list.split(/,/).map{|x| Regexp.new(x) }
106
+ options.include += regexps
107
+ rescue RegexpError => e
108
+ raise OptionParser::InvalidArgument, e.message
109
+ end
110
+ end
111
+ opts.on("-x", "--exclude PATTERNS",
112
+ "Don't generate info for files matching a",
113
+ "pattern (comma-separated regexp list)") do |list|
114
+ begin
115
+ regexps = list.split(/,/).map{|x| Regexp.new x}
116
+ options.skip += regexps
117
+ rescue RegexpError => e
118
+ raise OptionParser::InvalidArgument, e.message
119
+ end
120
+ end
121
+ opts.on("--exclude-only PATTERNS",
122
+ "Skip info only for files matching the",
123
+ "given patterns.") do |list|
124
+ begin
125
+ options.skip = list.split(/,/).map{|x| Regexp.new(x) }
126
+ rescue RegexpError => e
127
+ raise OptionParser::InvalidArgument, e.message
128
+ end
129
+ end
130
+ opts.on("--rails", "Skip config/, environment/ and vendor/.") do
131
+ options.skip.concat [%r{\bvendor/},%r{\bconfig/},%r{\benvironment/}]
132
+ end
133
+ opts.on("--[no-]callsites", "Show callsites in generated XHTML report.",
134
+ "(somewhat slower; disabled by default)") do |val|
135
+ options.callsites = val
136
+ end
137
+ opts.on("--[no-]xrefs", "Generate fully cross-referenced report.",
138
+ "(includes --callsites)") do |val|
139
+ options.crossrefs = val
140
+ options.callsites ||= val
141
+ end
142
+ opts.on("-p", "--profile", "Generate bogo-profiling info.") do
143
+ options.profiling = true
144
+ options.destdir ||= "profiling"
145
+ end
146
+ opts.on("-r", "--range RANGE", Float,
147
+ "Color scale range for profiling info (dB).") do |val|
148
+ options.range = val
149
+ end
150
+ opts.on("-a", "--annotate",
151
+ "Generate annotated source code.") do
152
+ options.html = false
153
+ options.textmode = :annotate
154
+ options.crossrefs = true
155
+ options.callsites = true
156
+ options.skip = [ %r!/test/unit/! ]
157
+ end
158
+
159
+ opts.on("-T", "--text-report", "Dump detailed plain-text report to stdout.",
160
+ "(filename, LoC, total lines, coverage)") do
161
+ options.textmode = :report
162
+ end
163
+ opts.on("-t", "--text-summary", "Dump plain-text summary to stdout.") do
164
+ options.textmode = :summary
165
+ end
166
+ opts.on("--text-counts", "Dump execution counts in plaintext.") do
167
+ options.textmode = :counts
168
+ end
169
+ opts.on("--text-coverage", "Dump coverage info to stdout, using",
170
+ "ANSI color sequences unless -n.") do
171
+ options.textmode = :coverage
172
+ end
173
+ opts.on("--gcc", "Dump uncovered line in GCC error format.") do
174
+ options.gcc_output = true
175
+ end
176
+ opts.on("--aggregate FILE", "Aggregate data from previous runs",
177
+ "in FILE. Overwrites FILE with the",
178
+ "merged data. FILE is created if",
179
+ "necessary.") do |file|
180
+ options.aggregate_file = file
181
+ end
182
+ opts.on("-D [FILE]", "--text-coverage-diff [FILE]",
183
+ "Compare code coverage with saved state",
184
+ "in FILE, defaults to coverage.info.",
185
+ "Implies --comments.") do |file|
186
+ options.textmode = :coverage_diff
187
+ options.comments_run_by_default = true
188
+ if options.coverage_diff_save
189
+ raise "You shouldn't use --save and --text-coverage-diff at a time."
190
+ end
191
+ options.coverage_diff_mode = :compare
192
+ options.coverage_diff_file = file if file && !file.empty?
193
+ end
194
+ opts.on("--save [FILE]", "Save coverage data to FILE,",
195
+ "for later use with rcov -D.",
196
+ "(default: coverage.info)") do |file|
197
+ options.coverage_diff_save = true
198
+ options.coverage_diff_mode = :record
199
+ if options.textmode == :coverage_diff
200
+ raise "You shouldn't use --save and --text-coverage-diff at a time."
201
+ end
202
+ options.coverage_diff_file = file if file && !file.empty?
203
+ end
204
+ opts.on("--[no-]html", "Generate HTML output.",
205
+ "(default: --html)") do |val|
206
+ options.html = val
207
+ end
208
+ opts.on("--sort CRITERION", [:name, :loc, :coverage],
209
+ "Sort files in the output by the specified",
210
+ "field (name, loc, coverage)") do |criterion|
211
+ options.sort = criterion
212
+ end
213
+ opts.on("--sort-reverse", "Reverse files in the output.") do
214
+ options.sort_reverse = true
215
+ end
216
+ opts.on("--threshold INT", "Only list files with coverage < INT %.",
217
+ "(default: 101)") do |threshold|
218
+ begin
219
+ threshold = Integer(threshold)
220
+ raise if threshold <= 0 || threshold > 101
221
+ rescue Exception
222
+ raise OptionParser::InvalidArgument, threshold
223
+ end
224
+ options.output_threshold = threshold
225
+ end
226
+ opts.on("--charset CHARSET",
227
+ "Charset used in Content-Type declaration of HTML reports.") do |c|
228
+ options.charset = c
229
+ end
230
+ opts.on("--[no-]validator-links", "Add link to W3C's validation services.",
231
+ "(default: true)") do |show_validator_links|
232
+ options.show_validator_links = show_validator_links
233
+ end
234
+ opts.on("--only-uncovered", "Same as --threshold 100") do
235
+ options.output_threshold = 100
236
+ end
237
+ opts.on("--replace-progname", "Replace $0 when loading the .rb files.") do
238
+ options.replace_prog_name = true
239
+ end
240
+ opts.on("-w", "Turn warnings on (like ruby).") do
241
+ $VERBOSE = true
242
+ end
243
+ opts.on("--no-rcovrt", "Do not use the optimized C runtime.",
244
+ "(will run 30-300 times slower)") do
245
+ $rcov_do_not_use_rcovrt = true
246
+ end
247
+ opts.on("--diff-cmd PROGNAME", "Use PROGNAME for --text-coverage-diff.",
248
+ "(default: diff)") do |cmd|
249
+ options.diff_cmd = cmd
250
+ end
251
+ opts.separator ""
252
+ opts.on_tail("-h", "--help", "Show extended help message") do
253
+ require 'pp'
254
+ puts opts
255
+ puts <<EOF
256
+
257
+ Files matching any of the following regexps will be omitted in the report(s):
258
+ #{PP.pp(options.skip, "").chomp}
259
+ EOF
260
+ puts EXTRA_HELP
261
+ exit
262
+ end
263
+ opts.on_tail("--report-cov-bug SELECTOR",
264
+ "Report coverage analysis bug for the",
265
+ "method specified by SELECTOR",
266
+ "(format: Foo::Bar#method, A::B.method)") do |selector|
267
+ case selector
268
+ when /([^.]+)(#|\.)(.*)/: options.report_cov_bug_for = selector
269
+ else
270
+ raise OptionParser::InvalidArgument, selector
271
+ end
272
+ options.textmode = nil
273
+ options.html = false
274
+ options.callsites = true
275
+ end
276
+ opts.on_tail("--version", "Show version") do
277
+ puts "rcov " + Rcov::VERSION + " " + Rcov::RELEASE_DATE
278
+ exit
279
+ end
280
+ end
281
+
282
+ $ORIGINAL_ARGV = ARGV.clone
283
+ if (idx = ARGV.index("--"))
284
+ extra_args = ARGV[idx+1..-1]
285
+ ARGV.replace(ARGV[0,idx])
286
+ else
287
+ extra_args = []
288
+ end
289
+
290
+ begin
291
+ opts.parse! ARGV
292
+ rescue OptionParser::InvalidOption, OptionParser::InvalidArgument,
293
+ OptionParser::MissingArgument => e
294
+ puts opts
295
+ puts
296
+ puts e.message
297
+ exit(-1)
298
+ end
299
+ options.destdir ||= "coverage"
300
+ unless ARGV[0] or options.aggregate_file && File.file?(options.aggregate_file)
301
+ puts opts
302
+ exit
303
+ end
304
+
305
+ # {{{ set loadpath
306
+ options.loadpaths.reverse_each{|x| $:.unshift x}
307
+
308
+ #{{{ require 'rcov': do it only now in order to be able to run rcov on itself
309
+ # since we need to set $: before.
310
+
311
+ require 'rcov'
312
+
313
+ options.callsites = true if options.report_cov_bug_for
314
+ options.textmode = :gcc if !options.textmode and options.gcc_output
315
+
316
+ def rcov_load_aggregate_data(file)
317
+ require 'zlib'
318
+ begin
319
+ old_data = nil
320
+ Zlib::GzipReader.open(file){|gz| old_data = Marshal.load(gz) }
321
+ rescue
322
+ old_data = {}
323
+ end
324
+ old_data || {}
325
+ end
326
+
327
+ def rcov_save_aggregate_data(file)
328
+ require 'zlib'
329
+ Zlib::GzipWriter.open(file) do |f|
330
+ Marshal.dump({:callsites => $rcov_callsite_analyzer,
331
+ :coverage => $rcov_code_coverage_analyzer}, f)
332
+ end
333
+ end
334
+
335
+ if options.callsites
336
+ if options.aggregate_file
337
+ saved_aggregate_data = rcov_load_aggregate_data(options.aggregate_file)
338
+ if saved_aggregate_data[:callsites]
339
+ $rcov_callsite_analyzer = saved_aggregate_data[:callsites]
340
+ end
341
+ end
342
+ $rcov_callsite_analyzer ||= Rcov::CallSiteAnalyzer.new
343
+ $rcov_callsite_analyzer.install_hook
344
+ else
345
+ $rcov_callsite_analyzer = nil
346
+ end
347
+
348
+ # {{{ create formatters
349
+ formatters = []
350
+ make_formatter = lambda do |klass|
351
+ klass.new(:destdir => options.destdir, :color => options.color,
352
+ :fsr => options.range, :textmode => options.textmode,
353
+ :ignore => options.skip, :dont_ignore => options.include,
354
+ :sort => options.sort,
355
+ :sort_reverse => options.sort_reverse,
356
+ :output_threshold => options.output_threshold,
357
+ :callsite_analyzer => $rcov_callsite_analyzer,
358
+ :coverage_diff_mode => options.coverage_diff_mode,
359
+ :coverage_diff_file => options.coverage_diff_file,
360
+ :callsites => options.callsites,
361
+ :cross_references => options.crossrefs,
362
+ :diff_cmd => options.diff_cmd,
363
+ :comments_run_by_default => options.comments_run_by_default,
364
+ :gcc_output => options.gcc_output,
365
+ :validator_links => options.show_validator_links,
366
+ :charset => options.charset
367
+ )
368
+ end
369
+
370
+ if options.html
371
+ if options.profiling
372
+ formatters << make_formatter[Rcov::HTMLProfiling]
373
+ else
374
+ formatters << make_formatter[Rcov::HTMLCoverage]
375
+ end
376
+ end
377
+ textual_formatters = {:counts => Rcov::FullTextReport,
378
+ :coverage => Rcov::FullTextReport,
379
+ :gcc => Rcov::FullTextReport,
380
+ :annotate => Rcov::RubyAnnotation,
381
+ :summary => Rcov::TextSummary, :report => Rcov::TextReport,
382
+ :coverage_diff => Rcov::TextCoverageDiff}
383
+
384
+ if textual_formatters[options.textmode]
385
+ formatters << make_formatter[textual_formatters[options.textmode]]
386
+ end
387
+
388
+ formatters << make_formatter[Rcov::TextCoverageDiff] if options.coverage_diff_save
389
+
390
+ if options.aggregate_file
391
+ saved_aggregate_data ||= rcov_load_aggregate_data(options.aggregate_file)
392
+ if saved_aggregate_data[:coverage]
393
+ $rcov_code_coverage_analyzer = saved_aggregate_data[:coverage]
394
+ end
395
+ end
396
+ $rcov_code_coverage_analyzer ||= Rcov::CodeCoverageAnalyzer.new
397
+
398
+ # must be registered before test/unit puts its own
399
+
400
+
401
+ # The exception to rethrow after reporting has been handled.
402
+ $__rcov_exit_exception = nil
403
+
404
+ END {
405
+ $rcov_code_coverage_analyzer.remove_hook
406
+ $rcov_callsite_analyzer.remove_hook if $rcov_callsite_analyzer
407
+ rcov_save_aggregate_data(options.aggregate_file) if options.aggregate_file
408
+ $rcov_code_coverage_analyzer.dump_coverage_info(formatters)
409
+ if options.report_cov_bug_for
410
+ defsite = $rcov_callsite_analyzer.defsite(options.report_cov_bug_for)
411
+ if !defsite
412
+ $stderr.puts <<-EOF
413
+ Couldn't find definition site of #{options.report_cov_bug_for}.
414
+ Was it executed at all?
415
+ EOF
416
+ exit(-1)
417
+ end
418
+ lines, mark_info, count_info = $rcov_code_coverage_analyzer.data(defsite.file)
419
+ puts <<EOF
420
+
421
+ Please fill in the blanks in the following report.
422
+
423
+ You can report the bug via the Ruby-Talk ML, send it directly to
424
+ <mfp at acm dot org> (include "rcov" in the subject to get past the spam filters),
425
+ or post it to
426
+ http://eigenclass.org/hiki.rb?rcov+#{VERSION}
427
+
428
+ Thank you!
429
+
430
+ =============================================================================
431
+ Bug report generated on #{Time.new}
432
+
433
+ Ruby version: #{RUBY_VERSION} (#{RUBY_RELEASE_DATE})
434
+ Platform: #{RUBY_PLATFORM}
435
+ rcov version: #{Rcov::VERSION}
436
+ rcovrt loaded? #{$".any?{|x| /\brcovrt\b/ =~ x} }
437
+ using RubyGems? #{$".any?{|x| /\brubygems\b/ =~ x} }
438
+ Command-line arguments: #{$ORIGINAL_ARGV.inspect}
439
+ Coverage analysis bug in: #{options.report_cov_bug_for}
440
+
441
+ Line(s) ____________ should be ______ (red/green).
442
+
443
+ Raw coverage information (feel free to remove useless data, but please leave
444
+ some context around the faulty lines):
445
+
446
+ EOF
447
+ defsite.line.upto(SCRIPT_LINES__[defsite.file].size) do |i|
448
+ puts "%7d:%5d:%s" % [count_info[i-1], i, lines[i-1]]
449
+ end
450
+ exit
451
+ end
452
+ if formatters.all?{|formatter| formatter.sorted_file_pairs.empty? }
453
+ require 'pp'
454
+ $stderr.puts <<-EOF
455
+
456
+ No file to analyze was found. All the files loaded by rcov matched one of the
457
+ following expressions, and were thus ignored:
458
+ #{PP.pp(options.skip, "").chomp}
459
+
460
+ You can solve this by doing one or more of the following:
461
+ * rename the files not to be ignored so they don't match the above regexps
462
+ * use --include-file to give a list of patterns for files not to be ignored
463
+ * use --exclude-only to give the new list of regexps to match against
464
+ * structure your code as follows:
465
+ test/test_*.rb for the test cases
466
+ lib/**/*.rb for the target source code whose coverage you want
467
+ making sure that the test/test_*.rb files are loading from lib/, e.g. by
468
+ using the -Ilib command-line argument, adding
469
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
470
+ to test/test_*.rb, or running rcov via a Rakefile (read the RDoc
471
+ documentation or README.rake in the source distribution).
472
+ EOF
473
+ end
474
+
475
+ raise $__rcov_exit_exception if $__rcov_exit_exception
476
+ }
477
+
478
+ if options.test_unit_only
479
+ require 'test/unit'
480
+ module Test::Unit
481
+ class TestCase
482
+ remove_method(:run) if instance_methods.include? "run"
483
+ def run(result)
484
+ yield(STARTED, name)
485
+ @_result = result
486
+ begin
487
+ $rcov_code_coverage_analyzer.run_hooked do
488
+ setup
489
+ __send__(@method_name)
490
+ end
491
+ rescue AssertionFailedError => e
492
+ add_failure(e.message, e.backtrace)
493
+ rescue StandardError, ScriptError
494
+ add_error($!)
495
+ ensure
496
+ begin
497
+ $rcov_code_coverage_analyzer.run_hooked { teardown }
498
+ rescue AssertionFailedError => e
499
+ add_failure(e.message, e.backtrace)
500
+ rescue StandardError, ScriptError
501
+ add_error($!)
502
+ end
503
+ end
504
+ result.add_run
505
+ yield(FINISHED, name)
506
+ end
507
+ end
508
+ end
509
+ elsif options.spec_only
510
+ require 'spec'
511
+ override_run = lambda do
512
+ oldrun = instance_method(:run)
513
+ define_method(:run) do |*args|
514
+ $rcov_code_coverage_analyzer.run_hooked { oldrun.bind(self).call(*args) }
515
+ end
516
+ end
517
+ if defined? Spec::DSL::Example
518
+ Spec::DSL::Example.instance_eval(&override_run)
519
+ elsif defined? Spec::Example::ExampleGroup
520
+ Spec::Example::ExampleGroup.instance_eval(&override_run)
521
+ else
522
+ $stderr.puts <<-EOF
523
+ Your RSpec version isn't supported. If it's a old one, consider upgrading;
524
+ otherwise, please report the problem.
525
+ EOF
526
+ exit(-1)
527
+ end
528
+ else
529
+ $rcov_code_coverage_analyzer.install_hook
530
+ end
531
+
532
+ #{{{ Load scripts
533
+ begin
534
+ pending_scripts = ARGV.clone
535
+ ARGV.replace extra_args
536
+ until pending_scripts.empty?
537
+ prog = pending_scripts.shift
538
+ if options.replace_prog_name
539
+ $0 = File.basename(File.expand_path(prog))
540
+ end
541
+ load prog
542
+ end
543
+ rescue Object => err
544
+ $__rcov_exit_exception = err
545
+ end
546
+
547
+ __END__
548
+ # vi: set sw=4:
549
+ # Here is Emacs setting. DO NOT REMOVE!
550
+ # Local Variables:
551
+ # ruby-indent-level: 4
552
+ # End: