coverband 6.1.2 → 6.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +1 -0
- data/.rubocop.yml +5 -0
- data/README.md +6 -14
- data/changes.md +21 -0
- data/coverband.gemspec +5 -4
- data/lib/coverband/adapters/base.rb +5 -22
- data/lib/coverband/adapters/file_store.rb +0 -4
- data/lib/coverband/adapters/hash_redis_store.rb +20 -106
- data/lib/coverband/adapters/memcached_store.rb +0 -4
- data/lib/coverband/adapters/null_store.rb +0 -4
- data/lib/coverband/adapters/redis_store.rb +9 -22
- data/lib/coverband/adapters/stdout_store.rb +0 -4
- data/lib/coverband/collectors/abstract_tracker.rb +7 -2
- data/lib/coverband/collectors/coverage.rb +7 -18
- data/lib/coverband/collectors/delta.rb +1 -1
- data/lib/coverband/collectors/view_tracker.rb +6 -2
- data/lib/coverband/configuration.rb +7 -21
- data/lib/coverband/integrations/background.rb +2 -0
- data/lib/coverband/integrations/sidekiq_swarm.rb +8 -0
- data/lib/coverband/reporters/base.rb +2 -2
- data/lib/coverband/reporters/console_report.rb +13 -3
- data/lib/coverband/reporters/json_report.rb +36 -2
- data/lib/coverband/utils/dead_methods.rb +1 -1
- data/lib/coverband/utils/html_formatter.rb +18 -1
- data/lib/coverband/utils/results.rb +13 -0
- data/lib/coverband/utils/source_file.rb +4 -3
- data/lib/coverband/utils/tasks.rb +97 -15
- data/lib/coverband/version.rb +1 -1
- data/lib/coverband.rb +4 -2
- data/test/benchmarks/benchmark.rake +0 -1
- data/test/coverband/adapters/base_test.rb +1 -4
- data/test/coverband/adapters/hash_redis_store_test.rb +0 -51
- data/test/coverband/adapters/memecached_store_test.rb +26 -0
- data/test/coverband/adapters/redis_store_test.rb +0 -8
- data/test/coverband/collectors/coverage_test.rb +0 -42
- data/test/coverband/collectors/delta_test.rb +24 -26
- data/test/coverband/collectors/route_tracker_test.rb +1 -1
- data/test/coverband/collectors/view_tracker_test.rb +17 -4
- data/test/coverband/configuration_test.rb +6 -23
- data/test/coverband/integrations/resque_worker_test.rb +3 -1
- data/test/coverband/reporters/base_test.rb +0 -1
- data/test/coverband/reporters/json_test.rb +11 -0
- data/test/coverband/reporters/web_test.rb +52 -54
- data/test/rails5_dummy/config/coverband.rb +0 -1
- data/test/rails5_dummy/config/coverband_missing_redis.rb +0 -1
- data/test/test_helper.rb +10 -3
- data/views/source_file.erb +1 -1
- metadata +35 -18
@@ -4,11 +4,12 @@ require File.expand_path("../../test_helper", File.dirname(__FILE__))
|
|
4
4
|
|
5
5
|
class ViewTrackerTest < Minitest::Test
|
6
6
|
def tracker_key
|
7
|
-
"
|
7
|
+
"coverband_test_ViewTracker_tracker"
|
8
8
|
end
|
9
9
|
|
10
10
|
def setup
|
11
11
|
super
|
12
|
+
Coverband.configuration.ignore += ["app/views/anything/ignore_me.html.erb"]
|
12
13
|
fake_store.raw_store.del(tracker_key)
|
13
14
|
end
|
14
15
|
|
@@ -87,18 +88,30 @@ class ViewTrackerTest < Minitest::Test
|
|
87
88
|
Coverband::Collectors::ViewTracker.expects(:supported_version?).returns(true)
|
88
89
|
store = fake_store
|
89
90
|
file_path = "#{File.expand_path(Coverband.configuration.root)}/file"
|
90
|
-
target = [file_path, "not_used"]
|
91
|
+
target = [file_path, "not_used.html.erb"]
|
91
92
|
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots: "dir", target: target)
|
92
93
|
tracker.track_key(identifier: file_path)
|
93
94
|
tracker.save_report
|
94
|
-
assert_equal ["not_used"], tracker.unused_keys
|
95
|
+
assert_equal ["not_used.html.erb"], tracker.unused_keys
|
96
|
+
end
|
97
|
+
|
98
|
+
test "report hides partials marked in ignore config" do
|
99
|
+
Coverband::Collectors::ViewTracker.expects(:supported_version?).returns(true)
|
100
|
+
store = fake_store
|
101
|
+
file_path = "#{File.expand_path(Coverband.configuration.root)}/app/views/anything/ignore_me.html.erb"
|
102
|
+
target = [file_path, "not_used.html.erb"]
|
103
|
+
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots: "dir", target: target)
|
104
|
+
tracker.track_key(identifier: file_path)
|
105
|
+
tracker.save_report
|
106
|
+
assert_equal ["not_used.html.erb"], tracker.unused_keys
|
107
|
+
assert_equal [], tracker.used_keys.keys
|
95
108
|
end
|
96
109
|
|
97
110
|
test "reset store" do
|
98
111
|
Coverband::Collectors::ViewTracker.expects(:supported_version?).returns(true)
|
99
112
|
store = fake_store
|
100
113
|
store.raw_store.expects(:del).with(tracker_key)
|
101
|
-
store.raw_store.expects(:del).with("
|
114
|
+
store.raw_store.expects(:del).with("#{tracker_key}_time")
|
102
115
|
tracker = Coverband::Collectors::ViewTracker.new(store: store, roots: "dir")
|
103
116
|
tracker.track_key(identifier: "file")
|
104
117
|
tracker.reset_recordings
|
@@ -18,7 +18,7 @@ class BaseTest < Minitest::Test
|
|
18
18
|
|
19
19
|
test "ignore works with equal" do
|
20
20
|
Coverband::Collectors::Coverage.instance.reset_instance
|
21
|
-
expected = ["vendor/", "
|
21
|
+
expected = ["vendor/", "/tmp", "internal:prelude", "db/schema.rb", ".erb$", ".haml$", ".slim$", "config/environments"].map { |str| Regexp.new(str) }
|
22
22
|
assert_equal expected, Coverband.configuration.ignore
|
23
23
|
end
|
24
24
|
|
@@ -28,13 +28,14 @@ class BaseTest < Minitest::Test
|
|
28
28
|
end
|
29
29
|
Coverband::Collectors::Coverage.instance.reset_instance
|
30
30
|
expected = ["vendor/",
|
31
|
-
".erb$",
|
32
|
-
".slim$",
|
33
31
|
"/tmp",
|
34
32
|
"internal:prelude",
|
35
33
|
"db/schema.rb",
|
34
|
+
".erb$",
|
35
|
+
".haml$",
|
36
|
+
".slim$",
|
36
37
|
"config/environments",
|
37
|
-
"config/initializers"]
|
38
|
+
"config/initializers"].map { |str| Regexp.new(str) }
|
38
39
|
assert_equal expected, Coverband.configuration.ignore
|
39
40
|
end
|
40
41
|
|
@@ -44,7 +45,7 @@ class BaseTest < Minitest::Test
|
|
44
45
|
config.ignore = ["*invalidRegex*"]
|
45
46
|
end
|
46
47
|
Coverband::Collectors::Coverage.instance.reset_instance
|
47
|
-
expected = Coverband::Configuration::IGNORE_DEFAULTS << "config/environments"
|
48
|
+
expected = (Coverband::Configuration::IGNORE_DEFAULTS << "config/environments").map { |str| Regexp.new(str) }
|
48
49
|
assert_equal expected, Coverband.configuration.ignore
|
49
50
|
end
|
50
51
|
|
@@ -121,22 +122,4 @@ class BaseTest < Minitest::Test
|
|
121
122
|
config.redis_url = "redis://localhost:3333"
|
122
123
|
end
|
123
124
|
end
|
124
|
-
|
125
|
-
test "use_oneshot_lines_coverage" do
|
126
|
-
refute Coverband.configuration.use_oneshot_lines_coverage
|
127
|
-
|
128
|
-
Coverband.configuration.stubs(:one_shot_coverage_implemented_in_ruby_version?).returns(true)
|
129
|
-
Coverband.configuration.use_oneshot_lines_coverage = true
|
130
|
-
assert Coverband.configuration.use_oneshot_lines_coverage
|
131
|
-
|
132
|
-
Coverband.configuration.use_oneshot_lines_coverage = false
|
133
|
-
refute Coverband.configuration.use_oneshot_lines_coverage
|
134
|
-
|
135
|
-
Coverband.configuration.stubs(:one_shot_coverage_implemented_in_ruby_version?).returns(false)
|
136
|
-
exception = assert_raises Exception do
|
137
|
-
Coverband.configuration.use_oneshot_lines_coverage = true
|
138
|
-
end
|
139
|
-
assert_equal "One shot line coverage is only available in ruby >= 2.6", exception.message
|
140
|
-
refute Coverband.configuration.use_oneshot_lines_coverage
|
141
|
-
end
|
142
125
|
end
|
@@ -45,7 +45,9 @@ class ResqueWorkerTest < Minitest::Test
|
|
45
45
|
assert_equal 1, report[Coverband::EAGER_TYPE][relative_job_file]["data"][6]
|
46
46
|
else
|
47
47
|
assert_equal 0, report[Coverband::EAGER_TYPE][relative_job_file]["data"][6]
|
48
|
-
|
48
|
+
if report[Coverband::RUNTIME_TYPE] && report[Coverband::RUNTIME_TYPE][relative_job_file]
|
49
|
+
assert_equal 1, report[Coverband::RUNTIME_TYPE][relative_job_file]["data"][6]
|
50
|
+
end
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|
@@ -75,7 +75,6 @@ class ReportsBaseTest < Minitest::Test
|
|
75
75
|
roots = ['/base/[0-9]*/', '/base/78/app/']
|
76
76
|
|
77
77
|
Coverband.configuration.stubs(:all_root_paths).returns(roots)
|
78
|
-
lines_hit = [1, 3, 6]
|
79
78
|
store.stubs(:merged_coverage).returns(coverage)
|
80
79
|
File.expects(:exist?).at_least_once
|
81
80
|
.with('/base/[0-9]*/app/controllers/dashboard_controller.rb')
|
@@ -45,4 +45,15 @@ class ReportJSONTest < Minitest::Test
|
|
45
45
|
assert_equal parsed["files"][file].keys, expected_keys
|
46
46
|
end
|
47
47
|
end
|
48
|
+
|
49
|
+
test "supports merging" do
|
50
|
+
@store.send(:save_report, basic_coverage)
|
51
|
+
first_report = JSON.parse(Coverband::Reporters::JSONReport.new(@store, for_merged_report: true).report)
|
52
|
+
|
53
|
+
@store.send(:save_report, increased_basic_coverage)
|
54
|
+
second_report = JSON.parse(Coverband::Reporters::JSONReport.new(@store, for_merged_report: true).report)
|
55
|
+
data = Coverband::Reporters::JSONReport.new(@store).merge_reports(first_report, second_report)
|
56
|
+
assert_equal data[Coverband::RUNTIME_TYPE.to_s]["app_path/dog.rb"]["data"], [0, 4, 10]
|
57
|
+
assert_equal data[Coverband::MERGED_TYPE.to_s]["app_path/dog.rb"]["data"], [0, 4, 10]
|
58
|
+
end
|
48
59
|
end
|
@@ -6,75 +6,73 @@ require "rack/test"
|
|
6
6
|
|
7
7
|
ENV["RACK_ENV"] = "test"
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
include Rack::Test::Methods
|
9
|
+
module Coverband
|
10
|
+
class WebTest < Minitest::Test
|
11
|
+
include Rack::Test::Methods
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def app
|
14
|
+
Coverband::Reporters::Web.new
|
15
|
+
end
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
def teardown
|
18
|
+
super
|
19
|
+
end
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
test "renders index content" do
|
22
|
+
get "/"
|
23
|
+
assert last_response.ok?
|
24
|
+
assert_match "Coverband Home", last_response.body
|
25
|
+
end
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
test "renders index content for empty path" do
|
28
|
+
get ""
|
29
|
+
assert last_response.ok?
|
30
|
+
assert_match "Coverband Home", last_response.body
|
31
|
+
end
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
test "renders 404" do
|
34
|
+
get "/show"
|
35
|
+
assert last_response.not_found?
|
36
|
+
assert_equal "404 error!", last_response.body
|
37
|
+
end
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
39
|
+
test "clears coverband" do
|
40
|
+
post "/clear"
|
41
|
+
assert_equal 302, last_response.status
|
44
42
|
end
|
45
43
|
end
|
44
|
+
end
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
module Coverband
|
47
|
+
class AuthWebTest < Minitest::Test
|
48
|
+
include Rack::Test::Methods
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
50
|
+
def setup
|
51
|
+
super
|
52
|
+
@store = Coverband.configuration.store
|
53
|
+
Coverband.configure do |config|
|
54
|
+
config.password = "test_pass"
|
57
55
|
end
|
56
|
+
end
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
def app
|
59
|
+
Coverband::Reporters::Web.new
|
60
|
+
end
|
62
61
|
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
def teardown
|
63
|
+
super
|
64
|
+
end
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
66
|
+
test "renders index with basic auth" do
|
67
|
+
basic_authorize "anything", "test_pass"
|
68
|
+
get "/"
|
69
|
+
assert last_response.ok?
|
70
|
+
assert_match "Coverband Home", last_response.body
|
71
|
+
end
|
73
72
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
73
|
+
test "renders 401 auth error when not provided" do
|
74
|
+
get "/"
|
75
|
+
assert_equal 401, last_response.status
|
78
76
|
end
|
79
77
|
end
|
80
78
|
end
|
data/test/test_helper.rb
CHANGED
@@ -40,7 +40,7 @@ require "spy/integration"
|
|
40
40
|
require_relative "unique_files"
|
41
41
|
$VERBOSE = original_verbosity
|
42
42
|
|
43
|
-
unless ENV["ONESHOT"] ||
|
43
|
+
unless ENV["ONESHOT"] || $SKIP_SIMPLECOV
|
44
44
|
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
45
45
|
SimpleCov.start do
|
46
46
|
add_filter "test/forked"
|
@@ -89,8 +89,11 @@ TEST_COVERAGE_FILE = "/tmp/fake_file.json"
|
|
89
89
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
90
90
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
91
91
|
|
92
|
-
Mocha
|
93
|
-
|
92
|
+
Mocha.configure do |c|
|
93
|
+
c.stubbing_method_unnecessarily = :prevent
|
94
|
+
c.stubbing_method_on_non_mock_object = :allow
|
95
|
+
c.stubbing_method_on_nil = :prevent
|
96
|
+
end
|
94
97
|
|
95
98
|
def test(name, &block)
|
96
99
|
test_name = :"test_#{name.gsub(/\s+/, "_")}"
|
@@ -122,6 +125,10 @@ def basic_coverage
|
|
122
125
|
{"app_path/dog.rb" => example_line}
|
123
126
|
end
|
124
127
|
|
128
|
+
def increased_basic_coverage
|
129
|
+
{"app_path/dog.rb" => [0, 2, 6]}
|
130
|
+
end
|
131
|
+
|
125
132
|
def basic_coverage_full_path
|
126
133
|
{basic_coverage_file_full_path => example_line}
|
127
134
|
end
|
data/views/source_file.erb
CHANGED
@@ -27,7 +27,7 @@
|
|
27
27
|
<b><%= source_file.lines_of_code %></b> relevant lines.
|
28
28
|
<b><%= result.runtime_relavent_lines(source_file) %></b> runtime relevant lines.
|
29
29
|
<span class="green"><b><%= source_file.covered_lines.count %></b> lines covered</span> and
|
30
|
-
<span class="
|
30
|
+
<span class="<%= missed_lines_css_class(source_file.missed_lines.count) %>"><b><%= source_file.missed_lines.count %></b> lines missed.</span>
|
31
31
|
</div>
|
32
32
|
<div>
|
33
33
|
Coverage first seen: <%= source_file.first_updated_at %>, last activity recorded:
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coverband
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.1.
|
4
|
+
version: 6.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Mayer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-10-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: benchmark-ips
|
@@ -85,16 +85,16 @@ dependencies:
|
|
85
85
|
name: minitest
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
90
|
+
version: '0'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
97
|
+
version: '0'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: minitest-fork_executor
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,16 +127,16 @@ dependencies:
|
|
127
127
|
name: mocha
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- - "
|
130
|
+
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
132
|
+
version: '0'
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
|
-
- - "
|
137
|
+
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version:
|
139
|
+
version: '0'
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
141
|
name: rack
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -197,30 +197,30 @@ dependencies:
|
|
197
197
|
name: standard
|
198
198
|
requirement: !ruby/object:Gem::Requirement
|
199
199
|
requirements:
|
200
|
-
- -
|
200
|
+
- - ">="
|
201
201
|
- !ruby/object:Gem::Version
|
202
|
-
version: 1.
|
202
|
+
version: 1.35.1
|
203
203
|
type: :development
|
204
204
|
prerelease: false
|
205
205
|
version_requirements: !ruby/object:Gem::Requirement
|
206
206
|
requirements:
|
207
|
-
- -
|
207
|
+
- - ">="
|
208
208
|
- !ruby/object:Gem::Version
|
209
|
-
version: 1.
|
209
|
+
version: 1.35.1
|
210
210
|
- !ruby/object:Gem::Dependency
|
211
211
|
name: rubocop
|
212
212
|
requirement: !ruby/object:Gem::Requirement
|
213
213
|
requirements:
|
214
|
-
- -
|
214
|
+
- - ">="
|
215
215
|
- !ruby/object:Gem::Version
|
216
|
-
version:
|
216
|
+
version: '0'
|
217
217
|
type: :development
|
218
218
|
prerelease: false
|
219
219
|
version_requirements: !ruby/object:Gem::Requirement
|
220
220
|
requirements:
|
221
|
-
- -
|
221
|
+
- - ">="
|
222
222
|
- !ruby/object:Gem::Version
|
223
|
-
version:
|
223
|
+
version: '0'
|
224
224
|
- !ruby/object:Gem::Dependency
|
225
225
|
name: coveralls
|
226
226
|
requirement: !ruby/object:Gem::Requirement
|
@@ -249,6 +249,20 @@ dependencies:
|
|
249
249
|
- - ">="
|
250
250
|
- !ruby/object:Gem::Version
|
251
251
|
version: '0'
|
252
|
+
- !ruby/object:Gem::Dependency
|
253
|
+
name: dalli
|
254
|
+
requirement: !ruby/object:Gem::Requirement
|
255
|
+
requirements:
|
256
|
+
- - ">="
|
257
|
+
- !ruby/object:Gem::Version
|
258
|
+
version: '0'
|
259
|
+
type: :development
|
260
|
+
prerelease: false
|
261
|
+
version_requirements: !ruby/object:Gem::Requirement
|
262
|
+
requirements:
|
263
|
+
- - ">="
|
264
|
+
- !ruby/object:Gem::Version
|
265
|
+
version: '0'
|
252
266
|
- !ruby/object:Gem::Dependency
|
253
267
|
name: redis
|
254
268
|
requirement: !ruby/object:Gem::Requirement
|
@@ -277,6 +291,7 @@ files:
|
|
277
291
|
- ".github/workflows/main.yml"
|
278
292
|
- ".gitignore"
|
279
293
|
- ".jrubyrc"
|
294
|
+
- ".rubocop.yml"
|
280
295
|
- ".standard.yml"
|
281
296
|
- CODE_OF_CONDUCT.md
|
282
297
|
- CONTRIBUTING.md
|
@@ -317,6 +332,7 @@ files:
|
|
317
332
|
- lib/coverband/integrations/rack_server_check.rb
|
318
333
|
- lib/coverband/integrations/report_middleware.rb
|
319
334
|
- lib/coverband/integrations/resque.rb
|
335
|
+
- lib/coverband/integrations/sidekiq_swarm.rb
|
320
336
|
- lib/coverband/reporters/base.rb
|
321
337
|
- lib/coverband/reporters/console_report.rb
|
322
338
|
- lib/coverband/reporters/html_report.rb
|
@@ -382,6 +398,7 @@ files:
|
|
382
398
|
- test/coverband/adapters/base_test.rb
|
383
399
|
- test/coverband/adapters/file_store_test.rb
|
384
400
|
- test/coverband/adapters/hash_redis_store_test.rb
|
401
|
+
- test/coverband/adapters/memecached_store_test.rb
|
385
402
|
- test/coverband/adapters/null_store_test.rb
|
386
403
|
- test/coverband/adapters/redis_store_test.rb
|
387
404
|
- test/coverband/adapters/web_service_store_test.rb
|