valo-rcov 0.8.3.4

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.
Files changed (45) hide show
  1. data/BLURB +111 -0
  2. data/LICENSE +53 -0
  3. data/Rakefile +88 -0
  4. data/THANKS +96 -0
  5. data/bin/rcov +500 -0
  6. data/doc/readme_for_api +41 -0
  7. data/doc/readme_for_emacs +64 -0
  8. data/doc/readme_for_rake +62 -0
  9. data/doc/readme_for_vim +47 -0
  10. data/editor-extensions/rcov.el +131 -0
  11. data/editor-extensions/rcov.vim +38 -0
  12. data/ext/rcovrt/1.8/callsite.c +216 -0
  13. data/ext/rcovrt/1.8/rcovrt.c +287 -0
  14. data/ext/rcovrt/1.9/callsite.c +234 -0
  15. data/ext/rcovrt/1.9/rcovrt.c +264 -0
  16. data/ext/rcovrt/extconf.rb +21 -0
  17. data/lib/rcov.rb +1009 -0
  18. data/lib/rcov/formatters.rb +15 -0
  19. data/lib/rcov/formatters/base_formatter.rb +168 -0
  20. data/lib/rcov/formatters/full_text_report.rb +55 -0
  21. data/lib/rcov/formatters/html_coverage.rb +255 -0
  22. data/lib/rcov/formatters/html_erb_template.rb +128 -0
  23. data/lib/rcov/formatters/text_coverage_diff.rb +199 -0
  24. data/lib/rcov/formatters/text_report.rb +36 -0
  25. data/lib/rcov/formatters/text_summary.rb +15 -0
  26. data/lib/rcov/lowlevel.rb +145 -0
  27. data/lib/rcov/rcovtask.rb +156 -0
  28. data/lib/rcov/templates/detail.html.erb +78 -0
  29. data/lib/rcov/templates/index.html.erb +76 -0
  30. data/lib/rcov/templates/screen.css +165 -0
  31. data/lib/rcov/version.rb +10 -0
  32. data/setup.rb +1588 -0
  33. data/test/assets/sample_01.rb +7 -0
  34. data/test/assets/sample_02.rb +5 -0
  35. data/test/assets/sample_03.rb +20 -0
  36. data/test/assets/sample_04.rb +10 -0
  37. data/test/assets/sample_05-new.rb +17 -0
  38. data/test/assets/sample_05-old.rb +13 -0
  39. data/test/assets/sample_05.rb +17 -0
  40. data/test/call_site_analyzer_test.rb +171 -0
  41. data/test/code_coverage_analyzer_test.rb +184 -0
  42. data/test/file_statistics_test.rb +471 -0
  43. data/test/functional_test.rb +89 -0
  44. data/test/turn_off_rcovrt.rb +4 -0
  45. metadata +107 -0
@@ -0,0 +1,156 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Define a task library for performing code coverage analysis of unit tests
4
+ # using rcov.
5
+
6
+ require 'rake'
7
+ require 'rake/tasklib'
8
+
9
+ module Rcov
10
+
11
+ # Create a task that runs a set of tests through rcov, generating code
12
+ # coverage reports.
13
+ #
14
+ # Example:
15
+ #
16
+ # require 'rcov/rcovtask'
17
+ #
18
+ # Rcov::RcovTask.new do |t|
19
+ # t.libs << "test"
20
+ # t.test_files = FileList['test/test*.rb']
21
+ # t.verbose = true
22
+ # end
23
+ #
24
+ # If rake is invoked with a "TEST=filename" command line option,
25
+ # then the list of test files will be overridden to include only the
26
+ # filename specified on the command line. This provides an easy way
27
+ # to run just one test.
28
+ #
29
+ # If rake is invoked with a "RCOVOPTS=options" command line option,
30
+ # then the given options are passed to rcov.
31
+ #
32
+ # If rake is invoked with a "RCOVPATH=path/to/rcov" command line option,
33
+ # then the given rcov executable will be used; otherwise the one in your
34
+ # PATH will be used.
35
+ #
36
+ # Examples:
37
+ #
38
+ # rake rcov # run tests normally
39
+ # rake rcov TEST=just_one_file.rb # run just one test file.
40
+ # rake rcov RCOVOPTS="-p" # run in profile mode
41
+ # rake rcov RCOVOPTS="-T" # generate text report
42
+ #
43
+ class RcovTask < Rake::TaskLib
44
+
45
+ # Name of test task. (default is :rcov)
46
+ attr_accessor :name
47
+
48
+ # List of directories to added to $LOAD_PATH before running the
49
+ # tests. (default is 'lib')
50
+ attr_accessor :libs
51
+
52
+ # True if verbose test output desired. (default is false)
53
+ attr_accessor :verbose
54
+
55
+ # Request that the tests be run with the warning flag set.
56
+ # E.g. warning=true implies "ruby -w" used to run the tests.
57
+ attr_accessor :warning
58
+
59
+ # Glob pattern to match test files. (default is 'test/test*.rb')
60
+ attr_accessor :pattern
61
+
62
+ # Array of commandline options to pass to ruby when running the rcov loader.
63
+ attr_accessor :ruby_opts
64
+
65
+ # Array of commandline options to pass to rcov. An explicit
66
+ # RCOVOPTS=opts on the command line will override this. (default
67
+ # is <tt>["--text-report"]</tt>)
68
+ attr_accessor :rcov_opts
69
+
70
+ # Output directory for the XHTML report.
71
+ attr_accessor :output_dir
72
+
73
+ # Explicitly define the list of test files to be included in a
74
+ # test. +list+ is expected to be an array of file names (a
75
+ # FileList is acceptable). If both +pattern+ and +test_files+ are
76
+ # used, then the list of test files is the union of the two.
77
+ def test_files=(list)
78
+ @test_files = list
79
+ end
80
+
81
+ # Create a testing task.
82
+ def initialize(name=:rcov)
83
+ @name = name
84
+ @libs = ["lib"]
85
+ @pattern = nil
86
+ @test_files = nil
87
+ @verbose = false
88
+ @warning = false
89
+ @rcov_opts = ["--text-report"]
90
+ @ruby_opts = []
91
+ @output_dir = "coverage"
92
+ yield self if block_given?
93
+ @pattern = 'test/test*.rb' if @pattern.nil? && @test_files.nil?
94
+ define
95
+ end
96
+
97
+ # Create the tasks defined by this task lib.
98
+ def define
99
+ lib_path = @libs.join(File::PATH_SEPARATOR)
100
+ actual_name = Hash === name ? name.keys.first : name
101
+ unless Rake.application.last_comment
102
+ desc "Analyze code coverage with tests" +
103
+ (@name==:rcov ? "" : " for #{actual_name}")
104
+ end
105
+ task @name do
106
+ run_code = ''
107
+ RakeFileUtils.verbose(@verbose) do
108
+ run_code =
109
+ case rcov_path
110
+ when nil, ''
111
+ "-S rcov"
112
+ else %!"#{rcov_path}"!
113
+ end
114
+ ruby_opts = @ruby_opts.clone
115
+ ruby_opts.push( "-I#{lib_path}" )
116
+ ruby_opts.push run_code
117
+ ruby_opts.push( "-w" ) if @warning
118
+ ruby ruby_opts.join(" ") + " " + option_list +
119
+ %[ -o "#{@output_dir}" ] +
120
+ file_list.collect { |fn| %["#{fn}"] }.join(' ')
121
+ end
122
+ end
123
+
124
+ desc "Remove rcov products for #{actual_name}"
125
+ task paste("clobber_", actual_name) do
126
+ rm_r @output_dir rescue nil
127
+ end
128
+
129
+ clobber_task = paste("clobber_", actual_name)
130
+ task :clobber => [clobber_task]
131
+
132
+ task actual_name => clobber_task
133
+ self
134
+ end
135
+
136
+ def rcov_path # :nodoc:
137
+ ENV['RCOVPATH']
138
+ end
139
+
140
+ def option_list # :nodoc:
141
+ ENV['RCOVOPTS'] || @rcov_opts.join(" ") || ""
142
+ end
143
+
144
+ def file_list # :nodoc:
145
+ if ENV['TEST']
146
+ FileList[ ENV['TEST'] ]
147
+ else
148
+ result = []
149
+ result += @test_files.to_a if @test_files
150
+ result += FileList[ @pattern ].to_a if @pattern
151
+ FileList[result]
152
+ end
153
+ end
154
+ end
155
+ end
156
+
@@ -0,0 +1,78 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
3
+ <head>
4
+ <title><%= title %></title>
5
+ <link href="screen.css" media="screen" rel="stylesheet" type="text/css" />
6
+ <script type="text/javascript" src="rcov.js"></script>
7
+ </head>
8
+ <body>
9
+ <h3><%= title %></h3>
10
+ <p>Generated on <%= generated_on %> with <a href="<%= rcov::UPSTREAM_URL %>">rcov <%= rcov::VERSION %></a></p>
11
+ <% if output_threshold != 101 %>
12
+ <!-- Note: 101 is the default threshold if you don't enter one -->
13
+ <p>Threshold: <%= output_threshold %>%</p>
14
+ <% end %>
15
+ <hr />
16
+ <pre>
17
+ <span class='marked'>Code reported as executed by Ruby looks like this...</span><span class='marked1'>and this: this line is also marked as covered.</span><span class='inferred'>Lines considered as run by rcov, but not reported by Ruby, look like this,</span><span class='inferred1'>and this: these lines were inferred by rcov (using simple heuristics).</span><span class='uncovered'>Finally, here&apos;s a line marked as not executed.</span>
18
+ </pre>
19
+ <table class='report'>
20
+ <thead>
21
+ <tr>
22
+ <td class='heading'>Name</td>
23
+ <td class='heading'>Total lines</td>
24
+ <td class='heading'>Lines of code</td>
25
+ <td class='heading'>Total coverage</td>
26
+ <td class='heading'>Code coverage</td>
27
+ </tr>
28
+ </thead>
29
+ <tbody>
30
+ <!-- alternate light/dark here -->
31
+ <tr class='light'>
32
+ <td><%= fileinfo.name %></td>
33
+ <td class='lines_total'><tt><%= fileinfo.num_lines %></tt></td>
34
+ <td class='lines_code'><tt><%= fileinfo.num_code_lines %></tt></td>
35
+ <td>
36
+ <table cellspacing='0' cellpadding='0' align='right'>
37
+ <tr>
38
+ <td><tt class='coverage_total'><%= "%3.2f" % fileinfo.total_coverage_for_report %>%</tt>&nbsp;</td>
39
+ <td>
40
+ <table cellspacing='0' class='percent_graph' cellpadding='0' width='100'>
41
+ <tr>
42
+ <td class='covered' width='<%= fileinfo.total_coverage_for_report.round %>'></td>
43
+ <td class='uncovered' width='<%= 100 - fileinfo.total_coverage_for_report.round %>'></td>
44
+ </tr>
45
+ </table>
46
+ </td>
47
+ </tr>
48
+ </table>
49
+ </td>
50
+ <td>
51
+ <table cellspacing='0' cellpadding='0' align='right'>
52
+ <tr>
53
+ <td><tt class='coverage_code'><%= "%3.2f" % fileinfo.code_coverage_for_report %>%</tt>&nbsp;</td>
54
+ <td>
55
+ <table cellspacing='0' class='percent_graph' cellpadding='0' width='100'>
56
+ <tr>
57
+ <td class='covered' width='<%= fileinfo.code_coverage_for_report.round %>'/>
58
+ <td class='uncovered' width='<%= 100 - fileinfo.code_coverage_for_report.round %>'/>
59
+ </tr>
60
+ </table>
61
+ </td>
62
+ </tr>
63
+ </table>
64
+ </td>
65
+ </tr>
66
+ <% fileinfo.num_lines.times do |i| %>
67
+ <% line = fileinfo.lines[i].chomp %>
68
+ <% count = fileinfo.counts[i] %>
69
+ <tr class="<%= line_css(i) %>">
70
+ <td colspan="5"><pre><a name="line<%= i.next %>"></a><%= i.next %> <%= line %></pre></td>
71
+ </tr>
72
+ <% end %>
73
+ </tbody>
74
+ </table>
75
+ <hr/>
76
+ <p>Generated on <%= generated_on %> with <a href="<%= rcov::UPSTREAM_URL %>">rcov <%= rcov::VERSION %></a></p>
77
+ </body>
78
+ </html>
@@ -0,0 +1,76 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
3
+ <head>
4
+ <title><%= title %></title>
5
+ <link href="screen.css" media="screen" rel="stylesheet" type="text/css" />
6
+ <script type="text/javascript" src="rcov.js"></script>
7
+ </head>
8
+ <body>
9
+ <h3><%= title %></h3>
10
+ <p>Generated on <%= generated_on %> with <a href="<%= rcov::UPSTREAM_URL %>">rcov <%= rcov::VERSION %></a></p>
11
+ <% if output_threshold != 101 %>
12
+ <!-- Note: 101 is the default threshold if you don't enter one -->
13
+ <p>Threshold: <%= output_threshold %>%</p>
14
+ <% end %>
15
+ <hr />
16
+ <table class='report'>
17
+ <thead>
18
+ <tr>
19
+ <td class='heading'>Name</td>
20
+ <td class='heading'>Total lines</td>
21
+ <td class='heading'>Lines of code</td>
22
+ <td class='heading'>Total coverage</td>
23
+ <td class='heading'>Code coverage</td>
24
+ </tr>
25
+ </thead>
26
+ <tbody>
27
+ <% files.each do |f| %>
28
+ <!-- alternate light/dark here -->
29
+ <tr class='light'>
30
+ <td>
31
+ <% if f.name == 'TOTAL' %>
32
+ <%= f.name %>
33
+ <% else %>
34
+ <a href="<%= relative_filename(f.name) %>"><%= f.name %></a>
35
+ <% end %>
36
+ </td>
37
+ <td class='lines_total'><tt><%= f.num_lines %></tt></td>
38
+ <td class='lines_code'><tt><%= f.num_code_lines %></tt></td>
39
+ <td>
40
+ <table cellspacing='0' cellpadding='0' align='right'>
41
+ <tr>
42
+ <td><tt class='coverage_total'><%= "%3.2f" % f.total_coverage_for_report %>%</tt>&nbsp;</td>
43
+ <td>
44
+ <table cellspacing='0' class='percent_graph' cellpadding='0' width='100'>
45
+ <tr>
46
+ <td class='covered' width='<%= f.total_coverage_for_report.round %>'></td>
47
+ <td class='uncovered' width='<%= 100 - f.total_coverage_for_report.round %>'></td>
48
+ </tr>
49
+ </table>
50
+ </td>
51
+ </tr>
52
+ </table>
53
+ </td>
54
+ <td>
55
+ <table cellspacing='0' cellpadding='0' align='right'>
56
+ <tr>
57
+ <td><tt class='coverage_code'><%= "%3.2f" % f.code_coverage_for_report %>%</tt>&nbsp;</td>
58
+ <td>
59
+ <table cellspacing='0' class='percent_graph' cellpadding='0' width='100'>
60
+ <tr>
61
+ <td class='covered' width='<%= f.code_coverage_for_report.round %>'/>
62
+ <td class='uncovered' width='<%= 100 - f.code_coverage_for_report.round %>'/>
63
+ </tr>
64
+ </table>
65
+ </td>
66
+ </tr>
67
+ </table>
68
+ </td>
69
+ </tr>
70
+ <% end %>
71
+ </tbody>
72
+ </table>
73
+ <hr/>
74
+ <p>Generated on <%= generated_on %> with <a href="<%= rcov::UPSTREAM_URL %>">rcov <%= rcov::VERSION %></a></p>
75
+ </body>
76
+ </html>
@@ -0,0 +1,165 @@
1
+ body {
2
+ font: 62.5%/1.4em Helvetica, Arial, Sans-Serif;
3
+ color: #4C4C4C;
4
+ background-color: #F4F2ED;
5
+ padding: 1em;
6
+ margin: 8px 0 0 0;
7
+ }
8
+
9
+ a {
10
+ color:#191919;
11
+ font-weight:bold;
12
+ outline: none;
13
+ }
14
+
15
+ span.cross-ref-title {
16
+ font-size: 140%;
17
+ }
18
+ span.cross-ref a {
19
+ text-decoration: none;
20
+ }
21
+ span.cross-ref {
22
+ background-color:#f3f7fa;
23
+ border: 1px dashed #333;
24
+ margin: 1em;
25
+ padding: 0.5em;
26
+ overflow: hidden;
27
+ }
28
+
29
+ a.crossref-toggle {
30
+ text-decoration: none;
31
+ }
32
+ pre, code {
33
+ color: #000000;
34
+ font-family: "Bitstream Vera Sans Mono","Monaco","Courier New",monospace;
35
+ font-size: 95%;
36
+ line-height: 1.3em;
37
+ margin-top: 0;
38
+ margin-bottom: 0;
39
+ padding: 0;
40
+ word-wrap: break-word;
41
+ }
42
+
43
+ tr.marked td, span.marked, span.marked1 {
44
+ background-color: #DBDEBD;
45
+ }
46
+
47
+ span.marked, span.marked1 {
48
+ display: block;
49
+ }
50
+
51
+ tr.inferred td, span.inferred {
52
+ background-color: #CFE6E0;
53
+ }
54
+
55
+ tr.inferred1 td, span.inferred1 {
56
+ background-color: #CFE6E0;
57
+ }
58
+ span.inferred, span.inferred1 {
59
+ display: block;
60
+ }
61
+
62
+ tr.uncovered td, span.uncovered {
63
+ background-color: rgb(225, 110, 110);
64
+ }
65
+
66
+ span.uncovered1 {
67
+ background-color: rgb(235, 120, 120);
68
+ display: block;
69
+ }
70
+
71
+ span.overview {
72
+ border-bottom: 8px solid black;
73
+ }
74
+
75
+ div.overview {
76
+ border-bottom: 8px solid black;
77
+ }
78
+
79
+ div.footer {
80
+ font-size: 68%;
81
+ margin-top: 1.5em;
82
+ }
83
+
84
+ h1, h2, h3, h4, h5, h6 {
85
+ margin-bottom: 0.5em;
86
+ }
87
+
88
+ h3 {
89
+ display: block;
90
+ margin: 0 0 20px 0;
91
+ padding-bottom: 20px;
92
+ font-size: 2.0em;
93
+ letter-spacing: -1px;
94
+ color: #333333;
95
+ }
96
+
97
+ h5 {
98
+ margin-top: 0.5em;
99
+ }
100
+
101
+ .hidden {
102
+ display: none;
103
+ }
104
+
105
+ div.separator {
106
+ height: 10px;
107
+ }
108
+
109
+ table.percent_graph {
110
+ height: 12px;
111
+ border: #808080 1px solid;
112
+ empty-cells: show;
113
+ }
114
+
115
+ table.percent_graph td.covered {
116
+ height: 10px;
117
+ background: #00f000;
118
+ }
119
+
120
+ table.percent_graph td.uncovered {
121
+ height: 10px;
122
+ background: #e00000;
123
+ }
124
+
125
+ table.percent_graph td.NA {
126
+ height: 10px;
127
+ background: #eaeaea;
128
+ }
129
+
130
+ table.report {
131
+ border-collapse: collapse;
132
+ width: 100%;
133
+ }
134
+
135
+ table.report td.heading {
136
+ background: #dcecff;
137
+ border: #d0d0d0 1px solid;
138
+ font-weight: bold;
139
+ text-align: center;
140
+ }
141
+
142
+ table.report td.heading:hover {
143
+ background: #c0ffc0;
144
+ }
145
+
146
+ table.report td.text {
147
+ border: #d0d0d0 1px solid;
148
+ }
149
+
150
+ table.report td {
151
+ font-size: 125%;
152
+ }
153
+
154
+ table.report td.value,
155
+ table.report td.lines_total,
156
+ table.report td.lines_code {
157
+ text-align: right;
158
+ border: #d0d0d0 1px solid;
159
+ }
160
+ table.report tr.light {
161
+ background-color: rgb(240, 240, 245);
162
+ }
163
+ table.report tr.dark {
164
+ background-color: rgb(230, 230, 235);
165
+ }