coverband 6.1.2.rc.1 → 6.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +1 -0
  3. data/.rubocop.yml +5 -0
  4. data/README.md +3 -16
  5. data/changes.md +20 -0
  6. data/coverband.gemspec +5 -4
  7. data/lib/coverband/adapters/base.rb +5 -22
  8. data/lib/coverband/adapters/file_store.rb +0 -4
  9. data/lib/coverband/adapters/hash_redis_store.rb +20 -106
  10. data/lib/coverband/adapters/memcached_store.rb +0 -4
  11. data/lib/coverband/adapters/null_store.rb +0 -4
  12. data/lib/coverband/adapters/redis_store.rb +9 -22
  13. data/lib/coverband/adapters/stdout_store.rb +0 -4
  14. data/lib/coverband/collectors/abstract_tracker.rb +7 -2
  15. data/lib/coverband/collectors/coverage.rb +7 -18
  16. data/lib/coverband/collectors/delta.rb +1 -1
  17. data/lib/coverband/collectors/view_tracker.rb +3 -2
  18. data/lib/coverband/configuration.rb +6 -20
  19. data/lib/coverband/integrations/background.rb +2 -0
  20. data/lib/coverband/integrations/sidekiq_swarm.rb +8 -0
  21. data/lib/coverband/reporters/base.rb +2 -2
  22. data/lib/coverband/reporters/console_report.rb +13 -3
  23. data/lib/coverband/reporters/json_report.rb +36 -2
  24. data/lib/coverband/utils/dead_methods.rb +1 -1
  25. data/lib/coverband/utils/html_formatter.rb +18 -1
  26. data/lib/coverband/utils/results.rb +13 -0
  27. data/lib/coverband/utils/source_file.rb +4 -3
  28. data/lib/coverband/utils/tasks.rb +97 -15
  29. data/lib/coverband/version.rb +1 -1
  30. data/lib/coverband.rb +3 -1
  31. data/test/benchmarks/benchmark.rake +0 -1
  32. data/test/coverband/adapters/base_test.rb +1 -4
  33. data/test/coverband/adapters/hash_redis_store_test.rb +0 -51
  34. data/test/coverband/adapters/memecached_store_test.rb +26 -0
  35. data/test/coverband/adapters/redis_store_test.rb +0 -8
  36. data/test/coverband/collectors/coverage_test.rb +0 -42
  37. data/test/coverband/collectors/delta_test.rb +24 -26
  38. data/test/coverband/collectors/route_tracker_test.rb +1 -1
  39. data/test/coverband/collectors/view_tracker_test.rb +15 -2
  40. data/test/coverband/configuration_test.rb +3 -21
  41. data/test/coverband/integrations/resque_worker_test.rb +3 -1
  42. data/test/coverband/reporters/base_test.rb +0 -1
  43. data/test/coverband/reporters/json_test.rb +11 -0
  44. data/test/coverband/reporters/web_test.rb +52 -54
  45. data/test/rails5_dummy/config/coverband.rb +0 -1
  46. data/test/rails5_dummy/config/coverband_missing_redis.rb +0 -1
  47. data/test/test_helper.rb +10 -3
  48. data/views/source_file.erb +1 -1
  49. metadata +37 -20
@@ -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/", ".erb$", ".slim$", "/tmp", "internal:prelude", "db/schema.rb", "config/environments"]
21
+ expected = ["vendor/", ".erb$", ".slim$", "/tmp", "internal:prelude", "db/schema.rb", "config/environments"].map { |str| Regexp.new(str) }
22
22
  assert_equal expected, Coverband.configuration.ignore
23
23
  end
24
24
 
@@ -34,7 +34,7 @@ class BaseTest < Minitest::Test
34
34
  "internal:prelude",
35
35
  "db/schema.rb",
36
36
  "config/environments",
37
- "config/initializers"]
37
+ "config/initializers"].map { |str| Regexp.new(str) }
38
38
  assert_equal expected, Coverband.configuration.ignore
39
39
  end
40
40
 
@@ -44,7 +44,7 @@ class BaseTest < Minitest::Test
44
44
  config.ignore = ["*invalidRegex*"]
45
45
  end
46
46
  Coverband::Collectors::Coverage.instance.reset_instance
47
- expected = Coverband::Configuration::IGNORE_DEFAULTS << "config/environments"
47
+ expected = (Coverband::Configuration::IGNORE_DEFAULTS << "config/environments").map { |str| Regexp.new(str) }
48
48
  assert_equal expected, Coverband.configuration.ignore
49
49
  end
50
50
 
@@ -121,22 +121,4 @@ class BaseTest < Minitest::Test
121
121
  config.redis_url = "redis://localhost:3333"
122
122
  end
123
123
  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
124
  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
- assert_equal 1, report[Coverband::RUNTIME_TYPE][relative_job_file]["data"][6]
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
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.2.0")
10
- module Coverband
11
- class WebTest < Minitest::Test
12
- include Rack::Test::Methods
9
+ module Coverband
10
+ class WebTest < Minitest::Test
11
+ include Rack::Test::Methods
13
12
 
14
- def app
15
- Coverband::Reporters::Web.new
16
- end
13
+ def app
14
+ Coverband::Reporters::Web.new
15
+ end
17
16
 
18
- def teardown
19
- super
20
- end
17
+ def teardown
18
+ super
19
+ end
21
20
 
22
- test "renders index content" do
23
- get "/"
24
- assert last_response.ok?
25
- assert_match "Coverband Home", last_response.body
26
- end
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
- test "renders index content for empty path" do
29
- get ""
30
- assert last_response.ok?
31
- assert_match "Coverband Home", last_response.body
32
- end
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
- test "renders 404" do
35
- get "/show"
36
- assert last_response.not_found?
37
- assert_equal "404 error!", last_response.body
38
- end
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
- test "clears coverband" do
41
- post "/clear"
42
- assert_equal 302, last_response.status
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
- module Coverband
48
- class AuthWebTest < Minitest::Test
49
- include Rack::Test::Methods
46
+ module Coverband
47
+ class AuthWebTest < Minitest::Test
48
+ include Rack::Test::Methods
50
49
 
51
- def setup
52
- super
53
- @store = Coverband.configuration.store
54
- Coverband.configure do |config|
55
- config.password = "test_pass"
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
- def app
60
- Coverband::Reporters::Web.new
61
- end
58
+ def app
59
+ Coverband::Reporters::Web.new
60
+ end
62
61
 
63
- def teardown
64
- super
65
- end
62
+ def teardown
63
+ super
64
+ end
66
65
 
67
- test "renders index with basic auth" do
68
- basic_authorize "anything", "test_pass"
69
- get "/"
70
- assert last_response.ok?
71
- assert_match "Coverband Home", last_response.body
72
- end
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
- test "renders 401 auth error when not provided" do
75
- get "/"
76
- assert_equal 401, last_response.status
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
@@ -12,5 +12,4 @@ Coverband.configure do |config|
12
12
  config.background_reporting_enabled = true
13
13
  config.track_routes = true
14
14
  config.use_oneshot_lines_coverage = true if ENV["ONESHOT"]
15
- config.simulate_oneshot_lines_coverage = true if ENV["SIMULATE_ONESHOT"]
16
15
  end
@@ -11,5 +11,4 @@ Coverband.configure do |config|
11
11
  config.track_gems = true
12
12
  config.gem_details = true
13
13
  config.use_oneshot_lines_coverage = true if ENV["ONESHOT"]
14
- config.simulate_oneshot_lines_coverage = true if ENV["SIMULATE_ONESHOT"]
15
14
  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"] || ENV["SIMULATE_ONESHOT"] || $SKIP_SIMPLECOV
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::Configuration.prevent(:stubbing_method_unnecessarily)
93
- Mocha::Configuration.prevent(:stubbing_non_existent_method)
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
@@ -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="red"><b><%= source_file.missed_lines.count %></b> lines missed.</span>
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.2.rc.1
4
+ version: 6.1.3
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-04-27 00:00:00.000000000 Z
12
+ date: 2024-10-16 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: 5.18.1
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: 5.18.1
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: 1.7.0
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: 1.7.0
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.34.0
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.34.0
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: 1.60.0
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: 1.60.0
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
@@ -524,9 +541,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
524
541
  version: '2.7'
525
542
  required_rubygems_version: !ruby/object:Gem::Requirement
526
543
  requirements:
527
- - - ">"
544
+ - - ">="
528
545
  - !ruby/object:Gem::Version
529
- version: 1.3.1
546
+ version: '0'
530
547
  requirements: []
531
548
  rubygems_version: 3.4.10
532
549
  signing_key: