mergulhao-rcov 0.8.1.3.0

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.
@@ -0,0 +1,64 @@
1
+
2
+ <tt>rcov.el</tt> allows you to use rcov from Emacs conveniently.
3
+ * Run unit tests and jump to uncovered code by <tt>C-x `</tt>.
4
+ * Run unit tests and save the current coverage status.
5
+ * Run unit tests and jump to uncovered code introduced since the last run.
6
+ * View cross-reference annotated code.
7
+
8
+ == Installation
9
+
10
+ Copy <tt>rcov.el</tt> to the appropriate directory, which is in load-path.
11
+ Then require it.
12
+ (require 'rcov)
13
+
14
+
15
+ == Usage
16
+
17
+ There are some commands to run rcov in Emacs.
18
+ All of them displays +rcov+ window, whose major-mode is compilation-mode.
19
+ Therefore you can jump to uncovered code by <tt>C-x `</tt>.
20
+
21
+ +rcov-command-line+, +rcovsave-command-line+, and +rcovdiff-command-line+ define
22
+ command line to run rcov.
23
+ If you do not use +rcov+ from Rake, you must modify them.
24
+
25
+ === Finding uncovered code
26
+
27
+ Type the following while editing your program:
28
+ M-x rcov
29
+
30
+ === Setting the reference point
31
+
32
+ +rcov+'s <tt>--text-coverage-diff</tt> mode compares the current coverage status against
33
+ the saved one. It therefore needs that information to be recorded
34
+ before you write new code (typically right after you perform a commit) in
35
+ order to have something to compare against.
36
+
37
+ You can save the current status with the <tt>--save</tt> option.
38
+
39
+ Type the following to save the current status in Emacs:
40
+ M-x rcovsave
41
+ If you do not use +rcov+ from Rake, you must modify +rcovsave-command-line+ variable.
42
+
43
+ === Finding new uncovered code
44
+
45
+ Type the following to save the current status in Emacs:
46
+ M-x rcovdiff
47
+
48
+ === Viewing cross-reference annotated code
49
+
50
+ If you read cross-reference annotated code, issue
51
+ rake rcov RCOVOPTS='-a'
52
+ at the beginning.
53
+ This command creates +coverage+ directory and many *.rb files in it.
54
+ Filenames of these Ruby scripts are converted from original path.
55
+ You can browse them by normally <tt>C-x C-f</tt>.
56
+ You can think of <tt>-a</tt> option as <tt>--xrefs</tt> option and output format is Ruby script.
57
+
58
+ After find-file-ed annotated script, the major-mode is rcov-xref-mode,
59
+ which is derived from ruby-mode and specializes navigation.
60
+
61
+ <tt>Tab</tt> and <tt>M-Tab</tt> goes forward/backward links.
62
+ <tt>Ret</tt> follows selected link.
63
+
64
+ This feature is useful to read third-party code or to follow control flow.
@@ -0,0 +1,130 @@
1
+ rcov copyright (c) 2004-2006 Mauricio Fernandez <mfp@acm.org>
2
+ rcov includes xx 0.1.0, copyright (c) 2005, ePark Labs, Inc. and contributors
3
+
4
+ rcov README
5
+ ============
6
+
7
+ rcov is a code coverage tool for Ruby. It is commonly used for viewing
8
+ overall test coverage of target code. It features:
9
+ * fast execution: 20-300 times faster than previous tools
10
+ * multiple analysis modes: standard, bogo-profile, "intentional testing",
11
+ dependency analysis...
12
+ * detection of uncovered code introduced since the last run ("differential
13
+ code coverage")
14
+ * fairly accurate coverage information through code linkage inference using
15
+ simple heuristics
16
+ * cross-referenced XHTML and several kinds of text reports
17
+ * support for easy automation with Rake and Rant
18
+ * colorblind-friendliness
19
+
20
+ Requirements
21
+ ------------
22
+
23
+ * Ruby 1.8
24
+ * (recommended) C compiler: you can also use rcov without the rcovrt
25
+ extension but rcov will be two orders of magnitude slower. The extension
26
+ requires Ruby 1.8.3 or later.
27
+ If you're on win32, you can find a pre-built rcovrt extension at
28
+ http://eigenclass.org/hiki.rb?rcov
29
+
30
+
31
+ Normal install
32
+ --------------
33
+
34
+ De-compress the archive and enter its top directory.
35
+ Then type:
36
+
37
+ ($ su)
38
+ # ruby setup.rb
39
+
40
+ This simple step installs rcov under the default location for Ruby
41
+ libraries. You can also customize the installation by supplying some
42
+ options to setup.rb.
43
+ Try "ruby setup.rb --help".
44
+
45
+ A normal (rcovrt-enabled) install requires Ruby >= 1.8.3 and a working C
46
+ toolchain; if you cannot compile Ruby extensions proceed as described below.
47
+
48
+ If you're on win32, you can find a pre-built rcovrt extension at
49
+ http://eigenclass.org/hiki.rb?rcov
50
+
51
+ You might have to install a "development package" (often named ruby-dev or
52
+ ruby1.8-dev), or alternatively build ruby from the sources, if the compiler
53
+ cannot find the headers (ruby.h and friends).
54
+
55
+ Install without the rcovrt extension
56
+ ------------------------------------
57
+
58
+ ($su )
59
+ # ruby setup.rb all --without-ext
60
+
61
+ will install rcov without building the rcovrt extension.
62
+
63
+ Usage
64
+ -----
65
+
66
+ In the common scenario, your tests are under test/ and the target code
67
+ (whose coverage you want) is in lib/. In that case, all you have to do is
68
+ use rcov to run the tests (instead of testrb), and a number of XHTML files
69
+ with the code coverage information will be generated, e.g.
70
+
71
+ rcov -Ilib test/*.rb
72
+
73
+ will execute all the .rb files under test/ and generate the code coverage
74
+ report for the target code (i.e. for the files in lib/) under coverage/. The
75
+ target code needs not be under lib/; rcov will detect is as long as it is
76
+ require()d by the tests. rcov is smart enough to ignore "uninteresting"
77
+ files: the tests themselves, files installed in Ruby's standard locations,
78
+ etc. See rcov --help for the list of regexps rcov matches filenames
79
+ against.
80
+
81
+ rcov can also be used from Rake; see README.rake or the RDoc documentation
82
+ for more information. The Rakefile included in rcov's sources holds a few
83
+ tasks that run rcov on itself, producing a number of reports. You can try
84
+ rake rcov
85
+ preferably after a full install or
86
+ ruby setup.rb config
87
+ ruby setup.rb setup
88
+ so that the rcovrt extension can be used to speed up the process.
89
+ This will generate a cross-referenced XHTML report under coverage/.
90
+
91
+ rcov can output information in several formats, and perform different kinds
92
+ of analyses in addition to plain code coverage. See rcov --help for a
93
+ description of the available options.
94
+
95
+ License
96
+ -------
97
+
98
+ rcov is licensed under the same terms as Ruby. See LICENSE.
99
+ rcov includes a copy of the xx library, which carries the following
100
+ copyright notice:
101
+
102
+ ePark Labs Public License version 1
103
+ Copyright (c) 2005, ePark Labs, Inc. and contributors
104
+ All rights reserved.
105
+
106
+ Redistribution and use in source and binary forms, with or without modification,
107
+ are permitted provided that the following conditions are met:
108
+
109
+ 1. Redistributions of source code must retain the above copyright notice, this
110
+ list of conditions and the following disclaimer.
111
+ 2. Redistributions in binary form must reproduce the above copyright notice,
112
+ this list of conditions and the following disclaimer in the documentation
113
+ and/or other materials provided with the distribution.
114
+ 3. Neither the name of ePark Labs nor the names of its contributors may be
115
+ used to endorse or promote products derived from this software without
116
+ specific prior written permission.
117
+
118
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
119
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
120
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
121
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
122
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
123
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
124
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
125
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
126
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
127
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
128
+
129
+
130
+ Mauricio Fernandez <mfp@acm.org>
@@ -0,0 +1,62 @@
1
+
2
+ == Code coverage analysis automation with Rake
3
+
4
+ Since 0.4.0, <tt>rcov</tt> features a <tt>Rcov::RcovTask</tt> task for rake
5
+ which can be used to automate test coverage analysis. Basic usage is as
6
+ follows:
7
+
8
+ require 'rcov/rcovtask'
9
+ Rcov::RcovTask.new do |t|
10
+ t.test_files = FileList['test/test*.rb']
11
+ # t.verbose = true # uncomment to see the executed command
12
+ end
13
+
14
+ This will create by default a task named <tt>rcov</tt>, and also a task to
15
+ remove the output directory where the XHTML report is generated.
16
+ The latter will be named <tt>clobber_rcob</tt>, and will be added to the main
17
+ <tt>clobber</tt> target.
18
+
19
+ === Passing command line options to <tt>rcov</tt>
20
+
21
+ You can provide a description, change the name of the generated tasks (the
22
+ one used to generate the report(s) and the clobber_ one) and pass options to
23
+ <tt>rcov</tt>:
24
+
25
+ desc "Analyze code coverage of the unit tests."
26
+ Rcov::RcovTask.new(:coverage) do |t|
27
+ t.test_files = FileList['test/test*.rb']
28
+ t.verbose = true
29
+ ## get a text report on stdout when rake is run:
30
+ t.rcov_opts << "--text-report"
31
+ ## only report files under 80% coverage
32
+ t.rcov_opts << "--threshold 80"
33
+ end
34
+
35
+ That will generate a <tt>coverage</tt> task and the associated
36
+ <tt>clobber_coverage</tt> task to remove the directory the report is dumped
37
+ to ("<tt>coverage</tt>" by default).
38
+
39
+ You can specify a different destination directory, which comes handy if you
40
+ have several <tt>RcovTask</tt>s; the <tt>clobber_*</tt> will take care of
41
+ removing that directory:
42
+
43
+ desc "Analyze code coverage for the FileStatistics class."
44
+ Rcov::RcovTask.new(:rcov_sourcefile) do |t|
45
+ t.test_files = FileList['test/test_FileStatistics.rb']
46
+ t.verbose = true
47
+ t.rcov_opts << "--test-unit-only"
48
+ t.output_dir = "coverage.sourcefile"
49
+ end
50
+
51
+ Rcov::RcovTask.new(:rcov_ccanalyzer) do |t|
52
+ t.test_files = FileList['test/test_CodeCoverageAnalyzer.rb']
53
+ t.verbose = true
54
+ t.rcov_opts << "--test-unit-only"
55
+ t.output_dir = "coverage.ccanalyzer"
56
+ end
57
+
58
+ === Options passed through the <tt>rake</tt> command line
59
+
60
+ You can override the options defined in the RcovTask by passing the new
61
+ options at the time you invoke rake.
62
+ The documentation for the Rcov::RcovTask explains how this can be done.
@@ -0,0 +1,68 @@
1
+
2
+ == Code coverage analysis automation with Rant
3
+
4
+ Since 0.5.0, <tt>rcov</tt> features a <tt>Rcov</tt> generator for eant
5
+ which can be used to automate test coverage analysis. Basic usage is as
6
+ follows:
7
+
8
+ require 'rcov/rant'
9
+
10
+ desc "Create a cross-referenced code coverage report."
11
+ gen Rcov do |g|
12
+ g.test_files = sys['test/test*.rb']
13
+ end
14
+
15
+ This will create by default a task named <tt>rcov</tt>.
16
+
17
+ === Passing command line options to <tt>rcov</tt>
18
+
19
+ You can provide a description, change the name of the generated tasks (the
20
+ one used to generate the report(s) and the clobber_ one) and pass options to
21
+ <tt>rcov</tt>:
22
+
23
+ desc "Create cross-referenced code coverage report."
24
+ gen Rcov, :coverage do |g|
25
+ g.test_files = sys['test/test*.rb']
26
+ g.rcov_opts << "--threshold 80" << "--callsites"
27
+ end
28
+
29
+ That will generate a <tt>coverage</tt> task.
30
+
31
+ You can specify a different destination directory, which comes handy if you
32
+ have several rcov tasks:
33
+
34
+ desc "Analyze code coverage for the FileStatistics class."
35
+ gen Rcov, :rcov_sourcefile do |g|
36
+ g.libs << "ext/rcovrt"
37
+ g.test_files = sys['test/test_FileStatistics.rb']
38
+ g.rcov_opts << "--test-unit-only"
39
+ g.output_dir = "coverage.sourcefile"
40
+ end
41
+
42
+ desc "Analyze code coverage for CodeCoverageAnalyzer."
43
+ gen Rcov, :rcov_ccanalyzer do |g|
44
+ g.libs << "ext/rcovrt"
45
+ g.test_files = sys['test/test_CodeCoverageAnalyzer.rb']
46
+ g.rcov_opts << "--test-unit-only"
47
+ g.output_dir = "coverage.ccanalyzer"
48
+ end
49
+
50
+ === Options specified passed to the generator
51
+
52
+ The +Rcov+ generator recognizes the following options:
53
+ +libs+:: directories to be added to the <tt>$LOAD_PATH</tt>
54
+ +rcov_opts+:: array of options to be passed to rcov
55
+ +test_files+:: files to execute
56
+ +test_dirs+:: directories where to look for test files automatically
57
+ +pattern+:: pattern for automatic discovery of unit tests to be executed
58
+ +output_dir+:: directory where to leave the generated reports
59
+
60
+ +test_files+ overrides the combination of +test_dirs+ and +pattern+.
61
+
62
+
63
+ === Options passed through the <tt>rake</tt> command line
64
+
65
+ You can override the options defined in the Rcov tasks by specifying them
66
+ using environment variables at the time rant is executed.
67
+ RCOVPATH=/my/modified/rcov rant rcov # use the specified rcov executable
68
+ RCOVOPTS="--no-callsites -x foo" rant rcov # pass those options to rcov
@@ -0,0 +1,47 @@
1
+
2
+ <tt>rcov.vim</tt> allows you to run unit tests from vim and enter quickfix mode in
3
+ order to jump to uncovered code introduced since the last run.
4
+
5
+ == Installation
6
+ Copy <tt>rcov.vim</tt> to the appropriate "compiler" directory (typically
7
+ <tt>$HOME/.vim/compiler</tt>).
8
+
9
+ == Usage
10
+
11
+ === Setting the reference point
12
+
13
+ +rcov+'s <tt>--text-coverage-diff</tt> mode compares the current coverage status against
14
+ the saved one. It therefore needs that information to be recorded
15
+ before you write new code (typically right after you perform a commit) in
16
+ order to have something to compare against.
17
+
18
+ You can save the current status with the <tt>--save</tt> option.
19
+ If you're running +rcov+ from Rake, you can do something like
20
+ rake rcov_units RCOVOPTS="-T --save --rails"
21
+ in order to take the current status as the reference point.
22
+
23
+ === Finding new uncovered code
24
+
25
+ Type the following in command mode while editing your program:
26
+ :compiler rcov
27
+
28
+ rcov.vim assumes +rcov+ can be invoked with a rake task (see
29
+ README.rake[link:files/README_rake.html] for
30
+ information on how to create it).
31
+
32
+ You can then execute +rcov+ and enter quickfix mode by typing
33
+
34
+ :make <taskname>
35
+
36
+ where taskname is the +rcov+ task you want to use; if you didn't override the
37
+ default name in the Rakefile, just
38
+
39
+ :make rcov
40
+
41
+ will do.
42
+
43
+ vim will then enter quickfix mode, allowing you to jump to the areas that were
44
+ not covered since the last time you saved the coverage data.
45
+
46
+ --------
47
+ # vim: ft=text :
@@ -0,0 +1,86 @@
1
+ # This Rakefile serves as an example of how to use Rcov::RcovTask.
2
+ # Take a look at the RDoc documentation (or README.rake) for further
3
+ # information.
4
+
5
+ $:.unshift "lib" if File.directory? "lib"
6
+ require 'rcov/rcovtask'
7
+ require 'rake/testtask'
8
+ require 'rake/rdoctask'
9
+
10
+ # Use the specified rcov executable instead of the one in $PATH
11
+ # (this way we get a sort of informal functional test).
12
+ # This could also be specified from the command like, e.g.
13
+ # rake rcov RCOVPATH=/path/to/myrcov
14
+ ENV["RCOVPATH"] = "bin/rcov"
15
+
16
+ # The following task is largely equivalent to:
17
+ # Rcov::RcovTask.new
18
+ # (really!)
19
+ desc "Create a cross-referenced code coverage report."
20
+ Rcov::RcovTask.new do |t|
21
+ t.test_files = FileList['test/*_test.rb']
22
+ t.ruby_opts << "-Ilib:ext/rcovrt" # in order to use this rcov
23
+ t.rcov_opts << "--xrefs" # comment to disable cross-references
24
+ t.verbose = true
25
+ end
26
+
27
+ desc "Analyze code coverage for the FileStatistics class."
28
+ Rcov::RcovTask.new(:rcov_sourcefile) do |t|
29
+ t.test_files = FileList['test/file_statistics_test.rb']
30
+ t.verbose = true
31
+ t.rcov_opts << "--test-unit-only"
32
+ t.ruby_opts << "-Ilib:ext/rcovrt" # in order to use this rcov
33
+ t.output_dir = "coverage.sourcefile"
34
+ end
35
+
36
+ Rcov::RcovTask.new(:rcov_ccanalyzer) do |t|
37
+ t.test_files = FileList['test/code_coverage_analyzer_test.rb']
38
+ t.verbose = true
39
+ t.rcov_opts << "--test-unit-only"
40
+ t.ruby_opts << "-Ilib:ext/rcovrt" # in order to use this rcov
41
+ t.output_dir = "coverage.ccanalyzer"
42
+ end
43
+
44
+ desc "Run the unit tests with rcovrt."
45
+ Rake::TestTask.new(:test_rcovrt => ["ext/rcovrt/rcovrt.so"]) do |t|
46
+ t.libs << "ext/rcovrt"
47
+ t.test_files = FileList['test/*_test.rb']
48
+ t.verbose = true
49
+ end
50
+
51
+ file "ext/rcovrt/rcovrt.so" => FileList["ext/rcovrt/*.c"] do
52
+ ruby "setup.rb config"
53
+ ruby "setup.rb setup"
54
+ end
55
+
56
+ desc "Run the unit tests in pure-Ruby mode ."
57
+ Rake::TestTask.new(:test_pure_ruby) do |t|
58
+ t.libs << "ext/rcovrt"
59
+ t.test_files = FileList['test/turn_off_rcovrt.rb', 'test/*_test.rb']
60
+ t.verbose = true
61
+ end
62
+
63
+ desc "Run the unit tests"
64
+ task :test => [:test_rcovrt]
65
+ #, :test_pure_ruby] disabled since 1.8.5 broke them
66
+
67
+ desc "Generate rdoc documentation for the rcov library"
68
+ Rake::RDocTask.new("rdoc") { |rdoc|
69
+ rdoc.rdoc_dir = 'doc'
70
+ rdoc.title = "rcov"
71
+ rdoc.options << "--line-numbers" << "--inline-source"
72
+ rdoc.rdoc_files.include('README.API')
73
+ rdoc.rdoc_files.include('README.rake')
74
+ rdoc.rdoc_files.include('README.rant')
75
+ rdoc.rdoc_files.include('README.vim')
76
+ rdoc.rdoc_files.include('lib/**/*.rb')
77
+ }
78
+
79
+ task :default => :test
80
+
81
+ desc "install by setup.rb"
82
+ task :install do
83
+ sh "sudo ruby setup.rb install"
84
+ end
85
+
86
+ # vim: set sw=2 ft=ruby: