coverband 4.0.1 → 4.2.0

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 (90) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +6 -1
  3. data/.travis.yml +8 -2
  4. data/Gemfile +2 -0
  5. data/Gemfile.rails4 +2 -0
  6. data/README.md +135 -157
  7. data/Rakefile +1 -1
  8. data/changes.md +56 -5
  9. data/coverband.gemspec +5 -3
  10. data/lib/coverband/adapters/base.rb +44 -11
  11. data/lib/coverband/adapters/file_store.rb +8 -0
  12. data/lib/coverband/adapters/redis_store.rb +65 -8
  13. data/lib/coverband/at_exit.rb +37 -0
  14. data/lib/coverband/collectors/coverage.rb +43 -72
  15. data/lib/coverband/collectors/delta.rb +67 -0
  16. data/lib/coverband/configuration.rb +71 -2
  17. data/lib/coverband/integrations/background.rb +9 -10
  18. data/lib/coverband/integrations/middleware.rb +3 -2
  19. data/lib/coverband/integrations/rack_server_check.rb +4 -1
  20. data/lib/coverband/integrations/resque.rb +27 -0
  21. data/lib/coverband/reporters/base.rb +24 -36
  22. data/lib/coverband/reporters/html_report.rb +40 -15
  23. data/lib/coverband/reporters/web.rb +52 -10
  24. data/lib/coverband/utils/file_groups.rb +53 -0
  25. data/lib/coverband/utils/file_path_helper.rb +57 -0
  26. data/lib/coverband/utils/gem_list.rb +31 -0
  27. data/lib/coverband/utils/html_formatter.rb +50 -8
  28. data/lib/coverband/utils/railtie.rb +9 -1
  29. data/lib/coverband/utils/result.rb +16 -19
  30. data/lib/coverband/utils/results.rb +63 -0
  31. data/lib/coverband/utils/source_file.rb +23 -1
  32. data/lib/coverband/utils/tasks.rb +17 -17
  33. data/lib/coverband/version.rb +1 -1
  34. data/lib/coverband.rb +32 -2
  35. data/public/application.css +5 -0
  36. data/public/application.js +117 -1640
  37. data/public/dependencies.js +1581 -0
  38. data/public/favicon.png +0 -0
  39. data/test/benchmarks/benchmark.rake +36 -1
  40. data/test/benchmarks/coverage_fork.sh +37 -0
  41. data/test/{unit/adapters_base_test.rb → coverband/adapters/base_test.rb} +1 -1
  42. data/test/{unit/adapters_file_store_test.rb → coverband/adapters/file_store_test.rb} +1 -1
  43. data/test/{unit/adapters_redis_store_test.rb → coverband/adapters/redis_store_test.rb} +28 -11
  44. data/test/coverband/at_exit_test.rb +13 -0
  45. data/test/coverband/collectors/coverage_test.rb +73 -0
  46. data/test/coverband/collectors/delta_test.rb +52 -0
  47. data/test/coverband/configuration_test.rb +67 -0
  48. data/test/{unit → coverband}/coverband_test.rb +7 -0
  49. data/test/coverband/integrations/background_test.rb +31 -0
  50. data/test/{unit → coverband/integrations}/middleware_test.rb +3 -2
  51. data/test/{unit/rack_server_checkout_test.rb → coverband/integrations/rack_server_check_test.rb} +1 -1
  52. data/test/coverband/integrations/resque_worker_test.rb +42 -0
  53. data/test/coverband/integrations/test_resque_job.rb +7 -0
  54. data/test/coverband/reporters/base_test.rb +168 -0
  55. data/test/{unit/reports_console_test.rb → coverband/reporters/console_test.rb} +8 -7
  56. data/test/coverband/reporters/html_test.rb +45 -0
  57. data/test/coverband/reporters/web_test.rb +52 -0
  58. data/test/coverband/utils/file_groups_test.rb +55 -0
  59. data/test/{unit → coverband}/utils/file_list_test.rb +1 -1
  60. data/test/coverband/utils/gem_list_test.rb +48 -0
  61. data/test/{unit → coverband}/utils/source_file_test.rb +1 -1
  62. data/test/{unit → integration}/full_stack_test.rb +25 -12
  63. data/test/{unit → integration}/rails_full_stack_test.rb +27 -7
  64. data/test/rails4_dummy/config/application.rb +1 -1
  65. data/test/rails4_dummy/config/coverband.rb +4 -1
  66. data/test/rails4_dummy/tmp/.keep +0 -0
  67. data/test/rails5_dummy/config/application.rb +1 -1
  68. data/test/rails5_dummy/config/coverband.rb +3 -1
  69. data/test/rails5_dummy/tmp/.keep +0 -0
  70. data/test/rails_test_helper.rb +13 -8
  71. data/test/test_helper.rb +12 -17
  72. data/test/unique_files.rb +23 -0
  73. data/views/file_list.erb +33 -20
  74. data/views/gem_list.erb +54 -0
  75. data/views/layout.erb +13 -4
  76. data/views/settings.erb +35 -0
  77. data/views/source_file.erb +16 -4
  78. data/views/source_file_loader.erb +7 -0
  79. metadata +108 -62
  80. data/test/unit/background_test.rb +0 -29
  81. data/test/unit/collectors_coverage_test.rb +0 -48
  82. data/test/unit/configuration_test.rb +0 -23
  83. data/test/unit/reports_base_test.rb +0 -109
  84. data/test/unit/reports_html_test.rb +0 -29
  85. data/test/unit/reports_web_test.rb +0 -39
  86. /data/test/{unit → coverband}/utils/lines_classifier_test.rb +0 -0
  87. /data/test/{unit → coverband}/utils/result_test.rb +0 -0
  88. /data/test/{unit → coverband}/utils/s3_report_test.rb +0 -0
  89. /data/test/{unit → coverband}/utils/source_file_line_test.rb +0 -0
  90. /data/test/{unit/dog.rb → dog.rb} +0 -0
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('../test_helper', File.dirname(__FILE__))
4
-
5
- class BackgroundTest < Minitest::Test
6
- def setup
7
- super
8
- Coverband.configure do |config|
9
- config.store = Coverband::Adapters::RedisStore.new(Redis.new)
10
- config.background_reporting_enabled = true
11
- config.background_reporting_sleep_seconds = 30
12
- end
13
- Coverband::Background.stop
14
- end
15
-
16
- class ThreadDouble
17
- def exit
18
- end
19
- end
20
-
21
- def test_start
22
- Thread.expects(:new).yields.returns(ThreadDouble.new)
23
- Coverband::Background.expects(:loop).yields
24
- Coverband::Background.expects(:sleep).with(30)
25
- Coverband::Background.expects(:at_exit).returns(false)
26
- Coverband::Collectors::Coverage.instance.expects(:report_coverage).once
27
- 2.times { Coverband::Background.start }
28
- end
29
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('../test_helper', File.dirname(__FILE__))
4
- require File.expand_path('./dog', File.dirname(__FILE__))
5
-
6
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.3.0')
7
- class CollectorsCoverageTest < Minitest::Test
8
- attr_accessor :coverband
9
-
10
- def setup
11
- super
12
- Coverband.configure do |config|
13
- config.store = Coverband::Adapters::RedisStore.new(Redis.new)
14
- end
15
- @coverband = Coverband::Collectors::Coverage.instance.reset_instance
16
- end
17
-
18
- def teardown
19
- Thread.current[:coverband_instance] = nil
20
- Coverband.configure do |config|
21
- end
22
- @coverband = Coverband::Collectors::Coverage.instance.reset_instance
23
- end
24
-
25
- test 'gets coverage instance' do
26
- assert_equal Coverband::Collectors::Coverage, coverband.class
27
- end
28
-
29
- test 'defaults to a redis store' do
30
- assert_equal Coverband::Adapters::RedisStore, coverband.instance_variable_get('@store').class
31
- end
32
-
33
- test 'report_coverage raises errors in tests' do
34
- @coverband.reset_instance
35
- @coverband.expects(:ready_to_report?).raises('Oh no')
36
- assert_raises RuntimeError do
37
- @coverband.report_coverage
38
- end
39
- end
40
-
41
- test 'report_coverage does not raise errors in non-test mode' do
42
- Coverband.configuration.stubs(:test_env).returns(false)
43
- @coverband.expects(:ready_to_report?).raises('Oh no')
44
- @coverband.reset_instance
45
- @coverband.report_coverage
46
- end
47
- end
48
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('../test_helper', File.dirname(__FILE__))
4
-
5
- class BaseTest < Minitest::Test
6
- def setup
7
- super
8
- Coverband.configure do |config|
9
- config.root = Dir.pwd
10
- config.s3_bucket = nil
11
- config.root_paths = ['/app_path/']
12
- config.ignore = ['vendor']
13
- config.reporting_frequency = 100.0
14
- config.reporter = 'std_out'
15
- config.store = Coverband::Adapters::RedisStore.new(Redis.new)
16
- end
17
- end
18
-
19
- test 'defaults ' do
20
- coverband = Coverband::Collectors::Coverage.instance.reset_instance
21
- assert_equal ['vendor', 'internal:prelude', 'schema.rb'], coverband.instance_variable_get('@ignore_patterns')
22
- end
23
- end
@@ -1,109 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('../test_helper', File.dirname(__FILE__))
4
-
5
- class ReportsBaseTest < Minitest::Test
6
- test 'filename_from_key fix filename from a key with a swappable path' do
7
- Coverband.configure do |config|
8
- config.reporter = 'std_out'
9
- config.root = '/full/remote_app/path'
10
- end
11
-
12
- key = '/app/is/a/path.rb'
13
- # the code takes config.root expands and adds a '/' for the final path in roots
14
- roots = ['/app/', '/full/remote_app/path/']
15
-
16
- expected_path = '/full/remote_app/path/is/a/path.rb'
17
- assert_equal expected_path, Coverband::Reporters::Base.send(:filename_from_key, key, roots)
18
- end
19
-
20
- test 'filename_from_key fix filename a changing deploy path with double quotes' do
21
- Coverband.configure do |config|
22
- config.reporter = 'std_out'
23
- config.root = '/full/remote_app/path'
24
- end
25
-
26
- key = '/box/apps/app_name/releases/20140725203539/app/models/user.rb'
27
- # the code takes config.root expands and adds a '/' for the final path in roots
28
- # note to get regex to work for changing deploy directories it must be double escaped in double quotes or use single qoutes
29
- roots = ['/box/apps/app_name/releases/\\d+/', '/full/remote_app/path/']
30
-
31
- expected_path = '/full/remote_app/path/app/models/user.rb'
32
- assert_equal expected_path, Coverband::Reporters::Base.send(:filename_from_key, key, roots)
33
- end
34
-
35
- test 'filename_from_key fix filename a changing deploy path with single quotes' do
36
- Coverband.configure do |config|
37
- config.reporter = 'std_out'
38
- config.root = '/full/remote_app/path'
39
- end
40
-
41
- key = '/box/apps/app_name/releases/20140725203539/app/models/user.rb'
42
- # the code takes config.root expands and adds a '/' for the final path in roots
43
- # note to get regex to work for changing deploy directories it must be double escaped in double quotes or use single qoutes
44
- roots = ['/box/apps/app_name/releases/\d+/', '/full/remote_app/path/']
45
-
46
- expected_path = '/full/remote_app/path/app/models/user.rb'
47
- assert_equal expected_path, Coverband::Reporters::Base.send(:filename_from_key, key, roots)
48
- end
49
-
50
- test 'filename_from_key leave filename from a key with a local path' do
51
- Coverband.configure do |config|
52
- config.reporter = 'std_out'
53
- config.root = '/full/remote_app/path'
54
- end
55
-
56
- key = '/full/remote_app/path/is/a/path.rb'
57
- # the code takes config.root expands and adds a '/' for the final path in roots
58
- roots = ['/app/', '/full/remote_app/path/']
59
-
60
- expected_path = '/full/remote_app/path/is/a/path.rb'
61
- assert_equal expected_path, Coverband::Reporters::Base.send(:filename_from_key, key, roots)
62
- end
63
-
64
- test '#merge_arrays basic merge preserves order and counts' do
65
- first = [0, 0, 1, 0, 1]
66
- second = [nil, 0, 1, 0, 0]
67
- expects = [0, 0, 2, 0, 1]
68
-
69
- assert_equal expects, Coverband::Reporters::Base.send(:merge_arrays, first, second)
70
- end
71
-
72
- test '#merge_arrays basic merge preserves order and counts different lengths' do
73
- first = [0, 0, 1, 0, 1]
74
- second = [nil, 0, 1, 0, 0, 0, 0, 1]
75
- expects = [0, 0, 2, 0, 1, 0, 0, 1]
76
-
77
- assert_equal expects, Coverband::Reporters::Base.send(:merge_arrays, first, second)
78
- end
79
-
80
- test '#merge_arrays basic merge preserves nils' do
81
- first = [0, 1, 2, nil, nil, nil]
82
- second = [0, 1, 2, nil, 0, 1, 2]
83
- expects = [0, 2, 4, nil, 0, 1, 2]
84
-
85
- assert_equal expects, Coverband::Reporters::Base.send(:merge_arrays, first, second)
86
- end
87
-
88
- test "#get_current_scov_data_imp doesn't ignore folders with default ignore keys" do
89
- @redis = Redis.new
90
- store = Coverband::Adapters::RedisStore.new(@redis)
91
- store.clear!
92
-
93
- Coverband.configure do |config|
94
- config.reporter = 'std_out'
95
- config.ignore = %w(vendor .erb$ .slim$)
96
- config.root = '/full/remote_app/path'
97
- config.store = store
98
- end
99
-
100
- key = '/a_path/that_has_erb_in/thepath.rb'
101
- roots = ['/app/', '/full/remote_app/path/']
102
-
103
- lines_hit = [1, 3, 6]
104
- store.stubs(:coverage).returns(key => lines_hit)
105
- expected = { key => [1, 3, 6] }
106
-
107
- assert_equal expected, Coverband::Reporters::Base.send(:get_current_scov_data_imp, store, roots)
108
- end
109
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('../test_helper', File.dirname(__FILE__))
4
-
5
- class ReportHTMLTest < Minitest::Test
6
- BASE_KEY = Coverband::Adapters::RedisStore::BASE_KEY
7
-
8
- def setup
9
- super
10
- @redis = Redis.new
11
- @store = Coverband::Adapters::RedisStore.new(@redis)
12
- @store.clear!
13
- end
14
-
15
- test 'generate scov report' do
16
- Coverband.configure do |config|
17
- config.reporter = 'scov'
18
- config.store = @store
19
- config.s3_bucket = nil
20
- config.ignore = ['notsomething.rb']
21
- end
22
- mock_file_hash
23
- @store.send(:save_report, basic_coverage)
24
-
25
- html = Coverband::Reporters::HTMLReport.report(@store,
26
- html: true, open_report: false)
27
- assert_match 'Generated by', html
28
- end
29
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('../test_helper', File.dirname(__FILE__))
4
- require 'aws-sdk-s3'
5
- require File.expand_path('../../lib/coverband/reporters/web', File.dirname(__FILE__))
6
- require 'rack/test'
7
-
8
- ENV['RACK_ENV'] = 'test'
9
-
10
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
11
- module Coverband
12
- class WebTest < Minitest::Test
13
- include Rack::Test::Methods
14
-
15
- def app
16
- Coverband::Reporters::Web.new
17
- end
18
-
19
- def teardown
20
- super
21
- Coverband.configuration.s3_bucket = nil
22
- end
23
-
24
- # TODO: add tests for all endpoints
25
- test 'renders index content' do
26
- get '/'
27
- assert last_response.ok?
28
- assert_match 'Coverband Admin', last_response.body
29
- end
30
-
31
- test 'renders show content' do
32
- Coverband::Reporters::HTMLReport.expects(:report).returns('content')
33
- get '/show'
34
- assert last_response.ok?
35
- assert_equal 'content', last_response.body
36
- end
37
- end
38
- end
39
- end
File without changes
File without changes
File without changes