coverband 4.2.0.rc1 → 4.2.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -1
  3. data/.travis.yml +4 -2
  4. data/README.md +48 -43
  5. data/Rakefile +1 -1
  6. data/changes.md +40 -24
  7. data/coverband.gemspec +2 -0
  8. data/lib/coverband.rb +23 -3
  9. data/lib/coverband/adapters/base.rb +24 -1
  10. data/lib/coverband/adapters/redis_store.rb +28 -7
  11. data/lib/coverband/at_exit.rb +19 -2
  12. data/lib/coverband/collectors/coverage.rb +36 -82
  13. data/lib/coverband/collectors/delta.rb +63 -0
  14. data/lib/coverband/integrations/background.rb +4 -3
  15. data/lib/coverband/integrations/rack_server_check.rb +4 -1
  16. data/lib/coverband/reporters/base.rb +21 -14
  17. data/lib/coverband/reporters/html_report.rb +40 -15
  18. data/lib/coverband/reporters/web.rb +29 -6
  19. data/lib/coverband/utils/html_formatter.rb +20 -4
  20. data/lib/coverband/utils/railtie.rb +8 -0
  21. data/lib/coverband/utils/result.rb +3 -2
  22. data/lib/coverband/utils/results.rb +63 -0
  23. data/lib/coverband/utils/source_file.rb +5 -0
  24. data/lib/coverband/version.rb +1 -1
  25. data/public/application.css +5 -0
  26. data/public/application.js +108 -1644
  27. data/public/dependencies.js +1581 -0
  28. data/public/favicon.png +0 -0
  29. data/test/coverband/adapters/redis_store_test.rb +26 -9
  30. data/test/coverband/collectors/coverage_test.rb +56 -45
  31. data/test/coverband/collectors/delta_test.rb +52 -0
  32. data/test/coverband/coverband_test.rb +7 -0
  33. data/test/coverband/integrations/background_test.rb +14 -11
  34. data/test/coverband/integrations/middleware_test.rb +1 -0
  35. data/test/coverband/reporters/base_test.rb +4 -4
  36. data/test/coverband/reporters/console_test.rb +1 -1
  37. data/test/coverband/reporters/html_test.rb +6 -7
  38. data/test/integration/full_stack_test.rb +10 -8
  39. data/test/integration/rails_full_stack_test.rb +23 -4
  40. data/test/rails4_dummy/config/application.rb +1 -1
  41. data/test/rails4_dummy/config/coverband.rb +4 -1
  42. data/test/rails4_dummy/tmp/.keep +0 -0
  43. data/test/rails5_dummy/config/application.rb +1 -1
  44. data/test/rails5_dummy/config/coverband.rb +3 -1
  45. data/test/rails_test_helper.rb +13 -8
  46. data/test/test_helper.rb +9 -13
  47. data/test/unique_files.rb +23 -0
  48. data/views/file_list.erb +9 -0
  49. data/views/gem_list.erb +1 -1
  50. data/views/layout.erb +4 -3
  51. data/views/source_file.erb +16 -4
  52. data/views/source_file_loader.erb +7 -0
  53. metadata +29 -4
  54. data/test/integration/rails_gems_full_stack_test.rb +0 -36
@@ -10,6 +10,6 @@ module Rails4Dummy
10
10
  config.before_initialize do
11
11
  Coverband.start
12
12
  end
13
- config.eager_load = false
13
+ config.eager_load = true
14
14
  end
15
15
  end
@@ -4,5 +4,8 @@ Coverband.configure do |config|
4
4
  config.ignore = %w[vendor .erb$ .slim$]
5
5
  config.root_paths = []
6
6
  config.logger = Rails.logger
7
- config.background_reporting_sleep_seconds = 0.1
7
+ config.verbose = true
8
+ config.background_reporting_enabled = false
9
+ config.track_gems = true
10
+ config.gem_details = true
8
11
  end
File without changes
@@ -10,7 +10,7 @@ module Dummy
10
10
  config.before_initialize do
11
11
  Coverband.start
12
12
  end
13
- config.eager_load = false
13
+ config.eager_load = true
14
14
  end
15
15
  end
16
16
 
@@ -5,5 +5,7 @@ Coverband.configure do |config|
5
5
  config.root_paths = []
6
6
  config.logger = Rails.logger
7
7
  config.verbose = true
8
- config.background_reporting_sleep_seconds = 0.1
8
+ config.background_reporting_enabled = false
9
+ config.track_gems = true
10
+ config.gem_details = true
9
11
  end
@@ -1,11 +1,16 @@
1
- # Configure Rails Environment
2
- ENV["RAILS_ENV"] = "test"
3
- require 'rails'
4
1
  require File.expand_path('./test_helper', File.dirname(__FILE__))
5
- require_relative "../test/rails#{Rails::VERSION::MAJOR}_dummy/config/environment"
6
- require 'capybara/rails'
2
+ require 'capybara'
7
3
  require 'capybara/minitest'
4
+ def rails_setup
5
+ ENV["RAILS_ENV"] = "test"
6
+ require 'rails'
7
+ #coverband must be required after rails
8
+ load 'coverband/utils/railtie.rb'
9
+ Coverband.configure("./test/rails#{Rails::VERSION::MAJOR}_dummy/config/coverband.rb")
10
+ require_relative "../test/rails#{Rails::VERSION::MAJOR}_dummy/config/environment"
11
+ require 'capybara/rails'
12
+ #Our coverage report is wrapped in display:none as of now
13
+ Capybara.ignore_hidden_elements = false
14
+ require 'mocha/minitest'
15
+ end
8
16
 
9
- #Our coverage report is wrapped in display:none as of now
10
- Capybara.ignore_hidden_elements = false
11
- require 'mocha/minitest'
data/test/test_helper.rb CHANGED
@@ -16,6 +16,7 @@ require 'json'
16
16
  require 'redis'
17
17
  require 'resque'
18
18
  require 'pry-byebug'
19
+ require_relative 'unique_files'
19
20
  $VERBOSE = original_verbosity
20
21
 
21
22
  Coveralls.wear!
@@ -23,7 +24,10 @@ Coveralls.wear!
23
24
  module Coverband
24
25
  module Test
25
26
  def self.reset
26
- Coverband.configuration.store.clear!
27
+ [:eager_loading, nil].each do |type|
28
+ Coverband.configuration.store.type = type
29
+ Coverband.configuration.store.clear!
30
+ end
27
31
  Coverband.configuration.reset
28
32
  Coverband::Collectors::Coverage.instance.reset_instance
29
33
  Coverband::Background.stop
@@ -79,18 +83,6 @@ def basic_coverage
79
83
  { 'app_path/dog.rb' => example_line }
80
84
  end
81
85
 
82
- def fake_redis
83
- @redis ||= begin
84
- redis = OpenStruct.new
85
- redis
86
- end
87
- end
88
-
89
- def fake_coverage_report
90
- file_name = '/Users/danmayer/projects/hearno/script/tester.rb'
91
- { file_name => [1, nil, 1, 1, nil, nil, nil] }
92
- end
93
-
94
86
  def source_fixture(filename)
95
87
  File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', filename))
96
88
  end
@@ -99,6 +91,10 @@ def test_root
99
91
  File.expand_path(File.join(File.dirname(__FILE__)))
100
92
  end
101
93
 
94
+ def store
95
+ Coverband.configuration.store
96
+ end
97
+
102
98
  # Taken from http://stackoverflow.com/questions/4459330/how-do-i-temporarily-redirect-stderr-in-ruby
103
99
  def capture_stderr
104
100
  # The output stream must be an IO-like object. In this case we capture it in
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+ require 'fileutils'
5
+
6
+ UNIQUE_FILES_DIR = "./test/unique_files"
7
+
8
+ def require_unique_file(file = 'dog.rb')
9
+ dir = "#{UNIQUE_FILES_DIR}/#{SecureRandom.uuid}"
10
+ FileUtils.mkdir_p(dir)
11
+ temp_file = "#{dir}/#{file}"
12
+ File.open(temp_file, 'w'){ |w| w.write(File.read("./test/#{file}")) }
13
+ require temp_file
14
+ temp_file
15
+ end
16
+
17
+ def remove_unique_files
18
+ FileUtils.rm_r(UNIQUE_FILES_DIR) if File.exist?(UNIQUE_FILES_DIR)
19
+ end
20
+
21
+ Minitest.after_run do
22
+ remove_unique_files
23
+ end
data/views/file_list.erb CHANGED
@@ -23,9 +23,11 @@
23
23
  <tr>
24
24
  <th>File</th>
25
25
  <th>% covered</th>
26
+ <th>% runtime</th>
26
27
  <th>Lines</th>
27
28
  <th>Relevant Lines</th>
28
29
  <th>Lines covered</th>
30
+ <th>Lines runtime</th>
29
31
  <th>Lines missed</th>
30
32
  <th>Avg. Hits / Line</th>
31
33
  </tr>
@@ -37,9 +39,16 @@
37
39
  <%= link_to_source_file(source_file) %>
38
40
  </td>
39
41
  <td class="<%= coverage_css_class(source_file.covered_percent) %> strong"><%= source_file.covered_percent.round(2).to_s %> %</td>
42
+ <% runtime_percentage = result.file_with_type(source_file, Coverband::RUNTIME_TYPE).try(:covered_percent).try(:round, 2) %>
43
+ <td class="<%= "#{coverage_css_class(runtime_percentage)}" %> strong">
44
+ <%= "#{runtime_percentage || '0'} %" %>
45
+ </td>
40
46
  <td><%= source_file.lines.count %></td>
41
47
  <td><%= source_file.covered_lines.count + source_file.missed_lines.count %></td>
42
48
  <td><%= source_file.covered_lines.count %></td>
49
+ <td>
50
+ <%= result.file_with_type(source_file, Coverband::RUNTIME_TYPE).try(:covered_lines).try(:count) || 0 %>
51
+ </td>
43
52
  <td><%= source_file.missed_lines.count %></td>
44
53
  <td><%= source_file.covered_strength %></td>
45
54
  </tr>
data/views/gem_list.erb CHANGED
@@ -49,6 +49,6 @@
49
49
 
50
50
  <% if gem_details? %>
51
51
  <% source_files.each do |gem_files| %>
52
- <%= formatted_file_list(gem_files.first.gem_name, gem_files, skip_nav: true) %>
52
+ <%= formatted_file_list(gem_files.first.gem_name, result, gem_files, skip_nav: true) %>
53
53
  <% end %>
54
54
  <% end %>
data/views/layout.erb CHANGED
@@ -3,6 +3,7 @@
3
3
  <head>
4
4
  <title>Coverband: <%= Coverband::VERSION %></title>
5
5
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6
+ <script src='<%= assets_path('dependencies.js') %>' type='text/javascript'></script>
6
7
  <script src='<%= assets_path('application.js') %>' type='text/javascript'></script>
7
8
  <link href='<%= assets_path('application.css') %>' media='screen, projection, print' rel='stylesheet' type='text/css'>
8
9
  <link rel="shortcut icon" type="image/png" href="<%= assets_path("favicon_#{coverage_css_class(result.source_files.covered_percent)}.png") %>" />
@@ -33,10 +34,10 @@
33
34
  <ul class="group_tabs"></ul>
34
35
 
35
36
  <div id="content">
36
- <%= formatted_file_list("All Files", result.source_files) unless view_gems? %>
37
+ <%= formatted_file_list("All Files", result, result.source_files) unless view_gems? %>
37
38
 
38
39
  <% result.groups.each do |name, files| %>
39
- <%= formatted_file_list(name, files) %>
40
+ <%= formatted_file_list(name, result, files) %>
40
41
  <% end %>
41
42
  </div>
42
43
 
@@ -47,7 +48,7 @@
47
48
  <div class="source_files">
48
49
  <% result.source_files.each do |source_file| %>
49
50
  <% if (!source_file.gem? || (view_gems? && gem_details? && source_file.gem? )) %>
50
- <%= formatted_source_file(source_file) %>
51
+ <%= formatted_source_file_loader(result, source_file) %>
51
52
  <% end %>
52
53
  <% end %>
53
54
  </div>
@@ -1,23 +1,35 @@
1
1
  <div class="source_table" id="<%= id source_file %>">
2
2
  <div class="header">
3
3
  <h3><%= shortened_filename source_file %></h3>
4
- <h4><span class="<%= coverage_css_class(source_file.covered_percent) %>"><%= source_file.covered_percent.round(2).to_s %> %</span> covered</h4>
4
+ <h4>
5
+ <span class="<%= coverage_css_class(source_file.covered_percent) %>"><%= source_file.covered_percent.round(2).to_s %> %</span>
6
+ covered
7
+ <% if Coverband.configuration.web_enable_clear %>
8
+ <%= button("#{base_path}clear_file?filename=#{source_file.relative_path}", 'clear file coverage') %> &nbsp;
9
+ <% end %>
10
+ </h4>
5
11
  <div>
6
12
  <b><%= source_file.lines_of_code %></b> relevant lines.
7
13
  <span class="green"><b><%= source_file.covered_lines.count %></b> lines covered</span> and
8
14
  <span class="red"><b><%= source_file.missed_lines.count %></b> lines missed.</span>
9
15
  </div>
10
16
  <div>
11
- Coverage first seen: <%= source_file.first_updated_at %>, last activity recorded:
17
+ Coverage first seen: <%= source_file.first_updated_at %>, last activity recorded:
12
18
  <%= source_file.last_updated_at %>
13
19
  </div>
14
20
  </div>
15
21
 
16
22
  <pre>
17
23
  <ol>
18
- <% source_file.lines.each do |line| %>
24
+ <% source_file.lines.each_with_index do |line, index| %>
19
25
  <li class="<%= line.status %>" data-hits="<%= line.coverage ? line.coverage : '' %>" data-linenumber="<%= line.number %>">
20
- <% if line.covered? %><span class="hits"><%= line.coverage %></span><% end %>
26
+ <% if line.covered? %><span class="hits">
27
+ load:
28
+ <%= result.file_with_type(source_file, Coverband::EAGER_TYPE).try(:lines).try(:[], index).try(:coverage) || 0 %>,
29
+ runtime:
30
+ <%= result.file_with_type(source_file, Coverband::RUNTIME_TYPE).try(:lines).try(:[], index).try(:coverage) || 0 %>
31
+ all: <%= line.coverage %>
32
+ </span><% end %>
21
33
  <% if line.skipped? %><span class="hits">skipped</span><% end %>
22
34
  <code class="ruby"><%= CGI.escapeHTML(line.src.chomp) %></code>
23
35
  </li>
@@ -0,0 +1,7 @@
1
+ <div class="source_table" id="<%= id source_file %>" data-loader-url="<%= base_path %>load_file_details?filename=<%= source_file.filename %>">
2
+ <div class='loader'>
3
+ loading...
4
+ <br/>
5
+ <img src="<%= assets_path('loading.gif') %>" alt="loading"/>
6
+ </div>
7
+ </div>
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: 4.2.0.rc1
4
+ version: 4.2.0.rc2
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: 2019-03-13 00:00:00.000000000 Z
12
+ date: 2019-04-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk-s3
@@ -165,6 +165,20 @@ dependencies:
165
165
  - - ">="
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
+ - !ruby/object:Gem::Dependency
169
+ name: minitest-reporters
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ type: :development
176
+ prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
168
182
  - !ruby/object:Gem::Dependency
169
183
  name: classifier-reborn
170
184
  requirement: !ruby/object:Gem::Requirement
@@ -260,6 +274,7 @@ files:
260
274
  - lib/coverband/adapters/redis_store.rb
261
275
  - lib/coverband/at_exit.rb
262
276
  - lib/coverband/collectors/coverage.rb
277
+ - lib/coverband/collectors/delta.rb
263
278
  - lib/coverband/configuration.rb
264
279
  - lib/coverband/integrations/background.rb
265
280
  - lib/coverband/integrations/middleware.rb
@@ -277,6 +292,7 @@ files:
277
292
  - lib/coverband/utils/lines_classifier.rb
278
293
  - lib/coverband/utils/railtie.rb
279
294
  - lib/coverband/utils/result.rb
295
+ - lib/coverband/utils/results.rb
280
296
  - lib/coverband/utils/s3_report.rb
281
297
  - lib/coverband/utils/source_file.rb
282
298
  - lib/coverband/utils/tasks.rb
@@ -287,6 +303,8 @@ files:
287
303
  - public/colorbox/controls.png
288
304
  - public/colorbox/loading.gif
289
305
  - public/colorbox/loading_background.png
306
+ - public/dependencies.js
307
+ - public/favicon.png
290
308
  - public/favicon_green.png
291
309
  - public/favicon_red.png
292
310
  - public/favicon_yellow.png
@@ -315,6 +333,7 @@ files:
315
333
  - test/coverband/adapters/redis_store_test.rb
316
334
  - test/coverband/at_exit_test.rb
317
335
  - test/coverband/collectors/coverage_test.rb
336
+ - test/coverband/collectors/delta_test.rb
318
337
  - test/coverband/configuration_test.rb
319
338
  - test/coverband/coverband_test.rb
320
339
  - test/coverband/integrations/background_test.rb
@@ -345,7 +364,6 @@ files:
345
364
  - test/fixtures/utf-8.rb
346
365
  - test/integration/full_stack_test.rb
347
366
  - test/integration/rails_full_stack_test.rb
348
- - test/integration/rails_gems_full_stack_test.rb
349
367
  - test/rails4_dummy/app/controllers/dummy_controller.rb
350
368
  - test/rails4_dummy/config.ru
351
369
  - test/rails4_dummy/config/application.rb
@@ -354,19 +372,23 @@ files:
354
372
  - test/rails4_dummy/config/environment.rb
355
373
  - test/rails4_dummy/config/routes.rb
356
374
  - test/rails4_dummy/config/secrets.yml
375
+ - test/rails4_dummy/tmp/.keep
357
376
  - test/rails5_dummy/app/controllers/dummy_controller.rb
358
377
  - test/rails5_dummy/config.ru
359
378
  - test/rails5_dummy/config/application.rb
360
379
  - test/rails5_dummy/config/coverband.rb
361
380
  - test/rails5_dummy/config/environment.rb
362
381
  - test/rails5_dummy/config/routes.rb
382
+ - test/rails5_dummy/tmp/.keep
363
383
  - test/rails_test_helper.rb
364
384
  - test/test_helper.rb
385
+ - test/unique_files.rb
365
386
  - views/file_list.erb
366
387
  - views/gem_list.erb
367
388
  - views/layout.erb
368
389
  - views/settings.erb
369
390
  - views/source_file.erb
391
+ - views/source_file_loader.erb
370
392
  homepage: https://github.com/danmayer/coverband
371
393
  licenses:
372
394
  - MIT
@@ -402,6 +424,7 @@ test_files:
402
424
  - test/coverband/adapters/redis_store_test.rb
403
425
  - test/coverband/at_exit_test.rb
404
426
  - test/coverband/collectors/coverage_test.rb
427
+ - test/coverband/collectors/delta_test.rb
405
428
  - test/coverband/configuration_test.rb
406
429
  - test/coverband/coverband_test.rb
407
430
  - test/coverband/integrations/background_test.rb
@@ -432,7 +455,6 @@ test_files:
432
455
  - test/fixtures/utf-8.rb
433
456
  - test/integration/full_stack_test.rb
434
457
  - test/integration/rails_full_stack_test.rb
435
- - test/integration/rails_gems_full_stack_test.rb
436
458
  - test/rails4_dummy/app/controllers/dummy_controller.rb
437
459
  - test/rails4_dummy/config.ru
438
460
  - test/rails4_dummy/config/application.rb
@@ -441,11 +463,14 @@ test_files:
441
463
  - test/rails4_dummy/config/environment.rb
442
464
  - test/rails4_dummy/config/routes.rb
443
465
  - test/rails4_dummy/config/secrets.yml
466
+ - test/rails4_dummy/tmp/.keep
444
467
  - test/rails5_dummy/app/controllers/dummy_controller.rb
445
468
  - test/rails5_dummy/config.ru
446
469
  - test/rails5_dummy/config/application.rb
447
470
  - test/rails5_dummy/config/coverband.rb
448
471
  - test/rails5_dummy/config/environment.rb
449
472
  - test/rails5_dummy/config/routes.rb
473
+ - test/rails5_dummy/tmp/.keep
450
474
  - test/rails_test_helper.rb
451
475
  - test/test_helper.rb
476
+ - test/unique_files.rb
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('../rails_test_helper', File.dirname(__FILE__))
4
-
5
- class RailsGemsFullStackTest < Minitest::Test
6
- include Capybara::DSL
7
- include Capybara::Minitest::Assertions
8
-
9
- def setup
10
- super
11
- # The normal relative directory lookup of coverband won't work for our dummy rails project
12
- Coverband.configure("./test/rails#{Rails::VERSION::MAJOR}_dummy/config/coverband.rb")
13
- Coverband.configuration.track_gems = true
14
- Coverband.configuration.gem_details = true
15
- Coverband.configuration.background_reporting_enabled = false
16
- Coverband.start
17
- require 'rainbow'
18
- Rainbow('this text is red').red
19
- end
20
-
21
- def teardown
22
- super
23
- Capybara.reset_sessions!
24
- Capybara.use_default_driver
25
- end
26
-
27
- test 'this is how gem it' do
28
- visit '/dummy/show'
29
- assert_content('I am no dummy')
30
- Coverband.report_coverage(true)
31
- visit '/coverage'
32
- assert_content('Coverband Admin')
33
- assert_content('Gems')
34
- assert page.html.match('rainbow/wrapper.rb')
35
- end
36
- end