relevance-rcov 0.8.3.9 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +0 -3
- data/doc/readme_for_api.markdown +22 -0
- data/doc/readme_for_emacs.markdown +52 -0
- data/doc/readme_for_rake.markdown +51 -0
- data/doc/readme_for_vim.markdown +34 -0
- data/lib/rcov/version.rb +1 -1
- metadata +7 -12
- data/doc/readme_for_api +0 -41
- data/doc/readme_for_emacs +0 -64
- data/doc/readme_for_rake +0 -62
- data/doc/readme_for_vim +0 -47
data/Rakefile
CHANGED
@@ -81,8 +81,5 @@ Rake::RDocTask.new("rdoc") { |rdoc|
|
|
81
81
|
rdoc.rdoc_dir = 'doc'
|
82
82
|
rdoc.title = "rcov"
|
83
83
|
rdoc.options << "--line-numbers" << "--inline-source"
|
84
|
-
rdoc.rdoc_files.include('doc/readme_for_api')
|
85
|
-
rdoc.rdoc_files.include('doc/readme_for_rake')
|
86
|
-
rdoc.rdoc_files.include('doc/readme_for_vim')
|
87
84
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
88
85
|
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# RCov
|
2
|
+
|
3
|
+
RCov is a:
|
4
|
+
|
5
|
+
1. tool for code coverage analysis for Ruby
|
6
|
+
2. library for collecting code coverage and execution count information introspectively
|
7
|
+
|
8
|
+
If you want to use the command line tool, the output from `rcov -h` is self explanatory. If you want to automate the execution of RCov via Rake take a look at [readme for rake]("http://github.com/relevance/rcov/blob/master/doc/readme_for_rake.markdown"). If you want to use the associated library, read on.
|
9
|
+
|
10
|
+
## Usage of the RCov runtime/library
|
11
|
+
|
12
|
+
RCov is primarily a tool for code coverage analysis, but since 0.4.0 it exposes some of its code so that you can build on top of its heuristics for code analysis and its capabilities for coverage information and execution count gathering. The main classes of interest are `Rcov::FileStatistics`, `Rcov::CodeCoverageAnalyzer` and `Rcov::CallSiteAnalyzer`.
|
13
|
+
|
14
|
+
* `Rcov::FileStatistics` can use some heuristics to determine which parts of the file are executable and which are mere comments.
|
15
|
+
|
16
|
+
* `Rcov::CodeCoverageAnalyzer` is used to gather code coverage and execution count information inside a running Ruby program.
|
17
|
+
|
18
|
+
* `Rcov::CallSiteAnalyzer` is used to obtain information about where methods are defined and who calls them.
|
19
|
+
|
20
|
+
The parts of RCov's runtime meant to be reused (i.e. the external API) are documented with RDoc. Those not meant to be used are clearly marked as so or were deliberately removed from the present documentation.
|
21
|
+
|
22
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# rcov.el
|
2
|
+
|
3
|
+
`rcov.el` allows you to use rcov from Emacs conveniently.
|
4
|
+
|
5
|
+
* Run unit tests and jump to uncovered code by <code>C-x `</code>
|
6
|
+
* Run unit tests and save the current coverage status.
|
7
|
+
* Run unit tests and jump to uncovered code introduced since the last run.
|
8
|
+
* View cross-reference annotated code.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Copy <tt>rcov.el</tt> to the appropriate directory, which is in load-path then require it.
|
13
|
+
|
14
|
+
`(require 'rcov)`
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
There are some commands to run RCov in Emacs. All of them will display RCov window, whose `major-mode` is `compilation-mode`. This allow you to jump to uncovered code using C-x `. rcov-command-line, rcovsave-command-line, and rcovdiff-command-line define command line to run rcov. If you do not use RCov from Rake, you must modify them.
|
19
|
+
|
20
|
+
### Finding uncovered code
|
21
|
+
|
22
|
+
Type the following while editing your program:
|
23
|
+
|
24
|
+
`M-x rcov`
|
25
|
+
|
26
|
+
### Setting the reference point
|
27
|
+
|
28
|
+
RCov's `--text-coverage-diff` mode compares the current coverage status against the saved one. It therefore needs that information to be recorded before you write new code (typically right after you perform a commit) in order to have something to compare against. You can save the current status with the `--save` option. Type the following to save the current status in Emacs:
|
29
|
+
|
30
|
+
`M-x rcovsave`
|
31
|
+
|
32
|
+
If you do not use RCov from Rake, you must modify `rcovsave-command-line` variable.
|
33
|
+
|
34
|
+
### Finding new uncovered code
|
35
|
+
|
36
|
+
Type the following to save the current status in Emacs:
|
37
|
+
|
38
|
+
`M-x rcovdiff`
|
39
|
+
|
40
|
+
### Viewing cross-reference annotated code
|
41
|
+
|
42
|
+
If you read cross-reference annotated code, issue
|
43
|
+
|
44
|
+
`rake rcov RCOVOPTS='-a'`
|
45
|
+
|
46
|
+
at the beginning. This command creates a `coverage` directory and many `*.rb` files in it. Filenames of these Ruby scripts are converted from original path. You can browse them by normally `C-x C-f`. You can think of `-a` option as `--xrefs` option and output format is Ruby script. After `find-file-ed` annotated script, the `major-mode` is `rcov-xref-mode`,
|
47
|
+
which is derived from `ruby-mode` and specializes navigation.
|
48
|
+
|
49
|
+
* `Tab` and `M-Tab` goes forward/backward links.
|
50
|
+
* `Ret` follows selected link.
|
51
|
+
|
52
|
+
This feature is useful to read third-party code or to follow control flow.
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Code coverage analysis automation with Rake
|
2
|
+
|
3
|
+
Since 0.4.0, RCov features a `Rcov::RcovTask` task for rake
|
4
|
+
which can be used to automate test coverage analysis. Basic usage is as
|
5
|
+
follows:
|
6
|
+
<pre><code>
|
7
|
+
require 'rcov/rcovtask'
|
8
|
+
Rcov::RcovTask.new do |t|
|
9
|
+
t.test_files = FileList['test/test*.rb']
|
10
|
+
# t.verbose = true # uncomment to see the executed command
|
11
|
+
end
|
12
|
+
</pre></code>
|
13
|
+
|
14
|
+
This will create by default a task named `rcov`, and also a task to remove the output directory where the XHTML report is generated. The latter will be named `clobber_rcov`, and will be added to the main `clobber` target.
|
15
|
+
|
16
|
+
## Passing command line options to RCov
|
17
|
+
|
18
|
+
You can provide a description, change the name of the generated tasks (the one used to generate the report(s) and the `clobber_` one) and pass options to RCov:
|
19
|
+
<pre><code>
|
20
|
+
desc "Analyze code coverage of the unit tests."
|
21
|
+
Rcov::RcovTask.new(:coverage) do |t|
|
22
|
+
t.test_files = FileList['test/test*.rb']
|
23
|
+
t.verbose = true
|
24
|
+
## get a text report on stdout when rake is run:
|
25
|
+
t.rcov_opts << "--text-report"
|
26
|
+
## only report files under 80% coverage
|
27
|
+
t.rcov_opts << "--threshold 80"
|
28
|
+
end
|
29
|
+
</pre></code>
|
30
|
+
|
31
|
+
This will generate a `coverage` task and the associated `clobber_coverage` task to remove the directory the report is dumped to (`coverage` by default). You can specify a different destination directory, which comes handy if you have several `RcovTask`s; the `clobber_*` will take care of removing that directory:
|
32
|
+
<pre><code>
|
33
|
+
desc "Analyze code coverage for the FileStatistics class."
|
34
|
+
Rcov::RcovTask.new(:rcov_sourcefile) do |t|
|
35
|
+
t.test_files = FileList['test/test_FileStatistics.rb']
|
36
|
+
t.verbose = true
|
37
|
+
t.rcov_opts << "--test-unit-only"
|
38
|
+
t.output_dir = "coverage.sourcefile"
|
39
|
+
end
|
40
|
+
|
41
|
+
Rcov::RcovTask.new(:rcov_ccanalyzer) do |t|
|
42
|
+
t.test_files = FileList['test/test_CodeCoverageAnalyzer.rb']
|
43
|
+
t.verbose = true
|
44
|
+
t.rcov_opts << "--test-unit-only"
|
45
|
+
t.output_dir = "coverage.ccanalyzer"
|
46
|
+
end
|
47
|
+
</pre></code>
|
48
|
+
|
49
|
+
## Options passed through the `rake` command line
|
50
|
+
|
51
|
+
You can override the options defined in the RcovTask by passing the new options at the time you invoke rake. The documentation for the `Rcov::RcovTask` explains how this can be done.
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# rcov.vim
|
2
|
+
|
3
|
+
`rcov.vim` allows you to run unit tests from vim and enter quickfix mode in order to jump to uncovered code introduced since the last run.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
Copy `rcov.vim` to the appropriate `compiler` directory (typically `$HOME/.vim/compiler`).
|
7
|
+
|
8
|
+
### Usage
|
9
|
+
|
10
|
+
#### Setting the reference point
|
11
|
+
|
12
|
+
RCov's `--text-coverage-diff` mode compares the current coverage status against the saved one. It therefore needs that information to be recorded before you write new code (typically right after you perform a commit) in order to have something to compare against. You can save the current status with the `--save` option. If you're running RCov from Rake, you can do something like
|
13
|
+
|
14
|
+
`rake rcov_units RCOVOPTS="-T --save --rails"`
|
15
|
+
|
16
|
+
in order to take the current status as the reference point.
|
17
|
+
|
18
|
+
#### Finding new uncovered code
|
19
|
+
|
20
|
+
Type the following in command mode while editing your program:
|
21
|
+
|
22
|
+
`:compiler rcov`
|
23
|
+
|
24
|
+
`rcov.vim` assumes RCov can be invoked with a rake task (see [readme for rake]("http://github.com/relevance/rcov/blob/master/doc/readme_for_rake.markdown") for information on how to create it).
|
25
|
+
|
26
|
+
You can then execute +rcov+ and enter quickfix mode by typing
|
27
|
+
|
28
|
+
`:make <taskname>`
|
29
|
+
|
30
|
+
where taskname is the +rcov+ task you want to use; if you didn't override the default name in the Rakefile, just
|
31
|
+
|
32
|
+
`:make rcov`
|
33
|
+
|
34
|
+
will do. Vim will then enter quickfix mode, allowing you to jump to the areas that were not covered since the last time you saved the coverage data.
|
data/lib/rcov/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relevance-rcov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Relevance
|
@@ -21,11 +21,8 @@ executables:
|
|
21
21
|
- rcov
|
22
22
|
extensions:
|
23
23
|
- ext/rcovrt/extconf.rb
|
24
|
-
extra_rdoc_files:
|
25
|
-
|
26
|
-
- doc/readme_for_rake
|
27
|
-
- doc/readme_for_vim
|
28
|
-
- doc/readme_for_emacs
|
24
|
+
extra_rdoc_files: []
|
25
|
+
|
29
26
|
files:
|
30
27
|
- bin/rcov
|
31
28
|
- lib/rcov.rb
|
@@ -50,10 +47,10 @@ files:
|
|
50
47
|
- ext/rcovrt/1.9/callsite.c
|
51
48
|
- LICENSE
|
52
49
|
- Rakefile
|
53
|
-
- doc/readme_for_rake
|
54
|
-
- doc/readme_for_vim
|
55
|
-
- doc/readme_for_emacs
|
56
|
-
- doc/readme_for_api
|
50
|
+
- doc/readme_for_rake.markdown
|
51
|
+
- doc/readme_for_vim.markdown
|
52
|
+
- doc/readme_for_emacs.markdown
|
53
|
+
- doc/readme_for_api.markdown
|
57
54
|
- THANKS
|
58
55
|
- test/functional_test.rb
|
59
56
|
- test/file_statistics_test.rb
|
@@ -76,8 +73,6 @@ homepage: http://github.com/relevance/rcov
|
|
76
73
|
licenses:
|
77
74
|
post_install_message:
|
78
75
|
rdoc_options:
|
79
|
-
- --main
|
80
|
-
- doc/readme_for_api
|
81
76
|
- --title
|
82
77
|
- rcov code coverage tool
|
83
78
|
require_paths:
|
data/doc/readme_for_api
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
|
2
|
-
= +rcov+
|
3
|
-
|
4
|
-
+rcov+ is a:
|
5
|
-
1. tool for code coverage analysis for Ruby
|
6
|
-
2. library for collecting code coverage and execution count information
|
7
|
-
introspectively
|
8
|
-
|
9
|
-
If you want to use the command line tool, the output from
|
10
|
-
rcov -h
|
11
|
-
is self-explicative.
|
12
|
-
|
13
|
-
If you want to automate the execution of +rcov+ via Rake take a look at
|
14
|
-
readme_for_rake[link:files/README_rake.html].
|
15
|
-
|
16
|
-
If you want to use the associated library, read on.
|
17
|
-
|
18
|
-
== Usage of the +rcov+ runtime/library
|
19
|
-
|
20
|
-
+rcov+ is primarily a tool for code coverage analysis, but since 0.4.0 it
|
21
|
-
exposes some of its code so that you can build on top of its heuristics for
|
22
|
-
code analysis and its capabilities for coverage information and execution
|
23
|
-
count gathering.
|
24
|
-
|
25
|
-
The main classes of interest are Rcov::FileStatistics,
|
26
|
-
Rcov::CodeCoverageAnalyzer and Rcov::CallSiteAnalyzer.
|
27
|
-
|
28
|
-
Rcov::FileStatistics can use some heuristics to determine
|
29
|
-
which parts of the file are executable and which are mere comments.
|
30
|
-
|
31
|
-
Rcov::CodeCoverageAnalyzer is used to gather code coverage and execution
|
32
|
-
count information inside a running Ruby program.
|
33
|
-
|
34
|
-
Rcov::CallSiteAnalyzer is used to obtain information about where methods are
|
35
|
-
defined and who calls them.
|
36
|
-
|
37
|
-
The parts of +rcov+'s runtime meant to be reused (i.e. the external API) are
|
38
|
-
documented with RDoc. Those not meant to be used are clearly marked as so or
|
39
|
-
were deliberately removed from the present documentation.
|
40
|
-
|
41
|
-
|
data/doc/readme_for_emacs
DELETED
@@ -1,64 +0,0 @@
|
|
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.
|
data/doc/readme_for_rake
DELETED
@@ -1,62 +0,0 @@
|
|
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.
|
data/doc/readme_for_vim
DELETED
@@ -1,47 +0,0 @@
|
|
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_for_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 :
|