relevance-rcov 0.8.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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]
@@ -0,0 +1,560 @@
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
+ require 'cgi'
13
+ require 'rbconfig'
14
+ require 'optparse'
15
+ require 'ostruct'
16
+
17
+ SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
18
+ require 'rcov/version'
19
+ require 'rcov/formatters'
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::BaseFormatter::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 /([^.]+)(#|\.)(.*)/ then 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, :coverage => $rcov_code_coverage_analyzer}, f)
331
+ end
332
+ end
333
+
334
+ if options.callsites
335
+ if options.aggregate_file
336
+ saved_aggregate_data = rcov_load_aggregate_data(options.aggregate_file)
337
+ if saved_aggregate_data[:callsites]
338
+ $rcov_callsite_analyzer = saved_aggregate_data[:callsites]
339
+ end
340
+ end
341
+ $rcov_callsite_analyzer ||= Rcov::CallSiteAnalyzer.new
342
+ $rcov_callsite_analyzer.install_hook
343
+ else
344
+ $rcov_callsite_analyzer = nil
345
+ end
346
+
347
+ # {{{ create formatters
348
+ formatters = []
349
+ make_formatter = lambda do |klass|
350
+ klass.new(:destdir => options.destdir, :color => options.color,
351
+ :fsr => options.range, :textmode => options.textmode,
352
+ :ignore => options.skip, :dont_ignore => options.include,
353
+ :sort => options.sort,
354
+ :sort_reverse => options.sort_reverse,
355
+ :output_threshold => options.output_threshold,
356
+ :callsite_analyzer => $rcov_callsite_analyzer,
357
+ :coverage_diff_mode => options.coverage_diff_mode,
358
+ :coverage_diff_file => options.coverage_diff_file,
359
+ :callsites => options.callsites,
360
+ :cross_references => options.crossrefs,
361
+ :diff_cmd => options.diff_cmd,
362
+ :comments_run_by_default => options.comments_run_by_default,
363
+ :gcc_output => options.gcc_output,
364
+ :validator_links => options.show_validator_links,
365
+ :charset => options.charset
366
+ )
367
+ end
368
+
369
+ if options.html
370
+ if options.profiling
371
+ formatters << make_formatter[Rcov::HTMLProfiling]
372
+ else
373
+ formatters << make_formatter[Rcov::HTMLCoverage]
374
+ end
375
+ end
376
+ textual_formatters = {:counts => Rcov::FullTextReport,
377
+ :coverage => Rcov::FullTextReport,
378
+ :gcc => Rcov::FullTextReport,
379
+ :annotate => Rcov::RubyAnnotation,
380
+ :summary => Rcov::TextSummary, :report => Rcov::TextReport,
381
+ :coverage_diff => Rcov::TextCoverageDiff}
382
+
383
+ if textual_formatters[options.textmode]
384
+ formatters << make_formatter[textual_formatters[options.textmode]]
385
+ end
386
+
387
+ formatters << make_formatter[Rcov::TextCoverageDiff] if options.coverage_diff_save
388
+
389
+ if options.aggregate_file
390
+ saved_aggregate_data ||= rcov_load_aggregate_data(options.aggregate_file)
391
+ if saved_aggregate_data[:coverage]
392
+ $rcov_code_coverage_analyzer = saved_aggregate_data[:coverage]
393
+ end
394
+ end
395
+ $rcov_code_coverage_analyzer ||= Rcov::CodeCoverageAnalyzer.new
396
+
397
+ # must be registered before test/unit puts its own
398
+
399
+
400
+ # The exception to rethrow after reporting has been handled.
401
+ $__rcov_exit_exception = nil
402
+
403
+ END {
404
+ $rcov_code_coverage_analyzer.remove_hook
405
+ $rcov_callsite_analyzer.remove_hook if $rcov_callsite_analyzer
406
+ rcov_save_aggregate_data(options.aggregate_file) if options.aggregate_file
407
+ $rcov_code_coverage_analyzer.dump_coverage_info(formatters)
408
+ if options.report_cov_bug_for
409
+ defsite = $rcov_callsite_analyzer.defsite(options.report_cov_bug_for)
410
+ if !defsite
411
+ $stderr.puts <<-EOF
412
+ Couldn't find definition site of #{options.report_cov_bug_for}.
413
+ Was it executed at all?
414
+ EOF
415
+ exit(-1)
416
+ end
417
+ lines, mark_info, count_info = $rcov_code_coverage_analyzer.data(defsite.file)
418
+ puts <<EOF
419
+
420
+ Please fill in the blanks in the following report.
421
+
422
+ You can report the bug via the Ruby-Talk ML, send it directly to
423
+ <mfp at acm dot org> (include "rcov" in the subject to get past the spam filters),
424
+ or post it to
425
+ http://eigenclass.org/hiki.rb?rcov+#{VERSION}
426
+
427
+ Thank you!
428
+
429
+ =============================================================================
430
+ Bug report generated on #{Time.new}
431
+
432
+ Ruby version: #{RUBY_VERSION} (#{RUBY_RELEASE_DATE})
433
+ Platform: #{RUBY_PLATFORM}
434
+ rcov version: #{Rcov::VERSION}
435
+ rcovrt loaded? #{$".any?{|x| /\brcovrt\b/ =~ x} }
436
+ using RubyGems? #{$".any?{|x| /\brubygems\b/ =~ x} }
437
+ Command-line arguments: #{$ORIGINAL_ARGV.inspect}
438
+ Coverage analysis bug in: #{options.report_cov_bug_for}
439
+
440
+ Line(s) ____________ should be ______ (red/green).
441
+
442
+ Raw coverage information (feel free to remove useless data, but please leave
443
+ some context around the faulty lines):
444
+
445
+ EOF
446
+ defsite.line.upto(SCRIPT_LINES__[defsite.file].size) do |i|
447
+ puts "%7d:%5d:%s" % [count_info[i-1], i, lines[i-1]]
448
+ end
449
+ exit
450
+ end
451
+ if formatters.all?{|formatter| formatter.sorted_file_pairs.empty? }
452
+ require 'pp'
453
+ $stderr.puts <<-EOF
454
+
455
+ No file to analyze was found. All the files loaded by rcov matched one of the
456
+ following expressions, and were thus ignored:
457
+ #{PP.pp(options.skip, "").chomp}
458
+
459
+ You can solve this by doing one or more of the following:
460
+ * rename the files not to be ignored so they don't match the above regexps
461
+ * use --include-file to give a list of patterns for files not to be ignored
462
+ * use --exclude-only to give the new list of regexps to match against
463
+ * structure your code as follows:
464
+ test/test_*.rb for the test cases
465
+ lib/**/*.rb for the target source code whose coverage you want
466
+ making sure that the test/test_*.rb files are loading from lib/, e.g. by
467
+ using the -Ilib command-line argument, adding
468
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
469
+ to test/test_*.rb, or running rcov via a Rakefile (read the RDoc
470
+ documentation or README.rake in the source distribution).
471
+ EOF
472
+ end
473
+
474
+ raise $__rcov_exit_exception if $__rcov_exit_exception
475
+ }
476
+
477
+ if options.test_unit_only
478
+ require 'test/unit'
479
+ module Test::Unit
480
+ class TestCase
481
+ remove_method(:run) if instance_methods.include? "run"
482
+ def run(result)
483
+ yield(STARTED, name)
484
+ @_result = result
485
+ begin
486
+ $rcov_code_coverage_analyzer.run_hooked do
487
+ setup
488
+ __send__(@method_name)
489
+ end
490
+ rescue AssertionFailedError => e
491
+ add_failure(e.message, e.backtrace)
492
+ rescue StandardError, ScriptError
493
+ add_error($!)
494
+ ensure
495
+ begin
496
+ $rcov_code_coverage_analyzer.run_hooked { teardown }
497
+ rescue AssertionFailedError => e
498
+ add_failure(e.message, e.backtrace)
499
+ rescue StandardError, ScriptError
500
+ add_error($!)
501
+ end
502
+ end
503
+ result.add_run
504
+ yield(FINISHED, name)
505
+ end
506
+ end
507
+ end
508
+ elsif options.spec_only
509
+ require 'spec'
510
+ override_run = lambda do
511
+ oldrun = instance_method(:run)
512
+ define_method(:run) do |*args|
513
+ $rcov_code_coverage_analyzer.run_hooked { oldrun.bind(self).call(*args) }
514
+ end
515
+ end
516
+
517
+ if defined?(Spec::DSL::Example)
518
+ Spec::DSL::Example.instance_eval(&override_run)
519
+ elsif defined?(Spec::Example::ExampleMethods)
520
+ override_run = lambda do
521
+ oldexecute = instance_method(:execute)
522
+ define_method(:execute) do |*args|
523
+ $rcov_code_coverage_analyzer.run_hooked { oldexecute.bind(self).call(*args) }
524
+ end
525
+ end
526
+ Spec::Example::ExampleMethods.instance_eval(&override_run)
527
+ elsif defined?(Spec::Example::ExampleGroup)
528
+ Spec::Example::ExampleGroup.instance_eval(&override_run)
529
+ else
530
+ $stderr.puts <<-EOF
531
+ Your RSpec version isn't supported. If it's a old one, consider upgrading;
532
+ otherwise, please report the problem.
533
+ EOF
534
+ exit(-1)
535
+ end
536
+ else
537
+ $rcov_code_coverage_analyzer.install_hook
538
+ end
539
+
540
+ #{{{ Load scripts
541
+ begin
542
+ pending_scripts = ARGV.clone
543
+ ARGV.replace extra_args
544
+ until pending_scripts.empty?
545
+ prog = pending_scripts.shift
546
+ if options.replace_prog_name
547
+ $0 = File.basename(File.expand_path(prog))
548
+ end
549
+ load prog
550
+ end
551
+ rescue Object => err
552
+ $__rcov_exit_exception = err
553
+ end
554
+
555
+ __END__
556
+ # vi: set sw=4:
557
+ # Here is Emacs setting. DO NOT REMOVE!
558
+ # Local Variables:
559
+ # ruby-indent-level: 4
560
+ # End: