hooligan495-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/README.API +42 -0
- data/README.emacs +64 -0
- data/README.en +130 -0
- data/README.rake +62 -0
- data/README.rant +68 -0
- data/README.vim +47 -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.rb +990 -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/rcov.el +131 -0
- data/rcov.vim +38 -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 +99 -0
data/README.emacs
ADDED
@@ -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.
|
data/README.en
ADDED
@@ -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>
|
data/README.rake
ADDED
@@ -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.
|
data/README.rant
ADDED
@@ -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
|
data/README.vim
ADDED
@@ -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 :
|
data/Rakefile
ADDED
@@ -0,0 +1,193 @@
|
|
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
|
+
require 'rake/gempackagetask'
|
10
|
+
require 'rake/clean'
|
11
|
+
|
12
|
+
# Use the specified rcov executable instead of the one in $PATH
|
13
|
+
# (this way we get a sort of informal functional test).
|
14
|
+
# This could also be specified from the command like, e.g.
|
15
|
+
# rake rcov RCOVPATH=/path/to/myrcov
|
16
|
+
ENV["RCOVPATH"] = "bin/rcov"
|
17
|
+
|
18
|
+
# The following task is largely equivalent to:
|
19
|
+
# Rcov::RcovTask.new
|
20
|
+
# (really!)
|
21
|
+
desc "Create a cross-referenced code coverage report."
|
22
|
+
Rcov::RcovTask.new do |t|
|
23
|
+
t.test_files = FileList['test/*_test.rb']
|
24
|
+
t.ruby_opts << "-Ilib:ext/rcovrt" # in order to use this rcov
|
25
|
+
t.rcov_opts << "--xrefs" # comment to disable cross-references
|
26
|
+
t.verbose = true
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Analyze code coverage for the FileStatistics class."
|
30
|
+
Rcov::RcovTask.new(:rcov_sourcefile) do |t|
|
31
|
+
t.test_files = FileList['test/file_statistics_test.rb']
|
32
|
+
t.verbose = true
|
33
|
+
t.rcov_opts << "--test-unit-only"
|
34
|
+
t.ruby_opts << "-Ilib:ext/rcovrt" # in order to use this rcov
|
35
|
+
t.output_dir = "coverage.sourcefile"
|
36
|
+
end
|
37
|
+
|
38
|
+
Rcov::RcovTask.new(:rcov_ccanalyzer) do |t|
|
39
|
+
t.test_files = FileList['test/code_coverage_analyzer_test.rb']
|
40
|
+
t.verbose = true
|
41
|
+
t.rcov_opts << "--test-unit-only"
|
42
|
+
t.ruby_opts << "-Ilib:ext/rcovrt" # in order to use this rcov
|
43
|
+
t.output_dir = "coverage.ccanalyzer"
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Run the unit tests with rcovrt."
|
47
|
+
if RUBY_PLATFORM == 'java'
|
48
|
+
Rake::TestTask.new(:test_rcovrt => ["lib/rcovrt.jar"]) do |t|
|
49
|
+
t.libs << "lib"
|
50
|
+
t.test_files = FileList['test/*_test.rb']
|
51
|
+
t.verbose = true
|
52
|
+
end
|
53
|
+
else
|
54
|
+
Rake::TestTask.new(:test_rcovrt => ["ext/rcovrt/rcovrt.so"]) do |t|
|
55
|
+
t.libs << "ext/rcovrt"
|
56
|
+
t.test_files = FileList['test/*_test.rb']
|
57
|
+
t.verbose = true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
file "ext/rcovrt/rcovrt.so" => FileList["ext/rcovrt/*.c"] do
|
62
|
+
ruby "setup.rb config"
|
63
|
+
ruby "setup.rb setup"
|
64
|
+
end
|
65
|
+
|
66
|
+
desc "Run the unit tests in pure-Ruby mode ."
|
67
|
+
Rake::TestTask.new(:test_pure_ruby) do |t|
|
68
|
+
t.libs << "ext/rcovrt"
|
69
|
+
t.test_files = FileList['test/turn_off_rcovrt.rb', 'test/*_test.rb']
|
70
|
+
t.verbose = true
|
71
|
+
end
|
72
|
+
|
73
|
+
desc "Run the unit tests"
|
74
|
+
task :test => [:test_rcovrt]
|
75
|
+
#, :test_pure_ruby] disabled since 1.8.5 broke them
|
76
|
+
|
77
|
+
desc "Generate rdoc documentation for the rcov library"
|
78
|
+
Rake::RDocTask.new("rdoc") { |rdoc|
|
79
|
+
rdoc.rdoc_dir = 'doc'
|
80
|
+
rdoc.title = "rcov"
|
81
|
+
rdoc.options << "--line-numbers" << "--inline-source"
|
82
|
+
rdoc.rdoc_files.include('README.API')
|
83
|
+
rdoc.rdoc_files.include('README.rake')
|
84
|
+
rdoc.rdoc_files.include('README.rant')
|
85
|
+
rdoc.rdoc_files.include('README.vim')
|
86
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
87
|
+
}
|
88
|
+
|
89
|
+
task :default => :test
|
90
|
+
|
91
|
+
desc "install by setup.rb"
|
92
|
+
task :install do
|
93
|
+
sh "sudo ruby setup.rb install"
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
PKG_FILES = ["bin/rcov", "lib/rcov.rb", "lib/rcov/lowlevel.rb", "lib/rcov/xx.rb", "lib/rcov/version.rb", "lib/rcov/rant.rb", "lib/rcov/report.rb", "lib/rcov/rcovtask.rb", "ext/rcovrt/extconf.rb", "ext/rcovrt/rcovrt.c", "ext/rcovrt/callsite.c", "LEGAL", "LICENSE", "Rakefile", "Rantfile", "README.rake", "README.rant", "README.emacs", "README.en", "README.vim", "README.API", "THANKS", "test/functional_test.rb", "test/file_statistics_test.rb", "test/assets/sample_03.rb", "test/assets/sample_05-new.rb", "test/code_coverage_analyzer_test.rb", "test/assets/sample_04.rb", "test/assets/sample_02.rb", "test/assets/sample_05-old.rb", "test/assets/sample_01.rb", "test/turn_off_rcovrt.rb", "test/call_site_analyzer_test.rb", "test/assets/sample_05.rb", "rcov.vim", "rcov.el", "setup.rb", "BLURB", "CHANGES"]
|
98
|
+
|
99
|
+
# gem management tasks Use these to build the java code before creating the gem package
|
100
|
+
# this code can also be used to generate the MRI gem. But I left the gemspec file in too.
|
101
|
+
spec = Gem::Specification.new do |s|
|
102
|
+
s.name = %q{rcov}
|
103
|
+
s.version = "0.8.1.3.0"
|
104
|
+
|
105
|
+
s.required_rubygems_version = nil if s.respond_to? :required_rubygems_version=
|
106
|
+
s.authors = ["Mauricio Fernandez"]
|
107
|
+
s.cert_chain = nil
|
108
|
+
s.date = %q{2007-11-21}
|
109
|
+
s.default_executable = %q{rcov}
|
110
|
+
s.description = %q{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...}
|
111
|
+
s.email = %q{mfp@acm.org}
|
112
|
+
s.executables = ["rcov"]
|
113
|
+
s.extensions = ["ext/rcovrt/extconf.rb"]
|
114
|
+
s.platform = Gem::Platform::RUBY
|
115
|
+
s.extra_rdoc_files = ["README.API", "README.rake", "README.rant", "README.vim"]
|
116
|
+
s.files = PKG_FILES
|
117
|
+
s.has_rdoc = true
|
118
|
+
s.homepage = %q{http://eigenclass.org/hiki.rb?rcov}
|
119
|
+
s.rdoc_options = ["--main", "README.API", "--title", "rcov code coverage tool"]
|
120
|
+
s.require_paths = ["lib"]
|
121
|
+
s.required_ruby_version = Gem::Requirement.new("> 0.0.0")
|
122
|
+
s.rubygems_version = %q{1.2.0}
|
123
|
+
s.summary = %q{Code coverage analysis tool for Ruby}
|
124
|
+
s.test_files = ["test/functional_test.rb", "test/file_statistics_test.rb", "test/code_coverage_analyzer_test.rb", "test/call_site_analyzer_test.rb"]
|
125
|
+
|
126
|
+
if s.respond_to? :specification_version then
|
127
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
128
|
+
s.specification_version = 1
|
129
|
+
|
130
|
+
if current_version >= 3 then
|
131
|
+
else
|
132
|
+
end
|
133
|
+
else
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
#tasks added in to support generating the JRuby gem.
|
138
|
+
if RUBY_PLATFORM == 'java'
|
139
|
+
spec.platform = "jruby"
|
140
|
+
spec.extensions = []
|
141
|
+
#add the jruby extension to the file list
|
142
|
+
PKG_FILES << "lib/rcovrt.jar"
|
143
|
+
|
144
|
+
def java_classpath_arg
|
145
|
+
begin
|
146
|
+
require 'java'
|
147
|
+
classpath = java.lang.System.getProperty('java.class.path')
|
148
|
+
rescue LoadError
|
149
|
+
end
|
150
|
+
|
151
|
+
if classpath.empty?
|
152
|
+
classpath = FileList["#{ENV['JRUBY_HOME']}/lib/*.jar"].join(File::PATH_SEPARATOR)
|
153
|
+
end
|
154
|
+
|
155
|
+
classpath ? "-cp #{classpath}" : ""
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
CLEAN.include ["ext/java/classes", "lib/rcovrt.jar", "pkg"]
|
160
|
+
|
161
|
+
def compile_java
|
162
|
+
mkdir_p "ext/java/classes"
|
163
|
+
sh "javac -g -target 1.5 -source 1.5 -d ext/java/classes #{java_classpath_arg} #{FileList['ext/java/src/**/*.java'].join(' ')}"
|
164
|
+
end
|
165
|
+
|
166
|
+
def make_jar
|
167
|
+
require 'fileutils'
|
168
|
+
lib = File.join(File.dirname(__FILE__), 'lib')
|
169
|
+
FileUtils.mkdir(lib) unless File.exists? lib
|
170
|
+
sh "jar cf lib/rcovrt.jar -C ext/java/classes/ ."
|
171
|
+
end
|
172
|
+
|
173
|
+
file 'lib/rcovrt.jar' => FileList["ext/java/src/*.java"] do
|
174
|
+
compile_java
|
175
|
+
make_jar
|
176
|
+
end
|
177
|
+
|
178
|
+
desc "compile the java extension and put it into the lib directory"
|
179
|
+
task :java_compile => ["lib/rcovrt.jar"]
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
Rake::GemPackageTask.new(spec) do |p|
|
184
|
+
p.need_tar = true
|
185
|
+
p.gem_spec = spec
|
186
|
+
end
|
187
|
+
|
188
|
+
#extend the gem task to include the java_compile
|
189
|
+
if RUBY_PLATFORM == 'java'
|
190
|
+
Rake::Task["pkg"].enhance(["java_compile"])
|
191
|
+
end
|
192
|
+
|
193
|
+
# vim: set sw=2 ft=ruby:
|