jcov 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +5 -0
- data/LICENSE +19 -0
- data/README.rdoc +109 -0
- data/Rakefile +2 -0
- data/bin/jcov +36 -0
- data/examples/jasmine/.gitignore +1 -0
- data/examples/jasmine/jasmine/ConsoleReporter.js +177 -0
- data/examples/jasmine/jasmine/MIT.LICENSE.txt +20 -0
- data/examples/jasmine/jasmine/jasmine.js +2476 -0
- data/examples/jasmine/jasmine/runner.js +28 -0
- data/examples/jasmine/javascripts/mean.js +11 -0
- data/examples/jasmine/jcov.yml +8 -0
- data/examples/jasmine/tests/mean_spec.js +15 -0
- data/examples/jspec/.gitignore +1 -0
- data/examples/jspec/javascripts/mean.js +11 -0
- data/examples/jspec/jcov.yml +8 -0
- data/examples/jspec/jspec/ext/slowness.js +43 -0
- data/examples/jspec/jspec/ext/trace.js +28 -0
- data/examples/jspec/jspec/lib/MIT.LICENSE.txt +7 -0
- data/examples/jspec/jspec/lib/jspec.js +1925 -0
- data/examples/jspec/jspec/runner.js +66 -0
- data/examples/jspec/tests/mean_spec.js +15 -0
- data/features/configuration.feature +134 -0
- data/features/coverage.feature +246 -0
- data/features/html_report.feature +130 -0
- data/features/javascript_interface.feature +72 -0
- data/features/reporting.feature +108 -0
- data/features/run.feature +217 -0
- data/features/step_definitions/report_steps.rb +54 -0
- data/features/support/env.rb +29 -0
- data/jcov.gemspec +29 -0
- data/lib/jcov.rb +11 -0
- data/lib/jcov/commands.rb +47 -0
- data/lib/jcov/configuration.rb +54 -0
- data/lib/jcov/coverage.rb +151 -0
- data/lib/jcov/reporter.rb +2 -0
- data/lib/jcov/reporter/console_reporter.rb +107 -0
- data/lib/jcov/reporter/file.html.erb +26 -0
- data/lib/jcov/reporter/html_reporter.rb +64 -0
- data/lib/jcov/reporter/report.css +53 -0
- data/lib/jcov/reporter/report.html.erb +45 -0
- data/lib/jcov/runner.rb +100 -0
- data/lib/jcov/version.rb +3 -0
- metadata +195 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<% path = filename.split(/[^\/]*/).join('..') %>
|
3
|
+
<html lang='en'>
|
4
|
+
<head>
|
5
|
+
<meta charset='utf-8'>
|
6
|
+
<title>JCov: <%= filename %></title>
|
7
|
+
</meta>
|
8
|
+
<link href="<%= path %>report.css" media="screen" rel="stylesheet" type="text/css" />
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<% percent = (total_line_count > 0) ? 100 * covered_line_count / total_line_count : 100 %>
|
12
|
+
<h1><a href="<%= path %>report.html">JCov</a> : <%= filename %> : <span class="percent"><%= sprintf "%3s%", percent %></span></h1>
|
13
|
+
<table class="source">
|
14
|
+
<%
|
15
|
+
line_number = 0
|
16
|
+
content.each_line do |line|
|
17
|
+
line_number += 1
|
18
|
+
%>
|
19
|
+
<tr class="line <%= line_number % 2 == 0 ? 'even' : 'odd'%>" data-coverage="<%= coverage[line_number] || 'uncoverable' %>">
|
20
|
+
<td class="line-number"><%= line_number %></td>
|
21
|
+
<td class="code"><pre><%= CGI.escapeHTML(line) %><pre></td>
|
22
|
+
</tr>
|
23
|
+
<% end %>
|
24
|
+
</table>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'json'
|
4
|
+
require 'cgi'
|
5
|
+
|
6
|
+
module JCov::Reporter
|
7
|
+
|
8
|
+
class HTMLReporter
|
9
|
+
|
10
|
+
def initialize coverage_runner
|
11
|
+
@coverage_runner = coverage_runner
|
12
|
+
|
13
|
+
@report_index_template = File.read File.expand_path('../report.html.erb', __FILE__)
|
14
|
+
@report_file_template = File.read File.expand_path('../file.html.erb', __FILE__)
|
15
|
+
end
|
16
|
+
|
17
|
+
def report
|
18
|
+
make_output_dir
|
19
|
+
render_index
|
20
|
+
render_files
|
21
|
+
copy_css
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def make_output_dir
|
27
|
+
FileUtils.mkdir_p output_dir
|
28
|
+
end
|
29
|
+
|
30
|
+
def render_index
|
31
|
+
erb = ERB.new(@report_index_template)
|
32
|
+
out = erb.result(@coverage_runner.get_binding)
|
33
|
+
|
34
|
+
filename = File.join(output_dir, "report.html")
|
35
|
+
File.open(filename, "w") { |io| io.write out }
|
36
|
+
end
|
37
|
+
|
38
|
+
def render_files
|
39
|
+
@coverage_runner.reduced_coverage_data.each do |filename, total_line_count, covered_line_count|
|
40
|
+
|
41
|
+
content = File.read(filename)
|
42
|
+
coverage = @coverage_runner.coverage_data[filename]
|
43
|
+
|
44
|
+
erb = ERB.new(@report_file_template)
|
45
|
+
out = erb.result(binding)
|
46
|
+
|
47
|
+
FileUtils.mkdir_p File.join(output_dir, File.dirname(filename))
|
48
|
+
|
49
|
+
filename = File.join(output_dir, filename) << ".html"
|
50
|
+
File.open(filename, "w") { |io| io.write out }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def copy_css
|
55
|
+
FileUtils.cp File.expand_path('../report.css', __FILE__), output_dir
|
56
|
+
end
|
57
|
+
|
58
|
+
def output_dir
|
59
|
+
@coverage_runner.config.report_output_directory
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
body {
|
2
|
+
background-color: #DDD;
|
3
|
+
font-family: 'Lucida Grande', Helvetica, 'Helvetica Neue', Arial, sans-serif;
|
4
|
+
font-size: 13px;
|
5
|
+
font-style: normal;
|
6
|
+
font-weight: normal;
|
7
|
+
}
|
8
|
+
|
9
|
+
a, a:visited {
|
10
|
+
color: #546188;
|
11
|
+
}
|
12
|
+
a:hover {
|
13
|
+
color: #242168;
|
14
|
+
}
|
15
|
+
|
16
|
+
h1 {
|
17
|
+
background-color: #EEE;
|
18
|
+
padding: 10px;
|
19
|
+
width: 95%;
|
20
|
+
}
|
21
|
+
|
22
|
+
h1 a {
|
23
|
+
text-decoration: none;
|
24
|
+
}
|
25
|
+
|
26
|
+
table.source {
|
27
|
+
border-spacing: 0;
|
28
|
+
width: 95%
|
29
|
+
}
|
30
|
+
|
31
|
+
.line .line-number {
|
32
|
+
font-weight: bold;
|
33
|
+
padding: 2px 8px;
|
34
|
+
width: 30px;
|
35
|
+
}
|
36
|
+
|
37
|
+
.line .code pre {
|
38
|
+
display: inline;
|
39
|
+
font-family: monospace;
|
40
|
+
white-space: pre;
|
41
|
+
}
|
42
|
+
|
43
|
+
.line {
|
44
|
+
background: #AACAA5;
|
45
|
+
}
|
46
|
+
|
47
|
+
.line[data-coverage="0"] {
|
48
|
+
background: #E08572;
|
49
|
+
}
|
50
|
+
|
51
|
+
.line[data-coverage="uncoverable"] {
|
52
|
+
background: #E8E8E8;
|
53
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang='en'>
|
3
|
+
<head>
|
4
|
+
<meta charset='utf-8'>
|
5
|
+
<title>JCov</title>
|
6
|
+
</meta>
|
7
|
+
<link href="report.css" media="screen" rel="stylesheet" type="text/css" />
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<%
|
11
|
+
all_total = 0
|
12
|
+
all_cover = 0
|
13
|
+
reduced_coverage_data.each do |filename, total, cover|
|
14
|
+
all_total += total
|
15
|
+
all_cover += cover
|
16
|
+
end
|
17
|
+
total_coverage = (all_total == 0) ? "100%" : sprintf("%3s%", 100 * all_cover / all_total)
|
18
|
+
%>
|
19
|
+
<h1>JCov : <span class="total-coverage"><%= total_coverage %><span/></h1>
|
20
|
+
<table>
|
21
|
+
<tr><th>Filename</th><th>Coverage</th><th>Percent</th></tr>
|
22
|
+
<%
|
23
|
+
reduced_coverage_data.each do |filename, total, cover|
|
24
|
+
if (total > 0)
|
25
|
+
percent = 100 * cover / total
|
26
|
+
coverage_string = "(#{cover}/#{total})"
|
27
|
+
else
|
28
|
+
percent = 100
|
29
|
+
coverage_string = "(EMPTY)"
|
30
|
+
end
|
31
|
+
%>
|
32
|
+
<tr>
|
33
|
+
<td><a href="<%= filename %>.html"><%= filename %></a></td>
|
34
|
+
<td><%= coverage_string %></td>
|
35
|
+
<td><%= sprintf "%3s%", percent %></td>
|
36
|
+
</tr>
|
37
|
+
<% end %>
|
38
|
+
<tr>
|
39
|
+
<td><em>Total:</em></td>
|
40
|
+
<td>(<%= all_cover %>/<%= all_total %>)</td>
|
41
|
+
<td><%= total_coverage %></td>
|
42
|
+
</tr>
|
43
|
+
</table>
|
44
|
+
</body>
|
45
|
+
</html>
|
data/lib/jcov/runner.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
module JCov
|
2
|
+
|
3
|
+
class Runner
|
4
|
+
attr_reader :context
|
5
|
+
attr_reader :config
|
6
|
+
attr_reader :options
|
7
|
+
|
8
|
+
def initialize(config, options)
|
9
|
+
@config = config
|
10
|
+
@options = options
|
11
|
+
|
12
|
+
setup_context
|
13
|
+
end
|
14
|
+
|
15
|
+
def tests
|
16
|
+
# which tests shall we run?
|
17
|
+
if @tests.nil?
|
18
|
+
if options.args.size > 0
|
19
|
+
@tests = options.args
|
20
|
+
else
|
21
|
+
@tests = Dir.glob(File.join(config.test_directory, "**", "*.js"))
|
22
|
+
end
|
23
|
+
if options.test # limit to a single or group of tests
|
24
|
+
@tests = @tests.grep(/#{options.test}/)
|
25
|
+
end
|
26
|
+
# remove the runner if it's in there
|
27
|
+
@tests.delete(config.test_runner)
|
28
|
+
@tests.sort!
|
29
|
+
end
|
30
|
+
@tests
|
31
|
+
end
|
32
|
+
|
33
|
+
def print s
|
34
|
+
Kernel.print s
|
35
|
+
end
|
36
|
+
|
37
|
+
def println *s
|
38
|
+
Kernel.puts s
|
39
|
+
end
|
40
|
+
|
41
|
+
def load file
|
42
|
+
content = File.read(file)
|
43
|
+
|
44
|
+
context.eval(content, file)
|
45
|
+
end
|
46
|
+
|
47
|
+
# for JSpec
|
48
|
+
def readFile file
|
49
|
+
File.read(file)
|
50
|
+
end
|
51
|
+
|
52
|
+
# so we can do our dotted line output
|
53
|
+
def putc char
|
54
|
+
$stdout.putc(char);
|
55
|
+
$stdout.flush();
|
56
|
+
end
|
57
|
+
|
58
|
+
def failure_count
|
59
|
+
context.eval(config.error_field)
|
60
|
+
end
|
61
|
+
|
62
|
+
def run
|
63
|
+
context.load(config.test_runner)
|
64
|
+
|
65
|
+
failure_count
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def setup_context
|
71
|
+
# create a V8 context for this runner
|
72
|
+
@context = V8::Context.new
|
73
|
+
|
74
|
+
# create the jcov context object
|
75
|
+
@context["JCov"] = {}
|
76
|
+
|
77
|
+
setup_object_proxies
|
78
|
+
setup_method_proxies
|
79
|
+
end
|
80
|
+
|
81
|
+
def setup_object_proxies
|
82
|
+
context['JCov']['tests'] = tests
|
83
|
+
context['JCov']['config'] = config
|
84
|
+
context['JCov']['options'] = options.__hash__
|
85
|
+
end
|
86
|
+
|
87
|
+
def setup_method_proxies
|
88
|
+
# these will become global methods in the context
|
89
|
+
%w{print
|
90
|
+
println
|
91
|
+
load
|
92
|
+
readFile
|
93
|
+
putc}.each do |method|
|
94
|
+
context[method] = self.method(method)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
data/lib/jcov/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,195 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jcov
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Doug McInnes
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: commander
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '4.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: therubyracer
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - '='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.9.0
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - '='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.9.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rkelly
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.0.4
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.4
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: cucumber
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: aruba
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.4.6
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.4.6
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: capybara
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.1.1
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.1.1
|
110
|
+
description: Javascript Coverage Tool
|
111
|
+
email:
|
112
|
+
- dmcinnes@attinteractive.com
|
113
|
+
executables:
|
114
|
+
- jcov
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE
|
121
|
+
- README.rdoc
|
122
|
+
- Rakefile
|
123
|
+
- bin/jcov
|
124
|
+
- examples/jasmine/.gitignore
|
125
|
+
- examples/jasmine/jasmine/ConsoleReporter.js
|
126
|
+
- examples/jasmine/jasmine/MIT.LICENSE.txt
|
127
|
+
- examples/jasmine/jasmine/jasmine.js
|
128
|
+
- examples/jasmine/jasmine/runner.js
|
129
|
+
- examples/jasmine/javascripts/mean.js
|
130
|
+
- examples/jasmine/jcov.yml
|
131
|
+
- examples/jasmine/tests/mean_spec.js
|
132
|
+
- examples/jspec/.gitignore
|
133
|
+
- examples/jspec/javascripts/mean.js
|
134
|
+
- examples/jspec/jcov.yml
|
135
|
+
- examples/jspec/jspec/ext/slowness.js
|
136
|
+
- examples/jspec/jspec/ext/trace.js
|
137
|
+
- examples/jspec/jspec/lib/MIT.LICENSE.txt
|
138
|
+
- examples/jspec/jspec/lib/jspec.js
|
139
|
+
- examples/jspec/jspec/runner.js
|
140
|
+
- examples/jspec/tests/mean_spec.js
|
141
|
+
- features/configuration.feature
|
142
|
+
- features/coverage.feature
|
143
|
+
- features/html_report.feature
|
144
|
+
- features/javascript_interface.feature
|
145
|
+
- features/reporting.feature
|
146
|
+
- features/run.feature
|
147
|
+
- features/step_definitions/report_steps.rb
|
148
|
+
- features/support/env.rb
|
149
|
+
- jcov.gemspec
|
150
|
+
- lib/jcov.rb
|
151
|
+
- lib/jcov/commands.rb
|
152
|
+
- lib/jcov/configuration.rb
|
153
|
+
- lib/jcov/coverage.rb
|
154
|
+
- lib/jcov/reporter.rb
|
155
|
+
- lib/jcov/reporter/console_reporter.rb
|
156
|
+
- lib/jcov/reporter/file.html.erb
|
157
|
+
- lib/jcov/reporter/html_reporter.rb
|
158
|
+
- lib/jcov/reporter/report.css
|
159
|
+
- lib/jcov/reporter/report.html.erb
|
160
|
+
- lib/jcov/runner.rb
|
161
|
+
- lib/jcov/version.rb
|
162
|
+
homepage: ''
|
163
|
+
licenses: []
|
164
|
+
post_install_message:
|
165
|
+
rdoc_options: []
|
166
|
+
require_paths:
|
167
|
+
- lib
|
168
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
+
none: false
|
176
|
+
requirements:
|
177
|
+
- - ! '>='
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
requirements: []
|
181
|
+
rubyforge_project:
|
182
|
+
rubygems_version: 1.8.24
|
183
|
+
signing_key:
|
184
|
+
specification_version: 3
|
185
|
+
summary: Javascript Coverage Tool
|
186
|
+
test_files:
|
187
|
+
- features/configuration.feature
|
188
|
+
- features/coverage.feature
|
189
|
+
- features/html_report.feature
|
190
|
+
- features/javascript_interface.feature
|
191
|
+
- features/reporting.feature
|
192
|
+
- features/run.feature
|
193
|
+
- features/step_definitions/report_steps.rb
|
194
|
+
- features/support/env.rb
|
195
|
+
has_rdoc:
|